android: the player drops its unused artwork and visualization regions
No Android player turned artwork on, and Visualization had only NONE, so the capability flags, the Artwork and Visualization composables and NowPlaying.artworkUri go. ADR 0046 and the design doc note that Android no longer carries them; the desktop keeps both. (F4f) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fecc759717
commit
fc5ed4720f
3 files changed
+14
-87
No files matched your search
@@ -1,17 +1,13 @@
|
||||
package com.gregshuflin.synchronicity.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.MusicNote
|
||||
import androidx.compose.material.icons.filled.Pause
|
||||
import androidx.compose.material.icons.filled.PlayArrow
|
||||
import androidx.compose.material.icons.filled.Replay
|
||||
@@ -30,15 +26,12 @@ 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.draw.scale
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
|
||||
/**
|
||||
* The mobile audio player: one widget shared by Music and Podcasts, laid out and configured per
|
||||
@@ -48,13 +41,9 @@ import coil.compose.AsyncImage
|
||||
* that a player's landmarks stay put as its optional parts come and go, so this is written as named
|
||||
* regions stacked in a column and the capabilities only decide what goes *inside* one:
|
||||
* ```text
|
||||
* Artwork <- optional
|
||||
*
|
||||
* Primary metadata <- centered
|
||||
* Secondary metadata
|
||||
*
|
||||
* Optional visualization <- collapses to nothing when absent
|
||||
*
|
||||
* ━━━━━━━━━━●━━━━━━━━━━
|
||||
* elapsed remaining
|
||||
*
|
||||
@@ -64,9 +53,9 @@ import coil.compose.AsyncImage
|
||||
* ```
|
||||
*
|
||||
* **Configuration is capabilities, not modes.** There is no "music mode" and no "podcast mode": a
|
||||
* screen hands over a [PlayerCapabilities] saying whether it has artwork, what its primary
|
||||
* back/forward do, whether the timeline counts down, and passes whatever secondary controls it
|
||||
* offers as a slot. Music and Podcasts differ only in the value they pass — see ADR 0046.
|
||||
* screen hands over a [PlayerCapabilities] saying what its primary back/forward do, whether the
|
||||
* timeline counts down, and passes whatever secondary controls it offers as a slot. Music and
|
||||
* Podcasts differ only in the value they pass — see ADR 0046.
|
||||
*
|
||||
* **What differs from the desktop, and why.** The desktop's `player_controls.rs` puts the elapsed
|
||||
* and trailing times either side of the scrubber and anchors the transport to the left of a wide
|
||||
@@ -111,11 +100,7 @@ fun PlayerControls(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(REGION_GAP),
|
||||
) {
|
||||
if (capabilities.artwork) {
|
||||
Artwork(track?.artworkUri)
|
||||
}
|
||||
Metadata(track = track, isLoading = transport.isLoading)
|
||||
Visualization(capabilities.visualization)
|
||||
Timeline(
|
||||
transport = transport,
|
||||
trailingTime = capabilities.trailingTime,
|
||||
@@ -147,11 +132,6 @@ private val REGION_GAP = 8.dp
|
||||
private val METADATA_LINE_GAP = 2.dp
|
||||
private val PLAYER_PADDING = 16.dp
|
||||
|
||||
/** Cover art, when the player has it. Square, and the same size with or without an image. */
|
||||
private val ARTWORK_SIZE = 160.dp
|
||||
private val ARTWORK_CORNER = 4.dp
|
||||
private val ARTWORK_GLYPH_SIZE = 48.dp
|
||||
|
||||
/**
|
||||
* Play/pause against the buttons flanking it. Both are well past the 48dp minimum touch target:
|
||||
* "keep transport controls large and thumb-friendly", and this is the one control a user hits
|
||||
@@ -168,19 +148,6 @@ private val TRANSPORT_GAP = 12.dp
|
||||
/** How long the seek must settle before it is committed, so touch events don't fight it. */
|
||||
private const val SCRUB_COMMIT_DELAY_MS = 50L
|
||||
|
||||
/**
|
||||
* The optional visualization above the timeline — a spectrum analyzer, a waveform, chapter
|
||||
* segments. Nothing implements one yet; the variant list is the point, and so is the fact that the
|
||||
* region collapses to nothing without moving anything below it.
|
||||
*
|
||||
* Adding a real visualization touches this enum and the `Visualization` composable and nothing else
|
||||
* — in particular not the layout, which already reserves the slot's place in the order.
|
||||
*/
|
||||
enum class Visualization {
|
||||
/** No visualization: the region renders nothing and takes no height. */
|
||||
NONE
|
||||
}
|
||||
|
||||
/**
|
||||
* What the trailing time label counts.
|
||||
*
|
||||
@@ -233,10 +200,6 @@ data class Adjacency(val previous: Boolean = false, val next: Boolean = false)
|
||||
* without this widget having to know what they are.
|
||||
*/
|
||||
data class PlayerCapabilities(
|
||||
/** Whether to show cover art above the metadata. */
|
||||
val artwork: Boolean = false,
|
||||
/** The optional region between metadata and timeline. */
|
||||
val visualization: Visualization = Visualization.NONE,
|
||||
/** What the timeline's trailing label counts. */
|
||||
val trailingTime: TrailingTime = TrailingTime.TOTAL,
|
||||
/** The large controls flanking play/pause. */
|
||||
@@ -248,7 +211,6 @@ data class PlayerCapabilities(
|
||||
data class NowPlaying(
|
||||
val title: String,
|
||||
val subtitle: String? = null,
|
||||
val artworkUri: String? = null,
|
||||
/**
|
||||
* Whether the screen has a track either side of this one. Only read by a player whose primary
|
||||
* cluster is [TransportStep.Adjacent]; ignored by one that seeks instead.
|
||||
@@ -264,38 +226,6 @@ data class TransportState(
|
||||
val isLoading: Boolean = false,
|
||||
)
|
||||
|
||||
/**
|
||||
* **Artwork.** Always drawn at the same size whether or not the track has any, so the regions below
|
||||
* it don't jump between a track with a cover and one without.
|
||||
*/
|
||||
@Composable
|
||||
private fun Artwork(uri: String?) {
|
||||
val shape = RoundedCornerShape(ARTWORK_CORNER)
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.size(ARTWORK_SIZE)
|
||||
.clip(shape)
|
||||
.background(MaterialTheme.colorScheme.surfaceContainer),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
if (uri == null) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.MusicNote,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(ARTWORK_GLYPH_SIZE),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
} else {
|
||||
AsyncImage(
|
||||
model = uri,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(ARTWORK_SIZE),
|
||||
contentScale = ContentScale.Crop,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* **Metadata.** Title over subtitle, centered across the whole player — which is to say centered
|
||||
* over the scrubber below it, not over the transport cluster. Both lines truncate rather than wrap,
|
||||
@@ -337,19 +267,6 @@ private fun Metadata(track: NowPlaying?, isLoading: Boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* **Visualization.** The optional region, directly above the timeline and nowhere else. Renders
|
||||
* nothing at all when there is none — not an empty box of reserved height — because the principle
|
||||
* is that the slot appears and disappears without shifting the player's landmarks, and a collapsed
|
||||
* region shifts nothing.
|
||||
*/
|
||||
@Composable
|
||||
private fun Visualization(visualization: Visualization) {
|
||||
when (visualization) {
|
||||
Visualization.NONE -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* **Timeline.** The scrubber across the full width with elapsed and total-or-remaining beneath it.
|
||||
* Identical for every configuration: the only thing a capability changes here is what the trailing
|
||||
|
||||
@@ -141,6 +141,14 @@ straightforward inside rodio's `StretchSource` on the desktop, a custom media3
|
||||
`AudioProcessor` plus a session round-trip on Android, since the ExoPlayer
|
||||
lives in a separate `PlaybackService`. That is its own change.
|
||||
|
||||
**Update, 2026-09-29: Android dropped both unused regions.** Neither Android
|
||||
player ever turned artwork on (each screen's comment says why: the cover is
|
||||
already on screen), and the visualization slot had only `None`, so
|
||||
`PlayerControls.kt` no longer carries either capability. The desktop keeps
|
||||
both, since its music player does show album art. Filling the slot on Android
|
||||
now also means adding the capability and one line to the region stack back —
|
||||
still not a layout change, which was the point.
|
||||
|
||||
## Open: where the desktop's primary transport sits
|
||||
|
||||
The desktop transport is the bottom-left of the action row, as the design
|
||||
|
||||
@@ -5,7 +5,9 @@ The two players are `rust/gui-app/src/components/player_controls.rs` (gpui
|
||||
desktop) and `android/app/src/main/java/com/gregshuflin/synchronicity/ui/PlayerControls.kt`
|
||||
(Compose); each agent's configuration lives with the agent —
|
||||
`music_player()`/`podcast_player()` and `MUSIC_PLAYER`/`PODCAST_PLAYER`. The
|
||||
visualization slot exists and is empty; see the ADR for what filling it costs.
|
||||
desktop's visualization slot exists and is empty; Android's player has no
|
||||
visualization or artwork region, since nothing used them. See the ADR for what
|
||||
filling the slot costs.
|
||||
|
||||
## Goal
|
||||
|
||||
|
||||
Reference in new issue
Block a user