Native Android client for Spotify, built with Jetpack Compose
Kotlin ad-freeadblockandroidjetpack-composekotlinlyricsmusic-playermusic-videomyspotispotifyspotify-adblockerspotify-clientspotify-connectspotui
Tablets, foldables and Samsung DeX: window size classes, a navigation rail in Classic and a side-by-side floating bar in Immersive, more grid columns and centred pages, two-pane players, free orientation and resizable desktop windows, keyboard playback shortcuts and right-click menus
kota-zo1a6da5e883bb
diff --git a/base/app/src/main/AndroidManifest.xml b/base/app/src/main/AndroidManifest.xmlindex 158b7260..dc7ddb54 100644--- a/base/app/src/main/AndroidManifest.xml+++ b/base/app/src/main/AndroidManifest.xml@@ -30,6 +30,9 @@android:supportsRtl="true"android:theme="@style/Theme.Myspoti"android:usesCleartextTraffic="false">+ <!-- Samsung DeX: the app keeps running (and playing) when the window moves to or from DeX. -->+ <meta-data android:name="com.samsung.android.keepalive.density" android:value="true" />+ <meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true" /><!-- Cover art for Android Auto (content:// only); Spotify image CDN hosts only. --><providerandroid:name="com.music.spotui.di.ArtworkProvider"@@ -80,10 +83,16 @@android:exported="true"android:launchMode="singleTask"android:screenOrientation="unspecified"+ android:resizeableActivity="true"android:supportsPictureInPicture="true"- android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboardHidden"+ android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboardHidden|keyboard|navigation|density"android:windowSoftInputMode="adjustResize"android:theme="@style/Theme.Myspoti">+ <!-- Desktop windows (Samsung DeX, freeform): opens in a landscape window, resizable. -->+ <layout+ android:defaultWidth="1100dp"+ android:defaultHeight="760dp"+ android:gravity="center" /><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" />diff --git a/base/app/src/main/java/app/myspoti/MainActivity.kt b/base/app/src/main/java/app/myspoti/MainActivity.ktindex 9c9dc878..4237d0f8 100644--- a/base/app/src/main/java/app/myspoti/MainActivity.kt+++ b/base/app/src/main/java/app/myspoti/MainActivity.kt@@ -75,17 +75,19 @@ class MainActivity : AppCompatActivity() {// above their gradient on 14 and older.androidx.core.view.WindowCompat.setDecorFitsSystemWindows(window, false)// The user's rotation choice (portrait by default); changes are applied from the UI below.- requestedOrientation = com.music.spotui.data.preferences.OrientationPref.requested()+ requestedOrientation = orientationFor(resources.configuration)signedIn = prefs.getBoolean("LoggedIn", false)setupNeeded = com.music.spotui.ui.screens.Setup.needed(this)lookOffered = com.music.spotui.data.preferences.LookPref.isOffered(this)root = FrameLayout(this)val compose = ComposeView(this).apply {setContent {- SpotuiTheme { com.music.spotui.ui.look.ProvideLook {+ SpotuiTheme { com.music.spotui.ui.look.ProvideLook { com.music.spotui.ui.components.ProvideWindowSize {val orientation = com.music.spotui.data.preferences.OrientationPref.mode- androidx.compose.runtime.LaunchedEffect(orientation) {- requestedOrientation = com.music.spotui.data.preferences.OrientationPref.requested()+ // Re-checked when the window changes (unfolded, moved to DeX, split screen).+ val config = androidx.compose.ui.platform.LocalConfiguration.current+ androidx.compose.runtime.LaunchedEffect(orientation, config.smallestScreenWidthDp, config.screenLayout) {+ requestedOrientation = orientationFor(config)}androidx.compose.foundation.layout.Box(androidx.compose.ui.Modifier.fillMaxSize()) {when {@@ -138,7 +140,7 @@ class MainActivity : AppCompatActivity() {// so coming back finds the same screen).if (inPip) com.music.spotui.ui.components.PipVideo()}- } }+ } } }}}root.addView(compose, ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))@@ -161,6 +163,62 @@ class MainActivity : AppCompatActivity() {if (savedInstanceState == null) handle(intent)}+ /**+ * The rotation setting applies to phones only: tablets, unfolded foldables, split screen and+ * Samsung DeX windows follow the window (a forced portrait there letterboxes or rotates a+ * desktop window).+ */+ private fun orientationFor(config: android.content.res.Configuration): Int {+ val large = config.smallestScreenWidthDp >= 600 || isInMultiWindowMode || isDesktopMode(config)+ return if (large) android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED+ else com.music.spotui.data.preferences.OrientationPref.requested()+ }++ /** Samsung DeX (its own Configuration field), or a desktop-class window (Android 16 desktop windowing). */+ private fun isDesktopMode(config: android.content.res.Configuration): Boolean {+ val dex = runCatching {+ val c = config.javaClass+ c.getField("SEM_DESKTOP_MODE_ENABLED").getInt(c) == c.getField("semDesktopModeEnabled").getInt(config)+ }.getOrDefault(false)+ return dex || (config.uiMode and android.content.res.Configuration.UI_MODE_TYPE_MASK) == android.content.res.Configuration.UI_MODE_TYPE_DESK+ }++ /**+ * Keyboard shortcuts with a keyboard attached (DeX, tablets): keys the pages leave unused+ * (a text field takes its own space, a focused button its own Enter). Space plays or pauses,+ * media keys drive the player, Ctrl + arrows (and plain arrows nothing else took) seek 10 s.+ */+ override fun onKeyDown(keyCode: Int, event: android.view.KeyEvent): Boolean {+ if (signedIn && !inPip && handleShortcut(keyCode, event)) return true+ return super.onKeyDown(keyCode, event)+ }++ // Ctrl + arrows before the pages: plain arrows move the keyboard focus there.+ override fun dispatchKeyEvent(event: android.view.KeyEvent): Boolean {+ if (event.action == android.view.KeyEvent.ACTION_DOWN && event.isCtrlPressed && signedIn && !inPip &&+ (event.keyCode == android.view.KeyEvent.KEYCODE_DPAD_LEFT || event.keyCode == android.view.KeyEvent.KEYCODE_DPAD_RIGHT)+ && handleShortcut(event.keyCode, event)) return true+ return super.dispatchKeyEvent(event)+ }++ private fun handleShortcut(keyCode: Int, event: android.view.KeyEvent): Boolean {+ val player = com.music.spotui.di.SongPlayer+ if (com.music.spotui.di.Graph.currentSongState.title.value.isBlank()) return false+ when (keyCode) {+ android.view.KeyEvent.KEYCODE_SPACE, android.view.KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> {+ if (event.repeatCount == 0) { if (player.isPlaying()) player.pause(by = "keyboard") else player.play(by = "keyboard") }+ }+ android.view.KeyEvent.KEYCODE_MEDIA_PLAY -> if (event.repeatCount == 0) player.play(by = "keyboard")+ android.view.KeyEvent.KEYCODE_MEDIA_PAUSE -> if (event.repeatCount == 0) player.pause(by = "keyboard")+ android.view.KeyEvent.KEYCODE_MEDIA_NEXT -> if (event.repeatCount == 0) player.next(by = "keyboard")+ android.view.KeyEvent.KEYCODE_MEDIA_PREVIOUS -> if (event.repeatCount == 0) player.previous(by = "keyboard")+ android.view.KeyEvent.KEYCODE_DPAD_LEFT -> player.skipBy(-10_000L)+ android.view.KeyEvent.KEYCODE_DPAD_RIGHT -> player.skipBy(10_000L)+ else -> return false+ }+ return true+ }+// Leaving the app (Home, recents) while a music video plays: it goes on in a small window.override fun onUserLeaveHint() {super.onUserLeaveHint()diff --git a/base/app/src/main/java/com/music/spotui/App.kt b/base/app/src/main/java/com/music/spotui/App.ktindex 2094ad1c..efc225e8 100644--- a/base/app/src/main/java/com/music/spotui/App.kt+++ b/base/app/src/main/java/com/music/spotui/App.kt@@ -125,9 +125,16 @@ fun App() {com.music.spotui.ui.immersive.shell.LocalImmersiveFrostPage provides if (frostPage) glassPage else null,com.music.spotui.ui.immersive.shell.LocalImmersiveChrome provides if (immersive) chrome else null,) {+ // Large windows (tablets, foldables, DeX): Classic's tabs in a rail at the side, the+ // Immersive tab bar on the left edge (ImmersiveBottomChrome); phones keep the bottom bars.+ val large = com.music.spotui.ui.components.windowSize().largeandroidx.compose.foundation.layout.Box(Modifier.fillMaxSize()) {+ androidx.compose.foundation.layout.Row(Modifier.fillMaxSize()) {+ // Before the Scaffold, in a group of its own: the nav host keeps its place when the+ // window grows or shrinks past the threshold (back stack and pages kept).+ if (large && !immersive) com.music.spotui.ui.navigation.MainNavigationRail(navController)Scaffold(- modifier = Modifier,+ modifier = Modifier.weight(1f),bottomBar = {if (!immersive) MainBottomNavigation(navController = navController, bottomBarState = bottomBarState, bottomBarPlayerState)}@@ -139,6 +146,7 @@ fun App() {modifier = if (immersive) Modifier.background(com.music.spotui.ui.immersive.Immersive.Page) else Modifier,)}+ }if (immersive) ImmersiveShell(navController)// Over the pages and the bottom bar: pulling it down shows them, already in place.else com.music.spotui.ui.navigation.PlayerOverlay(navController)diff --git a/base/app/src/main/java/com/music/spotui/ui/components/WindowSize.kt b/base/app/src/main/java/com/music/spotui/ui/components/WindowSize.ktnew file mode 100644index 00000000..acd1d40b--- /dev/null+++ b/base/app/src/main/java/com/music/spotui/ui/components/WindowSize.kt@@ -0,0 +1,121 @@+package com.music.spotui.ui.components++import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.widthIn+import androidx.compose.foundation.layout.wrapContentWidth+import androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProvider+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberUpdatedState+import androidx.compose.runtime.staticCompositionLocalOf+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.composed+import androidx.compose.ui.input.pointer.PointerEventPass+import androidx.compose.ui.input.pointer.PointerEventType+import androidx.compose.ui.input.pointer.isSecondaryPressed+import androidx.compose.ui.input.pointer.pointerInput+import androidx.compose.ui.platform.LocalConfiguration+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp++/** Material's window width classes: under 600 dp, 600 to 839 dp, 840 dp and wider. */+enum class WidthClass { COMPACT, MEDIUM, EXPANDED }++/** Material's window height classes: under 480 dp, 480 to 899 dp, 900 dp and taller. */+enum class HeightClass { COMPACT, MEDIUM, EXPANDED }++/**+ * The app window's size (tablets, foldables, split screen, Samsung DeX windows of any shape).+ * Read from the configuration, which the activity keeps live across resizes (no restart, see+ * configChanges in the manifest), so every layout below follows a window being dragged.+ */+@Immutable+data class WindowSize(val widthDp: Int, val heightDp: Int) {+ val width: WidthClass = when {+ widthDp < 600 -> WidthClass.COMPACT+ widthDp < 840 -> WidthClass.MEDIUM+ else -> WidthClass.EXPANDED+ }+ val height: HeightClass = when {+ heightDp < 480 -> HeightClass.COMPACT+ heightDp < 900 -> HeightClass.MEDIUM+ else -> HeightClass.EXPANDED+ }++ /**+ * A large window: tablets, unfolded foldables, desktop windows. Phones are never large, in+ * either orientation (a phone on its side is wide but compact in height), so they keep+ * their own layouts exactly.+ */+ val large: Boolean get() = width != WidthClass.COMPACT && height != HeightClass.COMPACT++ /** Large and 840 dp or wider: room for columns side by side. */+ val expanded: Boolean get() = large && width == WidthClass.EXPANDED++ /** Large and wider than tall, or a large portrait tablet: the players lay out in two panes. */+ val twoPane: Boolean get() = large && (widthDp > heightDp || width == WidthClass.EXPANDED)++ /** Grid columns for a phone layout that had [phone] columns, spread to cells of about [cell]. */+ fun columns(phone: Int, cell: Dp = 180.dp): Int =+ if (!large) phone else (widthDp / cell.value).toInt().coerceIn(phone, phone * 4)++ companion object {+ /** The widest a content column (rows, track lists, settings) grows on a large window. */+ val MaxContentWidth = 960.dp+ /** The widest a detail page (album, playlist, artist, settings) grows, centred. */+ val MaxPageWidth = 1040.dp+ /** The widest a sheet grows on a large window, centred. */+ val MaxSheetWidth = 640.dp+ /** The widest the mini player grows on a large window. */+ val MaxMiniPlayerWidth = 720.dp+ }+}++private val LocalWindowSize = staticCompositionLocalOf<WindowSize?> { null }++/** The window's size classes; computed once by [ProvideWindowSize], or here when outside it. */+@Composable+fun windowSize(): WindowSize = LocalWindowSize.current ?: configurationWindowSize()++@Composable+private fun configurationWindowSize(): WindowSize {+ val c = LocalConfiguration.current+ return remember(c.screenWidthDp, c.screenHeightDp) { WindowSize(c.screenWidthDp, c.screenHeightDp) }+}++/** Computes the window's size classes once for everything inside (the activity's content). */+@Composable+fun ProvideWindowSize(content: @Composable () -> Unit) {+ CompositionLocalProvider(LocalWindowSize provides configurationWindowSize(), content = content)+}++/**+ * Large windows: caps the content at [max] and centres it, so rows are not stretched across a+ * desktop window. Phones: unchanged.+ */+fun Modifier.maxContentWidth(max: Dp = WindowSize.MaxContentWidth): Modifier = composed {+ if (!windowSize().large) this+ else this.fillMaxWidth().wrapContentWidth(Alignment.CenterHorizontally).widthIn(max = max)+}++/**+ * A mouse's right button (Samsung DeX, a tablet with a mouse) does what a long press does:+ * opens the same menu. Consumes the press so the row's own click does not fire too.+ */+fun Modifier.secondaryClick(action: (() -> Unit)?): Modifier = if (action == null) this else composed {+ val latest by rememberUpdatedState(action)+ pointerInput(Unit) {+ awaitPointerEventScope {+ while (true) {+ val e = awaitPointerEvent(PointerEventPass.Initial)+ if (e.type == PointerEventType.Press && e.buttons.isSecondaryPressed) {+ e.changes.forEach { it.consume() }+ latest()+ }+ }+ }+ }+}diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveClickable.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveClickable.ktindex 33610dd6..4326c1c9 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveClickable.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveClickable.kt@@ -5,6 +5,7 @@*/package com.music.spotui.ui.immersive.components+import com.music.spotui.ui.components.secondaryClickimport androidx.compose.animation.core.animateFloatAsStateimport androidx.compose.animation.core.springimport androidx.compose.foundation.ExperimentalFoundationApi@@ -45,6 +46,8 @@ fun Modifier.immersiveClickable(scaleX = scalescaleY = scale}+ // A mouse's right click opens the same menu as the long press (DeX, tablets).+ .secondaryClick(if (enabled) onLongClick else null).combinedClickable(interactionSource = interaction,indication = null,diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveRows.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveRows.ktindex 55f3ac86..72d71dd4 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveRows.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveRows.kt@@ -4,6 +4,7 @@*/package com.music.spotui.ui.immersive.components+import com.music.spotui.ui.components.secondaryClickimport androidx.compose.animation.animateColorAsStateimport androidx.compose.foundation.ExperimentalFoundationApiimport androidx.compose.foundation.clickable@@ -201,6 +202,8 @@ private fun RowScaffold(Row(modifier = modifier.fillMaxWidth()+ // A mouse's right click opens the same menu as the long press (DeX, tablets).+ .secondaryClick(onLongClick).combinedClickable(role = Role.Button,onClick = onClick,diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.ktindex 0919b7db..1371bd48 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt@@ -11,6 +11,7 @@*/package com.music.spotui.ui.immersive.lyrics+import com.music.spotui.ui.components.secondaryClickimport android.os.Buildimport androidx.compose.animation.animateColorAsStateimport androidx.compose.animation.core.LinearEasing@@ -580,6 +581,7 @@ private fun PanelRow(pathEffect = PathEffect.dashPathEffect(floatArrayOf(0.1f, 5.dp.toPx())),)} else Modifier)+ .secondaryClick(onHold).combinedClickable(enabled = synced || onHold != null, interactionSource = interaction, indication = null,onLongClick = onHold,diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveDiscoverScreens.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveDiscoverScreens.ktindex 1c2ceadb..2774853f 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveDiscoverScreens.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveDiscoverScreens.kt@@ -82,6 +82,8 @@ fun ImmersiveNewReleasesScreen(navController: NavController) {Graph.api.newReleases().map { ReleaseTile(it.spotifyId, it.name, it.artists, it.coverUri, it.artists) }}.getOrDefault(emptyList())}+ // Large windows: more releases per row (two on phones).+ val cols = com.music.spotui.ui.components.windowSize().columns(2, 220.dp)ImmersivePage(title = stringResource(R.string.browse_new_releases), onBack = { navController.popBackStack() }) {fun section(key: String, title: Int, list: List<ReleaseTile>?) {item(key = "$key:header") { SectionHeader(stringResource(title)) }@@ -90,7 +92,7 @@ fun ImmersiveNewReleasesScreen(navController: NavController) {list.isEmpty() -> item(key = "$key:empty") {Text(stringResource(R.string.nothing_here), style = Immersive.Subhead, modifier = Modifier.padding(horizontal = Immersive.Gutter, vertical = 4.dp))}- else -> items(list.chunked(2), key = { row -> "$key:" + row.first().id }) { pair ->+ else -> items(list.chunked(cols), key = { row -> "$key:" + row.first().id }) { pair ->Row(horizontalArrangement = Arrangement.spacedBy(14.dp),modifier = Modifier.fillMaxWidth().padding(horizontal = Immersive.Gutter).padding(bottom = 18.dp),@@ -102,7 +104,7 @@ fun ImmersiveNewReleasesScreen(navController: NavController) {modifier = Modifier.weight(1f),)}- if (pair.size == 1) Spacer(Modifier.weight(1f))+ repeat(cols - pair.size) { Spacer(Modifier.weight(1f)) }}}}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 d6baa27c..f292a0fd 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@@ -232,8 +232,12 @@ fun ImmersivePlayer(BackHandler(enabled = panel != Panel.NONE) { panel = Panel.NONE }BoxWithConstraints(modifier.fillMaxSize().background(Color.Black)) {- // Wider than tall (a phone on its side, a tablet): the cover beside the controls.- val landscape = maxWidth > maxHeight+ // Wider than tall (a phone on its side, a tablet), or a large portrait tablet: the cover+ // beside the controls. Very wide windows (DeX, large tablets): the lyrics and the queue+ // open in a third pane instead of over the cover.+ val window = com.music.spotui.ui.components.windowSize()+ val landscape = maxWidth > maxHeight || window.twoPane+ val sidePane = window.large && maxWidth >= SIDE_PANE_MIN_WIDTHPlayerBackdrop(palette, outgoingPalette, blend, state.coverUrl)CompositionLocalProvider(LocalPlayerTint provides tint) {if (landscape) LandscapePlayer(@@ -248,6 +252,7 @@ fun ImmersivePlayer(onOpenDevices = { showDevices = true },onMore = if (navController != null && state.song != null) ({ showMenu = true }) else null,onSource = { showQuality = true },+ sidePane = sidePane,) else Column(Modifier.fillMaxSize().statusBarsPadding().navigationBarsPadding()) {// The handle: always hands its drags to the sheet.Box(@@ -590,6 +595,7 @@ private fun LandscapePlayer(onOpenDevices: () -> Unit,onMore: (() -> Unit)?,onSource: () -> Unit,+ sidePane: Boolean = false,) {Column(Modifier.fillMaxSize().statusBarsPadding().navigationBarsPadding()) {// The handle: always hands its drags to the sheet.@@ -607,7 +613,8 @@ private fun LandscapePlayer() {BoxWithConstraints(Modifier.weight(1f).fillMaxHeight(), contentAlignment = Alignment.Center) {val side = minOf(maxWidth, maxHeight)- Crossfade(targetState = panel, animationSpec = tween(250), modifier = Modifier.fillMaxSize(), label = "playerLandscapePanel") { shown ->+ // With a side pane the cover stays: the panels open in the third column.+ Crossfade(targetState = if (sidePane) Panel.NONE else panel, animationSpec = tween(250), modifier = Modifier.fillMaxSize(), label = "playerLandscapePanel") { shown ->when (shown) {Panel.LYRICS -> ImmersiveLyricsPanel(Modifier.fillMaxSize(), PaddingValues(vertical = 4.dp))Panel.QUEUE -> ImmersiveQueuePanel(Modifier.fillMaxSize(), PaddingValues(vertical = 4.dp))@@ -657,9 +664,21 @@ private fun LandscapePlayer()}}+ if (sidePane && panel != Panel.NONE) Box(Modifier.weight(1.1f).fillMaxHeight()) {+ Crossfade(targetState = panel, animationSpec = tween(250), modifier = Modifier.fillMaxSize(), label = "playerSidePane") { shown ->+ when (shown) {+ Panel.LYRICS -> ImmersiveLyricsPanel(Modifier.fillMaxSize(), PaddingValues(vertical = 4.dp))+ Panel.QUEUE -> ImmersiveQueuePanel(Modifier.fillMaxSize(), PaddingValues(vertical = 4.dp))+ else -> Box(Modifier.fillMaxSize())+ }+ }+ }}}}+/** A window at least this wide shows the lyrics and the queue beside the cover and the controls. */+private val SIDE_PANE_MIN_WIDTH = 1100.dp+/** The right-hand column needs about this much height to show the volume bar as well. */private val LANDSCAPE_VOLUME_MIN_HEIGHT = 400.dpdiff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePodcastPlayer.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePodcastPlayer.ktindex 08fb609d..8bb8be0d 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePodcastPlayer.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePodcastPlayer.kt@@ -272,7 +272,7 @@ fun ImmersivePodcastPlayer(navController: NavController) {BoxWithConstraints(Modifier.fillMaxSize().background(Color.Black)) {// Wider than tall (a phone on its side, a tablet): the cover beside the controls.- val landscape = maxWidth > maxHeight+ val landscape = maxWidth > maxHeight || com.music.spotui.ui.components.windowSize().twoPaneMeshGradientBackground(palette = palette, trackKey = state.coverUrl)CompositionLocalProvider(LocalPlayerTint provides tint) {if (landscape) Column(Modifier.fillMaxSize().statusBarsPadding().navigationBarsPadding()) {diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveCategoryScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveCategoryScreen.ktindex dac2f03a..7486a47c 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveCategoryScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveCategoryScreen.kt@@ -59,7 +59,7 @@ fun ImmersiveCategoryScreen(navController: NavController, genre: String, title:Box(Modifier.fillMaxSize().background(Immersive.Page)) {LazyVerticalGrid(state = gridState,- columns = GridCells.Fixed(2),+ columns = GridCells.Fixed(com.music.spotui.ui.components.windowSize().columns(2, 200.dp)),contentPadding = PaddingValues(start = Immersive.Gutter, end = Immersive.Gutter,top = immersiveTopContentPadding(), bottom = Immersive.BottomChrome,diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.ktindex 46a188c6..8446e2fd 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt@@ -337,7 +337,9 @@ private fun ShortcutGrid(navController: NavController, items: List<HomeItem>, plmodifier = Modifier.padding(horizontal = Immersive.Gutter).padding(bottom = 22.dp),verticalArrangement = Arrangement.spacedBy(10.dp),) {- items.chunked(2).forEach { rowItems ->+ // Large windows: more tiles per row (two on phones).+ val cols = com.music.spotui.ui.components.windowSize().columns(2, 280.dp)+ items.chunked(cols).forEach { rowItems ->Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth()) {rowItems.forEach { item ->val playing = item.isPlayingIn(playingContext.value)@@ -370,7 +372,7 @@ private fun ShortcutGrid(navController: NavController, items: List<HomeItem>, pl)}}- if (rowItems.size == 1) Box(Modifier.weight(1f))+ repeat(cols - rowItems.size) { Box(Modifier.weight(1f)) }}}}diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveLibraryScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveLibraryScreen.ktindex 80a0e115..d5206602 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveLibraryScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveLibraryScreen.kt@@ -743,7 +743,7 @@ private fun LibraryGrid(LazyVerticalGrid(state = gridState,- columns = GridCells.Fixed(3),+ columns = GridCells.Fixed(com.music.spotui.ui.components.windowSize().columns(3, 170.dp)),modifier = Modifier.fillMaxSize().immersiveHazeSource().immersiveChromeScroll(),contentPadding = PaddingValues(start = Immersive.Gutter, end = Immersive.Gutter,diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveSearchScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveSearchScreen.ktindex f4ac470a..ca8c931c 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveSearchScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveSearchScreen.kt@@ -169,6 +169,8 @@ fun ImmersiveSearchScreen(navController: NavController) {vm.updateSongState(song.coverUri, song.title, song.singer, true, song.id, 0, song.album)}+ // Large windows: more browse tiles per row (two on phones).+ val browseCols = com.music.spotui.ui.components.windowSize().columns(2, 220.dp)Box(Modifier.fillMaxSize().background(Immersive.Page)) {LazyColumn(state = listState,@@ -221,8 +223,8 @@ fun ImmersiveSearchScreen(navController: NavController) {)} else {item(key = "search:browse-header") { SectionHeader(stringResource(R.string.browse_all)) }- items(tiles.chunked(2), key = { row -> "browse:" + row.first().key }) { row ->- BrowseTileRow(row = row, columns = 2) { tile ->+ items(tiles.chunked(browseCols), key = { row -> "browse:" + row.first().key }) { row ->+ BrowseTileRow(row = row, columns = browseCols) { tile ->// A genre opens a catalogue (a page of curated playlists), not a keyword search.if (tile.key == ImmersiveNewReleasesGenre) navController.navigate(Routes.NewReleases.route)else navController.navigate(categoryRoute(tile.key, tile.title))diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/shell/ImmersiveChrome.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/shell/ImmersiveChrome.ktindex d9cbb7cd..4c1e15d9 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/shell/ImmersiveChrome.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/shell/ImmersiveChrome.kt@@ -146,6 +146,8 @@ private val CHROME_GAP = 8.dp/** The mini player's margin to the screen edges; the tab bar sits [TAB_INSET] further in. */private val MINI_MARGIN = 14.dp+/** Large windows: the mini player beside the tab bar, never wider than this. */+private val LargeMiniPlayerWidth = 560.dpprivate val TAB_INSET = Immersive.Gutter - MINI_MARGIN/**@@ -163,6 +165,26 @@ fun ImmersiveBottomChrome() {val tabs = rememberTabNavigation(navController)if (tabs.fullScreen) return+ // Large windows (tablets, foldables, DeX): the tab bar and the mini player side by side in one+ // floating row, centred, each at its own capped width; there is room, so it never folds.+ if (com.music.spotui.ui.components.windowSize().large) {+ Box(+ modifier.fillMaxWidth().windowInsetsPadding(ImmersiveBarInsets)+ .padding(horizontal = MINI_MARGIN).padding(bottom = 2.dp),+ contentAlignment = Alignment.BottomCenter,+ ) {+ androidx.compose.foundation.layout.Row(+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(CHROME_GAP),+ ) {+ Box(Modifier.widthIn(max = ImmersiveBarMaxWidth)) {+ TabBarContent(selectedTab = tabs.selectedTab, onTabClick = tabs.onTabClick, modifier = Modifier)+ }+ Box(Modifier.weight(1f, fill = false).widthIn(max = LargeMiniPlayerWidth)) { miniPlayer(Modifier) }+ }+ }+ return+ }val chrome = LocalImmersiveChrome.currentval reduceMotion = rememberReduceMotion()val minimized = chrome?.minimized == truediff --git a/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt b/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.ktindex 996c9da9..69bd3fd9 100644--- a/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt+++ b/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt@@ -51,6 +51,9 @@ import kotlinx.coroutines.flow.Flowimport kotlinx.coroutines.flow.emptyFlowimport androidx.compose.foundation.layout.navigationBarsPadding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.layout.widthIn+import androidx.compose.foundation.layout.statusBarsPadding/*** What re-tapping the tab you are already on does in the official app: Home and Library@@ -96,11 +99,6 @@ class NoRippleInteractionSource : MutableInteractionSource {@Composablefun MainBottomNavigation(navController: NavHostController, bottomBarState: MutableState<Boolean>, bottomBarPlayerState : MutableState<Boolean>) {- val navItems = listOf(- Routes.Home,- Routes.Search,- Routes.Library- )// Visibility follows the screen actually shown (not flags each screen sets,// which raced during transitions and left the mini player over the full one).val shownRoute = navController.currentBackStackEntryAsState().value?.destination?.route@@ -138,19 +136,21 @@ fun MainBottomNavigation(navController: NavHostController, bottomBarState: Mutabenter = slideInVertically(initialOffsetY = { it }),exit = slideOutVertically(targetOffsetY = { it }),content = {- MiniPlayer(navController)+ // Large windows: a capped, centred capsule, not a bar across a desktop window.+ Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {+ Box(if (com.music.spotui.ui.components.windowSize().large) Modifier.widthIn(max = com.music.spotui.ui.components.WindowSize.MaxMiniPlayerWidth) else Modifier) {+ MiniPlayer(navController)+ }+ }})Spacer(modifier = Modifier.height(4.dp))- val navStack by navController.currentBackStackEntryAsState()- val currentRoute = navStack?.destination?.route- // The tab the user is in, even on one of its sub-pages (album, artist…).- var selectedTab by androidx.compose.runtime.saveable.rememberSaveable { androidx.compose.runtime.mutableStateOf(Routes.Home.route) }- if (currentRoute in navItems.map { it.route }) selectedTab = currentRoute!!-+ val tabs = rememberTabNavigation(navController)+ // Large windows: the tabs are in the rail at the side (MainNavigationRail).+ if (!com.music.spotui.ui.components.windowSize().large) {// Official bar proportions: a 58 dp strip (the gesture inset is added by// navigationBarsPadding above), three equal thirds edge to edge, so the// tabs spread over the full width instead of clustering in the middle.@@ -160,37 +160,16 @@ fun MainBottomNavigation(navController: NavHostController, bottomBarState: Mutab.height(NavBarHeight),verticalAlignment = Alignment.CenterVertically,) {- navItems.forEach { item ->+ TabItems.forEach { item ->NavBarTab(iconRes = item.icon,label = if (item.labelRes != 0) stringResource(item.labelRes) else item.label,- selected = selectedTab == item.route,- onClick = {- // Standard bottom-tab navigation: each tab keeps its- // state (no reload, scroll kept) when you come back.- if (item.route == selectedTab) {- if (currentRoute == item.route) {- // Already on the tab's own page: nothing to reload, only- // the re-tap shortcut (scroll to top, or focus search).- TabReselect.emit(item.route)- } else if (!navController.popBackStack(item.route, inclusive = false)) {- // On one of its sub-pages: back to its root page first.- navController.navigate(item.route) { launchSingleTop = true }- }- } else {- selectedTab = item.route- navController.navigate(item.route) {- popUpTo(navController.graph.findStartDestination().id) { saveState = true }- launchSingleTop = true- // Home always opens Home itself (its scroll kept), not the- // page last left open from it (a playlist, an artist…).- restoreState = item.route != Routes.Home.route- }- }- },+ selected = tabs.selected == item.route,+ onClick = { tabs.open(item) },)}}+ }@@ -203,6 +182,80 @@ fun MainBottomNavigation(navController: NavHostController, bottomBarState: Mutab)}+private val TabItems = listOf(Routes.Home, Routes.Search, Routes.Library)++/** The tab shown (also on its sub-pages) and what a tap on a tab does; shared by the bar and the rail. */+private class TabNavigation(private val navController: NavHostController, private val state: androidx.compose.runtime.MutableState<String>, private val currentRoute: String?) {+ val selected: String get() = state.value++ fun open(item: Routes) {+ // Standard bottom-tab navigation: each tab keeps its+ // state (no reload, scroll kept) when you come back.+ if (item.route == state.value) {+ if (currentRoute == item.route) {+ // Already on the tab's own page: nothing to reload, only+ // the re-tap shortcut (scroll to top, or focus search).+ TabReselect.emit(item.route)+ } else if (!navController.popBackStack(item.route, inclusive = false)) {+ // On one of its sub-pages: back to its root page first.+ navController.navigate(item.route) { launchSingleTop = true }+ }+ } else {+ state.value = item.route+ navController.navigate(item.route) {+ popUpTo(navController.graph.findStartDestination().id) { saveState = true }+ launchSingleTop = true+ // Home always opens Home itself (its scroll kept), not the+ // page last left open from it (a playlist, an artist…).+ restoreState = item.route != Routes.Home.route+ }+ }+ }+}++@Composable+private fun rememberTabNavigation(navController: NavHostController): TabNavigation {+ val navStack by navController.currentBackStackEntryAsState()+ val currentRoute = navStack?.destination?.route+ // The tab the user is in, even on one of its sub-pages (album, artist…).+ val selectedTab = androidx.compose.runtime.saveable.rememberSaveable { androidx.compose.runtime.mutableStateOf(Routes.Home.route) }+ if (currentRoute in TabItems.map { it.route }) selectedTab.value = currentRoute!!+ return TabNavigation(navController, selectedTab, currentRoute)+}++/**+ * Large windows (tablets, foldables, DeX): the three tabs in a rail down the left side instead+ * of a phone bar stretched across the window. Hidden with the bar on the full-screen routes.+ */+@Composable+fun MainNavigationRail(navController: NavHostController) {+ val shownRoute = navController.currentBackStackEntryAsState().value?.destination?.route+ if (shownRoute == Routes.Player.route || shownRoute == Routes.Queue.route) return+ val tabs = rememberTabNavigation(navController)+ Column(+ modifier = Modifier+ .fillMaxHeight()+ .width(88.dp)+ .background(AppShade)+ .statusBarsPadding()+ .navigationBarsPadding()+ .padding(top = 24.dp),+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(12.dp),+ ) {+ TabItems.forEach { item ->+ Row(Modifier.fillMaxWidth().height(72.dp)) {+ NavBarTab(+ iconRes = item.icon,+ label = if (item.labelRes != 0) stringResource(item.labelRes) else item.label,+ selected = tabs.selected == item.route,+ onClick = { tabs.open(item) },+ )+ }+ }+ }+}+// Official app metrics. Material3's NavigationBarItem measures its icon slot at a// fixed 24 dp, so a 28 dp Icon there was clipped back down: the bar is drawn by hand.private val NavBarHeight = 58.dpdiff --git a/base/app/src/main/java/com/music/spotui/ui/navigation/MyNavHost.kt b/base/app/src/main/java/com/music/spotui/ui/navigation/MyNavHost.ktindex a1249fb7..956d3fbc 100644--- a/base/app/src/main/java/com/music/spotui/ui/navigation/MyNavHost.kt+++ b/base/app/src/main/java/com/music/spotui/ui/navigation/MyNavHost.kt@@ -19,6 +19,11 @@ import androidx.compose.animation.slideOutVerticallyimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxHeight+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.widthIn+import androidx.compose.foundation.layout.wrapContentWidth+import androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.navigation.NamedNavArgumentimport androidx.navigation.NavBackStackEntry@@ -479,13 +484,32 @@ private fun NavGraphBuilder.page(LocalPageSettled provides settled,com.music.spotui.ui.immersive.shell.backdrop.backdrops.LocalBackdropSourceAlpha provides alpha,) {+ // Large windows: detail pages (album, playlist, artist, settings…) keep a readable width,+ // centred, instead of rows 2000 px wide; the tab pages and grids use the whole width+ // (more columns). The inner box is always there, so a resize never rebuilds the page.+ val capped = com.music.spotui.ui.components.windowSize().large &&+ entry.destination.route?.substringBefore('/')?.substringBefore('?') !in FullWidthRoutes// Immersive look: every page (Classic fallbacks too) sits on its black page colour.Box(Modifier.fillMaxSize().then(if (fade == null) Modifier else Modifier.graphicsLayer { this.alpha = fade.value })- .background(if (immersive) com.music.spotui.ui.immersive.Immersive.Page else AppBackground)) { scope.content(entry) }+ .background(if (immersive) com.music.spotui.ui.immersive.Immersive.Page else AppBackground)) {+ Box(+ Modifier.fillMaxHeight().then(+ if (capped) Modifier.fillMaxWidth().wrapContentWidth(Alignment.CenterHorizontally)+ .widthIn(max = com.music.spotui.ui.components.WindowSize.MaxPageWidth)+ else Modifier.fillMaxWidth()+ )+ ) { scope.content(entry) }+ }}}+/** Pages that use a large window's whole width (grids, the tabs' own pages, the player). */+private val FullWidthRoutes = setOf(+ Routes.Home.route, Routes.Search.route, Routes.Library.route, Routes.Player.route, Routes.Queue.route,+ Routes.Category.route, Routes.NewReleases.route,+)+/*** false while this page is sliding in or out. Heavy views (video players, surfaces)* wait for it: built in the first frame, they stalled it and the motion jumped.diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/ArtistScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/ArtistScreen.ktindex 350268c3..de11ab43 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/ArtistScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/ArtistScreen.kt@@ -1,5 +1,6 @@package com.music.spotui.ui.screens+import com.music.spotui.ui.components.secondaryClickimport com.music.spotui.ui.components.widePressableimport com.music.spotui.ui.components.wideClickableimport com.music.spotui.ui.theme.tone@@ -594,6 +595,8 @@ private fun PopularTrackRow(verticalAlignment = Alignment.CenterVertically,modifier = Modifier.fillMaxWidth()+ // A mouse's right click opens the same menu as the long press (DeX, tablets).+ .secondaryClick(onMore).combinedClickable(interactionSource = remember { MutableInteractionSource() },indication = null,diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/CategoryScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/CategoryScreen.ktindex b69dddf2..b9e95a2f 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/CategoryScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/CategoryScreen.kt@@ -110,7 +110,7 @@ private fun CategoryGrid(entries: List<LibraryEntry>, navController: NavControllreturn}LazyVerticalGrid(- columns = GridCells.Fixed(2),+ columns = GridCells.Fixed(com.music.spotui.ui.components.windowSize().columns(2, 200.dp)),contentPadding = PaddingValues(12.dp, 8.dp, 12.dp, com.music.spotui.ui.components.bottomBarsSpace()),horizontalArrangement = Arrangement.spacedBy(12.dp),verticalArrangement = Arrangement.spacedBy(16.dp),diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/DiscoverScreens.kt b/base/app/src/main/java/com/music/spotui/ui/screens/DiscoverScreens.ktindex 256833f2..eee97c84 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/DiscoverScreens.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/DiscoverScreens.kt@@ -125,7 +125,7 @@ fun NewReleasesScreen(navController: NavController) {Column(Modifier.fillMaxSize().background(Background).statusBarsPadding()) {ScreenHeader(stringResource(R.string.browse_new_releases), navController)LazyVerticalGrid(- columns = GridCells.Fixed(2),+ columns = GridCells.Fixed(com.music.spotui.ui.components.windowSize().columns(2, 200.dp)),contentPadding = PaddingValues(12.dp, 0.dp, 12.dp, com.music.spotui.ui.components.bottomBarsSpace()),horizontalArrangement = Arrangement.spacedBy(12.dp),verticalArrangement = Arrangement.spacedBy(16.dp),diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.ktindex d118da14..0fa53fbe 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt@@ -338,8 +338,10 @@ private fun HomePill(label: String, selected: Boolean = false, onClick: () -> Un@OptIn(ExperimentalGlideComposeApi::class)@Composableprivate fun HomeShortcutGrid(navController: NavController, items: List<HomeItem>) {+ // Large windows: more tiles per row (two on phones).+ val cols = com.music.spotui.ui.components.windowSize().columns(2, 280.dp)Column(modifier = Modifier.padding(8.dp, 4.dp)) {- items.chunked(2).forEach { rowItems ->+ items.chunked(cols).forEach { rowItems ->Row(horizontalArrangement = Arrangement.spacedBy(8.dp),modifier = Modifier@@ -376,7 +378,7 @@ private fun HomeShortcutGrid(navController: NavController, items: List<HomeItem>)}}- if (rowItems.size == 1) Spacer(modifier = Modifier.weight(1f))+ repeat(cols - rowItems.size) { Spacer(modifier = Modifier.weight(1f)) }}}}diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/LibraryScreeen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/LibraryScreeen.ktindex cca82b00..75c1ab83 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/LibraryScreeen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/LibraryScreeen.kt@@ -722,7 +722,7 @@ fun LibraryGridScreen(LazyVerticalGrid(state = gridState,- columns = GridCells.Fixed(3),+ columns = GridCells.Fixed(com.music.spotui.ui.components.windowSize().columns(3, 170.dp)),modifier = Modifier.fillMaxSize().padding(padding)diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.ktindex 23c2845f..a09c0271 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt@@ -1,5 +1,6 @@package com.music.spotui.ui.screens+import com.music.spotui.ui.components.secondaryClickimport com.music.spotui.ui.components.pressableimport androidx.compose.ui.res.stringResource@@ -269,7 +270,7 @@ private fun LyricLineText(val lineModifier = modifier.fillMaxWidth().then(- if (onTap != null || onHold != null) Modifier.combinedClickable(+ if (onTap != null || onHold != null) Modifier.secondaryClick(onHold).combinedClickable(interactionSource = remember { MutableInteractionSource() },indication = null,onLongClick = onHold,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 d682d659..6b45d3cb 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@@ -28,6 +28,7 @@ import androidx.compose.foundation.clickableimport androidx.compose.material.icons.outlined.AddCircleOutlineimport androidx.compose.foundation.interaction.MutableInteractionSourceimport androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.ColumnScopeimport androidx.compose.foundation.layout.aspectRatioimport androidx.compose.foundation.layout.widthInimport androidx.compose.foundation.layout.sizeIn@@ -456,16 +457,14 @@ fun PlayerScreen(navController: NavController) {contentAlignment = Alignment.TopCenter,) {val wide = maxWidth > 600.dp && maxWidth > maxHeight- val contentWidth = if (wide) maxWidth.coerceAtMost(520.dp) else maxWidth+ // Large windows wider than tall (tablets, foldables, DeX) and large portrait tablets: the+ // cover on the left, the title and controls on the right, each in a capped half.+ val twoPane = !immersive && com.music.spotui.ui.components.windowSize().twoPane+ val contentWidth = if (twoPane) ((maxWidth - 72.dp) / 2).coerceIn(0.dp, 560.dp)+ else if (wide) maxWidth.coerceAtMost(520.dp) else maxWidth// Immersive: the artwork takes the whole height instead of leaving room for controls.val screenHeight = androidx.compose.ui.platform.LocalConfiguration.current.screenHeightDp.dp- Column(- modifier = Modifier- .fillMaxHeight()- .width(contentWidth)- .navigationBarsPadding(),- horizontalAlignment = Alignment.CenterHorizontally- ) {+ val topBar: @Composable () -> Unit = {// Immersive mode has no top bar: only the artwork and the compact strip remain.if (!immersive) {PlayerTopBar(@@ -477,6 +476,8 @@ fun PlayerScreen(navController: NavController) {// Official: the cover starts closer to the header.Spacer(modifier = Modifier.height(14.dp))}+ }+ val mediaArea: @Composable (Modifier, Alignment) -> Unit = { mediaModifier, mediaAlignment ->// Media area: artwork (swipe to change track) or the music video, with// Spotify's "Passer à la vidéo" pill over it (black, like the official app).// Square, but never taller than what the controls leave (foldables, landscape-ish@@ -488,8 +489,8 @@ fun PlayerScreen(navController: NavController) {// peek, with or without Canvas / clip pill, on short screens too. The art shrinks, the// controls do not; on tall screens the slot's spare height sits under the art.androidx.compose.foundation.layout.BoxWithConstraints(- modifier = if (immersive) Modifier else Modifier.fillMaxWidth().weight(1f),- contentAlignment = Alignment.TopCenter,+ modifier = mediaModifier,+ contentAlignment = mediaAlignment,) {val artSide = if (immersive) screenHeightelse minOf(contentWidth, maxHeight).coerceAtLeast(0.dp)@@ -589,6 +590,8 @@ fun PlayerScreen(navController: NavController) {}}}+ }+ val controls: @Composable ColumnScope.() -> Unit = {// The slot (pill 32dp + 20dp gap) is reserved in every non-immersive layout, Canvas or// not, and before the clip is even known: the title, seek bar and buttons then sit at// the same height on every track, and a skip between the two kinds no longer moves@@ -709,6 +712,33 @@ fun PlayerScreen(navController: NavController) {Spacer(modifier = Modifier.height(12.dp))}}+ if (twoPane) Column(+ modifier = Modifier+ .fillMaxHeight()+ .fillMaxWidth()+ .navigationBarsPadding(),+ horizontalAlignment = Alignment.CenterHorizontally+ ) {+ Box(Modifier.width(contentWidth * 2 + 72.dp)) { Column { topBar() } }+ Row(+ modifier = Modifier.fillMaxWidth().weight(1f),+ horizontalArrangement = Arrangement.spacedBy(72.dp, Alignment.CenterHorizontally),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ mediaArea(Modifier.width(contentWidth).fillMaxHeight(), Alignment.Center)+ Column(Modifier.width(contentWidth), horizontalAlignment = Alignment.CenterHorizontally) { controls() }+ }+ } else Column(+ modifier = Modifier+ .fillMaxHeight()+ .width(contentWidth)+ .navigationBarsPadding(),+ horizontalAlignment = Alignment.CenterHorizontally+ ) {+ topBar()+ mediaArea(if (immersive) Modifier else Modifier.fillMaxWidth().weight(1f), Alignment.TopCenter)+ controls()+ }}}// The lyrics card belongs to the scrolled layout; in immersive mode the list holds thediff --git a/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.ktindex 81f7404c..0b3c94a8 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/SearchScreen.kt@@ -1,5 +1,6 @@package com.music.spotui.ui.screens+import com.music.spotui.ui.components.secondaryClickimport com.music.spotui.ui.theme.toneimport com.music.spotui.ui.theme.AppTextimport com.music.spotui.ui.theme.AppMuted@@ -575,6 +576,8 @@ fun SearchSongRow(modifier = Modifier.fillMaxWidth().padding(16.dp, 8.dp)+ // A mouse's right click opens the same menu as the long press (DeX, tablets).+ .secondaryClick(onLongClick).combinedClickable(interactionSource = remember { MutableInteractionSource() },indication = null,@@ -782,7 +785,9 @@ fun BrowseAllSection(onCategoryClick: (genre: String, title: String) -> Unit) {fontWeight = FontWeight.Bold,modifier = Modifier.padding(16.dp, 12.dp, 16.dp, 8.dp),)- tiles.chunked(2).forEach { rowItems ->+ // Large windows: more tiles per row (two on phones).+ val cols = com.music.spotui.ui.components.windowSize().columns(2, 220.dp)+ tiles.chunked(cols).forEach { rowItems ->Row(modifier = Modifier.fillMaxWidth()@@ -792,8 +797,8 @@ fun BrowseAllSection(onCategoryClick: (genre: String, title: String) -> Unit) {rowItems.forEach { t ->BrowseCategoryTile(t.title, t.color, t.image, Modifier.weight(1f)) { onCategoryClick(t.key, t.title) }}- // Keep a half-width spacer if the last row has a single tile.- if (rowItems.size == 1) Spacer(Modifier.weight(1f))+ // Keep the tiles' width on a last row that is not full.+ repeat(cols - rowItems.size) { Spacer(Modifier.weight(1f)) }}}}