Native Android client for Spotify, built with Jetpack Compose
Kotlin ad-freeadblockandroidjetpack-composekotlinlyricsmusic-playermusic-videomyspotispotifyspotify-adblockerspotify-clientspotify-connectspotui
A new "Stats for nerds" sheet in the player menu of both looks (and on a long press of the source line under the title) shows, live once a second only while it is open, what plays in Myspoti's player (source, codec, sample rate, bit depth, channels, bit rate, file size of a download, buffer ahead, audio output with its Bluetooth, USB or wired device, crossfade) and, for Spotify, what the page announces and the state of the mirror, with a note that Spotify's own stream is encrypted in the page so its exact codec and bit rate are not accessible [skip ci]
kota-zoabc24e9bb101
diff --git a/base/app/src/main/java/com/music/spotui/di/LocalPlayer.kt b/base/app/src/main/java/com/music/spotui/di/LocalPlayer.ktindex 338a64bd..a0bbf03a 100644--- a/base/app/src/main/java/com/music/spotui/di/LocalPlayer.kt+++ b/base/app/src/main/java/com/music/spotui/di/LocalPlayer.kt@@ -891,6 +891,8 @@ object LocalPlayer {fun audioFormat(): androidx.media3.common.Format? = if (CastPlayback.active) null else exo?.audioFormat/** The length the player knows of the audio itself (null: not known), never Spotify's. */fun knownLength(): Long? = if (CastPlayback.active) null else exo?.duration?.takeIf { it != C.TIME_UNSET && it > 0 }+ /** How far ahead of the position the song is loaded, ms (null: nothing playing here); read by "Stats for nerds" only. */+ fun bufferedAheadMs(): Long? = if (CastPlayback.active) null else exo?.let { (it.bufferedPosition - it.currentPosition).coerceAtLeast(0L) }fun current(): LocalTrack? = exo?.currentMediaItemIndex?.let { tracks.getOrNull(it) }/**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.ktindex bc22c453..e0033ccc 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@@ -115,6 +115,9 @@ object ExtensionAudio {/** The extension that gave the audio of the song with Spotify id [trackId] last, or null. */fun providerOf(trackId: String): String? = known[trackId]?.stream?.providerId+ /** The answer kept for the song [trackId] (what the extension announced about its audio), or null. */+ fun streamOf(trackId: String): AudioStream? = known[trackId]?.stream+/** The quality the extension announced for the song [trackId] ("FLAC · 24-bit · 96 kHz"), or null. */fun qualityOf(trackId: String): String? = known[trackId]?.stream?.qualityLabel()diff --git a/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt b/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.ktindex 2f3f52e5..2a797f39 100644--- a/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt+++ b/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt@@ -304,7 +304,7 @@ private fun DeviceRow(icon: ImageVector, name: String, detail: String?, current:}}-private fun streamingLabel(q: com.music.spotui.data.preferences.StreamingQuality): Int = when (q) {+internal fun streamingLabel(q: com.music.spotui.data.preferences.StreamingQuality): Int = when (q) {com.music.spotui.data.preferences.StreamingQuality.AUTO -> R.string.quality_streaming_autocom.music.spotui.data.preferences.StreamingQuality.LOW -> R.string.quality_streaming_lowcom.music.spotui.data.preferences.StreamingQuality.NORMAL -> R.string.quality_streaming_normal@@ -359,7 +359,7 @@ fun QualitySheet(onDismiss: () -> Unit) {}}-private fun codecName(mime: String): String = when {+internal fun codecName(mime: String): String = when {"mp4a" in mime -> "AAC""flac" in mime -> "FLAC""opus" in mime -> "Opus"diff --git a/base/app/src/main/java/com/music/spotui/ui/components/SongOptionsSheet.kt b/base/app/src/main/java/com/music/spotui/ui/components/SongOptionsSheet.ktindex fd509337..463125c8 100644--- a/base/app/src/main/java/com/music/spotui/ui/components/SongOptionsSheet.kt+++ b/base/app/src/main/java/com/music/spotui/ui/components/SongOptionsSheet.kt@@ -43,6 +43,7 @@ import androidx.compose.material.icons.outlined.Infoimport androidx.compose.material.icons.outlined.Blockimport androidx.compose.material.icons.outlined.Bookmarkimport androidx.compose.material.icons.outlined.Delete+import androidx.compose.material.icons.outlined.Analyticsimport androidx.compose.material.icons.outlined.Speedimport androidx.compose.material.icons.outlined.ThumbDownOffAltimport kotlinx.coroutines.launch@@ -109,6 +110,11 @@ fun SongOptionsSheet(var showSleep by remember { mutableStateOf(false) }var showCredits by remember { mutableStateOf(false) }var showSpeed by remember { mutableStateOf(false) }+ var showNerd by remember { mutableStateOf(false) }+ if (showNerd) {+ StatsForNerdsSheet(onDismiss = { showNerd = false; onDismiss() })+ return+ }if (showCredits) {CreditsSheet(song = song, onDismiss = { showCredits = false; onDismiss() })return@@ -327,6 +333,7 @@ fun SongOptionsSheet(stringResource(R.string.context_menu_sleep_timer),tint = if (active) MenuGreen else MenuIconColor,) { showSleep = true }+ MenuRow(Icons.Outlined.Analytics, stringResource(R.string.nerd_title)) { showNerd = true }}// Entries from extensions (menu.items), after the app's own; each names its extension.if (hasId) com.music.spotui.extensions.ExtensionMenuEntries(diff --git a/base/app/src/main/java/com/music/spotui/ui/components/StatsForNerdsSheet.kt b/base/app/src/main/java/com/music/spotui/ui/components/StatsForNerdsSheet.ktnew file mode 100644index 00000000..b0a306a4--- /dev/null+++ b/base/app/src/main/java/com/music/spotui/ui/components/StatsForNerdsSheet.kt@@ -0,0 +1,200 @@+package com.music.spotui.ui.components++import android.content.Context+import android.media.AudioDeviceInfo+import android.media.AudioManager+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.navigationBarsPadding+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScroll+import androidx.compose.material3.ExperimentalMaterial3Api+import androidx.compose.material3.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.produceState+import androidx.compose.ui.Modifier+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import androidx.media3.common.C+import app.myspoti.engine.R+import com.music.spotui.cast.CastPlayback+import com.music.spotui.data.offline.OfflineStore+import com.music.spotui.data.preferences.CrossfadePref+import com.music.spotui.data.preferences.StreamingQuality+import com.music.spotui.di.ConnectMirror+import com.music.spotui.di.LocalPlayer+import com.music.spotui.di.SongPlayer+import com.music.spotui.extensions.ExtensionAudio+import com.music.spotui.extensions.Extensions+import com.music.spotui.ui.theme.AppMuted+import com.music.spotui.ui.theme.AppText+import com.music.spotui.ui.theme.tone+import kotlinx.coroutines.delay+import java.util.Locale++/**+ * "Stats for nerds": what the app knows of the sound that plays, read again every second while the+ * sheet is open (and not at all otherwise: the reading lives in the sheet's composition). For+ * Myspoti's own player: the source, the format the decoder reports, the bit rate, the buffer, the+ * output and the processing. For Spotify: what the page announces and the mirror; the stream itself+ * is encrypted in the page, so nothing more is claimed. The sources asked and the quality announced+ * are told in full by "Why this source?" ([WhySourceSheet]), opened from the player's source line.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun StatsForNerdsSheet(onDismiss: () -> Unit) {+ val context = LocalContext.current+ val sections by produceState(emptyList<NerdSection>()) {+ while (true) {+ value = NerdStats.read(context)+ delay(1_000L)+ }+ }+ LookSheet(onDismissRequest = onDismiss, containerColor = tone(0xFF282828)) {+ Column(Modifier.fillMaxWidth().navigationBarsPadding().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {+ Text(stringResource(R.string.nerd_title), color = AppText, fontSize = 20.sp, fontWeight = FontWeight.Bold,+ modifier = Modifier.padding(horizontal = 20.dp, vertical = 8.dp))+ sections.forEach { s ->+ Text(s.title, color = AppText, fontSize = 15.sp, fontWeight = FontWeight.Bold,+ modifier = Modifier.padding(start = 20.dp, end = 20.dp, top = 12.dp, bottom = 2.dp))+ s.rows.forEach { (label, value) ->+ Row(Modifier.fillMaxWidth().padding(horizontal = 20.dp, vertical = 3.dp)) {+ Text(label, color = AppMuted, fontSize = 13.sp, modifier = Modifier.weight(0.4f).padding(end = 12.dp))+ Text(value, color = AppText, fontSize = 14.sp, modifier = Modifier.weight(0.6f))+ }+ }+ s.note?.let { Text(it, color = AppMuted, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 6.dp)) }+ }+ }+ }+}++/** A block of the sheet: its [title], its (label, value) [rows] and a closing [note]. */+internal class NerdSection(val title: String, val rows: List<Pair<String, String>>, val note: String? = null)++internal object NerdStats {+ /** What is read, for both players; on the main thread (ExoPlayer's), with one call into the page. */+ suspend fun read(context: Context): List<NerdSection> = buildList {+ val local = LocalPlayer.active.value+ if (local) add(exoSection(context))+ add(spotifySection(context, local))+ }++ private fun exoSection(c: Context): NerdSection {+ val rows = ArrayList<Pair<String, String>>()+ fun row(label: Int, value: String?) { if (!value.isNullOrBlank()) rows += c.getString(label) to value }+ val t = LocalPlayer.current()+ val id = t?.uri?.takeIf { it.scheme == ExtensionAudio.SCHEME }?.lastPathSegment+ val download = t?.let { OfflineStore.byLocalId(it.id) }+ // The source, as the player's source line and the "why" page know it.+ row(R.string.nerd_source, when {+ id != null -> ExtensionAudio.streamedBy(t)?.let { c.getString(R.string.nerd_source_extension, it) } ?: c.getString(R.string.nerd_source_extension_waiting)+ download != null -> c.getString(R.string.nerd_source_download, listOfNotNull(download.file.substringAfterLast('.', "").uppercase().ifBlank { null },+ download.source.ifBlank { null }, download.providerId?.let { Extensions.registry.value.find(it)?.name }).joinToString(" · "))+ t != null -> c.getString(R.string.nerd_source_file)+ else -> null+ })+ val stream = id?.let(ExtensionAudio::streamOf)+ row(R.string.nerd_delivery, id?.let(ExtensionAudio::deliveryOf))+ row(R.string.nerd_announced, id?.let(ExtensionAudio::qualityOf))+ val f = LocalPlayer.audioFormat()+ if (f == null) {+ if (!CastPlayback.active) row(R.string.nerd_codec, c.getString(R.string.nerd_format_unknown))+ } else {+ val mime = f.sampleMimeType ?: f.codecs+ val codecs = f.codecs?.takeIf { it != mime }?.let { " ($it)" }.orEmpty()+ row(R.string.nerd_codec, mime?.let { codecName(it) + codecs + (if (it.contains('/')) " · $it" else "") })+ row(R.string.nerd_container, f.containerMimeType)+ row(R.string.nerd_sample_rate, f.sampleRate.takeIf { it > 0 }?.let(::khz))+ row(R.string.nerd_bit_depth, bits(c, f.pcmEncoding) ?: stream?.bitDepth?.let { c.getString(R.string.nerd_bit_depth_announced, it) })+ row(R.string.nerd_channels, f.channelCount.takeIf { it > 0 }?.toString())+ }+ val kbps = (f?.bitrate?.takeIf { it > 0 } ?: f?.averageBitrate?.takeIf { it > 0 })?.let { c.getString(R.string.nerd_bitrate_value, it / 1000) }+ ?: download?.takeIf { it.bytes > 0 }?.let { d ->+ val ms = LocalPlayer.knownLength() ?: t.durationMs+ if (ms > 0) c.getString(R.string.nerd_bitrate_average, (d.bytes * 8 / ms).toInt()) else null+ }+ row(R.string.nerd_bitrate, kbps)+ row(R.string.nerd_file_size, download?.bytes?.takeIf { it > 0 }?.let { android.text.format.Formatter.formatShortFileSize(c, it) })+ row(R.string.nerd_buffer, LocalPlayer.bufferedAheadMs()?.let { c.getString(R.string.nerd_buffer_value, it / 1000.0) })+ row(R.string.nerd_state, LocalPlayer.playbackState())+ rows += outputRows(c)+ row(R.string.nerd_processing, listOfNotNull(+ CrossfadePref.seconds.takeIf { it > 0 }?.let { c.getString(R.string.nerd_crossfade, it) },+ if (LocalPlayer.fadeProgress() < 1f) c.getString(R.string.nerd_fading) else null,+ ).joinToString(" · ").ifBlank { c.getString(R.string.nerd_processing_none) })+ return NerdSection(c.getString(R.string.nerd_section_exo), rows)+ }++ /** The bit depth a PCM encoding says, or null (a compressed format, or none reported). */+ private fun bits(c: Context, encoding: Int): String? = when (encoding) {+ C.ENCODING_PCM_8BIT -> c.getString(R.string.nerd_bit_depth_value, 8)+ C.ENCODING_PCM_16BIT, C.ENCODING_PCM_16BIT_BIG_ENDIAN -> c.getString(R.string.nerd_bit_depth_value, 16)+ C.ENCODING_PCM_24BIT, C.ENCODING_PCM_24BIT_BIG_ENDIAN -> c.getString(R.string.nerd_bit_depth_value, 24)+ C.ENCODING_PCM_32BIT, C.ENCODING_PCM_32BIT_BIG_ENDIAN -> c.getString(R.string.nerd_bit_depth_value, 32)+ C.ENCODING_PCM_FLOAT -> c.getString(R.string.nerd_bit_depth_float)+ else -> null+ }++ private fun khz(hz: Int): String = if (hz % 1000 == 0) "${hz / 1000} kHz" else "%.1f kHz".format(Locale.US, hz / 1000.0)++ /**+ * Where the sound goes: the speaker, Bluetooth, USB or wired headphones (with the device's name+ * when Android gives it), the highest rate a USB device says it takes, and the rate Android's+ * mixer runs at. Android does not tell an app the Bluetooth codec: it is not shown.+ */+ private fun outputRows(c: Context): List<Pair<String, String>> {+ val rows = ArrayList<Pair<String, String>>()+ val cast = CastPlayback.device.value?.takeIf { CastPlayback.active }+ if (cast != null) return listOf(c.getString(R.string.nerd_output) to c.getString(R.string.nerd_output_cast, cast.name))+ val am = c.getSystemService(Context.AUDIO_SERVICE) as AudioManager+ val outs = runCatching { am.getDevices(AudioManager.GET_DEVICES_OUTPUTS).toList() }.getOrDefault(emptyList())+ val usb = outs.firstOrNull { it.type == AudioDeviceInfo.TYPE_USB_DEVICE || it.type == AudioDeviceInfo.TYPE_USB_HEADSET || it.type == AudioDeviceInfo.TYPE_USB_ACCESSORY }+ val route = AudioRoute.current(c)+ val kindLabel = when {+ route.kind == AudioRoute.Kind.BLUETOOTH -> R.string.nerd_output_bluetooth+ usb != null -> R.string.nerd_output_usb+ route.kind == AudioRoute.Kind.WIRED -> R.string.nerd_output_wired+ else -> R.string.nerd_output_speaker+ }+ val device = usb.takeIf { kindLabel == R.string.nerd_output_usb }+ val name = if (device != null) runCatching { device.productName?.toString().orEmpty() }.getOrDefault("") else route.name+ val kind = c.getString(kindLabel)+ rows += c.getString(R.string.nerd_output) to (if (name.isBlank()) kind else c.getString(R.string.nerd_output_named, kind, name))+ device?.sampleRates?.maxOrNull()?.takeIf { it > 0 }?.let { rows += c.getString(R.string.nerd_output_max_rate) to khz(it) }+ am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE)?.toIntOrNull()?.let { rows += c.getString(R.string.nerd_mixer_rate) to khz(it) }+ return rows+ }++ private suspend fun spotifySection(c: Context, local: Boolean): NerdSection {+ val rows = ArrayList<Pair<String, String>>()+ val title = c.getString(R.string.nerd_section_spotify)+ val remote = SongPlayer.activeDevice.value+ if (remote != null) {+ rows += c.getString(R.string.nerd_device) to remote.name+ return NerdSection(title, rows, c.getString(R.string.nerd_spotify_remote))+ }+ val page = app.myspoti.host.android.MyspotiRuntime.spotify.player+ rows += c.getString(R.string.nerd_device) to c.getString(R.string.nerd_device_this_phone)+ val extension = Extensions.mirrorBy.value+ rows += c.getString(R.string.nerd_mirror) to when {+ extension != null -> c.getString(R.string.nerd_mirror_extension, extension)+ ConnectMirror.running -> c.getString(R.string.nerd_mirror_on)+ else -> c.getString(R.string.nerd_mirror_off)+ }+ // The level the page is given (the lowest one while it only mirrors), and what it says it plays aloud.+ rows += c.getString(R.string.nerd_requested) to c.getString(streamingLabel(StreamingQuality.of(page.streamingLevel)))+ if (!local) {+ val (bitrate, mime) = page.audioInfo()+ rows += c.getString(R.string.nerd_page_reports) to+ if (bitrate > 0) "${codecName(mime)} · ${bitrate / 1000} kbit/s" else c.getString(R.string.nerd_page_reports_none)+ }+ return NerdSection(title, rows, c.getString(R.string.nerd_spotify_note))+ }+}diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.ktindex 9be3aba2..78bf5f93 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt@@ -26,6 +26,7 @@ import androidx.compose.foundation.ExperimentalFoundationApiimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.basicMarqueeimport androidx.compose.foundation.clickable+import androidx.compose.foundation.combinedClickableimport androidx.compose.foundation.gestures.awaitEachGestureimport androidx.compose.foundation.gestures.awaitFirstDownimport androidx.compose.foundation.gestures.awaitVerticalTouchSlopOrCancellation@@ -221,6 +222,7 @@ fun ImmersivePlayer(var showMenu by remember { mutableStateOf(false) }var showDevices by remember { mutableStateOf(false) }var showQuality by remember { mutableStateOf(false) }+ var showNerd by remember { mutableStateOf(false) }val lyricsOpen = panel == Panel.LYRICSval queueOpen = panel == Panel.QUEUE@@ -300,6 +302,7 @@ fun ImmersivePlayer(onOpenDevices = { showDevices = true },onMore = if (navController != null && state.song != null) ({ showMenu = true }) else null,onSource = { showQuality = true },+ onSourceLong = { showNerd = true },sidePane = sidePane,) else Column(Modifier.fillMaxSize().statusBarsPadding().navigationBarsPadding()) {// The handle: always hands its drags to the sheet.@@ -426,6 +429,7 @@ fun ImmersivePlayer(state = state, actions = actions, tint = tint, scrolls = scrolls, collapse = { p() },onMore = if (navController != null && state.song != null) ({ showMenu = true }) else null,onSource = { showQuality = true },+ onSourceLong = { showNerd = true },)}}@@ -453,6 +457,7 @@ fun ImmersivePlayer(if (showDevices) DevicesSheet { showDevices = false }if (showQuality) com.music.spotui.ui.components.QualitySheet { showQuality = false }+ if (showNerd) com.music.spotui.ui.components.StatsForNerdsSheet { showNerd = false }val song = state.songif (showMenu && song != null && navController != null) {ImmersiveSongOptionsSheet(@@ -529,6 +534,7 @@ private fun RowScope.PlayerCredits(collapse: () -> Float,onMore: (() -> Unit)?,onSource: () -> Unit,+ onSourceLong: () -> Unit = {},) {// The header is a fixed HEADER_HEIGHT: the three lines are set tighter, so none is// clipped at the bottom. The source line's room is kept from the start (it is only known@@ -604,7 +610,7 @@ private fun RowScope.PlayerCredits(modifier = Modifier.graphicsLayer { alpha = sourceAlpha }.then(- if (hasSource) Modifier.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null, onClick = onSource)+ if (hasSource) Modifier.combinedClickable(interactionSource = remember { MutableInteractionSource() }, indication = null, onLongClick = onSourceLong, onClick = onSource)else Modifier,),)@@ -694,6 +700,7 @@ private fun LandscapePlayer(onOpenDevices: () -> Unit,onMore: (() -> Unit)?,onSource: () -> Unit,+ onSourceLong: () -> Unit = {},sidePane: Boolean = false,) {Column(Modifier.fillMaxSize().statusBarsPadding().navigationBarsPadding()) {@@ -753,7 +760,7 @@ private fun LandscapePlayer(val showVolume = maxHeight >= LANDSCAPE_VOLUME_MIN_HEIGHTColumn(Modifier.widthIn(max = PLAYER_MAX_WIDTH).verticalScroll(rememberScrollState())) {Row(Modifier.fillMaxWidth().height(HEADER_HEIGHT), verticalAlignment = Alignment.CenterVertically) {- PlayerCredits(state, actions, tint, scrolls = true, collapse = { 0f }, onMore = onMore, onSource = onSource)+ PlayerCredits(state, actions, tint, scrolls = true, collapse = { 0f }, onMore = onMore, onSource = onSource, onSourceLong = onSourceLong)}Spacer(Modifier.height(8.dp))PlayerControlsBlock(diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/sheets/ImmersiveSongOptionsSheet.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/sheets/ImmersiveSongOptionsSheet.ktindex 71f44310..c4b3c5de 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/sheets/ImmersiveSongOptionsSheet.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/sheets/ImmersiveSongOptionsSheet.kt@@ -28,6 +28,7 @@ import androidx.compose.material.icons.rounded.Radioimport androidx.compose.material.icons.rounded.Shareimport androidx.compose.material.icons.rounded.SortByAlphaimport androidx.compose.material.icons.rounded.SwapHoriz+import androidx.compose.material.icons.rounded.Analyticsimport androidx.compose.material.icons.rounded.Speedimport androidx.compose.material.icons.rounded.ThumbDownOffAltimport androidx.compose.runtime.Composable@@ -88,6 +89,8 @@ fun ImmersiveSongOptionsSheet(var showSpeed by remember { mutableStateOf(false) }var showMeaning by remember { mutableStateOf(false) }var showSources by remember { mutableStateOf(false) }+ var showNerd by remember { mutableStateOf(false) }+ if (showNerd) { com.music.spotui.ui.components.StatsForNerdsSheet(onDismiss = { showNerd = false; onDismiss() }); return }if (showSources) { com.music.spotui.ui.components.LyricsSourceSheet(onDismiss = { showSources = false; onDismiss() }); return }if (showCredits) { CreditsSheet(song = song, onDismiss = { showCredits = false; onDismiss() }); return }if (showMeaning) {@@ -310,6 +313,7 @@ fun ImmersiveSongOptionsSheet(stringResource(R.string.context_menu_sleep_timer),tint = if (SongPlayer.sleepEndsAt.value != null) LocalImmersiveSheetTint.current.accent else null,) { showSleep = true }+ ImmersiveSheetRow(Icons.Rounded.Analytics, stringResource(R.string.nerd_title)) { showNerd = true }}// Entries from extensions (menu.items), after the app's own; each names its extension.if (hasId) com.music.spotui.extensions.ExtensionMenuEntries(diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.ktindex 647739b4..e2043f09 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt@@ -25,6 +25,7 @@ import androidx.compose.animation.slideOutVerticallyimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.basicMarqueeimport androidx.compose.foundation.clickable+import androidx.compose.foundation.combinedClickableimport androidx.compose.material.icons.outlined.AddCircleOutlineimport androidx.compose.foundation.interaction.MutableInteractionSourceimport androidx.compose.foundation.layout.Arrangement@@ -1408,6 +1409,7 @@ fun PlayerFull(}}+@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)@Composablefun PlayerConnectRow(context: Context,@@ -1451,16 +1453,20 @@ fun PlayerConnectRow(// download); a tap opens what plays and its quality.val source = com.music.spotui.ui.components.playingSourceLabel()var quality by remember { mutableStateOf(false) }+ var nerd by remember { mutableStateOf(false) }if (quality) com.music.spotui.ui.components.QualitySheet { quality = false }+ if (nerd) com.music.spotui.ui.components.StatsForNerdsSheet { nerd = false }if (source.isNotBlank()) Text(text = source,color = com.music.spotui.ui.theme.AppMuted,fontSize = 11.sp,maxLines = 1,overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis,- modifier = Modifier.clickable(+ // A tap: what plays and its quality; a long press: the stats for nerds.+ modifier = Modifier.combinedClickable(interactionSource = remember { MutableInteractionSource() },indication = null,+ onLongClick = { nerd = true },) { quality = true },)}diff --git a/base/app/src/main/res/values/nerd_strings.xml b/base/app/src/main/res/values/nerd_strings.xmlnew file mode 100644index 00000000..1ca6ac2e--- /dev/null+++ b/base/app/src/main/res/values/nerd_strings.xml@@ -0,0 +1,54 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- "Stats for nerds": what the player knows of the sound, live while the sheet is open (EN). -->+<resources>+ <string name="nerd_title">Stats for nerds</string>+ <string name="nerd_section_exo">Myspoti player (ExoPlayer)</string>+ <string name="nerd_section_spotify">Spotify (Web Player)</string>+ <string name="nerd_source">Source</string>+ <string name="nerd_source_extension">Extension: %1$s</string>+ <string name="nerd_source_extension_waiting">An extension (not answered yet)</string>+ <string name="nerd_source_download">Download · %1$s</string>+ <string name="nerd_source_file">File on this phone</string>+ <string name="nerd_delivery">Delivery</string>+ <string name="nerd_announced">Announced by the source</string>+ <string name="nerd_codec">Codec</string>+ <string name="nerd_container">Container</string>+ <string name="nerd_sample_rate">Sample rate</string>+ <string name="nerd_bit_depth">Bit depth</string>+ <string name="nerd_bit_depth_announced">%1$d-bit (announced by the source)</string>+ <string name="nerd_bit_depth_float">32-bit float</string>+ <string name="nerd_bit_depth_value">%1$d-bit</string>+ <string name="nerd_channels">Channels</string>+ <string name="nerd_bitrate">Bit rate</string>+ <string name="nerd_bitrate_average">%1$d kbit/s (average, file size over duration)</string>+ <string name="nerd_bitrate_value">%1$d kbit/s</string>+ <string name="nerd_file_size">File size</string>+ <string name="nerd_buffer">Buffer</string>+ <string name="nerd_buffer_value">%1$.1f s ahead</string>+ <string name="nerd_state">Player state</string>+ <string name="nerd_format_unknown">Not known yet</string>+ <string name="nerd_output">Audio output</string>+ <string name="nerd_output_speaker">Phone speaker</string>+ <string name="nerd_output_bluetooth">Bluetooth</string>+ <string name="nerd_output_usb">USB</string>+ <string name="nerd_output_wired">Wired headphones</string>+ <string name="nerd_output_cast">Cast: %1$s</string>+ <string name="nerd_output_named">%1$s · %2$s</string>+ <string name="nerd_output_max_rate">Highest rate of the device</string>+ <string name="nerd_mixer_rate">Android mixer rate</string>+ <string name="nerd_processing">Processing</string>+ <string name="nerd_processing_none">None</string>+ <string name="nerd_crossfade">Crossfade %1$d s</string>+ <string name="nerd_fading">fading between two songs now</string>+ <string name="nerd_device">Device</string>+ <string name="nerd_device_this_phone">This phone</string>+ <string name="nerd_requested">Requested from the page</string>+ <string name="nerd_page_reports">Announced by the page</string>+ <string name="nerd_page_reports_none">Nothing reported yet</string>+ <string name="nerd_mirror">Spotify mirror</string>+ <string name="nerd_mirror_on">On: Spotify plays this song unheard at its lowest quality, so it counts it and Connect sees it</string>+ <string name="nerd_mirror_extension">On, kept by %1$s: Spotify plays unheard</string>+ <string name="nerd_mirror_off">Off</string>+ <string name="nerd_spotify_note">The Spotify stream is encrypted inside the page: its exact codec and bit rate are not accessible, only what the page announces.</string>+ <string name="nerd_spotify_remote">The sound comes from another device: this phone only commands it.</string>+</resources>