Fix moar ktlint issues

This commit is contained in:
Benoit Marty
2024-01-11 09:41:14 +01:00
committed by Benoit Marty
parent d3830af78b
commit 378692f743
528 changed files with 146 additions and 629 deletions

View File

@@ -37,7 +37,6 @@ class AnalyticsOptInNode @AssistedInject constructor(
@Assisted plugins: List<Plugin>,
private val presenter: AnalyticsOptInPresenter,
) : Node(buildContext, plugins = plugins) {
private fun onClickTerms(activity: Activity, darkTheme: Boolean) {
activity.openUrlInChromeCustomTab(null, darkTheme, AnalyticsConfig.POLICY_LINK)
}

View File

@@ -30,7 +30,6 @@ class AnalyticsOptInPresenter @Inject constructor(
private val buildMeta: BuildMeta,
private val analyticsService: AnalyticsService,
) : Presenter<AnalyticsOptInState> {
@Composable
override fun present(): AnalyticsOptInState {
val localCoroutineScope = rememberCoroutineScope()

View File

@@ -36,7 +36,6 @@ class DefaultAnalyticsPreferencesPresenter @Inject constructor(
private val analyticsService: AnalyticsService,
private val buildMeta: BuildMeta,
) : AnalyticsPreferencesPresenter {
@Composable
override fun present(): AnalyticsPreferencesState {
val localCoroutineScope = rememberCoroutineScope()

View File

@@ -30,7 +30,6 @@ import org.junit.Rule
import org.junit.Test
class AnalyticsOptInPresenterTest {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -29,7 +29,6 @@ import org.junit.Rule
import org.junit.Test
class AnalyticsPreferencesPresenterTest {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -23,7 +23,6 @@ import io.element.android.libraries.architecture.FeatureEntryPoint
import io.element.android.libraries.matrix.api.core.RoomId
interface CreateRoomEntryPoint : FeatureEntryPoint {
fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NodeBuilder
interface NodeBuilder {
fun callback(callback: Callback): NodeBuilder

View File

@@ -52,7 +52,6 @@ class ConfigureRoomFlowNode @AssistedInject constructor(
buildContext = buildContext,
plugins = plugins
) {
private val component by lazy {
parent!!.bindings<CreateRoomComponent.ParentBindings>().createRoomComponentBuilder().build()
}

View File

@@ -33,7 +33,6 @@ import javax.inject.Inject
class CreateRoomDataStore @Inject constructor(
val selectedUserListDataStore: UserListDataStore,
) {
private val createRoomConfigFlow: MutableStateFlow<CreateRoomConfig> = MutableStateFlow(CreateRoomConfig())
private var cachedAvatarUri: Uri? = null
set(value) {

View File

@@ -50,7 +50,6 @@ class CreateRoomFlowNode @AssistedInject constructor(
buildContext = buildContext,
plugins = plugins
) {
sealed interface NavTarget : Parcelable {
@Parcelize
data object Root : NavTarget

View File

@@ -27,12 +27,10 @@ import javax.inject.Inject
@ContributesBinding(AppScope::class)
class DefaultCreateRoomEntryPoint @Inject constructor() : CreateRoomEntryPoint {
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): CreateRoomEntryPoint.NodeBuilder {
val plugins = ArrayList<Plugin>()
return object : CreateRoomEntryPoint.NodeBuilder {
override fun callback(callback: CreateRoomEntryPoint.Callback): CreateRoomEntryPoint.NodeBuilder {
plugins += callback
return this

View File

@@ -35,7 +35,6 @@ class DefaultStartDMAction @Inject constructor(
private val matrixClient: MatrixClient,
private val analyticsService: AnalyticsService,
) : StartDMAction {
override suspend fun execute(userId: UserId, actionState: MutableState<AsyncAction<RoomId>>) {
actionState.value = AsyncAction.Loading
when (val result = matrixClient.startDM(userId)) {

View File

@@ -33,7 +33,6 @@ class AddPeopleNode @AssistedInject constructor(
@Assisted plugins: List<Plugin>,
private val presenter: AddPeoplePresenter,
) : Node(buildContext, plugins = plugins) {
interface Callback : Plugin {
fun onContinue()
}

View File

@@ -31,7 +31,6 @@ class AddPeoplePresenter @Inject constructor(
userRepository: UserRepository,
dataStore: CreateRoomDataStore,
) : Presenter<UserListState> {
private val userListPresenter = userListPresenterFactory.create(
UserListPresenterArgs(
selectionMode = SelectionMode.Multiple,

View File

@@ -38,7 +38,6 @@ class ConfigureRoomNode @AssistedInject constructor(
private val presenter: ConfigureRoomPresenter,
private val analyticsService: AnalyticsService,
) : Node(buildContext, plugins = plugins) {
init {
lifecycle.subscribe(
onResume = {

View File

@@ -57,7 +57,6 @@ class ConfigureRoomPresenter @Inject constructor(
private val analyticsService: AnalyticsService,
permissionsPresenterFactory: PermissionsPresenter.Factory,
) : Presenter<ConfigureRoomState> {
private val cameraPermissionPresenter: PermissionsPresenter = permissionsPresenterFactory.create(android.Manifest.permission.CAMERA)
private var pendingPermissionRequest = false

View File

@@ -26,7 +26,6 @@ import io.element.android.libraries.di.SingleIn
@SingleIn(CreateRoomScope::class)
@MergeSubcomponent(CreateRoomScope::class)
interface CreateRoomComponent : NodeFactoriesBindings {
@Subcomponent.Builder
interface Builder {
fun build(): CreateRoomComponent

View File

@@ -42,7 +42,6 @@ class CreateRoomRootNode @AssistedInject constructor(
private val analyticsService: AnalyticsService,
private val inviteFriendsUseCase: InviteFriendsUseCase,
) : Node(buildContext, plugins = plugins) {
interface Callback : Plugin {
fun onCreateNewRoom()
fun onStartChatSuccess(roomId: RoomId)

View File

@@ -41,7 +41,6 @@ class CreateRoomRootPresenter @Inject constructor(
private val startDMAction: StartDMAction,
private val buildMeta: BuildMeta,
) : Presenter<CreateRoomRootState> {
private val presenter = presenterFactory.create(
UserListPresenterArgs(
selectionMode = SelectionMode.Single,

View File

@@ -42,7 +42,6 @@ class DefaultUserListPresenter @AssistedInject constructor(
@Assisted val userRepository: UserRepository,
@Assisted val userListDataStore: UserListDataStore,
) : UserListPresenter {
@AssistedFactory
@ContributesBinding(SessionScope::class)
interface DefaultUserListFactory : UserListPresenter.Factory {

View File

@@ -22,7 +22,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
import javax.inject.Inject
class UserListDataStore @Inject constructor() {
private val selectedUsers: MutableStateFlow<List<MatrixUser>> = MutableStateFlow(emptyList())
fun selectUser(user: MatrixUser) {

View File

@@ -20,7 +20,6 @@ import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.usersearch.api.UserRepository
interface UserListPresenter : Presenter<UserListState> {
interface Factory {
fun create(
args: UserListPresenterArgs,

View File

@@ -32,7 +32,6 @@ import kotlinx.coroutines.test.runTest
import org.junit.Test
class DefaultStartDMActionTests {
@Test
fun `when dm is found, assert state is updated with given room id`() = runTest {
val matrixClient = FakeMatrixClient().apply {

View File

@@ -31,7 +31,6 @@ import org.junit.Rule
import org.junit.Test
class AddPeoplePresenterTests {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -62,7 +62,6 @@ private const val AN_URI_FROM_GALLERY = "content://uri_from_gallery"
@RunWith(RobolectricTestRunner::class)
class ConfigureRoomPresenterTests {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -38,7 +38,6 @@ import org.junit.Rule
import org.junit.Test
class CreateRoomRootPresenterTests {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -33,7 +33,6 @@ import org.junit.Rule
import org.junit.Test
class DefaultUserListPresenterTests {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -19,7 +19,6 @@ package io.element.android.features.createroom.impl.userlist
import androidx.compose.runtime.Composable
class FakeUserListPresenter : UserListPresenter {
private var state = aUserListState()
fun givenState(state: UserListState) {

View File

@@ -21,7 +21,6 @@ import io.element.android.libraries.usersearch.api.UserRepository
class FakeUserListPresenterFactory(
private val fakeUserListPresenter: FakeUserListPresenter = FakeUserListPresenter()
) : UserListPresenter.Factory {
override fun create(
args: UserListPresenterArgs,
userRepository: UserRepository,

View File

@@ -25,7 +25,6 @@ import io.element.android.libraries.matrix.test.A_ROOM_ID
import kotlinx.coroutines.delay
class FakeStartDMAction : StartDMAction {
private var executeResult: AsyncAction<RoomId> = AsyncAction.Success(A_ROOM_ID)
fun givenExecuteResult(result: AsyncAction<RoomId>) {

View File

@@ -22,7 +22,6 @@ import com.bumble.appyx.core.plugin.Plugin
import io.element.android.libraries.architecture.FeatureEntryPoint
interface FtueEntryPoint : FeatureEntryPoint {
fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NodeBuilder
interface NodeBuilder {

View File

@@ -27,12 +27,10 @@ import javax.inject.Inject
@ContributesBinding(AppScope::class)
class DefaultFtueEntryPoint @Inject constructor() : FtueEntryPoint {
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): FtueEntryPoint.NodeBuilder {
val plugins = ArrayList<Plugin>()
return object : FtueEntryPoint.NodeBuilder {
override fun callback(callback: FtueEntryPoint.Callback): FtueEntryPoint.NodeBuilder {
plugins += callback
return this

View File

@@ -70,7 +70,6 @@ class FtueFlowNode @AssistedInject constructor(
buildContext = buildContext,
plugins = plugins,
) {
sealed interface NavTarget : Parcelable {
@Parcelize
data object Placeholder : NavTarget

View File

@@ -32,7 +32,6 @@ class MigrationScreenNode @AssistedInject constructor(
@Assisted plugins: List<Plugin>,
private val presenter: MigrationScreenPresenter,
) : Node(buildContext, plugins = plugins) {
interface Callback : Plugin {
fun onMigrationFinished()
}

View File

@@ -29,7 +29,6 @@ import javax.inject.Inject
class SharedPrefsMigrationScreenStore @Inject constructor(
@DefaultPreferences private val sharedPreferences: SharedPreferences,
) : MigrationScreenStore {
override fun isMigrationScreenNeeded(sessionId: SessionId): Boolean {
return sharedPreferences.getBoolean(sessionId.toKey(), false).not()
}

View File

@@ -34,7 +34,6 @@ class NotificationsOptInNode @AssistedInject constructor(
@Assisted plugins: List<Plugin>,
presenterFactory: NotificationsOptInPresenter.Factory,
) : Node(buildContext, plugins = plugins) {
interface Callback : NodeInputs {
fun onNotificationsOptInFinished()
}

View File

@@ -40,7 +40,6 @@ class NotificationsOptInPresenter @AssistedInject constructor(
private val permissionStateProvider: PermissionStateProvider,
private val buildVersionSdkIntProvider: BuildVersionSdkIntProvider,
) : Presenter<NotificationsOptInState> {
@AssistedFactory
interface Factory {
fun create(callback: NotificationsOptInNode.Callback): NotificationsOptInPresenter

View File

@@ -48,7 +48,6 @@ class DefaultFtueState @Inject constructor(
private val lockScreenService: LockScreenService,
private val matrixClient: MatrixClient,
) : FtueState {
override val shouldDisplayFlow = MutableStateFlow(isAnyStepIncomplete())
override suspend fun reset() {

View File

@@ -33,7 +33,6 @@ class WelcomeNode @AssistedInject constructor(
@Assisted plugins: List<Plugin>,
private val buildMeta: BuildMeta,
) : Node(buildContext, plugins = plugins) {
interface Callback : Plugin {
fun onContinueClicked()
}

View File

@@ -29,7 +29,6 @@ import javax.inject.Inject
class AndroidWelcomeScreenState @Inject constructor(
@DefaultPreferences private val sharedPreferences: SharedPreferences,
) : WelcomeScreenState {
companion object {
private const val IS_WELCOME_SCREEN_SHOWN = "is_welcome_screen_shown"
}

View File

@@ -39,7 +39,6 @@ import kotlinx.coroutines.test.runTest
import org.junit.Test
class DefaultFtueStateTests {
@Test
fun `given any check being false, should display flow is true`() = runTest {
val coroutineScope = CoroutineScope(coroutineContext + SupervisorJob())
@@ -130,7 +129,8 @@ class DefaultFtueStateTests {
FtueStep.NotificationsOptIn,
FtueStep.LockscreenSetup,
FtueStep.AnalyticsOptIn,
null, // Final state
// Final state
null,
)
// Cleanup
@@ -204,7 +204,8 @@ class DefaultFtueStateTests {
permissionStateProvider: FakePermissionStateProvider = FakePermissionStateProvider(permissionGranted = false),
matrixClient: MatrixClient = FakeMatrixClient(),
lockScreenService: LockScreenService = FakeLockScreenService(),
sdkIntVersion: Int = Build.VERSION_CODES.TIRAMISU, // First version where notification permission is required
// First version where notification permission is required
sdkIntVersion: Int = Build.VERSION_CODES.TIRAMISU,
) = DefaultFtueState(
sdkVersionProvider = FakeBuildVersionSdkIntProvider(sdkIntVersion),
coroutineScope = coroutineScope,

View File

@@ -31,7 +31,6 @@ import org.junit.Rule
import org.junit.Test
class MigrationScreenPresenterTest {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -39,7 +39,6 @@ import org.junit.Rule
import org.junit.Test
class NotificationsOptInPresenterTests {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -17,7 +17,6 @@
package io.element.android.features.ftue.impl.welcome.state
class FakeWelcomeState : WelcomeScreenState {
private var isWelcomeScreenNeeded = true
override fun isWelcomeScreenNeeded(): Boolean {

View File

@@ -23,7 +23,6 @@ import io.element.android.libraries.architecture.FeatureEntryPoint
import io.element.android.libraries.matrix.api.core.RoomId
interface InviteListEntryPoint : FeatureEntryPoint {
fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NodeBuilder
interface NodeBuilder {

View File

@@ -27,12 +27,10 @@ import javax.inject.Inject
@ContributesBinding(AppScope::class)
class DefaultInviteListEntryPoint @Inject constructor() : InviteListEntryPoint {
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): InviteListEntryPoint.NodeBuilder {
val plugins = ArrayList<Plugin>()
return object : InviteListEntryPoint.NodeBuilder {
override fun callback(callback: InviteListEntryPoint.Callback): InviteListEntryPoint.NodeBuilder {
plugins += callback
return this

View File

@@ -38,7 +38,6 @@ private val seenInvitesKey = stringSetPreferencesKey("seenInvites")
class DefaultSeenInvitesStore @Inject constructor(
@ApplicationContext context: Context
) : SeenInvitesStore {
private val store = context.dataStore
override fun seenRoomIds(): Flow<Set<RoomId>> =

View File

@@ -35,7 +35,6 @@ class InviteListNode @AssistedInject constructor(
@Assisted plugins: List<Plugin>,
private val presenter: InviteListPresenter,
) : Node(buildContext, plugins = plugins) {
private fun onBackClicked() {
plugins<InviteListEntryPoint.Callback>().forEach { it.onBackClicked() }
}

View File

@@ -52,7 +52,6 @@ class InviteListPresenter @Inject constructor(
private val analyticsService: AnalyticsService,
private val notificationDrawerManager: NotificationDrawerManager,
) : Presenter<InviteListState> {
@Composable
override fun present(): InviteListState {
val invites by client

View File

@@ -22,7 +22,6 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
class FakeSeenInvitesStore : SeenInvitesStore {
private val existing = MutableStateFlow(emptySet<RoomId>())
private var provided: Set<RoomId>? = null

View File

@@ -38,7 +38,6 @@ import org.junit.Rule
import org.junit.Test
class LeaveRoomPresenterImplTest {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -22,7 +22,6 @@ import io.element.android.features.leaveroom.api.LeaveRoomPresenter
import io.element.android.features.leaveroom.api.LeaveRoomState
class FakeLeaveRoomPresenter : LeaveRoomPresenter {
val events = mutableListOf<LeaveRoomEvent>()
private fun handleEvent(event: LeaveRoomEvent) {

View File

@@ -45,14 +45,16 @@ android {
name = "maptiler_light_map_id",
value = System.getenv("ELEMENT_ANDROID_MAPTILER_LIGHT_MAP_ID")
?: readLocalProperty("services.maptiler.lightMapId")
?: "basic-v2" // fall back to maptiler's default light map.
// fall back to maptiler's default light map.
?: "basic-v2"
)
resValue(
type = "string",
name = "maptiler_dark_map_id",
value = System.getenv("ELEMENT_ANDROID_MAPTILER_DARK_MAP_ID")
?: readLocalProperty("services.maptiler.darkMapId")
?: "basic-v2-dark" // fall back to maptiler's default dark map.
// fall back to maptiler's default dark map.
?: "basic-v2-dark"
)
}
}

View File

@@ -22,7 +22,6 @@ import io.element.android.libraries.architecture.FeatureEntryPoint
import io.element.android.libraries.architecture.NodeInputs
interface ShowLocationEntryPoint : FeatureEntryPoint {
data class Inputs(val location: Location, val description: String?) : NodeInputs
fun createNode(parentNode: Node, buildContext: BuildContext, inputs: Inputs): Node

View File

@@ -29,7 +29,6 @@ internal class MapTilerStaticMapUrlBuilder(
private val lightMapId: String,
private val darkMapId: String,
) : StaticMapUrlBuilder {
constructor(context: Context) : this(
apiKey = context.apiKey,
lightMapId = context.mapId(darkMode = false),

View File

@@ -25,7 +25,6 @@ internal class MapTilerTileServerStyleUriBuilder(
private val lightMapId: String,
private val darkMapId: String,
) : TileServerStyleUriBuilder {
constructor(context: Context) : this(
apiKey = context.apiKey,
lightMapId = context.mapId(darkMode = false),

View File

@@ -20,7 +20,6 @@ import com.google.common.truth.Truth.assertThat
import org.junit.Test
internal class LocationKtTest {
@Test
fun `parseGeoUri - returns null for invalid urls`() {
assertThat(Location.fromGeoUri("")).isNull()

View File

@@ -20,7 +20,6 @@ import com.google.common.truth.Truth.assertThat
import org.junit.Test
class MapTilerStaticMapUrlBuilderTest {
private val builder = MapTilerStaticMapUrlBuilder(
apiKey = "anApiKey",
lightMapId = "aLightMapId",

View File

@@ -20,7 +20,6 @@ import com.google.common.truth.Truth.assertThat
import org.junit.Test
class MapTilerTileServerStyleUriBuilderTest {
private val builder = MapTilerTileServerStyleUriBuilder(
apiKey = "anApiKey",
lightMapId = "aLightMapId",

View File

@@ -29,7 +29,6 @@ import io.element.android.libraries.di.AppScope
class PermissionsPresenterImpl @AssistedInject constructor(
@Assisted private val permissions: List<String>
) : PermissionsPresenter {
@AssistedFactory
@ContributesBinding(AppScope::class)
interface Factory : PermissionsPresenter.Factory {

View File

@@ -36,7 +36,6 @@ class SendLocationNode @AssistedInject constructor(
private val presenter: SendLocationPresenter,
analyticsService: AnalyticsService,
) : Node(buildContext, plugins = plugins) {
init {
lifecycle.subscribe(
onResume = {

View File

@@ -47,7 +47,6 @@ class SendLocationPresenter @Inject constructor(
private val locationActions: LocationActions,
private val buildMeta: BuildMeta,
) : Presenter<SendLocationState> {
private val permissionsPresenter = permissionsPresenterFactory.create(MapDefaults.permissions)
@Composable

View File

@@ -38,7 +38,6 @@ class ShowLocationNode @AssistedInject constructor(
@Assisted buildContext: BuildContext,
@Assisted plugins: List<Plugin>,
) : Node(buildContext, plugins = plugins) {
init {
lifecycle.subscribe(
onResume = {

View File

@@ -42,7 +42,6 @@ class ShowLocationPresenter @AssistedInject constructor(
@Assisted private val location: Location,
@Assisted private val description: String?
) : Presenter<ShowLocationState> {
@AssistedFactory
interface Factory {
fun create(location: Location, description: String?): ShowLocationPresenter

View File

@@ -22,7 +22,6 @@ import org.junit.Test
import java.net.URLEncoder
internal class AndroidLocationActionsTest {
// We use an Android-native encoder in the actual app, switch to an equivalent JVM one for the tests
private fun urlEncoder(input: String) = URLEncoder.encode(input, "US-ASCII")

View File

@@ -19,7 +19,6 @@ package io.element.android.features.location.impl.common.actions
import io.element.android.features.location.api.Location
class FakeLocationActions : LocationActions {
var sharedLocation: Location? = null
private set

View File

@@ -19,7 +19,6 @@ package io.element.android.features.location.impl.common.permissions
import androidx.compose.runtime.Composable
class PermissionsPresenterFake : PermissionsPresenter {
val events = mutableListOf<PermissionsEvents>()
private fun handleEvent(event: PermissionsEvents) {

View File

@@ -42,7 +42,6 @@ import org.junit.Rule
import org.junit.Test
class SendLocationPresenterTest {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -35,7 +35,6 @@ import org.junit.Rule
import org.junit.Test
class ShowLocationPresenterTest {
@get:Rule
val warmUpRule = WarmUpRule()

View File

@@ -22,7 +22,6 @@ import com.bumble.appyx.core.plugin.Plugin
import io.element.android.libraries.architecture.FeatureEntryPoint
interface LockScreenEntryPoint : FeatureEntryPoint {
fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NodeBuilder
interface NodeBuilder {

View File

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

View File

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

View File

@@ -50,7 +50,6 @@ class LockScreenFlowNode @AssistedInject constructor(
buildContext = buildContext,
plugins = plugins,
) {
data class Inputs(
val initialNavTarget: NavTarget = NavTarget.Unlock,
) : NodeInputs

View File

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

View File

@@ -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.
*/

View File

@@ -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()!!

View File

@@ -99,7 +99,6 @@ private fun PinDigitView(
.size(48.dp)
.then(appearanceModifier),
contentAlignment = Alignment.Center,
) {
if (digit is PinDigit.Filled) {
val text = if (isSecured) {

View File

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

View File

@@ -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.
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 {

View File

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

View File

@@ -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 {

View File

@@ -41,7 +41,6 @@ open class SetupPinStateProvider : PreviewParameterProvider<SetupPinState> {
choosePinEntry = PinEntry.createEmpty(4).fillWith("1111"),
creationFailure = SetupPinFailure.PinBlacklisted
),
)
}

View File

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

View File

@@ -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.
*/

View File

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

View File

@@ -28,7 +28,6 @@ class PinUnlockHelper @Inject constructor(
private val biometricUnlockManager: BiometricUnlockManager,
private val pinCodeManager: PinCodeManager
) {
@Composable
fun OnUnlockEffect(onUnlock: () -> Unit) {
DisposableEffect(Unit) {

View File

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

View File

@@ -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 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -27,7 +27,6 @@ import kotlinx.coroutines.test.runTest
import org.junit.Test
class SetupBiometricPresenterTest {
@Test
fun `present - allow flow`() = runTest {
val lockScreenStore = InMemoryLockScreenStore()

Some files were not shown because too many files have changed in this diff Show More