From 1a94be4e9edb4c6967ec45c2cdc7e12b477c0e0e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Jul 2024 16:24:29 +0200 Subject: [PATCH 1/6] Rework. Keep `io.element.android.appconfig.LockScreenConfig` as simple as possible. --- appconfig/build.gradle.kts | 7 --- .../android/appconfig/LockScreenConfig.kt | 56 +++++++------------ .../impl/DefaultLockScreenService.kt | 1 - .../lockscreen/impl/LockScreenConfig.kt | 49 ++++++++++++++++ .../DefaultBiometricUnlockManager.kt | 2 +- .../settings/LockScreenSettingsPresenter.kt | 2 +- .../impl/setup/pin/SetupPinPresenter.kt | 2 +- .../impl/setup/pin/validation/PinValidator.kt | 2 +- .../storage/PreferencesLockScreenStore.kt | 2 +- .../impl/fixtures/LockScreenConfig.kt | 2 +- .../LockScreenSettingsPresenterTest.kt | 2 +- .../impl/setup/pin/SetupPinPresenterTest.kt | 2 +- 12 files changed, 77 insertions(+), 52 deletions(-) create mode 100644 features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/LockScreenConfig.kt diff --git a/appconfig/build.gradle.kts b/appconfig/build.gradle.kts index a6e66f1462..bb3f16e3b4 100644 --- a/appconfig/build.gradle.kts +++ b/appconfig/build.gradle.kts @@ -15,20 +15,13 @@ */ plugins { id("io.element.android-library") - alias(libs.plugins.anvil) } android { namespace = "io.element.android.appconfig" } -anvil { - generateDaggerFactories.set(true) -} - dependencies { implementation(libs.androidx.annotationjvm) - implementation(libs.dagger) - implementation(projects.libraries.di) implementation(projects.libraries.matrix.api) } diff --git a/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt b/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt index 02586bea0d..0312265366 100644 --- a/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt +++ b/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt @@ -16,44 +16,28 @@ package io.element.android.appconfig -import com.squareup.anvil.annotations.ContributesTo -import dagger.Module -import dagger.Provides -import io.element.android.libraries.di.AppScope import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds -/** - * Configuration for the lock screen feature. - * @property isPinMandatory Whether the PIN is mandatory or not. - * @property pinBlacklist Some PINs are forbidden. - * @property pinSize The size of the PIN. - * @property maxPinCodeAttemptsBeforeLogout Number of attempts before the user is logged out. - * @property gracePeriod Time period before locking the app once backgrounded. - * @property isStrongBiometricsEnabled Authentication with strong methods (fingerprint, some face/iris unlock implementations) is supported. - * @property isWeakBiometricsEnabled Authentication with weak methods (most face/iris unlock implementations) is supported. - */ -data class LockScreenConfig( - val isPinMandatory: Boolean, - val pinBlacklist: Set, - val pinSize: Int, - val maxPinCodeAttemptsBeforeLogout: Int, - val gracePeriod: Duration, - val isStrongBiometricsEnabled: Boolean, - val isWeakBiometricsEnabled: Boolean, -) +object LockScreenConfig { + /** Whether the PIN is mandatory or not. */ + const val IS_PIN_MANDATORY: Boolean = false -@ContributesTo(AppScope::class) -@Module -object LockScreenConfigModule { - @Provides - fun providesLockScreenConfig(): LockScreenConfig = LockScreenConfig( - isPinMandatory = false, - pinBlacklist = setOf("0000", "1234"), - pinSize = 4, - maxPinCodeAttemptsBeforeLogout = 3, - gracePeriod = 0.seconds, - isStrongBiometricsEnabled = true, - isWeakBiometricsEnabled = true, - ) + /** Set of forbidden PIN. */ + val PIN_BLACKLIST: Set = setOf("0000", "1234") + + /** The size of the PIN */ + const val PIN_SIZE: Int = 4 + + /** Number of attempts before the user is logged out. */ + const val MAX_PIN_CODE_ATTEMPTS_BEFORE_LOGOUT: Int = 3 + + /** Time period before locking the app once backgrounded. */ + val GRACE_PERIOD: Duration = 0.seconds + + /** Authentication with strong methods (fingerprint, some face/iris unlock implementations) is supported. */ + const val IS_STRONG_BIOMETRICS_ENABLED: Boolean = true + + /** Authentication with weak methods (most face/iris unlock implementations) is supported. */ + const val IS_WEAK_BIOMETRICS_ENABLED: Boolean = true } diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/DefaultLockScreenService.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/DefaultLockScreenService.kt index b0b7ab75b3..a72649a125 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/DefaultLockScreenService.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/DefaultLockScreenService.kt @@ -17,7 +17,6 @@ package io.element.android.features.lockscreen.impl import com.squareup.anvil.annotations.ContributesBinding -import io.element.android.appconfig.LockScreenConfig import io.element.android.features.lockscreen.api.LockScreenLockState import io.element.android.features.lockscreen.api.LockScreenService import io.element.android.features.lockscreen.impl.biometric.BiometricUnlockManager diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/LockScreenConfig.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/LockScreenConfig.kt new file mode 100644 index 0000000000..15eaaaab08 --- /dev/null +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/LockScreenConfig.kt @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 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 + * + * https://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.impl + +import com.squareup.anvil.annotations.ContributesTo +import dagger.Module +import dagger.Provides +import io.element.android.libraries.di.AppScope +import kotlin.time.Duration +import io.element.android.appconfig.LockScreenConfig as AppConfigLockScreenConfig + +data class LockScreenConfig( + val isPinMandatory: Boolean, + val pinBlacklist: Set, + val pinSize: Int, + val maxPinCodeAttemptsBeforeLogout: Int, + val gracePeriod: Duration, + val isStrongBiometricsEnabled: Boolean, + val isWeakBiometricsEnabled: Boolean, +) + +@ContributesTo(AppScope::class) +@Module +object LockScreenConfigModule { + @Provides + fun providesLockScreenConfig(): LockScreenConfig = LockScreenConfig( + isPinMandatory = AppConfigLockScreenConfig.IS_PIN_MANDATORY, + pinBlacklist = AppConfigLockScreenConfig.PIN_BLACKLIST, + pinSize = AppConfigLockScreenConfig.PIN_SIZE, + maxPinCodeAttemptsBeforeLogout = AppConfigLockScreenConfig.MAX_PIN_CODE_ATTEMPTS_BEFORE_LOGOUT, + gracePeriod = AppConfigLockScreenConfig.GRACE_PERIOD, + isStrongBiometricsEnabled = AppConfigLockScreenConfig.IS_STRONG_BIOMETRICS_ENABLED, + isWeakBiometricsEnabled = AppConfigLockScreenConfig.IS_WEAK_BIOMETRICS_ENABLED, + ) +} diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/biometric/DefaultBiometricUnlockManager.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/biometric/DefaultBiometricUnlockManager.kt index 95951866f3..68020ba20a 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/biometric/DefaultBiometricUnlockManager.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/biometric/DefaultBiometricUnlockManager.kt @@ -32,7 +32,7 @@ import androidx.compose.ui.res.stringResource import androidx.core.content.getSystemService import androidx.fragment.app.FragmentActivity import com.squareup.anvil.annotations.ContributesBinding -import io.element.android.appconfig.LockScreenConfig +import io.element.android.features.lockscreen.impl.LockScreenConfig import io.element.android.features.lockscreen.impl.R import io.element.android.features.lockscreen.impl.storage.LockScreenStore import io.element.android.libraries.cryptography.api.EncryptionDecryptionService diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/settings/LockScreenSettingsPresenter.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/settings/LockScreenSettingsPresenter.kt index fbbe0442c1..b0cb97350a 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/settings/LockScreenSettingsPresenter.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/settings/LockScreenSettingsPresenter.kt @@ -23,7 +23,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.produceState import androidx.compose.runtime.remember import androidx.compose.runtime.setValue -import io.element.android.appconfig.LockScreenConfig +import io.element.android.features.lockscreen.impl.LockScreenConfig import io.element.android.features.lockscreen.impl.biometric.BiometricUnlockManager import io.element.android.features.lockscreen.impl.pin.PinCodeManager import io.element.android.features.lockscreen.impl.storage.LockScreenStore diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt index ff2bdc56db..ac87d8b2f7 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt @@ -22,7 +22,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue -import io.element.android.appconfig.LockScreenConfig +import io.element.android.features.lockscreen.impl.LockScreenConfig import io.element.android.features.lockscreen.impl.pin.PinCodeManager import io.element.android.features.lockscreen.impl.pin.model.PinEntry import io.element.android.features.lockscreen.impl.setup.pin.validation.PinValidator diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/PinValidator.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/PinValidator.kt index 22e6275079..602ff4ccf0 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/PinValidator.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/PinValidator.kt @@ -16,7 +16,7 @@ package io.element.android.features.lockscreen.impl.setup.pin.validation -import io.element.android.appconfig.LockScreenConfig +import io.element.android.features.lockscreen.impl.LockScreenConfig import io.element.android.features.lockscreen.impl.pin.model.PinEntry import javax.inject.Inject diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/storage/PreferencesLockScreenStore.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/storage/PreferencesLockScreenStore.kt index b32ef8fd4c..dd0e4c67f6 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/storage/PreferencesLockScreenStore.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/storage/PreferencesLockScreenStore.kt @@ -25,7 +25,7 @@ import androidx.datastore.preferences.core.intPreferencesKey import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore import com.squareup.anvil.annotations.ContributesBinding -import io.element.android.appconfig.LockScreenConfig +import io.element.android.features.lockscreen.impl.LockScreenConfig import io.element.android.libraries.di.AppScope import io.element.android.libraries.di.ApplicationContext import io.element.android.libraries.di.SingleIn diff --git a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/fixtures/LockScreenConfig.kt b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/fixtures/LockScreenConfig.kt index aa575eabd4..cf95830539 100644 --- a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/fixtures/LockScreenConfig.kt +++ b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/fixtures/LockScreenConfig.kt @@ -16,7 +16,7 @@ package io.element.android.features.lockscreen.impl.fixtures -import io.element.android.appconfig.LockScreenConfig +import io.element.android.features.lockscreen.impl.LockScreenConfig import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds diff --git a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/settings/LockScreenSettingsPresenterTest.kt b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/settings/LockScreenSettingsPresenterTest.kt index c3358c471c..46baf620f4 100644 --- a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/settings/LockScreenSettingsPresenterTest.kt +++ b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/settings/LockScreenSettingsPresenterTest.kt @@ -20,7 +20,7 @@ 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.appconfig.LockScreenConfig +import io.element.android.features.lockscreen.impl.LockScreenConfig import io.element.android.features.lockscreen.impl.biometric.FakeBiometricUnlockManager import io.element.android.features.lockscreen.impl.fixtures.aLockScreenConfig import io.element.android.features.lockscreen.impl.fixtures.aPinCodeManager diff --git a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt index 36774d9ef4..10f1a6abc5 100644 --- a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt +++ b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt @@ -20,7 +20,7 @@ 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.appconfig.LockScreenConfig +import io.element.android.features.lockscreen.impl.LockScreenConfig import io.element.android.features.lockscreen.impl.fixtures.aLockScreenConfig import io.element.android.features.lockscreen.impl.fixtures.aPinCodeManager import io.element.android.features.lockscreen.impl.pin.DefaultPinCodeManagerCallback From 6d65c90e8105091b927f5c8beab3b59c7a36c673 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Jul 2024 16:09:09 +0200 Subject: [PATCH 2/6] Some renaming. --- .../io/element/android/appconfig/LockScreenConfig.kt | 4 ++-- .../features/lockscreen/impl/LockScreenConfig.kt | 4 ++-- .../lockscreen/impl/setup/pin/SetupPinPresenter.kt | 2 +- .../lockscreen/impl/setup/pin/SetupPinStateProvider.kt | 2 +- .../features/lockscreen/impl/setup/pin/SetupPinView.kt | 4 ++-- .../impl/setup/pin/validation/PinValidator.kt | 6 +++--- .../impl/setup/pin/validation/SetupPinFailure.kt | 2 +- .../impl/src/main/res/values-be/translations.xml | 4 ++-- .../impl/src/main/res/values-bg/translations.xml | 2 +- .../impl/src/main/res/values-cs/translations.xml | 4 ++-- .../impl/src/main/res/values-de/translations.xml | 4 ++-- .../impl/src/main/res/values-el/translations.xml | 4 ++-- .../impl/src/main/res/values-es/translations.xml | 4 ++-- .../impl/src/main/res/values-et/translations.xml | 4 ++-- .../impl/src/main/res/values-fr/translations.xml | 4 ++-- .../impl/src/main/res/values-hu/translations.xml | 4 ++-- .../impl/src/main/res/values-in/translations.xml | 4 ++-- .../impl/src/main/res/values-it/translations.xml | 4 ++-- .../impl/src/main/res/values-pt/translations.xml | 4 ++-- .../impl/src/main/res/values-ro/translations.xml | 4 ++-- .../impl/src/main/res/values-ru/translations.xml | 4 ++-- .../impl/src/main/res/values-sk/translations.xml | 4 ++-- .../impl/src/main/res/values-sv/translations.xml | 4 ++-- .../impl/src/main/res/values-uk/translations.xml | 4 ++-- .../impl/src/main/res/values-zh-rTW/translations.xml | 4 ++-- .../impl/src/main/res/values-zh/translations.xml | 4 ++-- .../lockscreen/impl/src/main/res/values/localazy.xml | 4 ++-- .../lockscreen/impl/fixtures/LockScreenConfig.kt | 4 ++-- .../lockscreen/impl/setup/pin/SetupPinPresenterTest.kt | 10 +++++----- 29 files changed, 58 insertions(+), 58 deletions(-) diff --git a/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt b/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt index 0312265366..78ed65b070 100644 --- a/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt +++ b/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt @@ -23,8 +23,8 @@ object LockScreenConfig { /** Whether the PIN is mandatory or not. */ const val IS_PIN_MANDATORY: Boolean = false - /** Set of forbidden PIN. */ - val PIN_BLACKLIST: Set = setOf("0000", "1234") + /** Set of forbidden PIN codes. */ + val FORBIDDEN_PIN_CODES: Set = setOf("0000", "1234") /** The size of the PIN */ const val PIN_SIZE: Int = 4 diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/LockScreenConfig.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/LockScreenConfig.kt index 15eaaaab08..b6f901de59 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/LockScreenConfig.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/LockScreenConfig.kt @@ -25,7 +25,7 @@ import io.element.android.appconfig.LockScreenConfig as AppConfigLockScreenConfi data class LockScreenConfig( val isPinMandatory: Boolean, - val pinBlacklist: Set, + val forbiddenPinCodes: Set, val pinSize: Int, val maxPinCodeAttemptsBeforeLogout: Int, val gracePeriod: Duration, @@ -39,7 +39,7 @@ object LockScreenConfigModule { @Provides fun providesLockScreenConfig(): LockScreenConfig = LockScreenConfig( isPinMandatory = AppConfigLockScreenConfig.IS_PIN_MANDATORY, - pinBlacklist = AppConfigLockScreenConfig.PIN_BLACKLIST, + forbiddenPinCodes = AppConfigLockScreenConfig.FORBIDDEN_PIN_CODES, pinSize = AppConfigLockScreenConfig.PIN_SIZE, maxPinCodeAttemptsBeforeLogout = AppConfigLockScreenConfig.MAX_PIN_CODE_ATTEMPTS_BEFORE_LOGOUT, gracePeriod = AppConfigLockScreenConfig.GRACE_PERIOD, diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt index ac87d8b2f7..2f1fdadc22 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt @@ -97,7 +97,7 @@ class SetupPinPresenter @Inject constructor( choosePinEntry = choosePinEntry.clear() confirmPinEntry = confirmPinEntry.clear() } - is SetupPinFailure.PinBlacklisted -> { + is SetupPinFailure.ForbiddenPin -> { choosePinEntry = choosePinEntry.clear() } null -> Unit diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinStateProvider.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinStateProvider.kt index d1820ea75d..1e8274b1b8 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinStateProvider.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinStateProvider.kt @@ -39,7 +39,7 @@ open class SetupPinStateProvider : PreviewParameterProvider { ), aSetupPinState( choosePinEntry = PinEntry.createEmpty(4).fillWith("1111"), - creationFailure = SetupPinFailure.PinBlacklisted + creationFailure = SetupPinFailure.ForbiddenPin ), ) } diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinView.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinView.kt index 2a0e890470..61d89bf3fd 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinView.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinView.kt @@ -135,7 +135,7 @@ private fun SetupPinContent( @Composable private fun SetupPinFailure.content(): String { return when (this) { - SetupPinFailure.PinBlacklisted -> stringResource(id = R.string.screen_app_lock_setup_pin_blacklisted_dialog_content) + SetupPinFailure.ForbiddenPin -> stringResource(id = R.string.screen_app_lock_setup_pin_forbidden_dialog_content) SetupPinFailure.PinsDontMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_content) } } @@ -143,7 +143,7 @@ private fun SetupPinFailure.content(): String { @Composable private fun SetupPinFailure.title(): String { return when (this) { - SetupPinFailure.PinBlacklisted -> stringResource(id = R.string.screen_app_lock_setup_pin_blacklisted_dialog_title) + SetupPinFailure.ForbiddenPin -> stringResource(id = R.string.screen_app_lock_setup_pin_forbidden_dialog_title) SetupPinFailure.PinsDontMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_title) } } diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/PinValidator.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/PinValidator.kt index 602ff4ccf0..b7f96ecec8 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/PinValidator.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/PinValidator.kt @@ -28,9 +28,9 @@ class PinValidator @Inject constructor(private val lockScreenConfig: LockScreenC fun isPinValid(pinEntry: PinEntry): Result { val pinAsText = pinEntry.toText() - val isBlacklisted = lockScreenConfig.pinBlacklist.any { it == pinAsText } - return if (isBlacklisted) { - Result.Invalid(SetupPinFailure.PinBlacklisted) + val isForbidden = lockScreenConfig.forbiddenPinCodes.any { it == pinAsText } + return if (isForbidden) { + Result.Invalid(SetupPinFailure.ForbiddenPin) } else { Result.Valid } diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/SetupPinFailure.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/SetupPinFailure.kt index 271dcc2f2c..873220eef7 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/SetupPinFailure.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/SetupPinFailure.kt @@ -17,6 +17,6 @@ package io.element.android.features.lockscreen.impl.setup.pin.validation sealed interface SetupPinFailure { - data object PinBlacklisted : SetupPinFailure + data object ForbiddenPin : SetupPinFailure data object PinsDontMatch : SetupPinFailure } diff --git a/features/lockscreen/impl/src/main/res/values-be/translations.xml b/features/lockscreen/impl/src/main/res/values-be/translations.xml index e38af70014..7667034623 100644 --- a/features/lockscreen/impl/src/main/res/values-be/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-be/translations.xml @@ -14,11 +14,11 @@ "Эканомце час і выкарыстоўвайце %1$s для разблакіроўкі праграмы" "Выберыце PIN-код" "Пацвярджэнне PIN-кода" - "Вы не можаце выбраць гэты PIN-код з меркаванняў бяспекі" - "Выберыце іншы PIN-код" "Заблакіруйце %1$s, каб павялічыць бяспеку вашых чатаў. Абярыце што-небудзь незабыўнае. Калі вы забудзецеся гэты PIN-код, вы выйдзеце з праграмы." + "Вы не можаце выбраць гэты PIN-код з меркаванняў бяспекі" + "Выберыце іншы PIN-код" "Увядзіце адзін і той жа PIN двойчы" "PIN-коды не супадаюць" "Каб працягнуць, вам неабходна паўторна ўвайсці ў сістэму і стварыць новы PIN-код" diff --git a/features/lockscreen/impl/src/main/res/values-bg/translations.xml b/features/lockscreen/impl/src/main/res/values-bg/translations.xml index a1b8ecda84..af8e8a9853 100644 --- a/features/lockscreen/impl/src/main/res/values-bg/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-bg/translations.xml @@ -9,7 +9,7 @@ "Предпочитам да използвам PIN" "Избор на PIN" "Потвърждаване на PIN" - "Избор на различен PIN" + "Избор на различен PIN" "Моля, въведете един и същ PIN два пъти" "PINs не съвпадат" diff --git a/features/lockscreen/impl/src/main/res/values-cs/translations.xml b/features/lockscreen/impl/src/main/res/values-cs/translations.xml index 264b9f08e5..b9984b1dc3 100644 --- a/features/lockscreen/impl/src/main/res/values-cs/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-cs/translations.xml @@ -14,11 +14,11 @@ "Ušetřete si čas a použijte pokaždé %1$s pro odemknutí aplikace" "Zvolte PIN" "Potvrďte PIN" - "Z bezpečnostních důvodů si toto nemůžete zvolit jako svůj PIN kód" - "Zvolte jiný PIN" "Zamkněte %1$s pro zvýšení bezpečnosti vašich konverzací. Vyberte si něco zapamatovatelného. Pokud tento kód PIN zapomenete, budete z aplikace odhlášeni." + "Z bezpečnostních důvodů si toto nemůžete zvolit jako svůj PIN kód" + "Zvolte jiný PIN" "Zadejte stejný PIN dvakrát" "PIN kódy se neshodují." "Abyste mohli pokračovat, budete se muset znovu přihlásit a vytvořit nový PIN" diff --git a/features/lockscreen/impl/src/main/res/values-de/translations.xml b/features/lockscreen/impl/src/main/res/values-de/translations.xml index 53df8aeca0..bf89b3f5e4 100644 --- a/features/lockscreen/impl/src/main/res/values-de/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-de/translations.xml @@ -14,11 +14,11 @@ "Spare dir etwas Zeit und benutze %1$s, um die App zu entsperren" "PIN wählen" "PIN bestätigen" - "Aus Sicherheitsgründen kann dieser PIN-Code nicht verwendet werden." - "Bitte eine andere PIN verwenden." "Sperre %1$s mit einem PIN Code, um den Zugriff auf deine Chats zu beschränken. Wähle etwas Einprägsames. Bei falscher Eingabe wirst du aus der App ausgeloggt." + "Aus Sicherheitsgründen kann dieser PIN-Code nicht verwendet werden." + "Bitte eine andere PIN verwenden." "Bitte gib die gleiche PIN wie zuvor ein." "Die PINs stimmen nicht überein" "Um fortzufahren, musst du dich erneut anmelden und eine neue PIN erstellen" diff --git a/features/lockscreen/impl/src/main/res/values-el/translations.xml b/features/lockscreen/impl/src/main/res/values-el/translations.xml index a7a8e954c1..ebc22971c2 100644 --- a/features/lockscreen/impl/src/main/res/values-el/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-el/translations.xml @@ -14,11 +14,11 @@ "Εξοικονόμησε χρόνο και χρησιμοποίησε %1$s για να ξεκλειδώσεις την εφαρμογή κάθε φορά" "Επέλεξε PIN" "Επιβεβαίωση PIN" - "Δεν μπορείς να το επιλέξεις ως κωδικό PIN για λόγους ασφαλείας" - "Επέλεξε διαφορετικό PIN" "Κλείδωμα του %1$s για να προσθέσεις επιπλέον ασφάλεια στις συνομιλίες σου. Επέλεξε κάτι αξιομνημόνευτο. Εάν ξεχάσεις αυτό το PIN, θα αποσυνδεθείς από την εφαρμογή." + "Δεν μπορείς να το επιλέξεις ως κωδικό PIN για λόγους ασφαλείας" + "Επέλεξε διαφορετικό PIN" "Παρακαλώ εισήγαγε το ίδιο PIN δύο φορές" "Τα PIN δεν ταιριάζουν" "Θα χρειαστεί να συνδεθείς ξανά και να δημιουργήσεις ένα νέο PIN για να προχωρήσεις" diff --git a/features/lockscreen/impl/src/main/res/values-es/translations.xml b/features/lockscreen/impl/src/main/res/values-es/translations.xml index c034d14fb0..1ab64c8f3b 100644 --- a/features/lockscreen/impl/src/main/res/values-es/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-es/translations.xml @@ -14,11 +14,11 @@ "Ahorra algo de tiempo y usa %1$s para desbloquear la aplicación cada vez" "Elegir PIN" "Confirmar PIN" - "No puedes usar este código PIN por motivos de seguridad" - "Elige un PIN diferente" "Añade un bloqueo a %1$s para añadir seguridad adicional a tus chats. Elige algo que puedas recordar. Si olvidas este PIN, se cerrará la sesión de la aplicación." + "No puedes usar este código PIN por motivos de seguridad" + "Elige un PIN diferente" "Por favor ingresa el mismo PIN dos veces" "Los PINs no coinciden" "Tendrás que volver a iniciar sesión y crear un nuevo PIN para continuar" diff --git a/features/lockscreen/impl/src/main/res/values-et/translations.xml b/features/lockscreen/impl/src/main/res/values-et/translations.xml index fd2632b884..25c2300510 100644 --- a/features/lockscreen/impl/src/main/res/values-et/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-et/translations.xml @@ -14,11 +14,11 @@ "Säästa aega ja kasuta alati %1$s rakenduse lukustuse eemaldamiseks" "Vali PIN-kood" "Korda PIN-koodi" - "Turvakaalutlustel sa ei saa sellist PIN-koodi kasutada" - "Kasuta mõnda teist PIN-koodi" "Lisamaks oma %1$s vestlustele turvalisust ja privaatsust, lukusta oma nutiseade. Vali midagi, mis hästi meelde jääb. Kui unustad selle PIN-koodi, siis turvakaalutlustel logitakse sind rakendusest välja." + "Turvakaalutlustel sa ei saa sellist PIN-koodi kasutada" + "Kasuta mõnda teist PIN-koodi" "Palun sisesta sama PIN-kood kaks korda" "PIN-koodid ei klapi omavahel" "Jätkamaks pead uuesti sisse logima ja looma uue PIN-koodi" diff --git a/features/lockscreen/impl/src/main/res/values-fr/translations.xml b/features/lockscreen/impl/src/main/res/values-fr/translations.xml index e086a88e61..a8b3757022 100644 --- a/features/lockscreen/impl/src/main/res/values-fr/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-fr/translations.xml @@ -14,11 +14,11 @@ "Gagnez du temps en utilisant %1$s pour déverrouiller l’application à chaque fois." "Choisissez un code PIN" "Confirmer le code PIN" - "Vous ne pouvez pas choisir ce code PIN pour des raisons de sécurité" - "Choisissez un code PIN différent" "Verrouillez %1$s pour ajouter une sécurité supplémentaire à vos discussions. Choisissez un code facile à retenir. Si vous oubliez le code PIN, vous serez déconnecté." + "Vous ne pouvez pas choisir ce code PIN pour des raisons de sécurité" + "Choisissez un code PIN différent" "Veuillez saisir le même code PIN deux fois" "Les codes PIN ne correspondent pas" "Pour continuer, vous devrez vous connecter à nouveau et créer un nouveau code PIN." diff --git a/features/lockscreen/impl/src/main/res/values-hu/translations.xml b/features/lockscreen/impl/src/main/res/values-hu/translations.xml index fba0444c15..2df43b3fae 100644 --- a/features/lockscreen/impl/src/main/res/values-hu/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-hu/translations.xml @@ -14,11 +14,11 @@ "Spóroljon meg némi időt, és használja a %1$st az alkalmazás feloldásához" "PIN-kód kiválasztása" "PIN-kód megerősítése" - "Ezt biztonsági okokból nem választhatja PIN-kódként" - "Válasszon egy másik PIN-kódot" "Az %1$s zárolása a csevegései nagyobb biztonsága érdekében. Válasszon valami megjegyezhetőt. Ha elfelejti a PIN-kódot, akkor ki lesz jelentkeztetve az alkalmazásból." + "Ezt biztonsági okokból nem választhatja PIN-kódként" + "Válasszon egy másik PIN-kódot" "Adja meg a PIN-kódját kétszer" "A PIN-kódok nem egyeznek" "A folytatáshoz újra be kell jelentkeznie, és létre kell hoznia egy új PIN-kódot" diff --git a/features/lockscreen/impl/src/main/res/values-in/translations.xml b/features/lockscreen/impl/src/main/res/values-in/translations.xml index 9a591be4c6..d6c7c3bc94 100644 --- a/features/lockscreen/impl/src/main/res/values-in/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-in/translations.xml @@ -14,11 +14,11 @@ "Hemat waktu Anda dan gunakan %1$s untuk membuka kunci aplikasi setiap kalinya" "Pilih PIN" "Konfirmasi PIN" - "Anda tidak dapat memilih PIN ini demi keamanan" - "Pilih PIN yang lain" "Kunci %1$s untuk menambahkan keamanan tambahan pada percakapan Anda. Pilih sesuatu yang mudah untuk diingat. Jika Anda lupa PIN ini, Anda akan dikeluarkan dari aplikasi." + "Anda tidak dapat memilih PIN ini demi keamanan" + "Pilih PIN yang lain" "Silakan masukkan PIN yang sama dua kali" "PIN tidak cocok" "Anda harus masuk ulang dan membuat PIN baru untuk melanjutkan" diff --git a/features/lockscreen/impl/src/main/res/values-it/translations.xml b/features/lockscreen/impl/src/main/res/values-it/translations.xml index 3c9cfbe45d..cdb48f8f63 100644 --- a/features/lockscreen/impl/src/main/res/values-it/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-it/translations.xml @@ -14,11 +14,11 @@ "Risparmia un po\' di tempo e usa %1$s per sbloccare l\'app ogni volta" "Scegli il PIN" "Conferma il PIN" - "Non puoi scegliere questo codice PIN per motivi di sicurezza" - "Scegli un PIN diverso" "Blocca %1$s per aggiungere ulteriore sicurezza alle tue conversazioni. Scegli qualcosa facile da ricordare. Se dimentichi questo PIN, verrai disconnesso dall\'app." + "Non puoi scegliere questo codice PIN per motivi di sicurezza" + "Scegli un PIN diverso" "Inserisci lo stesso PIN due volte" "I PIN non corrispondono" "Dovrai effettuare nuovamente l\'accesso e creare un nuovo PIN per procedere" diff --git a/features/lockscreen/impl/src/main/res/values-pt/translations.xml b/features/lockscreen/impl/src/main/res/values-pt/translations.xml index ab87d61955..b767f0266a 100644 --- a/features/lockscreen/impl/src/main/res/values-pt/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-pt/translations.xml @@ -14,11 +14,11 @@ "Poupa tempo e utiliza %1$s para desbloquear a aplicação" "Escolher PIN" "Confirmar PIN" - "Não podes escolher este código PIN por razões de segurança" - "Escolhe um PIN diferente" "Bloqueia a %1$s para dar mais segurança às tuas conversas. Escolhe algo memorável. Se te esqueceres deste PIN, a tua sessão será terminada." + "Não podes escolher este código PIN por razões de segurança" + "Escolhe um PIN diferente" "Insere o mesmo PIN duas vezes" "Os PINs não coincidem" "Terás de voltar a iniciar sessão e criar um novo PIN para continuar" diff --git a/features/lockscreen/impl/src/main/res/values-ro/translations.xml b/features/lockscreen/impl/src/main/res/values-ro/translations.xml index 06298d6ad3..69ecc93689 100644 --- a/features/lockscreen/impl/src/main/res/values-ro/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-ro/translations.xml @@ -14,11 +14,11 @@ "Economisiți timp și utilizați %1$s pentru a debloca aplicația de fiecare dată." "Alegeți codul PIN" "Confirmare PIN" - "Nu puteți alege acest cod PIN din motive de securitate" - "Alegeți un alt cod PIN" "Blocați %1$s pentru a adăuga un plus de securitate la conversațiile dvs. Alegeți ceva memorabil. Dacă uitați acest PIN, veți fi deconectat din aplicație." + "Nu puteți alege acest cod PIN din motive de securitate" + "Alegeți un alt cod PIN" "Vă rugăm să introduceți același cod PIN de două ori" "Codurile PIN nu corespund" "Va trebui să vă reconectați și să creați un cod PIN nou pentru a continua" diff --git a/features/lockscreen/impl/src/main/res/values-ru/translations.xml b/features/lockscreen/impl/src/main/res/values-ru/translations.xml index 07d4e4d3a6..dd9deb0ee1 100644 --- a/features/lockscreen/impl/src/main/res/values-ru/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-ru/translations.xml @@ -14,11 +14,11 @@ "Сэкономьте время и используйте %1$s для разблокировки приложения" "Выберите PIN-код" "Подтвердите PIN-код" - "Из соображений безопасности вы не можешь выбрать это в качестве PIN-кода" - "Выберите другой PIN-код" "Заблокируйте %1$s, чтобы повысить безопасность ваших чатов. Введите что-нибудь незабываемое. Если вы забудете этот PIN-код, вы выйдете из приложения." + "Из соображений безопасности вы не можешь выбрать это в качестве PIN-кода" + "Выберите другой PIN-код" "Повторите PIN-код" "PIN-коды не совпадают" "Чтобы продолжить, вам необходимо повторно войти в систему и создать новый PIN-код" diff --git a/features/lockscreen/impl/src/main/res/values-sk/translations.xml b/features/lockscreen/impl/src/main/res/values-sk/translations.xml index 7d78fa9fe0..7333d2a53f 100644 --- a/features/lockscreen/impl/src/main/res/values-sk/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-sk/translations.xml @@ -14,11 +14,11 @@ "Ušetrite si čas a použite zakaždým %1$s na odomknutie aplikácie" "Vyberte PIN" "Potvrdiť PIN" - "Z bezpečnostných dôvodov si nemôžete toto zvoliť ako svoj PIN kód." - "Vyberte iný PIN" "Uzamknite %1$s, aby ste zvýšili bezpečnosť svojich konverzácií. Vyberte si niečo zapamätateľné. Ak tento kód PIN zabudnete, budete z aplikácie odhlásení." + "Z bezpečnostných dôvodov si nemôžete toto zvoliť ako svoj PIN kód." + "Vyberte iný PIN" "Zadajte prosím ten istý PIN dvakrát" "PIN kódy sa nezhodujú" "Ak chcete pokračovať, musíte sa znovu prihlásiť a vytvoriť nový PIN kód." diff --git a/features/lockscreen/impl/src/main/res/values-sv/translations.xml b/features/lockscreen/impl/src/main/res/values-sv/translations.xml index 14a2faffd9..d022e6b953 100644 --- a/features/lockscreen/impl/src/main/res/values-sv/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-sv/translations.xml @@ -14,11 +14,11 @@ "Bespara dig själv lite tid och använd %1$s för att låsa upp appen varje gång" "Välj PIN-kod" "Bekräfta PIN-kod" - "Du kan inte välja detta som din PIN-kod av säkerhetsskäl" - "Välj en annan PIN-kod" "Lås %1$s för att lägga till extra säkerhet i dina chattar. Välj något minnesvärt. Om du glömmer den här PIN-koden loggas du ut från appen." + "Du kan inte välja detta som din PIN-kod av säkerhetsskäl" + "Välj en annan PIN-kod" "Ange samma PIN-kod två gånger" "PIN-koder matchar inte" "Du måste logga in igen och skapa en ny PIN-kod för att fortsätta" diff --git a/features/lockscreen/impl/src/main/res/values-uk/translations.xml b/features/lockscreen/impl/src/main/res/values-uk/translations.xml index c56d4e3d70..e97b0211ae 100644 --- a/features/lockscreen/impl/src/main/res/values-uk/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-uk/translations.xml @@ -14,11 +14,11 @@ "Заощаджуйте час і використовуйте %1$s для розблокування застосунку щоразу" "Виберіть PIN-код" "Підтвердити PIN-код" - "Ви не можете вибрати його як свій PIN-код з міркувань безпеки" - "Виберіть інший PIN-код" "Заблокуйте %1$s, щоб додати додаткову безпеку вашим чатам. Виберіть щось, що запам\'ятовується. Але якщо ви забудете PIN-код, ви вийдете з застосунку." + "Ви не можете вибрати його як свій PIN-код з міркувань безпеки" + "Виберіть інший PIN-код" "Будь ласка, введіть один і той самий PIN-код двічі" "PIN-коди не збігаються" "Щоб продовжити, вам потрібно буде повторно увійти та створити новий PIN-код" diff --git a/features/lockscreen/impl/src/main/res/values-zh-rTW/translations.xml b/features/lockscreen/impl/src/main/res/values-zh-rTW/translations.xml index 757604c4f4..48fc86718c 100644 --- a/features/lockscreen/impl/src/main/res/values-zh-rTW/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-zh-rTW/translations.xml @@ -13,11 +13,11 @@ "我想使用 PIN 碼" "選擇 PIN 碼" "確認 PIN 碼" - "基於安全性的考量,您選的 PIN 碼無法使用" - "選擇不一樣的 PIN 碼" "將 %1$s 上鎖,為你的聊天室添加一層防護。 請選擇好記憶的數字。如果忘記 PIN 碼,您會被登出。" + "基於安全性的考量,您選的 PIN 碼無法使用" + "選擇不一樣的 PIN 碼" "請輸入相同的 PIN 碼兩次" "PIN 碼不一樣" "您需要重新登入並建立新的 PIN 碼才能繼續" diff --git a/features/lockscreen/impl/src/main/res/values-zh/translations.xml b/features/lockscreen/impl/src/main/res/values-zh/translations.xml index 9d19208c6a..6fc69042a9 100644 --- a/features/lockscreen/impl/src/main/res/values-zh/translations.xml +++ b/features/lockscreen/impl/src/main/res/values-zh/translations.xml @@ -14,11 +14,11 @@ "节省时间,用 %1$s 来解锁应用程序" "选择 PIN 码" "确认 PIN 码" - "出于安全原因,您不能选择这个 PIN 码" - "选择不同的 PIN 码" "锁定 %1$s 以为聊天增加安全性。 选择好记的 PIN 码。如果忘掉了这个 PIN 码,就不得不登出应用。" + "出于安全原因,您不能选择这个 PIN 码" + "选择不同的 PIN 码" "请输入两次相同的 PIN 码" "PIN 码不匹配" "您需要重新登录并创建新的 PIN 才能继续" diff --git a/features/lockscreen/impl/src/main/res/values/localazy.xml b/features/lockscreen/impl/src/main/res/values/localazy.xml index 8f0a3def88..0836efa99b 100644 --- a/features/lockscreen/impl/src/main/res/values/localazy.xml +++ b/features/lockscreen/impl/src/main/res/values/localazy.xml @@ -14,11 +14,11 @@ "Save yourself some time and use %1$s to unlock the app each time" "Choose PIN" "Confirm PIN" - "You cannot choose this as your PIN code for security reasons" - "Choose a different PIN" "Lock %1$s to add extra security to your chats. Choose something memorable. If you forget this PIN, you will be logged out of the app." + "You cannot choose this as your PIN code for security reasons" + "Choose a different PIN" "Please enter the same PIN twice" "PINs don\'t match" "You’ll need to re-login and create a new PIN to proceed" diff --git a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/fixtures/LockScreenConfig.kt b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/fixtures/LockScreenConfig.kt index cf95830539..692e565b8b 100644 --- a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/fixtures/LockScreenConfig.kt +++ b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/fixtures/LockScreenConfig.kt @@ -22,7 +22,7 @@ import kotlin.time.Duration.Companion.seconds internal fun aLockScreenConfig( isPinMandatory: Boolean = false, - pinBlacklist: Set = emptySet(), + forbiddenPinCodes: Set = emptySet(), pinSize: Int = 4, maxPinCodeAttemptsBeforeLogout: Int = 3, gracePeriod: Duration = 3.seconds, @@ -31,7 +31,7 @@ internal fun aLockScreenConfig( ): LockScreenConfig { return LockScreenConfig( isPinMandatory = isPinMandatory, - pinBlacklist = pinBlacklist, + forbiddenPinCodes = forbiddenPinCodes, pinSize = pinSize, maxPinCodeAttemptsBeforeLogout = maxPinCodeAttemptsBeforeLogout, gracePeriod = gracePeriod, diff --git a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt index 10f1a6abc5..ecbeffc35c 100644 --- a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt +++ b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt @@ -37,7 +37,7 @@ import kotlinx.coroutines.test.runTest import org.junit.Test class SetupPinPresenterTest { - private val blacklistedPin = "1234" + private val forbiddenPin = "1234" private val halfCompletePin = "12" private val completePin = "1235" private val mismatchedPin = "1236" @@ -66,11 +66,11 @@ class SetupPinPresenterTest { state.confirmPinEntry.assertEmpty() assertThat(state.setupPinFailure).isNull() assertThat(state.isConfirmationStep).isFalse() - state.onPinEntryChanged(blacklistedPin) + state.onPinEntryChanged(forbiddenPin) } awaitLastSequentialItem().also { state -> - state.choosePinEntry.assertText(blacklistedPin) - assertThat(state.setupPinFailure).isEqualTo(SetupPinFailure.PinBlacklisted) + state.choosePinEntry.assertText(forbiddenPin) + assertThat(state.setupPinFailure).isEqualTo(SetupPinFailure.ForbiddenPin) state.eventSink(SetupPinEvents.ClearFailure) } awaitLastSequentialItem().also { state -> @@ -122,7 +122,7 @@ class SetupPinPresenterTest { private fun createSetupPinPresenter( callback: PinCodeManager.Callback, lockScreenConfig: LockScreenConfig = aLockScreenConfig( - pinBlacklist = setOf(blacklistedPin) + forbiddenPinCodes = setOf(forbiddenPin) ), ): SetupPinPresenter { val pinCodeManager = aPinCodeManager() From 8eb0d69493288709349be9425290d4b1d11c829a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Jul 2024 16:22:07 +0200 Subject: [PATCH 3/6] Change PIN grace period to 2 minutes. --- .../kotlin/io/element/android/appconfig/LockScreenConfig.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt b/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt index 78ed65b070..8e9b7b653c 100644 --- a/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt +++ b/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt @@ -17,7 +17,7 @@ package io.element.android.appconfig import kotlin.time.Duration -import kotlin.time.Duration.Companion.seconds +import kotlin.time.Duration.Companion.minutes object LockScreenConfig { /** Whether the PIN is mandatory or not. */ @@ -33,7 +33,7 @@ object LockScreenConfig { const val MAX_PIN_CODE_ATTEMPTS_BEFORE_LOGOUT: Int = 3 /** Time period before locking the app once backgrounded. */ - val GRACE_PERIOD: Duration = 0.seconds + val GRACE_PERIOD: Duration = 2.minutes /** Authentication with strong methods (fingerprint, some face/iris unlock implementations) is supported. */ const val IS_STRONG_BIOMETRICS_ENABLED: Boolean = true From 21fafe2fc91caea1d449670d62096c09efb81a23 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Jul 2024 16:26:09 +0200 Subject: [PATCH 4/6] No need to be a member of the class. --- .../features/lockscreen/impl/DefaultLockScreenService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/DefaultLockScreenService.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/DefaultLockScreenService.kt index a72649a125..55b53f054c 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/DefaultLockScreenService.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/DefaultLockScreenService.kt @@ -54,7 +54,7 @@ class DefaultLockScreenService @Inject constructor( private val coroutineScope: CoroutineScope, private val sessionObserver: SessionObserver, private val appForegroundStateService: AppForegroundStateService, - private val biometricUnlockManager: BiometricUnlockManager, + biometricUnlockManager: BiometricUnlockManager, ) : LockScreenService { private val _lockState = MutableStateFlow(LockScreenLockState.Unlocked) override val lockState: StateFlow = _lockState From 922f65cc9664e7e527a16e36ebea83e37efc501f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Jul 2024 16:27:29 +0200 Subject: [PATCH 5/6] Some renaming. --- .../features/lockscreen/impl/setup/pin/SetupPinPresenter.kt | 4 ++-- .../lockscreen/impl/setup/pin/SetupPinStateProvider.kt | 2 +- .../features/lockscreen/impl/setup/pin/SetupPinView.kt | 4 ++-- .../lockscreen/impl/setup/pin/validation/SetupPinFailure.kt | 2 +- .../lockscreen/impl/setup/pin/SetupPinPresenterTest.kt | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt index 2f1fdadc22..eec7e6a19b 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenter.kt @@ -76,7 +76,7 @@ class SetupPinPresenter @Inject constructor( if (confirmPinEntry == choosePinEntry) { pinCodeManager.createPinCode(confirmPinEntry.toText()) } else { - setupPinFailure = SetupPinFailure.PinsDontMatch + setupPinFailure = SetupPinFailure.PinsDoNotMatch } } } @@ -93,7 +93,7 @@ class SetupPinPresenter @Inject constructor( } SetupPinEvents.ClearFailure -> { when (setupPinFailure) { - is SetupPinFailure.PinsDontMatch -> { + is SetupPinFailure.PinsDoNotMatch -> { choosePinEntry = choosePinEntry.clear() confirmPinEntry = confirmPinEntry.clear() } diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinStateProvider.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinStateProvider.kt index 1e8274b1b8..f8d35ec630 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinStateProvider.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinStateProvider.kt @@ -35,7 +35,7 @@ open class SetupPinStateProvider : PreviewParameterProvider { choosePinEntry = PinEntry.createEmpty(4).fillWith("1789"), confirmPinEntry = PinEntry.createEmpty(4).fillWith("1788"), isConfirmationStep = true, - creationFailure = SetupPinFailure.PinsDontMatch + creationFailure = SetupPinFailure.PinsDoNotMatch ), aSetupPinState( choosePinEntry = PinEntry.createEmpty(4).fillWith("1111"), diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinView.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinView.kt index 61d89bf3fd..ad0b375812 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinView.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinView.kt @@ -136,7 +136,7 @@ private fun SetupPinContent( private fun SetupPinFailure.content(): String { return when (this) { SetupPinFailure.ForbiddenPin -> stringResource(id = R.string.screen_app_lock_setup_pin_forbidden_dialog_content) - SetupPinFailure.PinsDontMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_content) + SetupPinFailure.PinsDoNotMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_content) } } @@ -144,7 +144,7 @@ private fun SetupPinFailure.content(): String { private fun SetupPinFailure.title(): String { return when (this) { SetupPinFailure.ForbiddenPin -> stringResource(id = R.string.screen_app_lock_setup_pin_forbidden_dialog_title) - SetupPinFailure.PinsDontMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_title) + SetupPinFailure.PinsDoNotMatch -> stringResource(id = R.string.screen_app_lock_setup_pin_mismatch_dialog_title) } } diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/SetupPinFailure.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/SetupPinFailure.kt index 873220eef7..66f3cd0731 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/SetupPinFailure.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/pin/validation/SetupPinFailure.kt @@ -18,5 +18,5 @@ package io.element.android.features.lockscreen.impl.setup.pin.validation sealed interface SetupPinFailure { data object ForbiddenPin : SetupPinFailure - data object PinsDontMatch : SetupPinFailure + data object PinsDoNotMatch : SetupPinFailure } diff --git a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt index ecbeffc35c..3261aa9e71 100644 --- a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt +++ b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/setup/pin/SetupPinPresenterTest.kt @@ -89,7 +89,7 @@ class SetupPinPresenterTest { awaitLastSequentialItem().also { state -> state.choosePinEntry.assertText(completePin) state.confirmPinEntry.assertText(mismatchedPin) - assertThat(state.setupPinFailure).isEqualTo(SetupPinFailure.PinsDontMatch) + assertThat(state.setupPinFailure).isEqualTo(SetupPinFailure.PinsDoNotMatch) state.eventSink(SetupPinEvents.ClearFailure) } awaitLastSequentialItem().also { state -> From cf1b622da71c3a4ce45339ca150f7d6bcfd2c1e2 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Jul 2024 17:01:04 +0200 Subject: [PATCH 6/6] Doc: add missing period --- .../kotlin/io/element/android/appconfig/LockScreenConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt b/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt index 8e9b7b653c..0cfe2bd7a5 100644 --- a/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt +++ b/appconfig/src/main/kotlin/io/element/android/appconfig/LockScreenConfig.kt @@ -26,7 +26,7 @@ object LockScreenConfig { /** Set of forbidden PIN codes. */ val FORBIDDEN_PIN_CODES: Set = setOf("0000", "1234") - /** The size of the PIN */ + /** The size of the PIN. */ const val PIN_SIZE: Int = 4 /** Number of attempts before the user is logged out. */