Lockscreen: renaming
This commit is contained in:
@@ -251,8 +251,7 @@ 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.lockscreen.impl.auth.PinAuthenticationPresenter"
|
||||
excludes += "io.element.android.features.lockscreen.impl.auth.PinAuthenticationPresenter$*"
|
||||
excludes += "io.element.android.features.lockscreen.impl.unlock.PinUnlockPresenter$*"
|
||||
}
|
||||
bound {
|
||||
minValue = 85
|
||||
|
||||
@@ -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.lockscreen.impl.auth.PinAuthenticationNode
|
||||
import io.element.android.features.lockscreen.impl.create.CreatePinNode
|
||||
import io.element.android.features.lockscreen.impl.setup.SetupPinNode
|
||||
import io.element.android.features.lockscreen.impl.unlock.PinUnlockNode
|
||||
import io.element.android.libraries.architecture.BackstackNode
|
||||
import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler
|
||||
import io.element.android.libraries.architecture.createNode
|
||||
@@ -41,7 +41,7 @@ class LockScreenFlowNode @AssistedInject constructor(
|
||||
@Assisted plugins: List<Plugin>,
|
||||
) : BackstackNode<LockScreenFlowNode.NavTarget>(
|
||||
backstack = BackStack(
|
||||
initialElement = NavTarget.Auth,
|
||||
initialElement = NavTarget.Unlock,
|
||||
savedStateMap = buildContext.savedStateMap,
|
||||
),
|
||||
buildContext = buildContext,
|
||||
@@ -50,19 +50,19 @@ class LockScreenFlowNode @AssistedInject constructor(
|
||||
|
||||
sealed interface NavTarget : Parcelable {
|
||||
@Parcelize
|
||||
data object Auth : NavTarget
|
||||
data object Unlock : NavTarget
|
||||
|
||||
@Parcelize
|
||||
data object Create : NavTarget
|
||||
data object Setup : NavTarget
|
||||
}
|
||||
|
||||
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node {
|
||||
return when (navTarget) {
|
||||
NavTarget.Auth -> {
|
||||
createNode<PinAuthenticationNode>(buildContext)
|
||||
NavTarget.Unlock -> {
|
||||
createNode<PinUnlockNode>(buildContext)
|
||||
}
|
||||
NavTarget.Create -> {
|
||||
createNode<CreatePinNode>(buildContext)
|
||||
NavTarget.Setup -> {
|
||||
createNode<SetupPinNode>(buildContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class DefaultPinCodeManager @Inject constructor(
|
||||
return pinCodeStore.hasPinCode()
|
||||
}
|
||||
|
||||
override suspend fun createPinCode(pinCode: String) {
|
||||
override suspend fun SetupPinCode(pinCode: String) {
|
||||
val secretKey = secretKeyProvider.getOrCreateKey(SECRET_KEY_ALIAS)
|
||||
val encryptedPinCode = encryptionDecryptionService.encrypt(secretKey, pinCode.toByteArray()).toBase64()
|
||||
pinCodeStore.saveEncryptedPinCode(encryptedPinCode)
|
||||
|
||||
@@ -30,7 +30,7 @@ interface PinCodeManager {
|
||||
* Creates a new encrypted pin code.
|
||||
* @param pinCode the clear pin code to create
|
||||
*/
|
||||
suspend fun createPinCode(pinCode: String)
|
||||
suspend fun SetupPinCode(pinCode: String)
|
||||
|
||||
/**
|
||||
* @return true if the pin code is correct.
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create
|
||||
package io.element.android.features.lockscreen.impl.setup
|
||||
|
||||
sealed interface CreatePinEvents {
|
||||
data class OnPinEntryChanged(val entryAsText: String) : CreatePinEvents
|
||||
data object ClearFailure : CreatePinEvents
|
||||
sealed interface SetupPinEvents {
|
||||
data class OnPinEntryChanged(val entryAsText: String) : SetupPinEvents
|
||||
data object ClearFailure : SetupPinEvents
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create
|
||||
package io.element.android.features.lockscreen.impl.setup
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -27,16 +27,16 @@ import io.element.android.anvilannotations.ContributesNode
|
||||
import io.element.android.libraries.di.AppScope
|
||||
|
||||
@ContributesNode(AppScope::class)
|
||||
class CreatePinNode @AssistedInject constructor(
|
||||
class SetupPinNode @AssistedInject constructor(
|
||||
@Assisted buildContext: BuildContext,
|
||||
@Assisted plugins: List<Plugin>,
|
||||
private val presenter: CreatePinPresenter,
|
||||
private val presenter: SetupPinPresenter,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
|
||||
@Composable
|
||||
override fun View(modifier: Modifier) {
|
||||
val state = presenter.present()
|
||||
CreatePinView(
|
||||
SetupPinView(
|
||||
state = state,
|
||||
onBackClicked = { },
|
||||
modifier = modifier
|
||||
@@ -14,29 +14,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create
|
||||
package io.element.android.features.lockscreen.impl.setup
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import io.element.android.features.lockscreen.impl.create.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.create.validation.CreatePinFailure
|
||||
import io.element.android.features.lockscreen.impl.create.validation.PinValidator
|
||||
import io.element.android.features.lockscreen.impl.setup.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.setup.validation.SetupPinFailure
|
||||
import io.element.android.features.lockscreen.impl.setup.validation.PinValidator
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.core.meta.BuildMeta
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val PIN_SIZE = 4
|
||||
|
||||
class CreatePinPresenter @Inject constructor(
|
||||
class SetupPinPresenter @Inject constructor(
|
||||
private val pinValidator: PinValidator,
|
||||
private val buildMeta: BuildMeta,
|
||||
) : Presenter<CreatePinState> {
|
||||
) : Presenter<SetupPinState> {
|
||||
|
||||
@Composable
|
||||
override fun present(): CreatePinState {
|
||||
override fun present(): SetupPinState {
|
||||
var choosePinEntry by remember {
|
||||
mutableStateOf(PinEntry.empty(PIN_SIZE))
|
||||
}
|
||||
@@ -46,20 +46,20 @@ class CreatePinPresenter @Inject constructor(
|
||||
var isConfirmationStep by remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
var createPinFailure by remember {
|
||||
mutableStateOf<CreatePinFailure?>(null)
|
||||
var setupPinFailure by remember {
|
||||
mutableStateOf<SetupPinFailure?>(null)
|
||||
}
|
||||
|
||||
fun handleEvents(event: CreatePinEvents) {
|
||||
fun handleEvents(event: SetupPinEvents) {
|
||||
when (event) {
|
||||
is CreatePinEvents.OnPinEntryChanged -> {
|
||||
is SetupPinEvents.OnPinEntryChanged -> {
|
||||
if (isConfirmationStep) {
|
||||
confirmPinEntry = confirmPinEntry.fillWith(event.entryAsText)
|
||||
if (confirmPinEntry.isPinComplete()) {
|
||||
if (confirmPinEntry == choosePinEntry) {
|
||||
//TODO save in db and navigate to next screen
|
||||
} else {
|
||||
createPinFailure = CreatePinFailure.PinsDontMatch
|
||||
setupPinFailure = SetupPinFailure.PinsDontMatch
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -67,35 +67,35 @@ class CreatePinPresenter @Inject constructor(
|
||||
if (choosePinEntry.isPinComplete()) {
|
||||
when (val pinValidationResult = pinValidator.isPinValid(choosePinEntry)) {
|
||||
is PinValidator.Result.Invalid -> {
|
||||
createPinFailure = pinValidationResult.failure
|
||||
setupPinFailure = pinValidationResult.failure
|
||||
}
|
||||
PinValidator.Result.Valid -> isConfirmationStep = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CreatePinEvents.ClearFailure -> {
|
||||
when (createPinFailure) {
|
||||
is CreatePinFailure.PinsDontMatch -> {
|
||||
SetupPinEvents.ClearFailure -> {
|
||||
when (setupPinFailure) {
|
||||
is SetupPinFailure.PinsDontMatch -> {
|
||||
choosePinEntry = PinEntry.empty(PIN_SIZE)
|
||||
confirmPinEntry = PinEntry.empty(PIN_SIZE)
|
||||
}
|
||||
is CreatePinFailure.PinBlacklisted -> {
|
||||
is SetupPinFailure.PinBlacklisted -> {
|
||||
choosePinEntry = PinEntry.empty(PIN_SIZE)
|
||||
}
|
||||
null -> Unit
|
||||
}
|
||||
isConfirmationStep = false
|
||||
createPinFailure = null
|
||||
setupPinFailure = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CreatePinState(
|
||||
return SetupPinState(
|
||||
choosePinEntry = choosePinEntry,
|
||||
confirmPinEntry = confirmPinEntry,
|
||||
isConfirmationStep = isConfirmationStep,
|
||||
createPinFailure = createPinFailure,
|
||||
SetupPinFailure = setupPinFailure,
|
||||
appName = buildMeta.applicationName,
|
||||
eventSink = ::handleEvents
|
||||
)
|
||||
@@ -14,18 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create
|
||||
package io.element.android.features.lockscreen.impl.setup
|
||||
|
||||
import io.element.android.features.lockscreen.impl.create.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.create.validation.CreatePinFailure
|
||||
import io.element.android.features.lockscreen.impl.setup.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.setup.validation.SetupPinFailure
|
||||
|
||||
data class CreatePinState(
|
||||
data class SetupPinState(
|
||||
val choosePinEntry: PinEntry,
|
||||
val confirmPinEntry: PinEntry,
|
||||
val isConfirmationStep: Boolean,
|
||||
val createPinFailure: CreatePinFailure?,
|
||||
val SetupPinFailure: SetupPinFailure?,
|
||||
val appName: String,
|
||||
val eventSink: (CreatePinEvents) -> Unit
|
||||
val eventSink: (SetupPinEvents) -> Unit
|
||||
) {
|
||||
val pinSize = choosePinEntry.size
|
||||
val activePinEntry = if (isConfirmationStep) {
|
||||
@@ -14,47 +14,47 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create
|
||||
package io.element.android.features.lockscreen.impl.setup
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.features.lockscreen.impl.create.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.create.validation.CreatePinFailure
|
||||
import io.element.android.features.lockscreen.impl.setup.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.setup.validation.SetupPinFailure
|
||||
|
||||
open class CreatePinStateProvider : PreviewParameterProvider<CreatePinState> {
|
||||
override val values: Sequence<CreatePinState>
|
||||
open class SetupPinStateProvider : PreviewParameterProvider<SetupPinState> {
|
||||
override val values: Sequence<SetupPinState>
|
||||
get() = sequenceOf(
|
||||
aCreatePinState(),
|
||||
aCreatePinState(
|
||||
aSetupPinState(),
|
||||
aSetupPinState(
|
||||
choosePinEntry = PinEntry.empty(4).fillWith("12")
|
||||
),
|
||||
aCreatePinState(
|
||||
aSetupPinState(
|
||||
choosePinEntry = PinEntry.empty(4).fillWith("1789"),
|
||||
isConfirmationStep = true,
|
||||
),
|
||||
aCreatePinState(
|
||||
aSetupPinState(
|
||||
choosePinEntry = PinEntry.empty(4).fillWith("1789"),
|
||||
confirmPinEntry = PinEntry.empty(4).fillWith("1788"),
|
||||
isConfirmationStep = true,
|
||||
creationFailure = CreatePinFailure.PinsDontMatch
|
||||
creationFailure = SetupPinFailure.PinsDontMatch
|
||||
),
|
||||
aCreatePinState(
|
||||
aSetupPinState(
|
||||
choosePinEntry = PinEntry.empty(4).fillWith("1111"),
|
||||
creationFailure = CreatePinFailure.PinBlacklisted
|
||||
creationFailure = SetupPinFailure.PinBlacklisted
|
||||
),
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
fun aCreatePinState(
|
||||
fun aSetupPinState(
|
||||
choosePinEntry: PinEntry = PinEntry.empty(4),
|
||||
confirmPinEntry: PinEntry = PinEntry.empty(4),
|
||||
isConfirmationStep: Boolean = false,
|
||||
creationFailure: CreatePinFailure? = null,
|
||||
) = CreatePinState(
|
||||
creationFailure: SetupPinFailure? = null,
|
||||
) = SetupPinState(
|
||||
choosePinEntry = choosePinEntry,
|
||||
confirmPinEntry = confirmPinEntry,
|
||||
isConfirmationStep = isConfirmationStep,
|
||||
createPinFailure = creationFailure,
|
||||
SetupPinFailure = creationFailure,
|
||||
appName = "Element",
|
||||
eventSink = {}
|
||||
)
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
@file:OptIn(ExperimentalMaterial3Api::class)
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create
|
||||
package io.element.android.features.lockscreen.impl.setup
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
@@ -46,9 +46,9 @@ import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.features.lockscreen.impl.R
|
||||
import io.element.android.features.lockscreen.impl.create.model.PinDigit
|
||||
import io.element.android.features.lockscreen.impl.create.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.create.validation.CreatePinFailure
|
||||
import io.element.android.features.lockscreen.impl.setup.model.PinDigit
|
||||
import io.element.android.features.lockscreen.impl.setup.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.setup.validation.SetupPinFailure
|
||||
import io.element.android.libraries.designsystem.atomic.molecules.IconTitleSubtitleMolecule
|
||||
import io.element.android.libraries.designsystem.components.button.BackButton
|
||||
import io.element.android.libraries.designsystem.components.dialogs.ErrorDialog
|
||||
@@ -61,8 +61,8 @@ import io.element.android.libraries.designsystem.theme.pinDigitBg
|
||||
import io.element.android.libraries.theme.ElementTheme
|
||||
|
||||
@Composable
|
||||
fun CreatePinView(
|
||||
state: CreatePinState,
|
||||
fun SetupPinView(
|
||||
state: SetupPinState,
|
||||
onBackClicked: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
@@ -86,15 +86,15 @@ fun CreatePinView(
|
||||
.verticalScroll(state = scrollState)
|
||||
.padding(vertical = 16.dp, horizontal = 20.dp),
|
||||
) {
|
||||
CreatePinHeader(state.isConfirmationStep, state.appName)
|
||||
CreatePinContent(state)
|
||||
SetupPinHeader(state.isConfirmationStep, state.appName)
|
||||
SetupPinContent(state)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CreatePinHeader(
|
||||
private fun SetupPinHeader(
|
||||
isValidationStep: Boolean,
|
||||
appName: String,
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -116,44 +116,44 @@ private fun CreatePinHeader(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CreatePinContent(
|
||||
state: CreatePinState,
|
||||
private fun SetupPinContent(
|
||||
state: SetupPinState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
PinEntryTextField(
|
||||
state.activePinEntry,
|
||||
onValueChange = {
|
||||
state.eventSink(CreatePinEvents.OnPinEntryChanged(it))
|
||||
state.eventSink(SetupPinEvents.OnPinEntryChanged(it))
|
||||
},
|
||||
modifier = modifier
|
||||
.padding(top = 36.dp)
|
||||
.fillMaxWidth()
|
||||
)
|
||||
if (state.createPinFailure != null) {
|
||||
if (state.SetupPinFailure != null) {
|
||||
ErrorDialog(
|
||||
modifier = modifier,
|
||||
title = state.createPinFailure.title(),
|
||||
content = state.createPinFailure.content(),
|
||||
title = state.SetupPinFailure.title(),
|
||||
content = state.SetupPinFailure.content(),
|
||||
onDismiss = {
|
||||
state.eventSink(CreatePinEvents.ClearFailure)
|
||||
state.eventSink(SetupPinEvents.ClearFailure)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CreatePinFailure.content(): String {
|
||||
private fun SetupPinFailure.content(): String {
|
||||
return when (this) {
|
||||
CreatePinFailure.PinBlacklisted -> stringResource(id = R.string.screen_app_lock_setup_pin_blacklisted_dialog_content)
|
||||
CreatePinFailure.PinsDontMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_content)
|
||||
SetupPinFailure.PinBlacklisted -> stringResource(id = R.string.screen_app_lock_setup_pin_blacklisted_dialog_content)
|
||||
SetupPinFailure.PinsDontMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_content)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CreatePinFailure.title(): String {
|
||||
private fun SetupPinFailure.title(): String {
|
||||
return when (this) {
|
||||
CreatePinFailure.PinBlacklisted -> stringResource(id = R.string.screen_app_lock_setup_pin_blacklisted_dialog_title)
|
||||
CreatePinFailure.PinsDontMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_title)
|
||||
SetupPinFailure.PinBlacklisted -> stringResource(id = R.string.screen_app_lock_setup_pin_blacklisted_dialog_title)
|
||||
SetupPinFailure.PinsDontMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_title)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,9 +225,9 @@ private fun PinDigitView(
|
||||
|
||||
@Composable
|
||||
@PreviewsDayNight
|
||||
internal fun CreatePinViewPreview(@PreviewParameter(CreatePinStateProvider::class) state: CreatePinState) {
|
||||
internal fun SetupPinViewPreview(@PreviewParameter(SetupPinStateProvider::class) state: SetupPinState) {
|
||||
ElementPreview {
|
||||
CreatePinView(
|
||||
SetupPinView(
|
||||
state = state,
|
||||
onBackClicked = {},
|
||||
)
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create.model
|
||||
package io.element.android.features.lockscreen.impl.setup.model
|
||||
|
||||
sealed interface PinDigit {
|
||||
data object Empty : PinDigit
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create.model
|
||||
package io.element.android.features.lockscreen.impl.setup.model
|
||||
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create.validation
|
||||
package io.element.android.features.lockscreen.impl.setup.validation
|
||||
|
||||
sealed interface CreatePinFailure {
|
||||
data object PinBlacklisted : CreatePinFailure
|
||||
data object PinsDontMatch : CreatePinFailure
|
||||
sealed interface SetupPinFailure {
|
||||
data object PinBlacklisted : SetupPinFailure
|
||||
data object PinsDontMatch : SetupPinFailure
|
||||
}
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create.validation
|
||||
package io.element.android.features.lockscreen.impl.setup.validation
|
||||
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import io.element.android.features.lockscreen.impl.create.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.setup.model.PinEntry
|
||||
import javax.inject.Inject
|
||||
|
||||
class PinValidator @Inject constructor() {
|
||||
@@ -29,14 +29,14 @@ class PinValidator @Inject constructor() {
|
||||
|
||||
sealed interface Result {
|
||||
data object Valid : Result
|
||||
data class Invalid(val failure: CreatePinFailure) : Result
|
||||
data class Invalid(val failure: SetupPinFailure) : Result
|
||||
}
|
||||
|
||||
fun isPinValid(pinEntry: PinEntry): Result {
|
||||
val pinAsText = pinEntry.toText()
|
||||
val isBlacklisted = BLACKLIST.any { it == pinAsText }
|
||||
return if (isBlacklisted) {
|
||||
Result.Invalid(CreatePinFailure.PinBlacklisted)
|
||||
Result.Invalid(SetupPinFailure.PinBlacklisted)
|
||||
} else {
|
||||
Result.Valid
|
||||
}
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.auth
|
||||
package io.element.android.features.lockscreen.impl.unlock
|
||||
|
||||
sealed interface PinAuthenticationEvents {
|
||||
data object Unlock : PinAuthenticationEvents
|
||||
sealed interface PinUnlockEvents {
|
||||
data object Unlock : PinUnlockEvents
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.auth
|
||||
package io.element.android.features.lockscreen.impl.unlock
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -27,16 +27,16 @@ import io.element.android.anvilannotations.ContributesNode
|
||||
import io.element.android.libraries.di.AppScope
|
||||
|
||||
@ContributesNode(AppScope::class)
|
||||
class PinAuthenticationNode @AssistedInject constructor(
|
||||
class PinUnlockNode @AssistedInject constructor(
|
||||
@Assisted buildContext: BuildContext,
|
||||
@Assisted plugins: List<Plugin>,
|
||||
private val presenter: PinAuthenticationPresenter,
|
||||
private val presenter: PinUnlockPresenter,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
|
||||
@Composable
|
||||
override fun View(modifier: Modifier) {
|
||||
val state = presenter.present()
|
||||
PinAuthenticationView(
|
||||
PinUnlockView(
|
||||
state = state,
|
||||
modifier = modifier
|
||||
)
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.auth
|
||||
package io.element.android.features.lockscreen.impl.unlock
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import io.element.android.features.lockscreen.api.LockScreenStateService
|
||||
@@ -23,20 +23,20 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
class PinAuthenticationPresenter @Inject constructor(
|
||||
class PinUnlockPresenter @Inject constructor(
|
||||
private val pinStateService: LockScreenStateService,
|
||||
private val coroutineScope: CoroutineScope,
|
||||
) : Presenter<PinAuthenticationState> {
|
||||
) : Presenter<PinUnlockState> {
|
||||
|
||||
@Composable
|
||||
override fun present(): PinAuthenticationState {
|
||||
override fun present(): PinUnlockState {
|
||||
|
||||
fun handleEvents(event: PinAuthenticationEvents) {
|
||||
fun handleEvents(event: PinUnlockEvents) {
|
||||
when (event) {
|
||||
PinAuthenticationEvents.Unlock -> coroutineScope.launch { pinStateService.unlock() }
|
||||
PinUnlockEvents.Unlock -> coroutineScope.launch { pinStateService.unlock() }
|
||||
}
|
||||
}
|
||||
return PinAuthenticationState(
|
||||
return PinUnlockState(
|
||||
eventSink = ::handleEvents
|
||||
)
|
||||
}
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.auth
|
||||
package io.element.android.features.lockscreen.impl.unlock
|
||||
|
||||
data class PinAuthenticationState(
|
||||
val eventSink: (PinAuthenticationEvents) -> Unit
|
||||
data class PinUnlockState(
|
||||
val eventSink: (PinUnlockEvents) -> Unit
|
||||
)
|
||||
@@ -14,17 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.auth
|
||||
package io.element.android.features.lockscreen.impl.unlock
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
||||
open class PinAuthenticationStateProvider : PreviewParameterProvider<PinAuthenticationState> {
|
||||
override val values: Sequence<PinAuthenticationState>
|
||||
open class PinUnlockStateProvider : PreviewParameterProvider<PinUnlockState> {
|
||||
override val values: Sequence<PinUnlockState>
|
||||
get() = sequenceOf(
|
||||
aPinAuthenticationState(),
|
||||
aPinUnlockState(),
|
||||
)
|
||||
}
|
||||
|
||||
fun aPinAuthenticationState() = PinAuthenticationState(
|
||||
fun aPinUnlockState() = PinUnlockState(
|
||||
eventSink = {}
|
||||
)
|
||||
@@ -14,23 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.auth
|
||||
package io.element.android.features.lockscreen.impl.unlock
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.Orientation
|
||||
import androidx.compose.foundation.gestures.scrollable
|
||||
import androidx.compose.foundation.layout.Arrangement.spacedBy
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
@@ -41,7 +36,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.features.lockscreen.impl.auth.numpad.PinKeypad
|
||||
import io.element.android.features.lockscreen.impl.unlock.numpad.PinKeypad
|
||||
import io.element.android.libraries.designsystem.atomic.pages.HeaderFooterPage
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
@@ -52,13 +47,13 @@ import io.element.android.libraries.designsystem.theme.components.Text
|
||||
import io.element.android.libraries.theme.ElementTheme
|
||||
|
||||
@Composable
|
||||
fun PinAuthenticationView(
|
||||
state: PinAuthenticationState,
|
||||
fun PinUnlockView(
|
||||
state: PinUnlockState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Surface(modifier) {
|
||||
HeaderFooterPage(
|
||||
header = { PinAuthenticationHeader(modifier = Modifier.padding(top = 60.dp, bottom = 12.dp)) },
|
||||
header = { PinUnlockHeader(modifier = Modifier.padding(top = 60.dp, bottom = 12.dp)) },
|
||||
content = {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
@@ -76,12 +71,12 @@ fun PinAuthenticationView(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PinAuthenticationFooter(state: PinAuthenticationState) {
|
||||
private fun PinUnlockFooter(state: PinUnlockState) {
|
||||
Button(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = "Unlock",
|
||||
onClick = {
|
||||
state.eventSink(PinAuthenticationEvents.Unlock)
|
||||
state.eventSink(PinUnlockEvents.Unlock)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -116,7 +111,7 @@ private fun PinDot(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PinAuthenticationHeader(
|
||||
private fun PinUnlockHeader(
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(modifier, horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
@@ -151,9 +146,9 @@ private fun PinAuthenticationHeader(
|
||||
|
||||
@Composable
|
||||
@PreviewsDayNight
|
||||
internal fun PinAuthenticationViewPreview(@PreviewParameter(PinAuthenticationStateProvider::class) state: PinAuthenticationState) {
|
||||
internal fun PinUnlockViewPreview(@PreviewParameter(PinUnlockStateProvider::class) state: PinUnlockState) {
|
||||
ElementPreview {
|
||||
PinAuthenticationView(
|
||||
PinUnlockView(
|
||||
state = state,
|
||||
)
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.auth.numpad
|
||||
package io.element.android.features.lockscreen.impl.unlock.numpad
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.auth.numpad
|
||||
package io.element.android.features.lockscreen.impl.unlock.numpad
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.lockscreen.impl.create
|
||||
package io.element.android.features.lockscreen.impl.setup
|
||||
|
||||
import app.cash.molecule.RecompositionMode
|
||||
import app.cash.molecule.moleculeFlow
|
||||
import app.cash.turbine.test
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.features.lockscreen.impl.create.model.PinDigit
|
||||
import io.element.android.features.lockscreen.impl.create.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.create.validation.CreatePinFailure
|
||||
import io.element.android.features.lockscreen.impl.create.validation.PinValidator
|
||||
import io.element.android.features.lockscreen.impl.setup.model.PinDigit
|
||||
import io.element.android.features.lockscreen.impl.setup.model.PinEntry
|
||||
import io.element.android.features.lockscreen.impl.setup.validation.CreatePinFailure
|
||||
import io.element.android.features.lockscreen.impl.setup.validation.PinValidator
|
||||
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||
import io.element.android.tests.testutils.awaitLastSequentialItem
|
||||
import kotlinx.coroutines.test.runTest
|
||||
Reference in New Issue
Block a user