From 93941d52df9bbcfb137da45066a8e6a8a8b93a45 Mon Sep 17 00:00:00 2001 From: Fabian Devel Date: Tue, 12 Nov 2024 13:02:37 +0100 Subject: [PATCH] feat(InAppUpdateListener): Add failure listener --- .../java/com/infomaniak/lib/stores/BaseInAppUpdateManager.kt | 2 +- Stores/src/main/res/values-de/strings.xml | 2 ++ Stores/src/main/res/values-es/strings.xml | 2 ++ Stores/src/main/res/values-fr/strings.xml | 2 ++ Stores/src/main/res/values-it/strings.xml | 2 ++ Stores/src/main/res/values/strings.xml | 2 ++ .../lib/stores/updatemanagers/InAppUpdateManager.kt | 5 ++++- 7 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Stores/src/main/java/com/infomaniak/lib/stores/BaseInAppUpdateManager.kt b/Stores/src/main/java/com/infomaniak/lib/stores/BaseInAppUpdateManager.kt index a7e05fc5..fbb4275f 100644 --- a/Stores/src/main/java/com/infomaniak/lib/stores/BaseInAppUpdateManager.kt +++ b/Stores/src/main/java/com/infomaniak/lib/stores/BaseInAppUpdateManager.kt @@ -32,7 +32,7 @@ abstract class BaseInAppUpdateManager(private val activity: FragmentActivity) : open fun installDownloadedUpdate() = Unit - open fun requireUpdate() = activity.goToPlayStore() + open fun requireUpdate(onFailure: ((Exception) -> Unit)? = null) = activity.goToPlayStore() open fun init( mustRequireImmediateUpdate: Boolean = false, diff --git a/Stores/src/main/res/values-de/strings.xml b/Stores/src/main/res/values-de/strings.xml index 6bdad79c..a850ec08 100644 --- a/Stores/src/main/res/values-de/strings.xml +++ b/Stores/src/main/res/values-de/strings.xml @@ -16,5 +16,7 @@ ~ along with this program. If not, see . --> + Kein Update verfügbar + Installieren Ihre Version der Anwendung wird nicht mehr unterstützt.\nInstallieren Sie die neueste Version und profitieren Sie von den neuesten Verbesserungen und Neuerungen. diff --git a/Stores/src/main/res/values-es/strings.xml b/Stores/src/main/res/values-es/strings.xml index a89f957b..f6ce6361 100644 --- a/Stores/src/main/res/values-es/strings.xml +++ b/Stores/src/main/res/values-es/strings.xml @@ -16,5 +16,7 @@ ~ along with this program. If not, see . --> + No hay actualizaciones disponibles + Instalar Su versión de la aplicación ya no es compatible.\nInstale la última versión y aproveche las últimas mejoras y nuevas funciones. diff --git a/Stores/src/main/res/values-fr/strings.xml b/Stores/src/main/res/values-fr/strings.xml index c1823757..602f3721 100644 --- a/Stores/src/main/res/values-fr/strings.xml +++ b/Stores/src/main/res/values-fr/strings.xml @@ -16,5 +16,7 @@ ~ along with this program. If not, see . --> + Aucune mise à jour disponible + Installer Votre version de l’application n’est plus supportée.\nInstallez la dernière version et profitez des dernières améliorations et nouveautés. diff --git a/Stores/src/main/res/values-it/strings.xml b/Stores/src/main/res/values-it/strings.xml index 06039703..6abac314 100644 --- a/Stores/src/main/res/values-it/strings.xml +++ b/Stores/src/main/res/values-it/strings.xml @@ -16,5 +16,7 @@ ~ along with this program. If not, see . --> + Nessun aggiornamento disponibile + Installa La versione dell’applicazione in uso non è più supportata.\nInstalla la versione più recente e approfitta degli ultimi miglioramenti e delle nuove funzionalità. diff --git a/Stores/src/main/res/values/strings.xml b/Stores/src/main/res/values/strings.xml index 9dca62ae..685f4b7b 100644 --- a/Stores/src/main/res/values/strings.xml +++ b/Stores/src/main/res/values/strings.xml @@ -16,5 +16,7 @@ ~ along with this program. If not, see . --> + Install + No available update Your application version is no longer supported.\nInstall the latest version and benefit from the latest enhancements and new features. diff --git a/Stores/src/standard/java/com/infomaniak/lib/stores/updatemanagers/InAppUpdateManager.kt b/Stores/src/standard/java/com/infomaniak/lib/stores/updatemanagers/InAppUpdateManager.kt index 42576cf7..59842779 100644 --- a/Stores/src/standard/java/com/infomaniak/lib/stores/updatemanagers/InAppUpdateManager.kt +++ b/Stores/src/standard/java/com/infomaniak/lib/stores/updatemanagers/InAppUpdateManager.kt @@ -149,13 +149,16 @@ class InAppUpdateManager( } } - override fun requireUpdate() { + override fun requireUpdate(onFailure: ((Exception) -> Unit)?) { appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo -> if (updateType == AppUpdateType.IMMEDIATE) { val isUpdateStalled = appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS if (isUpdateStalled || !viewModel.isUpdateBottomSheetShown) startUpdateFlow(appUpdateInfo) } + }.addOnFailureListener { + it.printStackTrace() + onFailure?.invoke(it) } }