Skip to content

Native Android client for Spotify, built with Jetpack Compose

2.0.2-beta.6: uninstall an extension from the extensions list, with its sign-in and cache cleared

kota-zo08bf97bb7d17
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 509d1985..0d4aefa5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ Each release on GitHub shows its section below. The app shows it too when it off
- πŸ”” **Update popup fixed**: it shows as soon as the app knows about the update, a stray tap no longer closes it, and after "Later" the update stays in Settings, About.
- πŸ—‚οΈ **Settings in tabs** (classic look): Playback, Downloads, Appearance, Extensions, About. About shows your version and the update when there is one.
-- 🧩 **Extensions**: Refresh really refreshes now (no stale cache, real errors, update check of installed extensions). Extensions are also found and installed from **GitLab** and **Codeberg** (topic `myspoti-extension`).
+- 🧩 **Extensions**: Refresh really refreshes now (no stale cache, real errors, update check of installed extensions). Extensions are also found and installed from **GitLab** and **Codeberg** (topic `myspoti-extension`). Uninstall an extension right from the list (trash icon), which now also clears its sign-in and cache.
- πŸš— **Android Auto**: playback started from the car no longer stops after a few seconds, and the car's buttons keep working.
- πŸ”€ **Real crossfade** for songs played from extensions, downloads and device files (Settings, Playback). Spotify streams keep their fade out and in.
- πŸ–ΌοΈ **Sharp covers everywhere**: notification, lock screen, Android Auto, share card. Fixes a crash at playback start (#77).
diff --git a/base/app/src/main/java/com/music/spotui/extensions/ExtensionAudio.kt b/base/app/src/main/java/com/music/spotui/extensions/ExtensionAudio.kt
index c9c3cb0c..6f5bb70c 100644
--- a/base/app/src/main/java/com/music/spotui/extensions/ExtensionAudio.kt
+++ b/base/app/src/main/java/com/music/spotui/extensions/ExtensionAudio.kt
@@ -31,6 +31,9 @@ object ExtensionAudio {
}
private val known = ConcurrentHashMap<String, Known>()
+ /** Drops every remembered answer (an extension was removed: none of them may keep playing from it). */
+ fun forgetAll() = known.clear()
+
fun uri(s: SongsModel): Uri = Uri.Builder().scheme(SCHEME).authority("track").appendPath(s.spotifyTrackId)
.appendQueryParameter("title", s.title).appendQueryParameter("artist", s.singer)
.appendQueryParameter("album", s.album).appendQueryParameter("duration", s.durationMs.toString())
diff --git a/base/app/src/main/java/com/music/spotui/extensions/ExtensionAuth.kt b/base/app/src/main/java/com/music/spotui/extensions/ExtensionAuth.kt
index 9b197d0c..10ca737a 100644
--- a/base/app/src/main/java/com/music/spotui/extensions/ExtensionAuth.kt
+++ b/base/app/src/main/java/com/music/spotui/extensions/ExtensionAuth.kt
@@ -103,6 +103,13 @@ object ExtensionAuth {
fun cancel(extensionId: String) = synchronized(this) { if (open.value?.extensionId == extensionId) open.value = null }
/** The web view profile of [extensionId]: its own cookies and storage. */
+ /** Deletes the extension's sign-in profile (cookies and storage); best effort, on the main thread. */
+ fun forget(extensionId: String) {
+ android.os.Handler(android.os.Looper.getMainLooper()).post {
+ runCatching { ProfileStore.getInstance().deleteProfile(profile(extensionId)) }
+ }
+ }
+
fun profile(extensionId: String) = "ext-auth-" + extensionId.replace(Regex("[^A-Za-z0-9._-]"), "_")
}
diff --git a/base/app/src/main/java/com/music/spotui/extensions/Extensions.kt b/base/app/src/main/java/com/music/spotui/extensions/Extensions.kt
index 3c98ffcc..ff033d5d 100644
--- a/base/app/src/main/java/com/music/spotui/extensions/Extensions.kt
+++ b/base/app/src/main/java/com/music/spotui/extensions/Extensions.kt
@@ -291,6 +291,9 @@ object Extensions {
update { it.remove(id) }
packages.remove(id); stores.remove(id); settings.remove(id); logs.remove(id)
clearError(id)
+ runningSha.remove(id)
+ ExtensionAudio.forgetAll()
+ ExtensionAuth.forget(id)
File(dir, id).deleteRecursively()
Logbook.log("ext $id: uninstalled")
}
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/ExtensionsScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/ExtensionsScreen.kt
index b35fdf52..46ca85b0 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/ExtensionsScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/ExtensionsScreen.kt
@@ -452,6 +452,8 @@ private fun InstalledRow(e: InstalledExtension, error: String?, status: app.mysp
val pkg = remember(e.id, e.sha256) { Extensions.pkg(e.id) }
val m = pkg?.manifest
val state = stateLine(e, error, status)
+ var askUninstall by remember { mutableStateOf(false) }
+ val scope = rememberCoroutineScope()
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth().clickable(onClick = onOpen).padding(horizontal = 20.dp, vertical = 10.dp),
@@ -475,8 +477,23 @@ private fun InstalledRow(e: InstalledExtension, error: String?, status: app.mysp
m?.let { ActionIcons(it.asks().filter { a -> a.key in e.granted }) }
extra()
}
+ IconButton(onClick = { askUninstall = true }) {
+ Icon(Icons.Filled.Delete, contentDescription = stringResource(R.string.extension_uninstall), tint = AppMuted)
+ }
Switch(checked = e.enabled, onCheckedChange = { enable(e.id, it) })
}
+ if (askUninstall) androidx.compose.material3.AlertDialog(
+ onDismissRequest = { askUninstall = false },
+ containerColor = tone(0xFF282828),
+ text = { Text(stringResource(R.string.extension_uninstall_confirm, e.name), color = AppText) },
+ confirmButton = {
+ TextButton(onClick = {
+ askUninstall = false
+ scope.launch { Extensions.uninstall(e.id) }
+ }) { Text(stringResource(R.string.extension_uninstall), color = Warning) }
+ },
+ dismissButton = { TextButton(onClick = { askUninstall = false }) { Text(stringResource(R.string.extensions_cancel), color = AppText) } },
+ )
}
@Composable