Rework. Keep io.element.android.appconfig.LockScreenConfig as simple as possible.

This commit is contained in:
Benoit Marty
2024-07-10 16:24:29 +02:00
committed by Benoit Marty
parent 6def71ec84
commit 1a94be4e9e
12 changed files with 77 additions and 52 deletions

View File

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

View File

@@ -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<String>,
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<String> = 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
}