diff --git a/app/src/main/java/com/ivy/wallet/io/persistence/datastore/IvyDataStore.kt b/app/src/main/java/com/ivy/wallet/io/persistence/datastore/IvyDataStore.kt index 1d16b6c631..ed3267ec99 100644 --- a/app/src/main/java/com/ivy/wallet/io/persistence/datastore/IvyDataStore.kt +++ b/app/src/main/java/com/ivy/wallet/io/persistence/datastore/IvyDataStore.kt @@ -16,14 +16,17 @@ import javax.inject.Singleton class IvyDataStore @Inject constructor( @ApplicationContext private val appContext: Context ) { + @Deprecated("legacy") private val Context.dataStore: DataStore by preferencesDataStore(name = "ivy_wallet") + @Deprecated("legacy") suspend fun insert(pair: Preferences.Pair) { appContext.dataStore.edit { it.putAll(pair) } } + @Deprecated("legacy") suspend fun insert( key: Preferences.Key, value: T @@ -33,12 +36,14 @@ class IvyDataStore @Inject constructor( } } + @Deprecated("legacy") suspend fun remove(key: Preferences.Key) { appContext.dataStore.edit { it.remove(key = key) } } + @Deprecated("legacy") suspend fun get(key: Preferences.Key): T? = appContext.dataStore.data.map { it[key] }.firstOrNull() diff --git a/app/src/main/java/com/ivy/wallet/migrations/MigrationsManager.kt b/app/src/main/java/com/ivy/wallet/migrations/MigrationsManager.kt index 0466c0942d..98c54efbeb 100644 --- a/app/src/main/java/com/ivy/wallet/migrations/MigrationsManager.kt +++ b/app/src/main/java/com/ivy/wallet/migrations/MigrationsManager.kt @@ -5,6 +5,7 @@ import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit import com.ivy.wallet.data.dataStore import com.ivy.wallet.migrations.impl.GitHubPATMigration +import com.ivy.wallet.migrations.impl.GitHubWorkerMigration import dagger.Lazy import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.Dispatchers @@ -17,16 +18,18 @@ import javax.inject.Inject class MigrationsManager @Inject constructor( @ApplicationContext private val context: Context, - private val gitHubPATMigration: Lazy + private val gitHubPATMigration: Lazy, + private val gitHubWorkerMigration: Lazy, ) { private val migrations by lazy { listOf( - gitHubPATMigration.get() + gitHubPATMigration.get(), + gitHubWorkerMigration.get(), ) } suspend fun executeMigrations() { - delay(2_000L) // to not the make app slower + delay(2_000L) // to not the make the app start slower val data = context.dataStore.data.firstOrNull() diff --git a/app/src/main/java/com/ivy/wallet/migrations/impl/GitHubWorkerMigration.kt b/app/src/main/java/com/ivy/wallet/migrations/impl/GitHubWorkerMigration.kt new file mode 100644 index 0000000000..2ed35f7c0a --- /dev/null +++ b/app/src/main/java/com/ivy/wallet/migrations/impl/GitHubWorkerMigration.kt @@ -0,0 +1,23 @@ +package com.ivy.wallet.migrations.impl + +import com.ivy.wallet.backup.github.GitHubAutoBackupManager +import com.ivy.wallet.backup.github.GitHubBackup +import com.ivy.wallet.migrations.Migration +import kotlinx.coroutines.flow.firstOrNull +import timber.log.Timber +import javax.inject.Inject + +class GitHubWorkerMigration @Inject constructor( + private val gitHubBackup: GitHubBackup, + private val gitHubAutoBackupManager: GitHubAutoBackupManager, +) : Migration { + override val key: String + get() = "github_auto_backup_worker_v1" + + override suspend fun migrate() { + if (gitHubBackup.enabled.firstOrNull() == true) { + gitHubAutoBackupManager.scheduleAutoBackups() + Timber.i("GitHub auto-backups worker rescheduled.") + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/java/com/ivy/wallet/buildsrc/dependencies.kt b/buildSrc/src/main/java/com/ivy/wallet/buildsrc/dependencies.kt index 6414b6ec74..3c080a4584 100644 --- a/buildSrc/src/main/java/com/ivy/wallet/buildsrc/dependencies.kt +++ b/buildSrc/src/main/java/com/ivy/wallet/buildsrc/dependencies.kt @@ -21,8 +21,8 @@ import org.gradle.api.artifacts.dsl.DependencyHandler object Project { //Version - const val versionName = "4.4.1" - const val versionCode = 141 + const val versionName = "4.4.2" + const val versionCode = 142 //Compile SDK & Build Tools const val compileSdkVersion = 34 @@ -43,7 +43,7 @@ object GlobalVersions { * @param kotlinVersion must also be updated in buildSrc gradle */ fun DependencyHandler.appModuleDependencies( - kotlinVersion: String = GlobalVersions.kotlinVersion + kotlinVersion: String = GlobalVersions.kotlinVersion ) { // implementation(project(":ivy-design")) @@ -76,7 +76,7 @@ fun DependencyHandler.appModuleDependencies( } fun DependencyHandler.ivyDesignModuleDependencies( - kotlinVersion: String = GlobalVersions.kotlinVersion + kotlinVersion: String = GlobalVersions.kotlinVersion ) { // Coroutines(version = "1.5.0") // FunctionalProgramming( @@ -119,8 +119,8 @@ fun DependencyHandler.Firebase() { * https://developer.android.com/training/dependency-injection/hilt-android */ fun DependencyHandler.Hilt( - hiltVersion: String, - versionX: String + hiltVersion: String, + versionX: String ) { implementation("com.google.dagger:hilt-android:$hiltVersion") kapt("com.google.dagger:hilt-android-compiler:$hiltVersion") @@ -136,7 +136,7 @@ fun DependencyHandler.Hilt( } fun DependencyHandler.HiltTesting( - version: String + version: String ) { androidTestImplementation("com.google.dagger:hilt-android-testing:$version") kaptAndroidTest("com.google.dagger:hilt-android-compiler:$version") @@ -147,7 +147,7 @@ fun DependencyHandler.HiltTesting( * https://developer.android.com/jetpack/androidx/releases/room */ fun DependencyHandler.RoomDB( - version: String = "2.6.0-alpha03" + version: String = "2.6.0-alpha03" ) { implementation("androidx.room:room-runtime:$version") kapt("androidx.room:room-compiler:$version") @@ -158,7 +158,7 @@ fun DependencyHandler.RoomDB( * REST */ fun DependencyHandler.Networking( - retrofitVersion: String = "2.9.0" + retrofitVersion: String = "2.9.0" ) { //URL: https://github.com/square/retrofit implementation("com.squareup.retrofit2:retrofit:$retrofitVersion") @@ -177,7 +177,7 @@ fun DependencyHandler.Networking( * https://developer.android.com/jetpack/androidx/releases/lifecycle */ fun DependencyHandler.Lifecycle( - version: String = "2.6.1" + version: String = "2.6.1" ) { // https://developer.android.com/jetpack/androidx/releases/lifecycle implementation("androidx.lifecycle:lifecycle-livedata-ktx:$version")