Pin unlock : hides behind feature flag (disabled by default)
This commit is contained in:
parent
ea0963c0c8
commit
304ec0b740
7 changed files with 31 additions and 11 deletions
|
|
@ -21,6 +21,6 @@ import kotlinx.coroutines.flow.StateFlow
|
|||
interface PinStateDataSource {
|
||||
val pinState: StateFlow<PinState>
|
||||
|
||||
fun lock()
|
||||
fun unlock()
|
||||
suspend fun lock()
|
||||
suspend fun unlock()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ dependencies {
|
|||
implementation(projects.libraries.matrix.api)
|
||||
implementation(projects.libraries.matrixui)
|
||||
implementation(projects.libraries.designsystem)
|
||||
implementation(projects.libraries.featureflag.api)
|
||||
|
||||
testImplementation(libs.test.junit)
|
||||
testImplementation(libs.coroutines.test)
|
||||
|
|
|
|||
|
|
@ -19,17 +19,21 @@ package io.element.android.features.pin.impl.auth
|
|||
import androidx.compose.runtime.Composable
|
||||
import io.element.android.features.pin.api.PinStateDataSource
|
||||
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 pinStateDataSource: PinStateDataSource,
|
||||
private val coroutineScope: CoroutineScope,
|
||||
) : Presenter<PinAuthenticationState> {
|
||||
|
||||
@Composable
|
||||
override fun present(): PinAuthenticationState {
|
||||
|
||||
fun handleEvents(event: PinAuthenticationEvents) {
|
||||
when (event) {
|
||||
PinAuthenticationEvents.Unlock -> pinStateDataSource.unlock()
|
||||
PinAuthenticationEvents.Unlock -> coroutineScope.launch { pinStateDataSource.unlock() }
|
||||
}
|
||||
}
|
||||
return PinAuthenticationState(
|
||||
|
|
|
|||
|
|
@ -21,22 +21,30 @@ import io.element.android.features.pin.api.PinState
|
|||
import io.element.android.features.pin.api.PinStateDataSource
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.di.SingleIn
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import javax.inject.Inject
|
||||
|
||||
@SingleIn(AppScope::class)
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultPinStateDataSource @Inject constructor() : PinStateDataSource {
|
||||
class DefaultPinStateDataSource @Inject constructor(
|
||||
private val featureFlagService: FeatureFlagService,
|
||||
) : PinStateDataSource {
|
||||
|
||||
private val _pinState = MutableStateFlow<PinState>(PinState.Locked)
|
||||
private val _pinState = MutableStateFlow<PinState>(PinState.Unlocked)
|
||||
override val pinState: StateFlow<PinState> = _pinState
|
||||
|
||||
override fun unlock() {
|
||||
_pinState.value = PinState.Unlocked
|
||||
override suspend fun unlock() {
|
||||
if (featureFlagService.isFeatureEnabled(FeatureFlags.PinUnlock)) {
|
||||
_pinState.value = PinState.Unlocked
|
||||
}
|
||||
}
|
||||
|
||||
override fun lock() {
|
||||
_pinState.value = PinState.Locked
|
||||
override suspend fun lock() {
|
||||
if (featureFlagService.isFeatureEnabled(FeatureFlags.PinUnlock)) {
|
||||
_pinState.value = PinState.Locked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue