Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Offer the update again when its install is cancelled

Lelonio04095d6c9da9
diff --git a/app/src/main/java/dev/lelonio/square/update/InstallReceiver.kt b/app/src/main/java/dev/lelonio/square/update/InstallReceiver.kt
index a7968c8..6a2b81b 100644
--- a/app/src/main/java/dev/lelonio/square/update/InstallReceiver.kt
+++ b/app/src/main/java/dev/lelonio/square/update/InstallReceiver.kt
@@ -36,6 +36,10 @@ class InstallReceiver : BroadcastReceiver() {
// user typed.
val message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)
android.util.Log.w(TAG, "install did not complete: $message")
+ // So the update is offered again; see Updater.installAbandoned.
+ (context.applicationContext as? dev.lelonio.square.SquareApplication)
+ ?.updater
+ ?.installAbandoned()
}
}
}
diff --git a/app/src/main/java/dev/lelonio/square/update/Updater.kt b/app/src/main/java/dev/lelonio/square/update/Updater.kt
index 6ffc69d..11b1bb9 100644
--- a/app/src/main/java/dev/lelonio/square/update/Updater.kt
+++ b/app/src/main/java/dev/lelonio/square/update/Updater.kt
@@ -167,6 +167,7 @@ class Updater(context: Context) {
* this one asks to be trusted.
*/
fun install(update: State.Available) {
+ lastOffered = update
if (!canInstall()) {
_state.value = State.Failed(REASON_PERMISSION)
return
@@ -299,6 +300,22 @@ class Updater(context: Context) {
_state.value = State.Idle
}
+ /** What was last sent to the installer, to offer again if it did not go in. */
+ private var lastOffered: State.Available? = null
+
+ /**
+ * The installer did not install it: its dialog cancelled, or the install
+ * refused.
+ *
+ * Offered again rather than left at [State.Installing]. Nothing else moves
+ * the state on from there, so a dialog cancelled by mistake hid the update
+ * until the next release came out (#151).
+ */
+ fun installAbandoned() {
+ if (_state.value !is State.Installing) return
+ _state.value = lastOffered ?: State.Idle
+ }
+
companion object {
private const val TAG = "Updater"