Pin: rename feature pin to lockscreen

This commit is contained in:
ganfra
2023-10-17 18:38:30 +02:00
parent 65bbe72ecc
commit 78621e4256
26 changed files with 62 additions and 62 deletions

View File

@@ -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
@@ -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>(
@@ -136,12 +136,12 @@ class LoggedInFlowNode @AssistedInject constructor(
},
onResume = {
coroutineScope.launch {
pinStateService.entersForeground()
lockScreenStateService.entersForeground()
}
},
onPause = {
coroutineScope.launch {
pinStateService.entersBackground()
lockScreenStateService.entersBackground()
}
},
onStop = {
@@ -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 {
@@ -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,
@@ -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)
}

View File

@@ -19,7 +19,7 @@ plugins {
}
android {
namespace = "io.element.android.features.pin.api"
namespace = "io.element.android.features.lockscreen.api"
}
dependencies {

View File

@@ -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

View File

@@ -14,9 +14,9 @@
* limitations under the License.
*/
package io.element.android.features.pin.api
package io.element.android.features.lockscreen.api
sealed interface PinState {
data object Unlocked : PinState
data object Locked : PinState
sealed interface LockScreenState {
data object Unlocked : LockScreenState
data object Locked : LockScreenState
}

View File

@@ -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()

View File

@@ -22,7 +22,7 @@ plugins {
}
android {
namespace = "io.element.android.features.pin.impl"
namespace = "io.element.android.features.lockscreen.impl"
}
anvil {
@@ -32,7 +32,7 @@ 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)

View File

@@ -14,20 +14,20 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation
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)
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation
package io.element.android.features.lockscreen.impl
import android.os.Parcelable
import androidx.compose.runtime.Composable
@@ -27,8 +27,8 @@ 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.presentation.auth.PinAuthenticationNode
import io.element.android.features.pin.impl.presentation.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
@@ -36,10 +36,10 @@ 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,

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.auth
package io.element.android.features.lockscreen.impl.auth
sealed interface PinAuthenticationEvents {
data object Unlock : PinAuthenticationEvents

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.auth
package io.element.android.features.lockscreen.impl.auth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

View File

@@ -14,17 +14,17 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.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> {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.auth
package io.element.android.features.lockscreen.impl.auth
data class PinAuthenticationState(
val eventSink: (PinAuthenticationEvents) -> Unit

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.auth
package io.element.android.features.lockscreen.impl.auth
import androidx.compose.ui.tooling.preview.PreviewParameterProvider

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.auth
package io.element.android.features.lockscreen.impl.auth
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.create
package io.element.android.features.lockscreen.impl.create
sealed interface CreatePinEvents {
object MyEvent : CreatePinEvents

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.create
package io.element.android.features.lockscreen.impl.create
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.create
package io.element.android.features.lockscreen.impl.create
import androidx.compose.runtime.Composable
import io.element.android.libraries.architecture.Presenter

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.create
package io.element.android.features.lockscreen.impl.create
data class CreatePinState(
val eventSink: (CreatePinEvents) -> Unit

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.create
package io.element.android.features.lockscreen.impl.create
import androidx.compose.ui.tooling.preview.PreviewParameterProvider

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.presentation.create
package io.element.android.features.lockscreen.impl.create
import androidx.compose.foundation.layout.Box
import androidx.compose.material3.MaterialTheme

View File

@@ -14,10 +14,10 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.pin
package io.element.android.features.lockscreen.impl.pin
import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.features.pin.impl.pin.storage.PinCodeStore
import io.element.android.features.lockscreen.impl.pin.storage.PinCodeStore
import io.element.android.libraries.cryptography.api.CryptoService
import io.element.android.libraries.cryptography.api.EncryptionResult
import io.element.android.libraries.di.AppScope

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.pin
package io.element.android.features.lockscreen.impl.pin
/**
* This interface is the main interface to manage the pin code.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.pin.storage
package io.element.android.features.lockscreen.impl.pin.storage
/**
* Should be implemented by any class that provides access to the encrypted PIN code.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.pin.storage
package io.element.android.features.lockscreen.impl.pin.storage
interface PinCodeStore : EncryptedPinCodeStorage {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.pin.storage
package io.element.android.features.lockscreen.impl.pin.storage
import android.content.SharedPreferences
import androidx.core.content.edit

View File

@@ -14,11 +14,11 @@
* limitations under the License.
*/
package io.element.android.features.pin.impl.state
package io.element.android.features.lockscreen.impl.state
import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.features.pin.api.PinState
import io.element.android.features.pin.api.PinStateService
import io.element.android.features.lockscreen.api.LockScreenState
import io.element.android.features.lockscreen.api.LockScreenStateService
import io.element.android.libraries.di.AppScope
import io.element.android.libraries.di.SingleIn
import io.element.android.libraries.featureflag.api.FeatureFlagService
@@ -35,18 +35,18 @@ private const val GRACE_PERIOD_IN_MILLIS = 90 * 1000L
@SingleIn(AppScope::class)
@ContributesBinding(AppScope::class)
class DefaultPinStateService @Inject constructor(
class DefaultLockScreenStateService @Inject constructor(
private val featureFlagService: FeatureFlagService,
) : PinStateService {
) : LockScreenStateService {
private val _pinState = MutableStateFlow<PinState>(PinState.Unlocked)
override val pinState: StateFlow<PinState> = _pinState
private val _lockScreenState = MutableStateFlow<LockScreenState>(LockScreenState.Unlocked)
override val state: StateFlow<LockScreenState> = _lockScreenState
private var lockJob: Job? = null
override suspend fun unlock() {
if (featureFlagService.isFeatureEnabled(FeatureFlags.PinUnlock)) {
_pinState.value = PinState.Unlocked
_lockScreenState.value = LockScreenState.Unlocked
}
}
@@ -58,7 +58,7 @@ class DefaultPinStateService @Inject constructor(
lockJob = launch {
if (featureFlagService.isFeatureEnabled(FeatureFlags.PinUnlock)) {
delay(GRACE_PERIOD_IN_MILLIS)
_pinState.value = PinState.Locked
_lockScreenState.value = LockScreenState.Locked
}
}
}