From 34ca758e715fce909d76ecf2cfbf3db61b8c95fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Karpi=C5=84ski?= Date: Fri, 2 Aug 2024 21:04:32 +0200 Subject: [PATCH] Add fixes to some files that accidentally weren't added in an earlier commit --- .../medzik/librepass/android/MainActivity.kt | 2 - .../librepass/android/MigrationsManager.kt | 47 ------------------- .../librepass/android/ui/auth/LoginScreen.kt | 4 +- .../android/ui/auth/LoginViewModel.kt | 7 +-- 4 files changed, 3 insertions(+), 57 deletions(-) delete mode 100644 app/src/main/java/dev/medzik/librepass/android/MigrationsManager.kt diff --git a/app/src/main/java/dev/medzik/librepass/android/MainActivity.kt b/app/src/main/java/dev/medzik/librepass/android/MainActivity.kt index 4af8b2a7..7513ea55 100644 --- a/app/src/main/java/dev/medzik/librepass/android/MainActivity.kt +++ b/app/src/main/java/dev/medzik/librepass/android/MainActivity.kt @@ -30,8 +30,6 @@ class MainActivity : FragmentActivity() { finish() } - MigrationsManager.run(this, repository) - // retrieves aes key for vault decryption if key is valid // vault.getSecretsIfNotExpired(this) diff --git a/app/src/main/java/dev/medzik/librepass/android/MigrationsManager.kt b/app/src/main/java/dev/medzik/librepass/android/MigrationsManager.kt deleted file mode 100644 index 494ff664..00000000 --- a/app/src/main/java/dev/medzik/librepass/android/MigrationsManager.kt +++ /dev/null @@ -1,47 +0,0 @@ -package dev.medzik.librepass.android - -import android.content.Context -import dev.medzik.librepass.android.database.Repository -import dev.medzik.librepass.android.database.datastore.AppVersion -import dev.medzik.librepass.android.database.datastore.readAppVersion -import dev.medzik.librepass.android.database.datastore.writeAppVersion -import kotlinx.coroutines.runBlocking - -object MigrationsManager { - fun run( - context: Context, - repository: Repository - ) { - if (repository.credentials.get() == null) { - runBlocking { writeAppVersion(context, AppVersion(BuildConfig.VERSION_CODE)) } - return - } - - val appVersion = readAppVersion(context) - var versionCode = appVersion.lastVersionLaunched - - while (versionCode < BuildConfig.VERSION_CODE) { - when (versionCode) { - 0 -> disableBiometric(repository) - } - - versionCode++ - } - - runBlocking { writeAppVersion(context, AppVersion(versionCode)) } - } - - private fun disableBiometric(repository: Repository) { - val credentials = repository.credentials.get() ?: return - - runBlocking { - repository.credentials.update( - credentials.copy( - biometricReSetup = true, - biometricAesKey = null, - biometricAesKeyIV = null - ) - ) - } - } -} diff --git a/ui-logic/src/main/java/dev/medzik/librepass/android/ui/auth/LoginScreen.kt b/ui-logic/src/main/java/dev/medzik/librepass/android/ui/auth/LoginScreen.kt index 5b4a274b..d573f65b 100644 --- a/ui-logic/src/main/java/dev/medzik/librepass/android/ui/auth/LoginScreen.kt +++ b/ui-logic/src/main/java/dev/medzik/librepass/android/ui/auth/LoginScreen.kt @@ -27,7 +27,6 @@ import dev.medzik.android.compose.icons.TopAppBarBackIcon import dev.medzik.android.compose.theme.spacing import dev.medzik.android.compose.ui.LoadingButton import dev.medzik.android.compose.ui.textfield.TextFieldValue -import dev.medzik.librepass.android.business.injection.VaultCacheModule import dev.medzik.librepass.android.database.Repository import dev.medzik.librepass.android.ui.R import kotlinx.serialization.Serializable @@ -133,8 +132,7 @@ fun LoginScreenPreview() { navController = rememberNavController(), viewModel = LoginViewModel( context = context, - repository = repository, - vaultCache = VaultCacheModule.provideVaultCache(repository) + repository = repository ) ) } diff --git a/ui-logic/src/main/java/dev/medzik/librepass/android/ui/auth/LoginViewModel.kt b/ui-logic/src/main/java/dev/medzik/librepass/android/ui/auth/LoginViewModel.kt index a8f68de7..fe6f21ef 100644 --- a/ui-logic/src/main/java/dev/medzik/librepass/android/ui/auth/LoginViewModel.kt +++ b/ui-logic/src/main/java/dev/medzik/librepass/android/ui/auth/LoginViewModel.kt @@ -6,21 +6,18 @@ import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.qualifiers.ApplicationContext import dev.medzik.android.utils.showToast -import dev.medzik.librepass.android.business.VaultCache import dev.medzik.librepass.android.common.haveNetworkConnection import dev.medzik.librepass.android.database.Credentials import dev.medzik.librepass.android.database.Repository import dev.medzik.librepass.android.ui.R import dev.medzik.librepass.client.Server import dev.medzik.librepass.client.api.AuthClient -import dev.medzik.librepass.utils.fromHex import javax.inject.Inject @HiltViewModel class LoginViewModel @Inject constructor( @ApplicationContext private val context: Context, - private val repository: Repository, - private val vaultCache: VaultCache + private val repository: Repository ) : ViewModel() { var email = mutableStateOf("") var password = mutableStateOf("") @@ -54,7 +51,7 @@ class LoginViewModel @Inject constructor( ) repository.credentials.insert(credentialsDbEntry) - vaultCache.aesKey = credentials.aesKey.fromHex() +// vaultCache.aesKey = credentials.aesKey.fromHex() } catch (e: Exception) { // TODO }