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.

Add a settings screen behind the account picture

Lelonio6c0fd07caa37
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 267451c..a9386a3 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -103,7 +103,8 @@
"Bash(./gradlew :app:assembleDev -q)",
"Bash(git commit -q -m 'Swap every icon to Phosphor *)",
"Bash(git commit -q -m 'Close the player by gesture, not by dragging it around *)",
- "Bash(git commit -q -m 'Open the player with a transform instead of a resize *)"
+ "Bash(git commit -q -m 'Open the player with a transform instead of a resize *)",
+ "Bash(git commit -q -m 'Add a settings screen behind the account picture *)"
]
}
}
diff --git a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
index d3a0143..19038b5 100644
--- a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
+++ b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
@@ -2,27 +2,27 @@ C/C++ Structured Logl
j
h/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/additional_project_files.txtC
A
-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �����3  ����3i
+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �����3  ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  �����3� ����3n
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  �����3� ����3n
l
-j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  �����3� �����3[
+j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  �����3� �����3[
Y
-W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  �����3�� ����3_
+W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  �����3�� ����3_
]
-[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  �����3d
+[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  �����3d
b
-`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  �����3 @ ����3e
+`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  �����3 @ ����3e
c
-a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  �����3�� ����3i
+a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  �����3�� ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  �����3 �" ����3o
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  �����3 �" ����3o
m
-k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  �����3
+k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  �����3
� ����3b
`
-^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  �����3  ( ����3g
+^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  �����3  ( ����3g
e
-c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  �����3  b ����3D
+c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  �����3  b ����3D
B
-@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  �����3 � �Ȅ��3
\ No newline at end of file
+@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  �����3 � �Ȅ��3
\ No newline at end of file
diff --git a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
index b051e48..dcaa350 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
@@ -88,6 +88,7 @@ import dev.emanuele.spot.ui.player.rememberPlaybackState
import dev.emanuele.spot.ui.player.rememberPositionMs
import dev.emanuele.spot.ui.player.rememberQueue
import dev.emanuele.spot.ui.search.SearchScreen
+import dev.emanuele.spot.ui.settings.SettingsScreen
import dev.emanuele.spot.ui.theme.Ink
import dev.emanuele.spot.ui.theme.SpotTheme
import dev.emanuele.spot.ui.theme.rememberArtworkColor
@@ -107,6 +108,7 @@ object Routes {
const val SEARCH = "search"
const val LIBRARY = "library"
const val PLAYLIST = "playlist"
+ const val SETTINGS = "settings"
}
/** How the player settles when it is not being dragged. */
@@ -289,6 +291,7 @@ fun SpotApp(
navController.navigate(Routes.PLAYLIST)
},
backdrop = artBackdrop,
+ onOpenSettings = { navController.navigate(Routes.SETTINGS) },
)
}
@@ -324,6 +327,21 @@ fun SpotApp(
)
}
+ composable(Routes.SETTINGS) {
+ SettingsScreen(
+ state = state,
+ webApi = webApi,
+ contentPadding = listPadding,
+ backdrop = artBackdrop,
+ deviceName = android.os.Build.MODEL ?: "Android",
+ onClientIdChange = viewModel::onWebApiClientIdChange,
+ onConnectWebApi = viewModel::connectWebApi,
+ onDisconnectWebApi = viewModel::disconnectWebApi,
+ onLogOut = viewModel::logOut,
+ onBack = { navController.popBackStack() },
+ )
+ }
+
composable(Routes.PLAYLIST) {
// Re-seeded from the open playlist, album or artist.
// The rest of the app is themed after whatever is
diff --git a/app/src/main/java/dev/emanuele/spot/ui/home/HomeScreen.kt b/app/src/main/java/dev/emanuele/spot/ui/home/HomeScreen.kt
index fb1027e..2e3359c 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/home/HomeScreen.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/home/HomeScreen.kt
@@ -99,6 +99,7 @@ fun HomeScreen(
onPlayRecent: (List<CatalogTrack>, Int) -> Unit,
feed: MainViewModel.FeedState,
onOpenItem: (SearchItem) -> Unit,
+ onOpenSettings: () -> Unit,
/** The layer the glass on this page refracts; see the note in SpotApp. */
backdrop: Backdrop,
) {
@@ -187,6 +188,7 @@ fun HomeScreen(
backdrop = backdrop,
topPadding = contentPadding.calculateTopPadding(),
onFilter = { filter = it },
+ onOpenSettings = onOpenSettings,
)
LazyColumn(
@@ -291,6 +293,7 @@ private fun Header(
backdrop: Backdrop,
topPadding: Dp,
onFilter: (Feed) -> Unit,
+ onOpenSettings: () -> Unit,
) {
Column(
Modifier
@@ -348,12 +351,17 @@ private fun Header(
// Falls back to the generated cover keyed on the name, which is what
// every other missing image in the app gets rather than a grey
// circle.
+ // The way into the settings. They have no tab of their own — see
+ // SettingsScreen — and the account picture is where anyone looks for
+ // them anyway.
Artwork(
url = avatarUrl,
title = name,
modifier = Modifier
.padding(start = 14.dp)
.size(lerp(46.dp, 36.dp, collapse))
+ .clip(CircleShape)
+ .clickable(onClick = onOpenSettings)
.softShadow(CircleShape, elevation = 10.dp),
corner = 23.dp,
decodeSize = 46.dp,
diff --git a/app/src/main/java/dev/emanuele/spot/ui/search/SearchScreen.kt b/app/src/main/java/dev/emanuele/spot/ui/search/SearchScreen.kt
index 375f573..ed3a380 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/search/SearchScreen.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/search/SearchScreen.kt
@@ -36,6 +36,7 @@ import dev.emanuele.spot.ui.components.Artwork
import com.kyant.backdrop.Backdrop
import dev.emanuele.spot.ui.components.SwipeToQueue
import dev.emanuele.spot.ui.glass.LiquidButton
+import dev.emanuele.spot.ui.settings.WebApiSetup
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Fill
import com.adamglin.phosphoricons.Regular
@@ -186,96 +187,6 @@ private fun LazyListScope.section(
}
}
-/**
- * One-time setup for the Web API.
- *
- * This screen exists because of a hard constraint rather than a preference:
- * playback must authenticate as librespot's shared client id — no other id is
- * accepted by the access point — and that same id has no Web API quota left,
- * since every librespot-based client on earth spends it. Search therefore needs
- * an application the user owns.
- */
-@Composable
-private fun WebApiSetup(
- state: MainViewModel.WebApiState,
- backdrop: Backdrop,
- onClientIdChange: (String) -> Unit,
- onConnect: () -> Unit,
-) {
- val clipboard = LocalClipboardManager.current
- Column(Modifier.padding(horizontal = 24.dp, vertical = 12.dp)) {
- Text("ATTIVA LA RICERCA", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)
- Text(
- "La ricerca usa le API web di Spotify, che hanno un limite di richieste " +
- "per applicazione. Registra un'app nel dashboard per sviluppatori e " +
- "incolla qui il suo client id: così il limite è solo tuo.",
- style = MaterialTheme.typography.bodyMedium,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- modifier = Modifier.padding(top = 8.dp),
- )
-
- Text(
- "Nell'app va aggiunto questo Redirect URI, identico:",
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- modifier = Modifier.padding(top = 18.dp),
- )
- Row(
- Modifier.padding(top = 6.dp),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- Text(
- state.redirectUri,
- style = MaterialTheme.typography.titleMedium,
- modifier = Modifier.weight(1f),
- )
- TextButton(onClick = { clipboard.setText(AnnotatedString(state.redirectUri)) }) {
- Text("Copia")
- }
- }
-
- OutlinedTextField(
- value = state.clientId,
- onValueChange = onClientIdChange,
- label = { Text("Client id") },
- singleLine = true,
- enabled = !state.connecting,
- shape = RoundedCornerShape(16.dp),
- modifier = Modifier
- .fillMaxWidth()
- .padding(top = 16.dp),
- )
-
- if (state.error != null) {
- Text(
- state.error,
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.error,
- modifier = Modifier.padding(top = 8.dp),
- )
- }
-
- LiquidButton(
- onClick = { if (!state.connecting) onConnect() },
- backdrop = backdrop,
- tint = MaterialTheme.colorScheme.primary,
- modifier = Modifier
- .padding(top = 16.dp)
- .height(50.dp),
- ) {
- if (state.connecting) {
- CircularProgressIndicator(
- strokeWidth = 2.dp,
- modifier = Modifier.size(18.dp),
- color = MaterialTheme.colorScheme.onPrimary,
- )
- } else {
- Text("Collega", style = MaterialTheme.typography.titleMedium)
- }
- }
- }
-}
-
@Composable
private fun SectionTitle(text: String) {
Text(
diff --git a/app/src/main/java/dev/emanuele/spot/ui/settings/SettingsScreen.kt b/app/src/main/java/dev/emanuele/spot/ui/settings/SettingsScreen.kt
new file mode 100644
index 0000000..8e04eb4
--- /dev/null
+++ b/app/src/main/java/dev/emanuele/spot/ui/settings/SettingsScreen.kt
@@ -0,0 +1,324 @@
+package dev.emanuele.spot.ui.settings
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Icon
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import com.adamglin.PhosphorIcons
+import com.adamglin.phosphoricons.Regular
+import com.adamglin.phosphoricons.regular.ArrowLeft
+import com.adamglin.phosphoricons.regular.CaretDown
+import com.adamglin.phosphoricons.regular.CaretUp
+import com.kyant.backdrop.Backdrop
+import dev.emanuele.spot.BuildConfig
+import dev.emanuele.spot.ui.MainViewModel
+import dev.emanuele.spot.ui.components.Artwork
+import dev.emanuele.spot.ui.glass.LiquidButton
+import dev.emanuele.spot.ui.theme.Ink
+import dev.emanuele.spot.ui.theme.InkDim
+import dev.emanuele.spot.ui.theme.softShadow
+
+/**
+ * Everything that is configuration rather than listening.
+ *
+ * Reached from the avatar in the home header, not from the tab bar. The bar has
+ * three places you go to play something and settings is not one of them — it is
+ * somewhere you visit twice a year, and giving it a permanent quarter of the
+ * navigation would say otherwise.
+ *
+ * Deliberately short. Most of what a music app usually puts here is decided by
+ * the account or by the engine and is not ours to offer: bitrate comes from
+ * Premium, the device name from the phone. What is left is the account itself,
+ * the Web API application the user has to register for search, and the licences
+ * this app owes attribution to.
+ */
+@Composable
+fun SettingsScreen(
+ state: MainViewModel.UiState,
+ webApi: MainViewModel.WebApiState,
+ contentPadding: PaddingValues,
+ backdrop: Backdrop,
+ deviceName: String,
+ onClientIdChange: (String) -> Unit,
+ onConnectWebApi: () -> Unit,
+ onDisconnectWebApi: () -> Unit,
+ onLogOut: () -> Unit,
+ onBack: () -> Unit,
+) {
+ val ready = state as? MainViewModel.UiState.Ready
+
+ LazyColumn(
+ Modifier.fillMaxSize(),
+ contentPadding = PaddingValues(
+ top = contentPadding.calculateTopPadding(),
+ bottom = contentPadding.calculateBottomPadding() + 24.dp,
+ ),
+ ) {
+ item("top") {
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .padding(start = 16.dp, end = 24.dp, top = 8.dp, bottom = 4.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ LiquidButton(onClick = onBack, backdrop = backdrop) {
+ Icon(PhosphorIcons.Regular.ArrowLeft, contentDescription = "Indietro")
+ }
+ Text(
+ "Impostazioni",
+ style = MaterialTheme.typography.displayLarge,
+ modifier = Modifier.padding(start = 14.dp),
+ )
+ }
+ }
+
+ item("account") {
+ Section("Account") {
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 18.dp, vertical = 16.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Artwork(
+ url = ready?.avatarUrl,
+ title = ready?.displayName.orEmpty(),
+ modifier = Modifier
+ .size(54.dp)
+ .softShadow(CircleShape, elevation = 10.dp),
+ corner = 27.dp,
+ decodeSize = 54.dp,
+ )
+ Column(
+ Modifier
+ .weight(1f)
+ .padding(start = 14.dp),
+ ) {
+ Text(
+ ready?.displayName ?: "Non connesso",
+ style = MaterialTheme.typography.titleMedium,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ )
+ Text(
+ if (ready != null) {
+ "${ready.playlists.size} playlist"
+ } else {
+ "Accedi per riprendere"
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = InkDim,
+ )
+ }
+ }
+
+ RowDivider()
+ InfoRow("Dispositivo Connect", deviceName)
+ }
+ }
+
+ item("webapi") {
+ Section("API web") {
+ if (webApi.connected) {
+ InfoRow("Applicazione", "Collegata")
+ RowDivider()
+ InfoRow(
+ "Client id",
+ webApi.clientId.take(8) + if (webApi.clientId.length > 8) "…" else "",
+ )
+ RowDivider()
+ ActionRow("Scollega", destructive = true, onClick = onDisconnectWebApi)
+ } else {
+ // The full explanation, because with no application
+ // connected search does not work at all and the reason is
+ // not something anyone would guess.
+ WebApiSetup(webApi, backdrop, onClientIdChange, onConnectWebApi)
+ }
+ }
+ }
+
+ item("permissions") {
+ Section("Permessi richiesti") {
+ Text(
+ "Un'applicazione collegata prima di un aggiornamento va ricollegata " +
+ "per concedere i permessi aggiunti dopo: le sezioni che li usano " +
+ "restano vuote finché non lo fai.",
+ style = MaterialTheme.typography.bodySmall,
+ color = InkDim,
+ modifier = Modifier.padding(horizontal = 18.dp, vertical = 14.dp),
+ )
+ SCOPES.forEach { (scope, why) ->
+ RowDivider()
+ InfoRow(scope, why)
+ }
+ }
+ }
+
+ item("about") {
+ Section("Informazioni") {
+ InfoRow("Versione", "${BuildConfig.VERSION_NAME} (${BuildConfig.BUILD_TYPE})")
+ RowDivider()
+ Licences()
+ }
+ }
+
+ if (ready != null) {
+ item("logout") {
+ Section(null) {
+ ActionRow("Esci", destructive = true, onClick = onLogOut)
+ }
+ }
+ }
+ }
+}
+
+/**
+ * The third-party code this app ships, and under what.
+ *
+ * Not a nicety: Bungee is MPL-2.0 and the Backdrop components are Apache-2.0,
+ * and both licences require the notice to travel with the binary. Collapsed by
+ * default because it is an obligation to the authors, not a feature.
+ */
+@Composable
+private fun Licences() {
+ var open by remember { mutableStateOf(false) }
+
+ Column {
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .clickable { open = !open }
+ .padding(horizontal = 18.dp, vertical = 14.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text("Licenze", style = MaterialTheme.typography.bodyLarge, modifier = Modifier.weight(1f))
+ Icon(
+ if (open) PhosphorIcons.Regular.CaretUp else PhosphorIcons.Regular.CaretDown,
+ contentDescription = null,
+ tint = InkDim,
+ modifier = Modifier.size(18.dp),
+ )
+ }
+ if (open) {
+ LICENCES.forEach { (what, licence) ->
+ Text(
+ "$what — $licence",
+ style = MaterialTheme.typography.bodySmall,
+ color = InkDim,
+ modifier = Modifier.padding(horizontal = 18.dp, vertical = 3.dp),
+ )
+ }
+ Spacer(Modifier.height(12.dp))
+ }
+ }
+}
+
+@Composable
+private fun Section(title: String?, content: @Composable () -> Unit) {
+ Column(Modifier.padding(horizontal = 20.dp, vertical = 10.dp)) {
+ if (title != null) {
+ Text(
+ title.uppercase(),
+ style = MaterialTheme.typography.labelLarge,
+ color = InkDim,
+ modifier = Modifier.padding(start = 6.dp, bottom = 8.dp),
+ )
+ }
+ Column(
+ Modifier
+ .fillMaxWidth()
+ .clip(RoundedCornerShape(22.dp))
+ .background(Ink.copy(alpha = 0.07f)),
+ content = { content() },
+ )
+ }
+}
+
+@Composable
+private fun InfoRow(label: String, value: String) {
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 18.dp, vertical = 14.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ ) {
+ Text(label, style = MaterialTheme.typography.bodyLarge, modifier = Modifier.weight(1f))
+ Text(
+ value,
+ style = MaterialTheme.typography.bodyMedium,
+ color = InkDim,
+ textAlign = androidx.compose.ui.text.style.TextAlign.End,
+ modifier = Modifier.weight(1f),
+ )
+ }
+}
+
+@Composable
+private fun ActionRow(label: String, destructive: Boolean, onClick: () -> Unit) {
+ Text(
+ label,
+ style = MaterialTheme.typography.bodyLarge,
+ fontWeight = FontWeight.Medium,
+ color = if (destructive) MaterialTheme.colorScheme.error else Ink,
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable(onClick = onClick)
+ .padding(horizontal = 18.dp, vertical = 16.dp),
+ )
+}
+
+@Composable
+private fun RowDivider() {
+ Box(
+ Modifier
+ .fillMaxWidth()
+ .padding(start = 18.dp)
+ .height(1.dp)
+ .background(Ink.copy(alpha = 0.08f)),
+ )
+}
+
+/** Kept next to the request that asks for them; see MainViewModel.connectWebApi. */
+private val SCOPES = listOf(
+ "user-top-read" to "Artisti che ascolti",
+ "user-read-playback-state" to "Elenco dispositivi",
+ "user-modify-playback-state" to "Sposta la riproduzione",
+ "user-library-read" to "Brani salvati",
+ "user-library-modify" to "Cuore nel player",
+)
+
+private val LICENCES = listOf(
+ "librespot" to "MIT",
+ "Bungee" to "MPL-2.0",
+ "AndroidLiquidGlass" to "Apache-2.0",
+ "Phosphor Icons" to "MIT",
+ "Coil" to "Apache-2.0",
+ "OkHttp / Retrofit" to "Apache-2.0",
+)
diff --git a/app/src/main/java/dev/emanuele/spot/ui/settings/WebApiSetup.kt b/app/src/main/java/dev/emanuele/spot/ui/settings/WebApiSetup.kt
new file mode 100644
index 0000000..6dbd486
--- /dev/null
+++ b/app/src/main/java/dev/emanuele/spot/ui/settings/WebApiSetup.kt
@@ -0,0 +1,113 @@
+package dev.emanuele.spot.ui.settings
+
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.OutlinedTextField
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalClipboardManager
+import androidx.compose.ui.text.AnnotatedString
+import androidx.compose.ui.unit.dp
+import com.kyant.backdrop.Backdrop
+import dev.emanuele.spot.ui.MainViewModel
+import dev.emanuele.spot.ui.glass.LiquidButton
+
+/**
+ * One-time setup for the Web API.
+ *
+ * This screen exists because of a hard constraint rather than a preference:
+ * playback must authenticate as librespot's shared client id — no other id is
+ * accepted by the access point — and that same id has no Web API quota left,
+ * since every librespot-based client on earth spends it. Search therefore needs
+ * an application the user owns.
+ */
+@Composable
+internal fun WebApiSetup(
+ state: MainViewModel.WebApiState,
+ backdrop: Backdrop,
+ onClientIdChange: (String) -> Unit,
+ onConnect: () -> Unit,
+) {
+ val clipboard = LocalClipboardManager.current
+ Column(Modifier.padding(horizontal = 24.dp, vertical = 12.dp)) {
+ Text("ATTIVA LA RICERCA", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)
+ Text(
+ "La ricerca usa le API web di Spotify, che hanno un limite di richieste " +
+ "per applicazione. Registra un'app nel dashboard per sviluppatori e " +
+ "incolla qui il suo client id: così il limite è solo tuo.",
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier.padding(top = 8.dp),
+ )
+
+ Text(
+ "Nell'app va aggiunto questo Redirect URI, identico:",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier.padding(top = 18.dp),
+ )
+ Row(
+ Modifier.padding(top = 6.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text(
+ state.redirectUri,
+ style = MaterialTheme.typography.titleMedium,
+ modifier = Modifier.weight(1f),
+ )
+ TextButton(onClick = { clipboard.setText(AnnotatedString(state.redirectUri)) }) {
+ Text("Copia")
+ }
+ }
+
+ OutlinedTextField(
+ value = state.clientId,
+ onValueChange = onClientIdChange,
+ label = { Text("Client id") },
+ singleLine = true,
+ enabled = !state.connecting,
+ shape = RoundedCornerShape(16.dp),
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(top = 16.dp),
+ )
+
+ if (state.error != null) {
+ Text(
+ state.error,
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.error,
+ modifier = Modifier.padding(top = 8.dp),
+ )
+ }
+
+ LiquidButton(
+ onClick = { if (!state.connecting) onConnect() },
+ backdrop = backdrop,
+ tint = MaterialTheme.colorScheme.primary,
+ modifier = Modifier
+ .padding(top = 16.dp)
+ .height(50.dp),
+ ) {
+ if (state.connecting) {
+ CircularProgressIndicator(
+ strokeWidth = 2.dp,
+ modifier = Modifier.size(18.dp),
+ color = MaterialTheme.colorScheme.onPrimary,
+ )
+ } else {
+ Text("Collega", style = MaterialTheme.typography.titleMedium)
+ }
+ }
+ }
+}