diff --git a/Core b/Core index 2834399903..5a1d7b23a0 160000 --- a/Core +++ b/Core @@ -1 +1 @@ -Subproject commit 2834399903400e3fbf692b2ac39c4d1d09959ea2 +Subproject commit 5a1d7b23a06fe969052f840ac38c7def2e107647 diff --git a/app/src/main/java/com/infomaniak/mail/ui/MainActivity.kt b/app/src/main/java/com/infomaniak/mail/ui/MainActivity.kt index f0497cd8bd..ddc8fbdb03 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/MainActivity.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/MainActivity.kt @@ -42,7 +42,6 @@ import com.infomaniak.lib.core.utils.SentryLog import com.infomaniak.lib.core.utils.Utils import com.infomaniak.lib.core.utils.Utils.toEnumOrThrow import com.infomaniak.lib.core.utils.UtilsUi.openUrl -import com.infomaniak.lib.stores.StoreUtils.checkStalledUpdate import com.infomaniak.lib.stores.StoreUtils.checkUpdateIsAvailable import com.infomaniak.lib.stores.StoreUtils.initAppUpdateManager import com.infomaniak.lib.stores.StoreUtils.launchInAppReview @@ -327,7 +326,7 @@ class MainActivity : BaseActivity() { super.onResume() playServicesUtils.checkPlayServices(this) - checkAppUpdateStatus() + mainViewModel.checkAppUpdateStatus() if (binding.drawerLayout.isOpen) colorSystemBarsWithMenuDrawer() } @@ -464,14 +463,8 @@ class MainActivity : BaseActivity() { private fun initAppUpdateManager() { initAppUpdateManager( context = this, - onUpdateDownloaded = { - mainViewModel.canInstallUpdate.value = true - localSettings.hasAppUpdateDownloaded = true - }, - onUpdateInstalled = { - mainViewModel.canInstallUpdate.value = false - localSettings.hasAppUpdateDownloaded = false - }, + onUpdateDownloaded = { mainViewModel.toggleAppUpdateStatus(isUpdateDownloaded = true) }, + onUpdateInstalled = { mainViewModel.toggleAppUpdateStatus(isUpdateDownloaded = false) }, ) } @@ -488,11 +481,6 @@ class MainActivity : BaseActivity() { } } - private fun checkAppUpdateStatus() { - mainViewModel.canInstallUpdate.value = localSettings.hasAppUpdateDownloaded - checkStalledUpdate() - } - private fun showSyncDiscovery() = with(localSettings) { if (showSyncDiscoveryBottomSheet && appLaunches > 5 && !isUserAlreadySynchronized()) { showSyncDiscoveryBottomSheet = false diff --git a/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt b/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt index f3306cdca8..cad6456192 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt @@ -23,12 +23,15 @@ import com.infomaniak.lib.core.models.ApiResponse import com.infomaniak.lib.core.utils.ApiErrorCode.Companion.translateError import com.infomaniak.lib.core.utils.SentryLog import com.infomaniak.lib.core.utils.SingleLiveEvent +import com.infomaniak.lib.stores.StoreUtils import com.infomaniak.mail.MatomoMail.trackMultiSelectionEvent import com.infomaniak.mail.R +import com.infomaniak.mail.data.LocalSettings import com.infomaniak.mail.data.api.ApiRepository import com.infomaniak.mail.data.cache.RealmDatabase import com.infomaniak.mail.data.cache.mailboxContent.* -import com.infomaniak.mail.data.cache.mailboxContent.RefreshController.* +import com.infomaniak.mail.data.cache.mailboxContent.RefreshController.RefreshCallbacks +import com.infomaniak.mail.data.cache.mailboxContent.RefreshController.RefreshMode import com.infomaniak.mail.data.cache.mailboxInfo.MailboxController import com.infomaniak.mail.data.cache.mailboxInfo.PermissionsController import com.infomaniak.mail.data.cache.mailboxInfo.QuotasController @@ -40,7 +43,6 @@ import com.infomaniak.mail.data.models.MoveResult import com.infomaniak.mail.data.models.correspondent.Recipient import com.infomaniak.mail.data.models.mailbox.Mailbox import com.infomaniak.mail.data.models.message.Message -import com.infomaniak.mail.data.models.message.Message.* import com.infomaniak.mail.data.models.thread.Thread import com.infomaniak.mail.data.models.thread.Thread.ThreadFilter import com.infomaniak.mail.di.IoDispatcher @@ -72,6 +74,7 @@ class MainViewModel @Inject constructor( private val addressBookController: AddressBookController, private val draftController: DraftController, private val folderController: FolderController, + private val localSettings: LocalSettings, private val mailboxContentRealm: RealmDatabase.MailboxContent, private val mailboxController: MailboxController, private val mergedContactController: MergedContactController, @@ -1014,6 +1017,16 @@ class MainViewModel @Inject constructor( } } + fun checkAppUpdateStatus() { + canInstallUpdate.value = localSettings.hasAppUpdateDownloaded + StoreUtils.checkStalledUpdate() + } + + fun toggleAppUpdateStatus(isUpdateDownloaded: Boolean) { + canInstallUpdate.value = isUpdateDownloaded + localSettings.hasAppUpdateDownloaded = isUpdateDownloaded + } + companion object { private val TAG: String = MainViewModel::class.java.simpleName private val DEFAULT_SELECTED_FOLDER = FolderRole.INBOX diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index df86cfc91a..5c2577b81d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,5 @@ [versions] androidGradlePlugin = "8.1.4" -concurrentFuturesKtx = "1.1.0" dotsindicator = "5.0" dragdropswipeRecyclerview = "1.2.0" firebaseMessagingKtx = "23.3.1" @@ -20,6 +19,7 @@ realmKotlin = "1.12.0" sentryAndroidFragment = "6.29.0" testRunner = "1.5.2" webkit = "1.8.0" +workConcurrentFutures = "1.1.0" workRuntimeKtx = "2.8.1" [libraries] @@ -40,7 +40,7 @@ navigation-safeargs = { module = "androidx.navigation:navigation-safe-args-gradl realm-kotlin-base = { module = "io.realm.kotlin:library-base", version.ref = "realmKotlin" } sentry-android-fragment = { module = "io.sentry:sentry-android-fragment", version.ref = "sentryAndroidFragment" } webkit = { module = "androidx.webkit:webkit", version.ref = "webkit" } -work-concurrent-futures = { module = "androidx.concurrent:concurrent-futures-ktx", version.ref = "concurrentFuturesKtx" } +work-concurrent-futures = { module = "androidx.concurrent:concurrent-futures-ktx", version.ref = "workConcurrentFutures" } work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "workRuntimeKtx" } # Unit tests junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junitJupiterEngine" }