Skip to content

Commit

Permalink
Merge pull request #1592 from vector-im/feature/fga/setup_crypto_for_pin
Browse files Browse the repository at this point in the history
Feature/fga/setup crypto for pin
  • Loading branch information
ganfra authored Oct 18, 2023
2 parents e5a8fd9 + 436c9e8 commit 00e885f
Show file tree
Hide file tree
Showing 45 changed files with 963 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ import io.element.android.features.ftue.api.state.FtueState
import io.element.android.features.invitelist.api.InviteListEntryPoint
import io.element.android.features.networkmonitor.api.NetworkMonitor
import io.element.android.features.networkmonitor.api.NetworkStatus
import io.element.android.features.pin.api.PinEntryPoint
import io.element.android.features.pin.api.PinState
import io.element.android.features.pin.api.PinStateService
import io.element.android.features.lockscreen.api.LockScreenEntryPoint
import io.element.android.features.lockscreen.api.LockScreenState
import io.element.android.features.lockscreen.api.LockScreenStateService
import io.element.android.features.preferences.api.PreferencesEntryPoint
import io.element.android.features.roomlist.api.RoomListEntryPoint
import io.element.android.features.verifysession.api.VerifySessionEntryPoint
Expand Down Expand Up @@ -93,8 +93,8 @@ class LoggedInFlowNode @AssistedInject constructor(
private val networkMonitor: NetworkMonitor,
private val notificationDrawerManager: NotificationDrawerManager,
private val ftueState: FtueState,
private val pinEntryPoint: PinEntryPoint,
private val pinStateService: PinStateService,
private val lockScreenEntryPoint: LockScreenEntryPoint,
private val lockScreenStateService: LockScreenStateService,
private val matrixClient: MatrixClient,
snackbarDispatcher: SnackbarDispatcher,
) : BackstackNode<LoggedInFlowNode.NavTarget>(
Expand Down Expand Up @@ -136,12 +136,12 @@ class LoggedInFlowNode @AssistedInject constructor(
},
onResume = {
coroutineScope.launch {
pinStateService.entersForeground()
lockScreenStateService.entersForeground()
}
},
onPause = {
coroutineScope.launch {
pinStateService.entersBackground()
lockScreenStateService.entersBackground()
}
},
onStop = {
Expand Down Expand Up @@ -218,7 +218,7 @@ class LoggedInFlowNode @AssistedInject constructor(
createNode<LoggedInNode>(buildContext)
}
NavTarget.LockPermanent -> {
pinEntryPoint.createNode(this, buildContext)
lockScreenEntryPoint.createNode(this, buildContext)
}
NavTarget.RoomList -> {
val callback = object : RoomListEntryPoint.Callback {
Expand Down Expand Up @@ -345,9 +345,9 @@ class LoggedInFlowNode @AssistedInject constructor(
@Composable
override fun View(modifier: Modifier) {
Box(modifier = modifier) {
val pinState by pinStateService.pinState.collectAsState()
when (pinState) {
PinState.Unlocked -> {
val lockScreenState by lockScreenStateService.state.collectAsState()
when (lockScreenState) {
LockScreenState.Unlocked -> {
Children(
navModel = backstack,
modifier = Modifier,
Expand All @@ -359,7 +359,7 @@ class LoggedInFlowNode @AssistedInject constructor(
PermanentChild(permanentNavModel = permanentNavModel, navTarget = NavTarget.LoggedInPermanent)
}
}
PinState.Locked -> {
LockScreenState.Locked -> {
MoveActivityToBackgroundBackHandler()
PermanentChild(permanentNavModel = permanentNavModel, navTarget = NavTarget.LockPermanent)
}
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ koverMerged {
// Some options can't be tested at the moment
excludes += "io.element.android.features.preferences.impl.developer.DeveloperSettingsPresenter$*"
// Temporary until we have actually something to test.
excludes += "io.element.android.features.pin.impl.auth.PinAuthenticationPresenter"
excludes += "io.element.android.features.pin.impl.auth.PinAuthenticationPresenter$*"
excludes += "io.element.android.features.pin.impl.create.CreatePinPresenter"
excludes += "io.element.android.features.lockscreen.impl.auth.PinAuthenticationPresenter"
excludes += "io.element.android.features.lockscreen.impl.auth.PinAuthenticationPresenter$*"
excludes += "io.element.android.features.lockscreen.impl.create.CreatePinPresenter"
}
bound {
minValue = 85
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plugins {
}

android {
namespace = "io.element.android.features.pin.api"
namespace = "io.element.android.features.lockscreen.api"
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

package io.element.android.features.pin.api
package io.element.android.features.lockscreen.api

import io.element.android.libraries.architecture.SimpleFeatureEntryPoint

interface PinEntryPoint : SimpleFeatureEntryPoint
interface LockScreenEntryPoint : SimpleFeatureEntryPoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.element.android.features.lockscreen.api

sealed interface LockScreenState {
data object Unlocked : LockScreenState
data object Locked : LockScreenState
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

package io.element.android.features.pin.api
package io.element.android.features.lockscreen.api

import kotlinx.coroutines.flow.StateFlow

interface PinStateService {
val pinState: StateFlow<PinState>
interface LockScreenStateService {
val state: StateFlow<LockScreenState>

suspend fun entersForeground()
suspend fun entersBackground()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {
}

android {
namespace = "io.element.android.features.pin.impl"
namespace = "io.element.android.features.lockscreen.impl"
}

anvil {
Expand All @@ -32,20 +32,23 @@ anvil {
dependencies {
implementation(projects.anvilannotations)
anvil(projects.anvilcodegen)
api(projects.features.pin.api)
api(projects.features.lockscreen.api)
implementation(projects.libraries.core)
implementation(projects.libraries.architecture)
implementation(projects.libraries.matrix.api)
implementation(projects.libraries.matrixui)
implementation(projects.libraries.designsystem)
implementation(projects.libraries.featureflag.api)
implementation(projects.libraries.cryptography.api)

testImplementation(libs.test.junit)
testImplementation(libs.coroutines.test)
testImplementation(libs.molecule.runtime)
testImplementation(libs.test.truth)
testImplementation(libs.test.turbine)
testImplementation(projects.libraries.matrix.test)
testImplementation(projects.libraries.cryptography.test)
testImplementation(projects.libraries.cryptography.impl)

ksp(libs.showkase.processor)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl
package io.element.android.features.lockscreen.impl

import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.features.pin.api.PinEntryPoint
import io.element.android.features.lockscreen.api.LockScreenEntryPoint
import io.element.android.libraries.architecture.createNode
import io.element.android.libraries.di.AppScope
import javax.inject.Inject

@ContributesBinding(AppScope::class)
class DefaultPinEntryPoint @Inject constructor() : PinEntryPoint {
class DefaultLockScreenEntryPoint @Inject constructor() : LockScreenEntryPoint {

override fun createNode(parentNode: Node, buildContext: BuildContext): Node {
return parentNode.createNode<PinFlowNode>(buildContext)
return parentNode.createNode<LockScreenFlowNode>(buildContext)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl
package io.element.android.features.lockscreen.impl

import android.os.Parcelable
import androidx.compose.runtime.Composable
Expand All @@ -27,19 +27,19 @@ import com.bumble.appyx.navmodel.backstack.BackStack
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import io.element.android.anvilannotations.ContributesNode
import io.element.android.features.pin.impl.auth.PinAuthenticationNode
import io.element.android.features.pin.impl.create.CreatePinNode
import io.element.android.features.lockscreen.impl.auth.PinAuthenticationNode
import io.element.android.features.lockscreen.impl.create.CreatePinNode
import io.element.android.libraries.architecture.BackstackNode
import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler
import io.element.android.libraries.architecture.createNode
import io.element.android.libraries.di.AppScope
import kotlinx.parcelize.Parcelize

@ContributesNode(AppScope::class)
class PinFlowNode @AssistedInject constructor(
class LockScreenFlowNode @AssistedInject constructor(
@Assisted buildContext: BuildContext,
@Assisted plugins: List<Plugin>,
) : BackstackNode<PinFlowNode.NavTarget>(
) : BackstackNode<LockScreenFlowNode.NavTarget>(
backstack = BackStack(
initialElement = NavTarget.Auth,
savedStateMap = buildContext.savedStateMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.auth
package io.element.android.features.lockscreen.impl.auth

sealed interface PinAuthenticationEvents {
data object Unlock : PinAuthenticationEvents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.auth
package io.element.android.features.lockscreen.impl.auth

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.auth
package io.element.android.features.lockscreen.impl.auth

import androidx.compose.runtime.Composable
import io.element.android.features.pin.api.PinStateService
import io.element.android.features.lockscreen.api.LockScreenStateService
import io.element.android.libraries.architecture.Presenter
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import javax.inject.Inject

class PinAuthenticationPresenter @Inject constructor(
private val pinStateService: PinStateService,
private val pinStateService: LockScreenStateService,
private val coroutineScope: CoroutineScope,
) : Presenter<PinAuthenticationState> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.auth
package io.element.android.features.lockscreen.impl.auth

data class PinAuthenticationState(
val eventSink: (PinAuthenticationEvents) -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.auth
package io.element.android.features.lockscreen.impl.auth

import androidx.compose.ui.tooling.preview.PreviewParameterProvider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.auth
package io.element.android.features.lockscreen.impl.auth

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.create
package io.element.android.features.lockscreen.impl.create

sealed interface CreatePinEvents {
object MyEvent : CreatePinEvents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.create
package io.element.android.features.lockscreen.impl.create

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.create
package io.element.android.features.lockscreen.impl.create

import androidx.compose.runtime.Composable
import io.element.android.libraries.architecture.Presenter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.create
package io.element.android.features.lockscreen.impl.create

data class CreatePinState(
val eventSink: (CreatePinEvents) -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.create
package io.element.android.features.lockscreen.impl.create

import androidx.compose.ui.tooling.preview.PreviewParameterProvider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.element.android.features.pin.impl.create
package io.element.android.features.lockscreen.impl.create

import androidx.compose.foundation.layout.Box
import androidx.compose.material3.MaterialTheme
Expand Down
Loading

0 comments on commit 00e885f

Please sign in to comment.