From 5374c50fb1b68ef1cae6f5684d59d45ada505ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Danil=C4=8Denko?= Date: Mon, 16 Sep 2024 12:21:23 +0200 Subject: [PATCH 1/4] Increased app's version to 0.27.0(305) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 33e5a5f2a..ab7d8860e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { ext.coroutines_version = '1.8.0' // build & version - ext.buildNumber = 304 + ext.buildNumber = 305 ext.versionNumber = "0.27.0" // JNI libs From a3abb7bec9b20aea5f6cf0f1165f2f32a6222a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Danil=C4=8Denko?= Date: Mon, 16 Sep 2024 14:13:00 +0200 Subject: [PATCH 2/4] Fix the MigrationManager issue with versions comparison, removed unused anymore code --- .../wallet/application/MigrationManager.kt | 37 ++++--------------- .../wallet/ui/fragment/auth/AuthViewModel.kt | 13 +++---- 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/com/tari/android/wallet/application/MigrationManager.kt b/app/src/main/java/com/tari/android/wallet/application/MigrationManager.kt index 1d9259730..d2123e333 100644 --- a/app/src/main/java/com/tari/android/wallet/application/MigrationManager.kt +++ b/app/src/main/java/com/tari/android/wallet/application/MigrationManager.kt @@ -2,48 +2,27 @@ package com.tari.android.wallet.application import com.tari.android.wallet.BuildConfig import com.tari.android.wallet.application.walletManager.WalletManager -import com.tari.android.wallet.data.sharedPrefs.network.NetworkPrefRepository import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.apache.maven.artifact.versioning.DefaultArtifactVersion -import java.io.File import javax.inject.Inject import javax.inject.Singleton @Singleton class MigrationManager @Inject constructor( private val walletManager: WalletManager, - private val application: TariWalletApplication, - private val networkRepository: NetworkPrefRepository, ) { - - suspend fun validateVersion(onValid: () -> Unit, onError: () -> Unit) { - val walletVersion = getCurrentWalletVersion() - - // FIXME: Temporary migration mechanism. It should be removed when minValidVersion is greater than 1.0.0-rc.8 - if (walletVersion.isNotEmpty() && DefaultArtifactVersion(walletVersion) < DefaultArtifactVersion(PEER_DB_MIGRATION_MIN_VERSION)) { - performPeerDbMigration() - } - - if (walletVersion.isEmpty() || DefaultArtifactVersion(walletVersion) < DefaultArtifactVersion(BuildConfig.LIB_WALLET_MIN_VALID_VERSION)) { + suspend fun validateVersion(onValid: () -> Unit, onError: () -> Unit) = withContext(Dispatchers.IO) { + val walletVersion = walletManager.getCommsConfig().getLastVersion() + .replace("v", "") + .takeIf { it.isNotEmpty() } + ?.let { DefaultArtifactVersion(it) } + val minValidVersion = DefaultArtifactVersion(BuildConfig.LIB_WALLET_MIN_VALID_VERSION.replace("v", "")) + + if (walletVersion == null || walletVersion < minValidVersion) { onError() } else { onValid() } } - - private suspend fun getCurrentWalletVersion(): String = withContext(Dispatchers.IO) { walletManager.getCommsConfig().getLastVersion() } - - private suspend fun performPeerDbMigration() = withContext(Dispatchers.IO) { - application.applicationInfo.dataDir?.let { appDir -> - val peerDbFile = File(appDir, "files/${networkRepository.currentNetwork.network.uriComponent}/data.mdb") - if (peerDbFile.exists()) { - peerDbFile.delete() - } - } - } - - companion object { - const val PEER_DB_MIGRATION_MIN_VERSION = "1.0.0-rc.8" - } } diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/AuthViewModel.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/AuthViewModel.kt index 19b195ad3..1fd27398e 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/AuthViewModel.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/AuthViewModel.kt @@ -1,8 +1,9 @@ package com.tari.android.wallet.ui.fragment.auth -import androidx.lifecycle.viewModelScope import com.tari.android.wallet.R import com.tari.android.wallet.application.MigrationManager +import com.tari.android.wallet.extension.launchOnIo +import com.tari.android.wallet.extension.launchOnMain import com.tari.android.wallet.infrastructure.security.biometric.BiometricAuthenticationService import com.tari.android.wallet.service.service.WalletServiceLauncher import com.tari.android.wallet.ui.common.CommonViewModel @@ -12,8 +13,6 @@ import com.tari.android.wallet.ui.dialog.modular.modules.button.ButtonModule import com.tari.android.wallet.ui.dialog.modular.modules.button.ButtonStyle import com.tari.android.wallet.ui.dialog.modular.modules.head.HeadModule import com.tari.android.wallet.ui.fragment.home.navigation.Navigation -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import javax.inject.Inject class AuthViewModel : CommonViewModel() { @@ -32,15 +31,15 @@ class AuthViewModel : CommonViewModel() { init { component.inject(this) - viewModelScope.launch(Dispatchers.IO) { + launchOnIo { migrationManager.validateVersion( onValid = { - viewModelScope.launch(Dispatchers.Main) { + launchOnMain { goAuth.postValue(Unit) } }, onError = { - viewModelScope.launch(Dispatchers.Main) { + launchOnMain { showIncompatibleVersionDialog() } } @@ -65,7 +64,7 @@ class AuthViewModel : CommonViewModel() { private fun deleteWallet() { // disable CTAs - viewModelScope.launch(Dispatchers.IO) { + launchOnIo { walletServiceLauncher.stopAndDelete() navigation.postValue(Navigation.TxListNavigation.ToSplashScreen) } From 23f2e60e39715a463ae51e14f02aea55710db79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Danil=C4=8Denko?= Date: Fri, 13 Sep 2024 13:02:57 +0200 Subject: [PATCH 3/4] Don't hide dialogs on leaving screen (#1205) --- .../java/com/tari/android/wallet/ui/common/CommonActivity.kt | 1 - .../java/com/tari/android/wallet/ui/common/CommonFragment.kt | 5 ----- .../com/tari/android/wallet/ui/common/CommonViewModel.kt | 4 ++-- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/tari/android/wallet/ui/common/CommonActivity.kt b/app/src/main/java/com/tari/android/wallet/ui/common/CommonActivity.kt index 7573f1b60..a4c64e99a 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/common/CommonActivity.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/common/CommonActivity.kt @@ -146,7 +146,6 @@ abstract class CommonActivity : App override fun onStop() { shakeDetector.stop() - dialogManager.dismiss() // TODO don't dismiss dialogs onStop. Think about a better way to handle this. super.onStop() screenCaptureCallback?.let { unregisterScreenCaptureCallback(it) } } diff --git a/app/src/main/java/com/tari/android/wallet/ui/common/CommonFragment.kt b/app/src/main/java/com/tari/android/wallet/ui/common/CommonFragment.kt index 25cf8ef0d..fa0619bbc 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/common/CommonFragment.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/common/CommonFragment.kt @@ -169,11 +169,6 @@ abstract class CommonFragment : Fra action() } } - - override fun onDestroy() { - dialogManager?.dismiss() - super.onDestroy() - } } /** diff --git a/app/src/main/java/com/tari/android/wallet/ui/common/CommonViewModel.kt b/app/src/main/java/com/tari/android/wallet/ui/common/CommonViewModel.kt index ebb86bbd6..7eeb7b9e7 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/common/CommonViewModel.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/common/CommonViewModel.kt @@ -17,6 +17,7 @@ import com.tari.android.wallet.di.ApplicationComponent import com.tari.android.wallet.di.DiContainer import com.tari.android.wallet.event.EventBus import com.tari.android.wallet.extension.addTo +import com.tari.android.wallet.extension.launchOnMain import com.tari.android.wallet.ffi.FFIWallet import com.tari.android.wallet.infrastructure.logging.LoggerTags import com.tari.android.wallet.model.CoreError @@ -42,7 +43,6 @@ import com.tari.android.wallet.ui.fragment.home.navigation.TariNavigator import com.tari.android.wallet.ui.fragment.settings.themeSelector.TariTheme import io.reactivex.disposables.CompositeDisposable import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch import javax.inject.Inject @@ -271,7 +271,7 @@ open class CommonViewModel : ViewModel() { } fun hideDialog(dialogId: Int = ModularDialogArgs.DialogId.NO_ID) { - viewModelScope.launch(Dispatchers.Main) { + launchOnMain { dialogManager.dismiss(dialogId) } } From 676e98cb79d4d0f88657cea12b411fe217774dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Danil=C4=8Denko?= Date: Mon, 16 Sep 2024 14:47:41 +0200 Subject: [PATCH 4/4] Increase app's version to 0.27.1(306) --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index ab7d8860e..76b914395 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,8 @@ buildscript { ext.coroutines_version = '1.8.0' // build & version - ext.buildNumber = 305 - ext.versionNumber = "0.27.0" + ext.buildNumber = 306 + ext.versionNumber = "0.27.1" // JNI libs ext.libwalletHostURL = "https://github.com/tari-project/tari/releases/download/"