diff --git a/app/build.gradle b/app/build.gradle index f71469f5..3bc73216 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,8 +20,8 @@ android { applicationId appPackageId minSdkVersion 22 targetSdkVersion 31 - versionCode 1405 - versionName "1.4.5" + versionCode 1406 + versionName "1.4.6" testInstrumentationRunner "com.yogeshpaliyal.keypass.CustomTestRunner" } diff --git a/app/src/main/java/com/yogeshpaliyal/keypass/ui/nav/DashboardActivity.kt b/app/src/main/java/com/yogeshpaliyal/keypass/ui/nav/DashboardActivity.kt index 19163fd5..c96da06f 100644 --- a/app/src/main/java/com/yogeshpaliyal/keypass/ui/nav/DashboardActivity.kt +++ b/app/src/main/java/com/yogeshpaliyal/keypass/ui/nav/DashboardActivity.kt @@ -17,7 +17,6 @@ import androidx.navigation.NavController import androidx.navigation.NavDestination import androidx.navigation.findNavController import com.google.android.material.transition.MaterialElevationScale -import com.yogeshpaliyal.common.worker.migrateToDatastore import com.yogeshpaliyal.keypass.R import com.yogeshpaliyal.keypass.databinding.ActivityDashboardBinding import com.yogeshpaliyal.keypass.ui.addTOTP.AddTOTPActivity @@ -120,8 +119,6 @@ class DashboardActivity : } setOnMenuItemClickListener(this@DashboardActivity) } - - migrateToDatastore() } override fun onMenuItemClick(item: MenuItem?): Boolean { diff --git a/common/src/main/java/com/yogeshpaliyal/common/di/module/AppModule.kt b/common/src/main/java/com/yogeshpaliyal/common/di/module/AppModule.kt index d4473dd4..c489597e 100644 --- a/common/src/main/java/com/yogeshpaliyal/common/di/module/AppModule.kt +++ b/common/src/main/java/com/yogeshpaliyal/common/di/module/AppModule.kt @@ -1,13 +1,11 @@ package com.yogeshpaliyal.common.di.module import android.content.Context -import android.content.SharedPreferences import androidx.room.Room import androidx.room.migration.Migration import androidx.sqlite.db.SupportSQLiteDatabase import com.yogeshpaliyal.common.AppDatabase import com.yogeshpaliyal.common.R -import com.yogeshpaliyal.common.utils.MySharedPreferences import com.yogeshpaliyal.common.utils.getRandomString import dagger.Module import dagger.Provides @@ -45,10 +43,4 @@ object AppModule { }) .build() } - - @Provides - @Singleton - fun getSharedPre(@ApplicationContext context: Context): SharedPreferences { - return MySharedPreferences(context).sharedPref - } } diff --git a/common/src/main/java/com/yogeshpaliyal/common/utils/MySharedPreferences.kt b/common/src/main/java/com/yogeshpaliyal/common/utils/MySharedPreferences.kt deleted file mode 100644 index 02c52239..00000000 --- a/common/src/main/java/com/yogeshpaliyal/common/utils/MySharedPreferences.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.yogeshpaliyal.common.utils - -import android.content.Context -import android.security.keystore.KeyGenParameterSpec -import android.security.keystore.KeyProperties -import androidx.security.crypto.EncryptedSharedPreferences -import androidx.security.crypto.MasterKey - -class MySharedPreferences(context: Context) { - private val masterKeyAlias = MasterKey.Builder(context).also { - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { - // this is equivalent to using deprecated MasterKeys.AES256_GCM_SPEC - - // this is equivalent to using deprecated MasterKeys.AES256_GCM_SPEC - val spec = KeyGenParameterSpec.Builder( - MasterKey.DEFAULT_MASTER_KEY_ALIAS, - KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT - ) - .setBlockModes(KeyProperties.BLOCK_MODE_GCM) - .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) - .setKeySize(256) - .build() - it.setKeyGenParameterSpec(spec) - } - // it.setUserAuthenticationRequired(true) - } - .build() - - val sharedPref = EncryptedSharedPreferences.create( - context, - "secret_shared_prefs", - masterKeyAlias, - EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, - EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM - ) -} diff --git a/common/src/main/java/com/yogeshpaliyal/common/worker/MyWorkManager.kt b/common/src/main/java/com/yogeshpaliyal/common/worker/MyWorkManager.kt index 1589f1cc..8a725cf2 100644 --- a/common/src/main/java/com/yogeshpaliyal/common/worker/MyWorkManager.kt +++ b/common/src/main/java/com/yogeshpaliyal/common/worker/MyWorkManager.kt @@ -16,11 +16,3 @@ suspend fun Context?.executeAutoBackup() { .enqueueUniqueWork("AutoBackupWorker", ExistingWorkPolicy.KEEP, work) } } - -fun Context?.migrateToDatastore() { - this ?: return - val work = OneTimeWorkRequestBuilder().build() - - WorkManager.getInstance(this.applicationContext) - .enqueueUniqueWork("SharedPrefMigrationWorker", ExistingWorkPolicy.KEEP, work) -} diff --git a/common/src/main/java/com/yogeshpaliyal/common/worker/SharedPrefMigrationWorker.kt b/common/src/main/java/com/yogeshpaliyal/common/worker/SharedPrefMigrationWorker.kt deleted file mode 100644 index 3b30e899..00000000 --- a/common/src/main/java/com/yogeshpaliyal/common/worker/SharedPrefMigrationWorker.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.yogeshpaliyal.common.worker - -import android.content.Context -import android.content.SharedPreferences -import androidx.core.content.edit -import androidx.datastore.preferences.core.* -import androidx.hilt.work.HiltWorker -import androidx.work.CoroutineWorker -import androidx.work.WorkerParameters -import com.yogeshpaliyal.common.utils.dataStore -import dagger.assisted.Assisted -import dagger.assisted.AssistedInject -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext -import java.lang.Exception - -@HiltWorker -class SharedPrefMigrationWorker @AssistedInject constructor( - @Assisted val context: Context, - @Assisted workerParams: WorkerParameters, - private val sharedPreferences: SharedPreferences -) : - CoroutineWorker(context, workerParams) { - override suspend fun doWork(): Result { - try { - withContext(Dispatchers.IO) { - for (mutableEntry in sharedPreferences.all) { - context.dataStore.edit { editor -> - val value = mutableEntry.value - when (value) { - is String -> editor[stringPreferencesKey(mutableEntry.key)] = value - is Boolean -> editor[booleanPreferencesKey(mutableEntry.key)] = value - is Long -> editor[longPreferencesKey(mutableEntry.key)] = value - is Int -> editor[intPreferencesKey(mutableEntry.key)] = value - is Double -> editor[doublePreferencesKey(mutableEntry.key)] = value - is Float -> editor[floatPreferencesKey(mutableEntry.key)] = value - } - sharedPreferences.edit { - remove(mutableEntry.key) - } - } - } - } - } catch (e: Exception) { - e.printStackTrace() - } - return Result.success() - } -} diff --git a/fastlane/metadata/android/en-US/changelogs/1406.txt b/fastlane/metadata/android/en-US/changelogs/1406.txt new file mode 100644 index 00000000..11e27a18 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/1406.txt @@ -0,0 +1 @@ +Bug Fix and improvements \ No newline at end of file diff --git a/whatsnew/whatsnew-en-US b/whatsnew/whatsnew-en-US index 11e27a18..e52bfbd8 100644 --- a/whatsnew/whatsnew-en-US +++ b/whatsnew/whatsnew-en-US @@ -1 +1 @@ -Bug Fix and improvements \ No newline at end of file +Crash Fix and improvements \ No newline at end of file