Fix moar ktlint issues
This commit is contained in:
parent
a831f05f6e
commit
5d086ad82d
528 changed files with 146 additions and 629 deletions
|
|
@ -26,13 +26,11 @@ import javax.inject.Inject
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultLockScreenEntryPoint @Inject constructor() : LockScreenEntryPoint {
|
||||
|
||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): LockScreenEntryPoint.NodeBuilder {
|
||||
var innerTarget: LockScreenEntryPoint.Target = LockScreenEntryPoint.Target.Unlock
|
||||
val callbacks = mutableListOf<LockScreenEntryPoint.Callback>()
|
||||
|
||||
return object : LockScreenEntryPoint.NodeBuilder {
|
||||
|
||||
override fun callback(callback: LockScreenEntryPoint.Callback): LockScreenEntryPoint.NodeBuilder {
|
||||
callbacks += callback
|
||||
return this
|
||||
|
|
|
|||
|
|
@ -57,25 +57,24 @@ class DefaultLockScreenService @Inject constructor(
|
|||
private val appForegroundStateService: AppForegroundStateService,
|
||||
private val biometricUnlockManager: BiometricUnlockManager,
|
||||
) : LockScreenService {
|
||||
|
||||
private val _lockScreenState = MutableStateFlow<LockScreenLockState>(LockScreenLockState.Unlocked)
|
||||
override val lockState: StateFlow<LockScreenLockState> = _lockScreenState
|
||||
private val _lockState = MutableStateFlow<LockScreenLockState>(LockScreenLockState.Unlocked)
|
||||
override val lockState: StateFlow<LockScreenLockState> = _lockState
|
||||
|
||||
private var lockJob: Job? = null
|
||||
|
||||
init {
|
||||
pinCodeManager.addCallback(object : DefaultPinCodeManagerCallback() {
|
||||
override fun onPinCodeVerified() {
|
||||
_lockScreenState.value = LockScreenLockState.Unlocked
|
||||
_lockState.value = LockScreenLockState.Unlocked
|
||||
}
|
||||
|
||||
override fun onPinCodeRemoved() {
|
||||
_lockScreenState.value = LockScreenLockState.Unlocked
|
||||
_lockState.value = LockScreenLockState.Unlocked
|
||||
}
|
||||
})
|
||||
biometricUnlockManager.addCallback(object : DefaultBiometricUnlockCallback() {
|
||||
override fun onBiometricUnlockSuccess() {
|
||||
_lockScreenState.value = LockScreenLockState.Unlocked
|
||||
_lockState.value = LockScreenLockState.Unlocked
|
||||
coroutineScope.launch {
|
||||
lockScreenStore.resetCounter()
|
||||
}
|
||||
|
|
@ -91,7 +90,6 @@ class DefaultLockScreenService @Inject constructor(
|
|||
*/
|
||||
private fun observeSessionsState() {
|
||||
sessionObserver.addListener(object : SessionListener {
|
||||
|
||||
override suspend fun onSessionCreated(userId: String) = Unit
|
||||
|
||||
override suspend fun onSessionDeleted(userId: String) {
|
||||
|
|
@ -135,7 +133,7 @@ class DefaultLockScreenService @Inject constructor(
|
|||
private fun CoroutineScope.lockIfNeeded(gracePeriod: Duration = Duration.ZERO) = launch {
|
||||
if (isPinSetup().first()) {
|
||||
delay(gracePeriod)
|
||||
_lockScreenState.value = LockScreenLockState.Locked
|
||||
_lockState.value = LockScreenLockState.Locked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ class LockScreenFlowNode @AssistedInject constructor(
|
|||
buildContext = buildContext,
|
||||
plugins = plugins,
|
||||
) {
|
||||
|
||||
data class Inputs(
|
||||
val initialNavTarget: NavTarget = NavTarget.Unlock,
|
||||
) : NodeInputs
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import java.security.InvalidKeyException
|
|||
import javax.crypto.Cipher
|
||||
|
||||
interface BiometricUnlock {
|
||||
|
||||
interface Callback {
|
||||
fun onBiometricSetupError()
|
||||
fun onBiometricUnlockSuccess()
|
||||
|
|
@ -62,7 +61,6 @@ class DefaultBiometricUnlock(
|
|||
private val keyAlias: String,
|
||||
private val callbacks: List<BiometricUnlock.Callback>
|
||||
) : BiometricUnlock {
|
||||
|
||||
override val isActive: Boolean = true
|
||||
|
||||
private lateinit var cryptoObject: CryptoObject
|
||||
|
|
@ -105,7 +103,6 @@ private class AuthenticationCallback(
|
|||
private val callbacks: List<BiometricUnlock.Callback>,
|
||||
private val deferredAuthenticationResult: CompletableDeferred<BiometricUnlock.AuthenticationResult>,
|
||||
) : BiometricPrompt.AuthenticationCallback() {
|
||||
|
||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
||||
super.onAuthenticationError(errorCode, errString)
|
||||
val biometricUnlockError = BiometricUnlockError(errorCode, errString.toString())
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package io.element.android.features.lockscreen.impl.biometric
|
|||
import androidx.compose.runtime.Composable
|
||||
|
||||
interface BiometricUnlockManager {
|
||||
|
||||
/**
|
||||
* If the device is secured for example with a pin, pattern or password.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ class DefaultBiometricUnlockManager @Inject constructor(
|
|||
private val secretKeyRepository: SecretKeyRepository,
|
||||
private val coroutineScope: CoroutineScope,
|
||||
) : BiometricUnlockManager {
|
||||
|
||||
private val callbacks = CopyOnWriteArrayList<BiometricUnlock.Callback>()
|
||||
private val biometricManager = BiometricManager.from(context)
|
||||
private val keyguardManager: KeyguardManager = context.getSystemService()!!
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ private fun PinDigitView(
|
|||
.size(48.dp)
|
||||
.then(appearanceModifier),
|
||||
contentAlignment = Alignment.Center,
|
||||
|
||||
) {
|
||||
if (digit is PinDigit.Filled) {
|
||||
val text = if (isSecured) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class DefaultPinCodeManager @Inject constructor(
|
|||
private val encryptionDecryptionService: EncryptionDecryptionService,
|
||||
private val lockScreenStore: LockScreenStore,
|
||||
) : PinCodeManager {
|
||||
|
||||
private val callbacks = CopyOnWriteArrayList<PinCodeManager.Callback>()
|
||||
|
||||
override fun addCallback(callback: PinCodeManager.Callback) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import kotlinx.coroutines.flow.Flow
|
|||
* Implementation should take care of encrypting the pin code and storing it.
|
||||
*/
|
||||
interface PinCodeManager {
|
||||
|
||||
/**
|
||||
* Callbacks for pin code management events.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import kotlinx.collections.immutable.toPersistentList
|
|||
data class PinEntry(
|
||||
val digits: ImmutableList<PinDigit>,
|
||||
) {
|
||||
|
||||
companion object {
|
||||
fun createEmpty(size: Int): PinEntry {
|
||||
val digits = List(size) { PinDigit.Empty }
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ class LockScreenSettingsFlowNode @AssistedInject constructor(
|
|||
buildContext = buildContext,
|
||||
plugins = plugins,
|
||||
) {
|
||||
|
||||
sealed interface NavTarget : Parcelable {
|
||||
@Parcelize
|
||||
data object Unknown : NavTarget
|
||||
|
|
@ -72,7 +71,6 @@ class LockScreenSettingsFlowNode @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private val pinCodeManagerCallback = object : DefaultPinCodeManagerCallback() {
|
||||
|
||||
override fun onPinCodeRemoved() {
|
||||
navigateUp()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ class LockScreenSettingsNode @AssistedInject constructor(
|
|||
@Assisted plugins: List<Plugin>,
|
||||
private val presenter: LockScreenSettingsPresenter,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
|
||||
interface Callback : Plugin {
|
||||
fun onChangePinClicked()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ class LockScreenSettingsPresenter @Inject constructor(
|
|||
private val biometricUnlockManager: BiometricUnlockManager,
|
||||
private val coroutineScope: CoroutineScope,
|
||||
) : Presenter<LockScreenSettingsState> {
|
||||
|
||||
@Composable
|
||||
override fun present(): LockScreenSettingsState {
|
||||
val showRemovePinOption by produceState(initialValue = false) {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ class LockScreenSetupFlowNode @AssistedInject constructor(
|
|||
buildContext = buildContext,
|
||||
plugins = plugins,
|
||||
) {
|
||||
|
||||
interface Callback : Plugin {
|
||||
fun onSetupDone()
|
||||
}
|
||||
|
|
@ -70,7 +69,6 @@ class LockScreenSetupFlowNode @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private val pinCodeManagerCallback = object : DefaultPinCodeManagerCallback() {
|
||||
|
||||
override fun onPinCodeCreated() {
|
||||
backstack.newRoot(NavTarget.Biometric)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ class SetupBiometricNode @AssistedInject constructor(
|
|||
@Assisted plugins: List<Plugin>,
|
||||
private val presenter: SetupBiometricPresenter,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
|
||||
interface Callback : Plugin {
|
||||
fun onBiometricSetupDone()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import javax.inject.Inject
|
|||
class SetupBiometricPresenter @Inject constructor(
|
||||
private val lockScreenStore: LockScreenStore,
|
||||
) : Presenter<SetupBiometricState> {
|
||||
|
||||
@Composable
|
||||
override fun present(): SetupBiometricState {
|
||||
var isBiometricSetupDone by remember {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class SetupPinNode @AssistedInject constructor(
|
|||
@Assisted plugins: List<Plugin>,
|
||||
private val presenter: SetupPinPresenter,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
|
||||
@Composable
|
||||
override fun View(modifier: Modifier) {
|
||||
val state = presenter.present()
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ class SetupPinPresenter @Inject constructor(
|
|||
private val buildMeta: BuildMeta,
|
||||
private val pinCodeManager: PinCodeManager,
|
||||
) : Presenter<SetupPinState> {
|
||||
|
||||
@Composable
|
||||
override fun present(): SetupPinState {
|
||||
var choosePinEntry by remember {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ open class SetupPinStateProvider : PreviewParameterProvider<SetupPinState> {
|
|||
choosePinEntry = PinEntry.createEmpty(4).fillWith("1111"),
|
||||
creationFailure = SetupPinFailure.PinBlacklisted
|
||||
),
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import io.element.android.features.lockscreen.impl.pin.model.PinEntry
|
|||
import javax.inject.Inject
|
||||
|
||||
class PinValidator @Inject constructor(private val lockScreenConfig: LockScreenConfig) {
|
||||
|
||||
sealed interface Result {
|
||||
data object Valid : Result
|
||||
data class Invalid(val failure: SetupPinFailure) : Result
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package io.element.android.features.lockscreen.impl.storage
|
|||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface LockScreenStore : EncryptedPinCodeStorage {
|
||||
|
||||
/**
|
||||
* Returns the remaining PIN code attempts. When this reaches 0 the PIN code access won't be available for some time.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ class PreferencesLockScreenStore @Inject constructor(
|
|||
@ApplicationContext private val context: Context,
|
||||
private val lockScreenConfig: LockScreenConfig,
|
||||
) : LockScreenStore {
|
||||
|
||||
private val pinCodeKey = stringPreferencesKey("encoded_pin_code")
|
||||
private val remainingAttemptsKey = intPreferencesKey("remaining_pin_code_attempts")
|
||||
private val biometricUnlockKey = booleanPreferencesKey("biometric_unlock_enabled")
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ class PinUnlockHelper @Inject constructor(
|
|||
private val biometricUnlockManager: BiometricUnlockManager,
|
||||
private val pinCodeManager: PinCodeManager
|
||||
) {
|
||||
|
||||
@Composable
|
||||
fun OnUnlockEffect(onUnlock: () -> Unit) {
|
||||
DisposableEffect(Unit) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class PinUnlockNode @AssistedInject constructor(
|
|||
@Assisted plugins: List<Plugin>,
|
||||
private val presenter: PinUnlockPresenter,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
|
||||
interface Callback : Plugin {
|
||||
fun onUnlock()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ class PinUnlockPresenter @Inject constructor(
|
|||
private val coroutineScope: CoroutineScope,
|
||||
private val pinUnlockHelper: PinUnlockHelper,
|
||||
) : Presenter<PinUnlockState> {
|
||||
|
||||
@Composable
|
||||
override fun present(): PinUnlockState {
|
||||
val pinEntryState = remember {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.remember
|
||||
|
||||
class FakeBiometricUnlockManager : BiometricUnlockManager {
|
||||
|
||||
override var isDeviceSecured: Boolean = true
|
||||
override var hasAvailableAuthenticator: Boolean = false
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import kotlinx.coroutines.test.runTest
|
|||
import org.junit.Test
|
||||
|
||||
class DefaultPinCodeManagerTest {
|
||||
|
||||
private val lockScreenStore = InMemoryLockScreenStore()
|
||||
private val secretKeyRepository = SimpleSecretKeyRepository()
|
||||
private val encryptionDecryptionService = AESEncryptionDecryptionService()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import com.google.common.truth.Truth.assertThat
|
|||
import org.junit.Test
|
||||
|
||||
class PinEntryTest {
|
||||
|
||||
@Test
|
||||
fun `when using fillWith with empty string ensure pin is empty`() {
|
||||
val pinEntry = PinEntry.createEmpty(4)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||
private const val DEFAULT_REMAINING_ATTEMPTS = 3
|
||||
|
||||
class InMemoryLockScreenStore : LockScreenStore {
|
||||
|
||||
private val hasPinCode = MutableStateFlow(false)
|
||||
private var pinCode: String? = null
|
||||
set(value) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import kotlinx.coroutines.test.runTest
|
|||
import org.junit.Test
|
||||
|
||||
class LockScreenSettingsPresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - remove pin flow`() = runTest {
|
||||
val presenter = createLockScreenSettingsPresenter(this)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import kotlinx.coroutines.test.runTest
|
|||
import org.junit.Test
|
||||
|
||||
class SetupBiometricPresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - allow flow`() = runTest {
|
||||
val lockScreenStore = InMemoryLockScreenStore()
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import kotlinx.coroutines.test.runTest
|
|||
import org.junit.Test
|
||||
|
||||
class SetupPinPresenterTest {
|
||||
|
||||
private val blacklistedPin = "1234"
|
||||
private val halfCompletePin = "12"
|
||||
private val completePin = "1235"
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import kotlinx.coroutines.test.runTest
|
|||
import org.junit.Test
|
||||
|
||||
class PinUnlockPresenterTest {
|
||||
|
||||
private val halfCompletePin = "12"
|
||||
private val completePin = "1235"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue