Skip to content

Commit

Permalink
feat(InAppUpdateManager): Add kdoc for the inAppUpdate manager
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Nov 15, 2024
1 parent c7e849e commit f264ddd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import com.infomaniak.lib.core.utils.goToPlayStore
import com.infomaniak.lib.core.utils.showToast
import com.infomaniak.lib.stores.databinding.ActivityUpdateRequiredBinding
import com.infomaniak.lib.stores.updatemanagers.InAppUpdateManager
import io.sentry.Sentry
import kotlin.system.exitProcess
import com.infomaniak.lib.core.R as RCore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ import com.infomaniak.lib.stores.StoreUtils
import com.infomaniak.lib.stores.StoresSettingsRepository
import io.sentry.Sentry

/**
* Manager encapsulating all the needed logic for Google Play's in-app update api
* Implements [BaseInAppUpdateManager] to add compatibility with fDroid
*
* @param activity: Activity on which the lifecycleObserver will be bound
* @param appId: Parameter needed for the fDroid manager, won't compile without it
* @param versionCode: Parameter needed for the fDroid manager, won't compile without it
*/
class InAppUpdateManager(
private val activity: FragmentActivity,
appId: String,
Expand Down Expand Up @@ -149,7 +157,7 @@ class InAppUpdateManager(
.addOnSuccessListener { onInstallSuccess?.invoke() }
.addOnFailureListener {
viewModel.resetUpdateSettings()
onInstallFailure?.invoke(it)
onInstallFailure?.invoke(AppUpdateException(it.message))
}
}

Expand All @@ -161,6 +169,9 @@ class InAppUpdateManager(
if (isUpdateStalled || !viewModel.isUpdateBottomSheetShown) startUpdateFlow(appUpdateInfo)
}
}.addOnFailureListener {
Sentry.captureMessage("Impossible to require update") { scope ->
scope.setTag("reason", it.message.toString())
}
it.printStackTrace()
onFailure?.invoke(it)
}
Expand Down Expand Up @@ -196,4 +207,6 @@ class InAppUpdateManager(
AppUpdateOptions.newBuilder(updateType).build(),
)
}

private class AppUpdateException(override val message: String?) : Exception()
}

0 comments on commit f264ddd

Please sign in to comment.