Skip to content

Native Android client for Spotify, built with Jetpack Compose

A What's New page behind a bell on Home lists the new releases and episodes of the artists and shows you follow, newest first under New and Earlier, with play, add to library, and a menu to add to the queue or a playlist

andreiP49dfbdf248873
diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/Mappers.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/Mappers.kt
index 2aa4e5ae..cd52bf36 100644
--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/Mappers.kt
+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/Mappers.kt
@@ -253,5 +253,27 @@ internal fun show(d: JsonElement?): app.myspoti.api.Show? {
)
}
+/**
+ * A row of the What's New feed: `{id, state{state, timestamp{isoString}}, content{__typename, data}}`,
+ * where `data` is an `Album` or an `Episode`. Chapters and the feed's own notifications are
+ * skipped: the Web Player draws nothing for them either.
+ */
+internal fun whatsNewItem(row: JsonElement?): app.myspoti.api.WhatsNewItem? {
+ val id = row.str("id") ?: return null
+ val data = row.obj("content.data")
+ val state = app.myspoti.api.WhatsNewState.entries.firstOrNull { it.name == row.str("state.state") }
+ ?: app.myspoti.api.WhatsNewState.UNKNOWN
+ val at = row.str("state.timestamp.isoString")
+ return when (data.typename()) {
+ // `type` is "ALBUM" for every release here; `albumType` says single, EP or album.
+ "Album" -> album(data)?.let { a ->
+ val type = data.str("albumType")?.takeIf { a.type == "ALBUM" } ?: a.type
+ app.myspoti.api.WhatsNewItem(id, state, at, album = a.copy(type = type))
+ }
+ "Episode" -> episode(data)?.let { app.myspoti.api.WhatsNewItem(id, state, at, episode = it) }
+ else -> null
+ }
+}
+
/** Discography and "appears on" rows hold `releases.items[0]`. */
internal fun release(row: JsonElement?): Album? = album(row.list("releases.items").firstOrNull() ?: row)
diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyMore.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyMore.kt
index 6d64a30f..a8ca4a14 100644
--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyMore.kt
+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyMore.kt
@@ -35,6 +35,8 @@ import app.myspoti.api.TrackExtras
import app.myspoti.api.UserProfile
import app.myspoti.api.UserRef
import app.myspoti.api.Users
+import app.myspoti.api.WhatsNewContent
+import app.myspoti.api.WhatsNewItem
import app.myspoti.api.Uri
import app.myspoti.api.ArtistRef
import app.myspoti.spotify.bridge.Bridge
@@ -124,6 +126,27 @@ class SpotifyHome(private val gql: Gql) : Home {
}
}
+ // The Web Player's own page: 50 entries, the pill as `includedContentTypes` (none: both).
+ override suspend fun whatsNewFeed(offset: Int, limit: Int, content: WhatsNewContent): Page<WhatsNewItem> {
+ val feed = gql.query("queryWhatsNewFeed", vars(
+ "offset" to offset, "limit" to limit, "onlyUnPlayedItems" to false,
+ "includedContentTypes" to when (content) {
+ WhatsNewContent.ALL -> emptyList()
+ WhatsNewContent.MUSIC -> listOf("ALBUM")
+ WhatsNewContent.PODCASTS -> listOf("EPISODE")
+ },
+ "includeEpisodeContentRatingsV2" to true,
+ )).at("data.whatsNewFeedItems")
+ return page(feed, offset, ::whatsNewItem)
+ }
+
+ // `$items` is an input object holding the list (a bare list is refused with 400), as the Web
+ // Player sends it: {items: {items: [{id, state}]}}.
+ override suspend fun markWhatsNewSeen(ids: List<String>) {
+ if (ids.isEmpty()) return
+ gql.query("SetItemsStateInWhatsNewFeed", vars("items" to mapOf("items" to ids.map { mapOf("id" to it, "state" to "SEEN") })))
+ }
+
override suspend fun category(uri: Uri): BrowsePage {
val page = gql.query("browsePage", vars(
"uri" to uri, "pagePagination" to mapOf("offset" to 0, "limit" to 10),
diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/gql/Gql.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/gql/Gql.kt
index 9691500a..68e0a5b2 100644
--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/gql/Gql.kt
+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/gql/Gql.kt
@@ -293,9 +293,12 @@ class SpotifyHttp(
}
}
-/** Operations that change something: not replayed when their outcome is unknown, and any error fails them. */
+/**
+ * Operations that change something: not replayed when their outcome is unknown, and any error fails them.
+ * A few of the Web Player's own are capitalised (`SetItemsStateInWhatsNewFeed`).
+ */
fun isMutation(name: String): Boolean =
- Regex("^(add|remove|move|update|delete|set|create|follow|unfollow|pin|unpin|edit|save|ban|unban|clear)[A-Z]").containsMatchIn(name)
+ Regex("^(add|remove|move|update|delete|set|Set|create|follow|unfollow|pin|unpin|edit|save|ban|unban|clear)[A-Z]").containsMatchIn(name)
/**
* Throws when [response] reports a failure: errors without data for a read, any error or
diff --git a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/WhatsNewTest.kt b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/WhatsNewTest.kt
new file mode 100644
index 00000000..702ca3ea
--- /dev/null
+++ b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/WhatsNewTest.kt
@@ -0,0 +1,107 @@
+package app.myspoti.spotify
+
+import app.myspoti.api.WhatsNewItem
+import app.myspoti.api.WhatsNewState
+import app.myspoti.api.whatsNewSections
+import app.myspoti.spotify.bridge.Bridge
+import app.myspoti.spotify.gql.Gql
+import kotlinx.coroutines.runBlocking
+import kotlinx.serialization.json.JsonObject
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Assertions.assertNotNull
+import org.junit.jupiter.api.Assertions.assertNull
+import org.junit.jupiter.api.Test
+import java.time.Instant
+
+/** The "What's New" feed (`queryWhatsNewFeed`) and the page's New / Earlier split. */
+class WhatsNewTest {
+ private fun json(s: String) = Bridge.json.parseToJsonElement(s)
+
+ // The fields the Web Player's page reads (dwp-whats-new-feed, 2026-11-03), trimmed.
+ private val feed = json("""
+ {"items":[
+ {"id":"n1","state":{"state":"NEW","timestamp":null},
+ "content":{"__typename":"AlbumResponseWrapper","data":{"__typename":"Album","uri":"spotify:album:a1","name":"Single One",
+ "type":"ALBUM","albumType":"SINGLE","date":{"isoString":"2026-11-01T00:00:00Z"},
+ "artists":{"items":[{"uri":"spotify:artist:x","profile":{"name":"Artist X"}}]},
+ "coverArt":{"sources":[{"url":"https://i.scdn.co/image/c1","width":300,"height":300}]}}}},
+ {"id":"s1","state":{"state":"SEEN","timestamp":{"isoString":"2026-10-20T08:00:00Z"}},
+ "content":{"__typename":"EpisodeOrChapterResponseWrapper","data":{"__typename":"Episode","uri":"spotify:episode:e1","name":"Episode One",
+ "description":"About it","duration":{"totalMilliseconds":1800000},"releaseDate":{"isoString":"2026-10-19T05:00:00Z"},
+ "podcastV2":{"data":{"__typename":"Podcast","uri":"spotify:show:p","name":"The Show"}},
+ "playability":{"playable":true}}}},
+ {"id":"c1","state":{"state":"SEEN"},
+ "content":{"__typename":"EpisodeOrChapterResponseWrapper","data":{"__typename":"Chapter","uri":"spotify:episode:ch"}}}
+ ],"totalCount":3}
+ """)
+
+ @Test fun `feed rows map to albums and episodes, chapters dropped`() {
+ val page = page(feed, 0, ::whatsNewItem)
+ assertEquals(listOf("n1", "s1"), page.items.map { it.id })
+
+ val album = page.items[0]
+ assertEquals(WhatsNewState.NEW, album.state)
+ assertNull(album.stateAt)
+ assertEquals("SINGLE", album.album!!.type)
+ assertEquals(listOf("Artist X"), album.album!!.artists.map { it.name })
+ assertEquals("spotify:album:a1", album.uri)
+ assertEquals("2026-11-01T00:00:00Z", album.releaseDate)
+
+ val episode = page.items[1]
+ assertNull(episode.album)
+ assertEquals("The Show", episode.episode!!.show!!.name)
+ assertEquals(1_800_000, episode.episode!!.durationMs)
+ assertEquals("2026-10-20T08:00:00Z", episode.stateAt)
+ // Raw rows count for paging: the dropped chapter still holds its position.
+ assertNull(page.nextOffset)
+ }
+
+ @Test fun `a row without an id or content is skipped`() {
+ assertNull(whatsNewItem(json("""{"state":{"state":"NEW"},"content":{"data":{"__typename":"Album","uri":"spotify:album:a"}}}""")))
+ assertNull(whatsNewItem(json("""{"id":"x","state":{"state":"NEW"},"content":{"data":{"__typename":"NotFound"}}}""")))
+ assertNotNull(whatsNewItem(json("""{"id":"x","state":{"state":"ODD"},"content":{"data":{"__typename":"Album","uri":"spotify:album:a"}}}""")))
+ }
+
+ private val now = Instant.parse("2026-11-03T12:00:00Z").toEpochMilli()
+
+ private fun item(id: String, state: WhatsNewState, stateAt: String? = null, released: String?) = WhatsNewItem(
+ id, state, stateAt,
+ album = app.myspoti.api.Album("spotify:album:$id", id, emptyList(), emptyList(), "SINGLE", released, 1),
+ )
+
+ @Test fun `new is the leading run of unseen or just-seen entries`() {
+ val sections = whatsNewSections(listOf(
+ item("unseen", WhatsNewState.NEW, released = "2026-11-02T00:00:00Z"),
+ // Seen 30 minutes ago: still new, as on the Web Player.
+ item("justSeen", WhatsNewState.SEEN, "2026-11-03T11:30:00Z", released = "2026-11-03T00:00:00Z"),
+ item("old", WhatsNewState.SEEN, "2026-11-01T11:00:00Z", released = "2026-10-30T00:00:00Z"),
+ // After the first older entry everything is earlier, even an unseen one.
+ item("late", WhatsNewState.NEW, released = "2026-10-31T00:00:00Z"),
+ ), now)
+ assertEquals(listOf("justSeen", "unseen"), sections.fresh.map { it.id })
+ assertEquals(listOf("late", "old"), sections.earlier.map { it.id })
+ }
+
+ @Test fun `each section runs newest first, undated entries last`() {
+ val sections = whatsNewSections(listOf(
+ item("b", WhatsNewState.SEEN, "2026-10-01T00:00:00Z", released = "2026-10-02"),
+ item("none", WhatsNewState.SEEN, "2026-10-01T00:00:00Z", released = null),
+ item("c", WhatsNewState.SEEN, "2026-10-01T00:00:00Z", released = "2026-10-05T10:00:00+02:00"),
+ item("a", WhatsNewState.SEEN, "2026-10-01T00:00:00Z", released = "2026-09-30T00:00:00Z"),
+ ), now)
+ assertEquals(emptyList<WhatsNewItem>(), sections.fresh)
+ assertEquals(listOf("c", "b", "a", "none"), sections.earlier.map { it.id })
+ }
+ @Test fun `marking seen sends the list inside the items input object`() = runBlocking {
+ val sent = mutableListOf<Pair<String, JsonObject>>()
+ val gql = object : Gql {
+ override suspend fun query(name: String, variables: JsonObject) =
+ json("""{"data":{"setItemsStateInWhatsNewFeed":{"items":[]}}}""").also { sent += name to variables }
+ }
+ SpotifyHome(gql).markWhatsNewSeen(listOf("music_release:a", "podcast_release:b"))
+ SpotifyHome(gql).markWhatsNewSeen(emptyList())
+ // Shape accepted live (2026-11-03); a bare list answered 400 VALIDATION_INVALID_TYPE_VARIABLE.
+ assertEquals(listOf("SetItemsStateInWhatsNewFeed" to json(
+ """{"items":{"items":[{"id":"music_release:a","state":"SEEN"},{"id":"podcast_release:b","state":"SEEN"}]}}""")), sent)
+ }
+}
diff --git a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/gql/GqlErrorsTest.kt b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/gql/GqlErrorsTest.kt
index 00535630..21ccea0f 100644
--- a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/gql/GqlErrorsTest.kt
+++ b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/gql/GqlErrorsTest.kt
@@ -14,6 +14,7 @@ class GqlErrorsTest {
assertTrue(isMutation("addToPlaylist"))
assertTrue(isMutation("unfollowUsers"))
assertTrue(isMutation("removeRecentSearches"))
+ assertTrue(isMutation("SetItemsStateInWhatsNewFeed"))
assertFalse(isMutation("fetchPlaylist"))
assertFalse(isMutation("searchTracks"))
assertFalse(isMutation("address"))
diff --git a/base/api/src/main/kotlin/app/myspoti/api/Api.kt b/base/api/src/main/kotlin/app/myspoti/api/Api.kt
index 9c4f2f4d..1146031a 100644
--- a/base/api/src/main/kotlin/app/myspoti/api/Api.kt
+++ b/base/api/src/main/kotlin/app/myspoti/api/Api.kt
@@ -222,6 +222,13 @@ interface Home {
suspend fun category(uri: Uri): BrowsePage
/** New releases from the artists the user follows, newest first ("What's new"). */
suspend fun whatsNew(offset: Int = 0, limit: Int = 50): Page<Album>
+ /**
+ * The "What's New" feed in full: the releases of the followed artists and the episodes of the
+ * followed shows, each with its seen state (see [whatsNewSections]).
+ */
+ suspend fun whatsNewFeed(offset: Int = 0, limit: Int = 50, content: WhatsNewContent = WhatsNewContent.ALL): Page<WhatsNewItem>
+ /** Marks entries of the feed seen ([WhatsNewItem.id]), as opening the Web Player's page does. */
+ suspend fun markWhatsNewSeen(ids: List<String>)
}
interface Podcasts {
diff --git a/base/api/src/main/kotlin/app/myspoti/api/WhatsNew.kt b/base/api/src/main/kotlin/app/myspoti/api/WhatsNew.kt
new file mode 100644
index 00000000..c127d523
--- /dev/null
+++ b/base/api/src/main/kotlin/app/myspoti/api/WhatsNew.kt
@@ -0,0 +1,64 @@
+package app.myspoti.api
+
+import java.time.Instant
+import java.time.LocalDate
+import java.time.OffsetDateTime
+import java.time.ZoneOffset
+
+/** What the "What's New" feed is narrowed to: none, or one of the Web Player's two pills. */
+enum class WhatsNewContent { ALL, MUSIC, PODCASTS }
+
+/** Where an entry of the feed stands for the account, in the Web Player's words. */
+enum class WhatsNewState { NEW, SEEN, HIDDEN, UNKNOWN }
+
+/**
+ * One entry of the "What's New" feed (`queryWhatsNewFeed`): a release of an artist the account
+ * follows ([album]) or an episode of a show it follows ([episode]), exactly one of the two.
+ */
+data class WhatsNewItem(
+ /** The feed's own id for the entry: what [Home.markWhatsNewSeen] takes. */
+ val id: String,
+ val state: WhatsNewState,
+ /** The entry's state timestamp (ISO 8601), when the server gives one. */
+ val stateAt: String? = null,
+ val album: Album? = null,
+ val episode: Episode? = null,
+) {
+ val uri: Uri get() = album?.uri ?: episode?.uri.orEmpty()
+ /** The day it came out (ISO 8601), what the feed is ordered by. */
+ val releaseDate: String? get() = album?.releaseDate ?: episode?.releaseDate
+}
+
+/** The feed as the Web Player's page splits it: the "New" entries on top, then "Earlier". */
+data class WhatsNewSections(val fresh: List<WhatsNewItem>, val earlier: List<WhatsNewItem>)
+
+/**
+ * The Web Player's "New" rule: an entry is new while unseen with no timestamp, or within an hour
+ * of its timestamp. The page marks every entry seen as soon as it opens, so what was new still
+ * reads as new when it is opened again shortly after. "New" is the run of such entries at the top;
+ * everything from the first other one on is "Earlier".
+ *
+ * Each section is ordered newest first by release date, the server's own order kept for a tie or
+ * an entry without a date.
+ */
+fun whatsNewSections(items: List<WhatsNewItem>, nowMs: Long = System.currentTimeMillis()): WhatsNewSections {
+ val split = items.indexOfFirst { !it.isFresh(nowMs) }.let { if (it < 0) items.size else it }
+ fun newestFirst(list: List<WhatsNewItem>) = list.sortedByDescending { isoMs(it.releaseDate) }
+ return WhatsNewSections(newestFirst(items.take(split)), newestFirst(items.drop(split)))
+}
+
+private fun WhatsNewItem.isFresh(nowMs: Long): Boolean {
+ val at = isoMs(stateAt) ?: return state == WhatsNewState.NEW
+ return nowMs - at <= FRESH_MS
+}
+
+/** One hour, the Web Player's own window. */
+private const val FRESH_MS = 3_600_000L
+
+/** Epoch ms of an ISO date or date-time ("2026-10-31", "2026-10-31T00:00:00Z"); null when unreadable. */
+private fun isoMs(iso: String?): Long? {
+ if (iso.isNullOrBlank()) return null
+ return runCatching { OffsetDateTime.parse(iso).toInstant().toEpochMilli() }.getOrNull()
+ ?: runCatching { Instant.parse(iso).toEpochMilli() }.getOrNull()
+ ?: runCatching { LocalDate.parse(iso.take(10)).atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli() }.getOrNull()
+}
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveWhatsNewScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveWhatsNewScreen.kt
new file mode 100644
index 00000000..b188acc8
--- /dev/null
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveWhatsNewScreen.kt
@@ -0,0 +1,193 @@
+package com.music.spotui.ui.immersive.pages
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.rounded.Favorite
+import androidx.compose.material.icons.rounded.FavoriteBorder
+import androidx.compose.material.icons.rounded.MoreHoriz
+import androidx.compose.material.icons.rounded.Pause
+import androidx.compose.material.icons.rounded.PlayArrow
+import androidx.compose.material3.Icon
+import androidx.compose.runtime.remember
+import androidx.compose.ui.draw.clip
+import com.music.spotui.di.SongPlayer
+import com.music.spotui.ui.screens.WhatsNewOptionsSheet
+import com.music.spotui.ui.screens.togglePlay
+import com.music.spotui.ui.screens.whatsNewPlayback
+import com.music.spotui.ui.screens.whatsNewSaved
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.foundation.lazy.itemsIndexed
+import androidx.compose.foundation.lazy.rememberLazyListState
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import androidx.navigation.NavController
+import app.myspoti.api.WhatsNewContent
+import app.myspoti.api.WhatsNewItem
+import app.myspoti.engine.R
+import com.music.spotui.ui.components.FastScrollbar
+import com.music.spotui.ui.immersive.Immersive
+import com.music.spotui.ui.immersive.components.ImmersiveCover
+import com.music.spotui.ui.immersive.components.ImmersiveMessageState
+import com.music.spotui.ui.immersive.components.ImmersiveRowDividerInset
+import com.music.spotui.ui.immersive.components.SectionHeader
+import com.music.spotui.ui.immersive.components.immersiveClickable
+import com.music.spotui.ui.immersive.components.immersiveSongListSkeleton
+import com.music.spotui.ui.immersive.screens.ImmersiveChip
+import com.music.spotui.ui.immersive.screens.ImmersiveChipRow
+import com.music.spotui.ui.immersive.screens.ImmersiveRowDivider
+import com.music.spotui.ui.immersive.shell.ImmersiveTopBar
+import com.music.spotui.ui.immersive.shell.immersiveHazeSource
+import com.music.spotui.ui.immersive.shell.immersiveLargeTitle
+import com.music.spotui.ui.immersive.shell.immersiveTopContentPadding
+import com.music.spotui.ui.screens.coverUrl
+import com.music.spotui.ui.screens.rememberWhatsNewFeed
+import com.music.spotui.ui.screens.route
+import com.music.spotui.ui.screens.title
+import com.music.spotui.ui.screens.toggled
+import com.music.spotui.ui.screens.whatsNewDate
+import com.music.spotui.ui.screens.whatsNewSubtitle
+
+/**
+ * "What's New" of the Immersive look, replacing the Classic `WhatsNewScreen`: the large title and
+ * its subtitle, the Music / Podcasts pills, then the releases and episodes of what the account
+ * follows under "New" and "Earlier", newest first. A row opens its album or episode.
+ */
+@Composable
+fun ImmersiveWhatsNewScreen(navController: NavController) {
+ var content by rememberSaveable { mutableStateOf(WhatsNewContent.ALL) }
+ var attempt by rememberSaveable { mutableStateOf(0) }
+ val feed = rememberWhatsNewFeed(content, attempt)
+ val listState = rememberLazyListState()
+ val title = stringResource(R.string.whats_new_title)
+ val subtitle = stringResource(R.string.whats_new_subtitle)
+
+ ImmersivePageFrame {
+ LazyColumn(
+ state = listState,
+ contentPadding = PaddingValues(top = immersiveTopContentPadding(), bottom = Immersive.BottomChrome),
+ modifier = Modifier.fillMaxSize().immersiveHazeSource(),
+ ) {
+ immersiveLargeTitle(title, subtitle = subtitle)
+ item(key = "whatsnew:pills", contentType = "pills") {
+ ImmersiveChipRow {
+ ImmersiveChip(stringResource(R.string.recents_filter_music), selected = content == WhatsNewContent.MUSIC) {
+ content = content.toggled(WhatsNewContent.MUSIC)
+ }
+ ImmersiveChip(stringResource(R.string.recents_filter_podcasts), selected = content == WhatsNewContent.PODCASTS) {
+ content = content.toggled(WhatsNewContent.PODCASTS)
+ }
+ }
+ }
+ val sections = feed.sections
+ when {
+ sections == null && feed.failure != null -> item(key = "whatsnew:failed") {
+ ImmersiveMessageState(
+ message = stringResource(R.string.whats_new_failed, feed.failure.orEmpty()),
+ actionLabel = stringResource(R.string.home_retry),
+ onAction = { attempt++ },
+ )
+ }
+ sections == null -> immersiveSongListSkeleton(count = 10, keyPrefix = "skeleton:whatsnew")
+ sections.fresh.isEmpty() && sections.earlier.isEmpty() -> item(key = "whatsnew:empty") {
+ ImmersiveMessageState(stringResource(R.string.whats_new_empty))
+ }
+ else -> {
+ section(R.string.whats_new_section_new, sections.fresh, navController)
+ section(R.string.whats_new_section_earlier, sections.earlier, navController)
+ }
+ }
+ }
+ FastScrollbar(listState, Modifier.align(Alignment.CenterEnd))
+ ImmersiveTopBar(title = title, listState = listState, onBack = { navController.navigateUp() })
+ }
+}
+
+private fun LazyListScope.section(title: Int, list: List<WhatsNewItem>, navController: NavController) {
+ if (list.isEmpty()) return
+ item(key = "title:$title") { SectionHeader(title = stringResource(title), modifier = Modifier.padding(top = 8.dp)) }
+ itemsIndexed(list, key = { _, item -> "item:${item.id}" }) { index, item ->
+ Column {
+ WhatsNewRow(item) { navController.navigate(item.route()) }
+ if (index < list.lastIndex) ImmersiveRowDivider(ImmersiveRowDividerInset)
+ }
+ }
+}
+
+/**
+ * Cover, title, "Single • Artist" (or the show) and the day it came out, then the Web Player's
+ * actions: the heart for the library, the ⋯ menu, and play at the end.
+ */
+@Composable
+private fun WhatsNewRow(item: WhatsNewItem, onClick: () -> Unit) {
+ val saved = whatsNewSaved(item)
+ val playback = whatsNewPlayback(item)
+ var menu by remember { mutableStateOf(false) }
+ if (menu) WhatsNewOptionsSheet(item, saved) { menu = false }
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .immersiveClickable(onClick = onClick, pressedScale = 0.98f)
+ .padding(start = Immersive.Gutter, end = Immersive.Gutter, top = 8.dp, bottom = 4.dp),
+ ) {
+ ImmersiveCover(item.coverUrl, Modifier.size(52.dp), Immersive.CoverSmall)
+ Column(Modifier.padding(start = 14.dp).weight(1f)) {
+ Text(
+ item.title, style = Immersive.Body.copy(fontWeight = FontWeight.Medium, color = if (playback.current) Immersive.Accent else Immersive.Text),
+ maxLines = 2, overflow = TextOverflow.Ellipsis,
+ )
+ Text(whatsNewSubtitle(item), style = Immersive.Subhead, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ val date = whatsNewDate(item)
+ if (date.isNotEmpty()) Text(date, style = Immersive.Caption, maxLines = 1)
+ Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(top = 2.dp)) {
+ Icon(
+ if (saved) Icons.Rounded.Favorite else Icons.Rounded.FavoriteBorder,
+ contentDescription = stringResource(if (saved) R.string.immersive_detail_unsave else R.string.immersive_detail_save),
+ tint = if (saved) Immersive.Accent else Immersive.TextSecondary,
+ modifier = Modifier.clip(CircleShape).immersiveClickable(onClick = { SongPlayer.setSaved(item.uri, !saved) }, pressedScale = 0.9f)
+ .padding(6.dp).size(22.dp),
+ )
+ Icon(
+ Icons.Rounded.MoreHoriz,
+ contentDescription = stringResource(R.string.immersive_shell_more),
+ tint = Immersive.TextSecondary,
+ modifier = Modifier.padding(start = 8.dp).clip(CircleShape).immersiveClickable(onClick = { menu = true }, pressedScale = 0.9f)
+ .padding(6.dp).size(22.dp),
+ )
+ Spacer(Modifier.weight(1f))
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier.size(38.dp).clip(CircleShape).background(Immersive.Text)
+ .immersiveClickable(onClick = { item.togglePlay(playback) }, pressedScale = 0.9f),
+ ) {
+ Icon(
+ if (playback.playing) Icons.Rounded.Pause else Icons.Rounded.PlayArrow,
+ contentDescription = stringResource(if (playback.playing) R.string.immersive_player_pause else R.string.immersive_player_play),
+ tint = Immersive.Page,
+ modifier = Modifier.size(24.dp),
+ )
+ }
+ }
+ }
+ }
+}
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.kt
index 78f933e1..1f0b8afe 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
@@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
+import androidx.compose.material.icons.rounded.NotificationsNone
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
@@ -200,9 +201,10 @@ fun ImmersiveHomeScreen(navController: NavController) {
}
}
}
- // The greeting and the profile disc on floating glass; the feed scrolls under it.
+ // The greeting, the bell and the profile disc on floating glass; the feed scrolls under it.
ImmersiveFloatingHeader(title, collapse = rememberTopBarCollapse(listState, 24.dp)) {
val size = LocalBarControlSize.current
+ WhatsNewBell(size) { navController.navigate(Routes.WhatsNew.route) }
// The tap area is the header's full height and reaches past the disc toward the
// title, so the small disc of the minimized bar is still easy to hit.
Box(
@@ -223,6 +225,25 @@ fun ImmersiveHomeScreen(navController: NavController) {
}
}
+/** The bell left of the profile disc: opens "What's New". Its tap area is the header's full height, as the disc's is. */
+@Composable
+private fun WhatsNewBell(size: androidx.compose.ui.unit.Dp, onClick: () -> Unit) {
+ Box(
+ Modifier
+ .height(ImmersiveHeaderContentHeight)
+ .width(size)
+ .immersiveClickable(onClick = onClick),
+ contentAlignment = Alignment.Center,
+ ) {
+ androidx.compose.material3.Icon(
+ androidx.compose.material.icons.Icons.Rounded.NotificationsNone,
+ contentDescription = stringResource(R.string.whats_new_title),
+ tint = Immersive.Text,
+ modifier = Modifier.size(size * 0.55f),
+ )
+ }
+}
+
private fun visibleSections(feed: HomeFeedModel): List<HomeSection> =
if (Features.PODCASTS) feed.sections
else feed.sections.map { s -> s.copy(items = s.items.filterNot { it is HomeItem.Show }) }.filter { it.items.isNotEmpty() }
diff --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.kt
index 9d57ea37..f344a8f0 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
@@ -210,6 +210,15 @@ fun MyNavHost(
if (isImmersive()) com.music.spotui.ui.immersive.pages.ImmersiveRecentlyPlayedScreen(navHostController) else com.music.spotui.ui.screens.RecentlyPlayedScreen(navHostController)
}
+ // New releases and episodes of what the account follows (the bell on Home).
+ page(Routes.WhatsNew.route) {
+ LaunchedEffect(playerState) {
+ bottomBarState.value = true
+ bottomBarPlayerState.value = playerState != ""
+ }
+ if (isImmersive()) com.music.spotui.ui.immersive.pages.ImmersiveWhatsNewScreen(navHostController) else com.music.spotui.ui.screens.WhatsNewScreen(navHostController)
+ }
+
page(Routes.Liked.route){
LaunchedEffect(playerState) {
bottomBarState.value = true
diff --git a/base/app/src/main/java/com/music/spotui/ui/navigation/Routes.kt b/base/app/src/main/java/com/music/spotui/ui/navigation/Routes.kt
index 268e89be..7619660e 100644
--- a/base/app/src/main/java/com/music/spotui/ui/navigation/Routes.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/navigation/Routes.kt
@@ -34,6 +34,8 @@ sealed class Routes(
object NewEpisodes : Routes(0, "NewEpisodes", "newepisodes")
object Recap : Routes(0, "Recap", "recap")
object Recent : Routes(0, "Recent", "recent")
+ /** The "What's New" feed behind the bell on Home. */
+ object WhatsNew : Routes(0, "WhatsNew", "whatsnew")
object Friends : Routes(0, "Friends", "friends")
object Settings : Routes(0, "Settings", "settings")
object Extensions : Routes(0, "Extensions", "extensions")
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.kt
index 67e40039..d522fe82 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
@@ -39,6 +39,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.material.icons.outlined.Notifications
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Card
@@ -304,6 +305,7 @@ private fun HomeHeaderRow(navController: NavController, facet: String, onFacet:
}
}
}
+ WhatsNewBell { navController.navigate(com.music.spotui.ui.navigation.Routes.WhatsNew.route) }
// B31: a separator between the profile and the options, reported missing from this
// header (the sheets already carry one).
Box(
@@ -479,6 +481,25 @@ private fun HomeFeedCard(item: HomeItem, onClick: () -> Unit) {
}
}
+/** The bell beside the avatar: opens "What's New". */
+@Composable
+private fun WhatsNewBell(onClick: () -> Unit) {
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier
+ .clickable(interactionSource = remember { MutableInteractionSource() }, indication = null, onClick = onClick)
+ .padding(end = 10.dp, top = 10.dp, bottom = 10.dp)
+ .size(34.dp),
+ ) {
+ androidx.compose.material3.Icon(
+ androidx.compose.material.icons.Icons.Outlined.Notifications,
+ contentDescription = stringResource(R.string.whats_new_title),
+ tint = AppText,
+ modifier = Modifier.size(24.dp),
+ )
+ }
+}
+
/** Profile sheet behind the avatar: account name and sign-out (in the Web Player). */
@OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class, ExperimentalGlideComposeApi::class)
@Composable
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/WhatsNewScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/WhatsNewScreen.kt
new file mode 100644
index 00000000..f1657473
--- /dev/null
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/WhatsNewScreen.kt
@@ -0,0 +1,395 @@
+package com.music.spotui.ui.screens
+
+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.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.statusBarsPadding
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.navigationBarsPadding
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.automirrored.filled.ArrowBack
+import androidx.compose.material.icons.automirrored.outlined.PlaylistAdd
+import androidx.compose.material.icons.automirrored.outlined.QueueMusic
+import androidx.compose.material.icons.filled.CheckCircle
+import androidx.compose.material.icons.filled.MoreHoriz
+import androidx.compose.material.icons.filled.Pause
+import androidx.compose.material.icons.filled.PlayArrow
+import androidx.compose.material.icons.outlined.AddCircleOutline
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+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.graphics.Color
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.navigation.NavController
+import app.myspoti.api.WhatsNewContent
+import app.myspoti.api.WhatsNewItem
+import app.myspoti.api.WhatsNewSections
+import app.myspoti.api.WhatsNewState
+import app.myspoti.api.best
+import app.myspoti.api.whatsNewSections
+import app.myspoti.engine.R
+import app.myspoti.host.android.MyspotiRuntime
+import com.bumptech.glide.integration.compose.CrossFade
+import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
+import com.bumptech.glide.integration.compose.GlideImage
+import com.music.spotui.ui.components.wideClickable
+import com.music.spotui.data.api.Response
+import com.music.spotui.di.Graph
+import com.music.spotui.di.SongPlayer
+import com.music.spotui.ui.navigation.albumRoute
+import com.music.spotui.ui.navigation.episodeRoute
+import com.music.spotui.ui.theme.AppAccent
+import com.music.spotui.ui.theme.AppMuted
+import com.music.spotui.ui.theme.AppText
+import com.music.spotui.ui.theme.tone
+import java.time.Instant
+import java.time.LocalDate
+import java.time.OffsetDateTime
+import java.time.ZoneId
+import java.time.format.DateTimeFormatter
+import java.util.Locale
+import android.widget.Toast
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import kotlinx.coroutines.withTimeoutOrNull
+
+/** Entries per request: what the Web Player's page asks for. */
+private const val PAGE = 50
+
+/** Where loading stops, should a feed ever run long. */
+private const val MAX_ITEMS = 200
+
+/** The feed of one pill, as both looks' pages show it; null [sections] while it loads. */
+internal class WhatsNewFeed {
+ var sections by mutableStateOf<WhatsNewSections?>(null)
+ var failure by mutableStateOf<String?>(null)
+}
+
+/**
+ * Loads the feed for [content], and marks its unseen entries seen once they are on screen, as the
+ * Web Player's page does: what was new moves to "Earlier" on a later visit.
+ * [attempt] loads it again (a retry).
+ */
+@Composable
+internal fun rememberWhatsNewFeed(content: WhatsNewContent, attempt: Int): WhatsNewFeed {
+ val feed = remember { WhatsNewFeed() }
+ LaunchedEffect(content, attempt) {
+ feed.failure = null
+ feed.sections = null
+ // The whole feed at once (a few months, 72 entries on a real account): "New" and
+ // "Earlier" are split over its full order, and the Web Player stopped at the first 50.
+ runCatching {
+ val items = mutableListOf<WhatsNewItem>()
+ var offset: Int? = 0
+ while (offset != null && items.size < MAX_ITEMS) {
+ val current: Int = offset
+ val page = MyspotiRuntime.api.home.whatsNewFeed(current, PAGE, content)
+ items += page.items
+ offset = page.nextOffset?.takeIf { it > current }
+ }
+ items.distinctBy { it.id }
+ }
+ .onSuccess { items ->
+ // Split before marking: what was unseen stays under "New" on this visit.
+ feed.sections = whatsNewSections(items)
+ val unseen = items.filter { it.state == WhatsNewState.NEW }.map { it.id }
+ if (unseen.isNotEmpty()) runCatching { MyspotiRuntime.api.home.markWhatsNewSeen(unseen) }
+ }
+ .onFailure { feed.failure = it.message ?: it.toString() }
+ }
+ return feed
+}
+
+/** Where the player stands with an entry: on it (the release as the context, or the episode), and playing. */
+internal data class WhatsNewPlayback(val current: Boolean, val playing: Boolean)
+
+@Composable
+internal fun whatsNewPlayback(item: WhatsNewItem): WhatsNewPlayback {
+ val now = SongPlayer.nowPlaying.value
+ val current = if (item.album != null) now.contextUri == item.uri else now.uri == item.uri
+ return WhatsNewPlayback(current, current && Graph.currentSongState.playingState.value)
+}
+
+/**
+ * The entry's play button: pauses or resumes it when it is on, else starts it. A release plays
+ * from its first song with the release as the context, as its page's own button does.
+ */
+internal fun WhatsNewItem.togglePlay(state: WhatsNewPlayback) {
+ val id = uri.substringAfterLast(':')
+ when {
+ state.playing -> SongPlayer.pause()
+ state.current -> SongPlayer.play()
+ album == null -> SongPlayer.playSong("episode:$id")
+ else -> MyspotiRuntime.scope.launch {
+ val page = withTimeoutOrNull(15_000) {
+ Graph.api.getAlbumPage(id).first { it is Response.Error || (it is Response.Success && it.data.tracks.isNotEmpty()) }
+ }
+ val songs = (page as? Response.Success)?.data?.tracks.orEmpty()
+ withContext(Dispatchers.Main) {
+ if (songs.isEmpty()) Toast.makeText(Graph.app, R.string.page_load_failed, Toast.LENGTH_SHORT).show()
+ else SongPlayer.playSong(songs.first().url, contextUri = uri, songs = songs)
+ }
+ }
+ }
+}
+
+/** Whether the entry is in the library (Your Episodes for an episode), asked of Spotify once shown. */
+@Composable
+internal fun whatsNewSaved(item: WhatsNewItem): Boolean {
+ LaunchedEffect(item.uri) { SongPlayer.requestSaved(item.uri) }
+ return SongPlayer.library[item.uri] == true
+}
+
+/**
+ * The ⋯ menu of an entry: add it to (or remove it from) the library, add it to the queue, and
+ * for a release "Add to playlist" (all its songs, as its page's menu does).
+ */
+@OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class)
+@Composable
+internal fun WhatsNewOptionsSheet(item: WhatsNewItem, saved: Boolean, onDismiss: () -> Unit) {
+ var adding by remember { mutableStateOf(false) }
+ if (adding) { com.music.spotui.ui.components.AddCollectionToPlaylistSheet(item.uri, item.title, onDismiss); return }
+ val episode = item.album == null
+ com.music.spotui.ui.components.LookSheet(onDismissRequest = onDismiss, containerColor = tone(0xFF282828)) {
+ Column(Modifier.navigationBarsPadding().padding(bottom = 12.dp)) {
+ Text(item.title, color = AppText, fontSize = 18.sp, fontWeight = FontWeight.Bold, maxLines = 1, overflow = TextOverflow.Ellipsis,
+ modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 8.dp))
+ com.music.spotui.ui.components.OptionRow(
+ if (saved) Icons.Filled.CheckCircle else Icons.Outlined.AddCircleOutline,
+ stringResource(when {
+ episode && saved -> R.string.episode_unsave
+ episode -> R.string.episode_save
+ saved -> R.string.whats_new_remove_library
+ else -> R.string.whats_new_add_library
+ }),
+ ) {
+ SongPlayer.setSaved(item.uri, !saved)
+ onDismiss()
+ }
+ com.music.spotui.ui.components.OptionRow(Icons.AutoMirrored.Outlined.QueueMusic, stringResource(R.string.context_menu_add_to_queue)) {
+ if (episode) SongPlayer.addEpisodeToQueue("episode:" + item.uri.substringAfterLast(':'))
+ else com.music.spotui.di.CollectionQueue.queue(item.uri, next = false)
+ onDismiss()
+ }
+ if (!episode) com.music.spotui.ui.components.OptionRow(Icons.AutoMirrored.Outlined.PlaylistAdd, stringResource(R.string.context_menu_add_to_playlist)) {
+ adding = true
+ }
+ }
+ }
+}
+
+/** The Web Player's pills: none selected shows both, a selected one again shows both. */
+internal fun WhatsNewContent.toggled(pill: WhatsNewContent): WhatsNewContent =
+ if (this == pill) WhatsNewContent.ALL else pill
+
+/** An album opens its page, an episode its own page. */
+internal fun WhatsNewItem.route(): String {
+ val id = uri.substringAfterLast(':')
+ album?.let { a -> return albumRoute(a.name, a.artists.joinToString(", ") { it.name }, id) }
+ return episodeRoute(id, episode?.name.orEmpty())
+}
+
+internal val WhatsNewItem.title: String get() = album?.name ?: episode?.name.orEmpty()
+
+/** The release's cover, or the episode's (its show's when it has none of its own). */
+internal val WhatsNewItem.coverUrl: String?
+ get() {
+ val images = album?.images ?: episode?.let { e -> e.images.ifEmpty { e.show?.images.orEmpty() } }.orEmpty()
+ return images.best(300)?.url
+ }
+
+/** "Single • Artist" for a release, the show's name for an episode. */
+@Composable
+internal fun whatsNewSubtitle(item: WhatsNewItem): String {
+ val album = item.album ?: return item.episode?.show?.name.orEmpty()
+ val type = when (album.type.uppercase()) {
+ "SINGLE" -> stringResource(R.string.album_type_single)
+ "EP" -> stringResource(R.string.album_type_ep)
+ "COMPILATION" -> stringResource(R.string.album_type_compilation)
+ else -> stringResource(R.string.album_type_album)
+ }
+ return listOf(type, album.artists.joinToString(", ") { it.name }).filter { it.isNotBlank() }.joinToString(" • ")
+}
+
+/** The day it came out: today, yesterday, or day and month (and year when not this one). */
+@Composable
+internal fun whatsNewDate(item: WhatsNewItem): String {
+ val iso = item.releaseDate ?: return ""
+ val date = runCatching { OffsetDateTime.parse(iso).atZoneSameInstant(ZoneId.systemDefault()).toLocalDate() }.getOrNull()
+ ?: runCatching { Instant.parse(iso).atZone(ZoneId.systemDefault()).toLocalDate() }.getOrNull()
+ ?: runCatching { LocalDate.parse(iso.take(10)) }.getOrNull()
+ ?: return ""
+ val today = LocalDate.now()
+ return when (date) {
+ today -> stringResource(R.string.recents_today)
+ today.minusDays(1) -> stringResource(R.string.recents_yesterday)
+ else -> date.format(DateTimeFormatter.ofPattern(if (date.year == today.year) "d MMM" else "d MMM yyyy", Locale.getDefault()))
+ }
+}
+
+/**
+ * "What's New", behind the bell on Home: the releases of the artists the account follows and the
+ * episodes of its shows, newest first, under "New" and "Earlier" as on the Web Player's page.
+ */
+@Composable
+fun WhatsNewScreen(navController: NavController) {
+ var content by remember { mutableStateOf(WhatsNewContent.ALL) }
+ var attempt by remember { mutableStateOf(0) }
+ val feed = rememberWhatsNewFeed(content, attempt)
+
+ Column(Modifier.fillMaxSize().background(com.music.spotui.ui.theme.AppBackground).statusBarsPadding()) {
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ modifier = Modifier.fillMaxWidth().padding(start = 8.dp, end = 16.dp, top = 8.dp),
+ ) {
+ Icon(
+ imageVector = Icons.AutoMirrored.Filled.ArrowBack,
+ contentDescription = stringResource(R.string.accessibility_navigate_back),
+ tint = AppText,
+ modifier = Modifier.wideClickable(horizontal = 8.dp, vertical = 10.dp) { navController.popBackStack() }
+ .size(40.dp).padding(8.dp),
+ )
+ Text(
+ stringResource(R.string.whats_new_title),
+ fontWeight = FontWeight.Bold, color = AppText, fontSize = 24.sp, maxLines = 1,
+ overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(start = 4.dp),
+ )
+ }
+ Text(
+ stringResource(R.string.whats_new_subtitle),
+ color = AppMuted, fontSize = 13.sp, modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 2.dp),
+ )
+ Row(
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 10.dp),
+ ) {
+ FilterPill(stringResource(R.string.recents_filter_music), content == WhatsNewContent.MUSIC) {
+ content = content.toggled(WhatsNewContent.MUSIC)
+ }
+ FilterPill(stringResource(R.string.recents_filter_podcasts), content == WhatsNewContent.PODCASTS) {
+ content = content.toggled(WhatsNewContent.PODCASTS)
+ }
+ }
+ val sections = feed.sections
+ when {
+ sections == null && feed.failure != null -> Column(Modifier.padding(20.dp)) {
+ Text(stringResource(R.string.whats_new_failed, feed.failure.orEmpty()), color = AppMuted, fontSize = 14.sp)
+ Text(
+ stringResource(R.string.home_retry), color = AppText, fontSize = 14.sp, fontWeight = FontWeight.Bold,
+ modifier = Modifier.padding(top = 12.dp).clickable { attempt++ },
+ )
+ }
+ sections == null -> com.music.spotui.ui.components.SkeletonList(count = 9)
+ sections.fresh.isEmpty() && sections.earlier.isEmpty() -> Text(
+ stringResource(R.string.whats_new_empty), color = AppMuted, fontSize = 14.sp, modifier = Modifier.padding(20.dp),
+ )
+ else -> LazyColumn(contentPadding = PaddingValues(bottom = com.music.spotui.ui.components.bottomBarsSpace())) {
+ section(R.string.whats_new_section_new, sections.fresh, navController)
+ section(R.string.whats_new_section_earlier, sections.earlier, navController)
+ }
+ }
+ }
+}
+
+private fun LazyListScope.section(title: Int, list: List<WhatsNewItem>, navController: NavController) {
+ if (list.isEmpty()) return
+ item(key = "title:$title") {
+ Text(
+ stringResource(title), color = AppText, fontSize = 18.sp, fontWeight = FontWeight.Bold,
+ modifier = Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 6.dp),
+ )
+ }
+ items(list, key = { "item:${it.id}" }) { item -> WhatsNewRow(item) { navController.navigate(item.route()) } }
+}
+
+/**
+ * Cover, title, "Single • Artist" (or the show) and the day it came out, then the Web Player's
+ * actions: + / ✓ for the library, the ⋯ menu, and play at the end.
+ */
+@OptIn(ExperimentalGlideComposeApi::class)
+@Composable
+private fun WhatsNewRow(item: WhatsNewItem, onClick: () -> Unit) {
+ val saved = whatsNewSaved(item)
+ val playback = whatsNewPlayback(item)
+ var menu by remember { mutableStateOf(false) }
+ if (menu) WhatsNewOptionsSheet(item, saved) { menu = false }
+ Row(
+ modifier = Modifier.fillMaxWidth().clickable(onClick = onClick).padding(start = 16.dp, end = 16.dp, top = 8.dp, bottom = 4.dp),
+ ) {
+ GlideImage(
+ transition = CrossFade,
+ model = item.coverUrl.orEmpty(),
+ contentDescription = null,
+ contentScale = ContentScale.Crop,
+ modifier = Modifier.size(64.dp).clip(RoundedCornerShape(4.dp)).background(tone(0xFF282828)),
+ )
+ Column(Modifier.padding(start = 12.dp).weight(1f)) {
+ Text(item.title, color = if (playback.current) AppAccent else AppText, fontSize = 16.sp, fontWeight = FontWeight.Bold,
+ maxLines = 2, overflow = TextOverflow.Ellipsis)
+ Text(whatsNewSubtitle(item), color = AppMuted, fontSize = 13.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ val date = whatsNewDate(item)
+ if (date.isNotEmpty()) Text(date, color = AppMuted, fontSize = 12.sp, maxLines = 1)
+ Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(top = 2.dp)) {
+ LikeButton(liked = saved, size = 24.dp) { SongPlayer.setSaved(item.uri, !saved) }
+ Icon(
+ Icons.Filled.MoreHoriz,
+ contentDescription = stringResource(R.string.content_description_context_menu),
+ tint = AppMuted,
+ modifier = Modifier.padding(start = 12.dp).clip(CircleShape).clickable { menu = true }.padding(8.dp).size(24.dp),
+ )
+ Spacer(Modifier.weight(1f))
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier.size(40.dp).clip(CircleShape).background(AppText).clickable { item.togglePlay(playback) },
+ ) {
+ Icon(
+ if (playback.playing) Icons.Filled.Pause else Icons.Filled.PlayArrow,
+ contentDescription = stringResource(if (playback.playing) R.string.content_description_pause_button else R.string.content_description_play_button),
+ tint = Color.Black,
+ modifier = Modifier.size(24.dp),
+ )
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun FilterPill(label: String, selected: Boolean, onClick: () -> Unit) {
+ Box(
+ Modifier.clip(RoundedCornerShape(50))
+ .background(if (selected) AppText else tone(0xFF282828))
+ .clickable(onClick = onClick)
+ .padding(horizontal = 14.dp, vertical = 7.dp),
+ ) {
+ Text(label, color = if (selected) Color.Black else AppText, fontSize = 13.sp, fontWeight = FontWeight.Medium, maxLines = 1)
+ }
+}
diff --git a/base/app/src/main/res/values-de/myspoti_strings.xml b/base/app/src/main/res/values-de/myspoti_strings.xml
index 37f277a1..9ec25155 100644
--- a/base/app/src/main/res/values-de/myspoti_strings.xml
+++ b/base/app/src/main/res/values-de/myspoti_strings.xml
@@ -372,6 +372,14 @@
<string name="recents_filter_podcasts">Podcasts</string>
<string name="recents_today">Heute</string>
<string name="recents_yesterday">Gestern</string>
+ <string name="whats_new_title">Neuheiten</string>
+ <string name="whats_new_subtitle">Die neuesten Veröffentlichungen und Folgen der Künstler und Shows, denen du folgst.</string>
+ <string name="whats_new_section_new">Neu</string>
+ <string name="whats_new_section_earlier">Früher</string>
+ <string name="whats_new_empty">Noch nichts Neues. Folge Künstlern und Podcasts, um ihre neuen Veröffentlichungen und Folgen hier zu sehen.</string>
+ <string name="whats_new_failed">Neuheiten konnten nicht geladen werden (%1$s)</string>
+ <string name="whats_new_add_library">Zur Bibliothek hinzufügen</string>
+ <string name="whats_new_remove_library">Aus der Bibliothek entfernen</string>
<string name="recents_played_one">1 Titel gespielt</string>
<string name="recents_played_many">%1$d Titel gespielt</string>
<string name="recents_saved_one">1 Titel hinzugefügt</string>
diff --git a/base/app/src/main/res/values-el/myspoti_strings.xml b/base/app/src/main/res/values-el/myspoti_strings.xml
index 75565e58..0aa5f43a 100644
--- a/base/app/src/main/res/values-el/myspoti_strings.xml
+++ b/base/app/src/main/res/values-el/myspoti_strings.xml
@@ -372,6 +372,14 @@
<string name="recents_filter_podcasts">Podcast</string>
<string name="recents_today">Σήμερα</string>
<string name="recents_yesterday">Χθες</string>
+ <string name="whats_new_title">Τι νέο υπάρχει</string>
+ <string name="whats_new_subtitle">Οι πιο πρόσφατες κυκλοφορίες και τα επεισόδια από τους καλλιτέχνες και τις εκπομπές που ακολουθείτε.</string>
+ <string name="whats_new_section_new">Νέα</string>
+ <string name="whats_new_section_earlier">Παλαιότερα</string>
+ <string name="whats_new_empty">Τίποτα νέο ακόμα. Ακολουθήστε καλλιτέχνες και podcast για να βλέπετε εδώ τις νέες κυκλοφορίες και τα επεισόδιά τους.</string>
+ <string name="whats_new_failed">Δεν ήταν δυνατή η φόρτωση του «Τι νέο υπάρχει» (%1$s)</string>
+ <string name="whats_new_add_library">Προσθήκη στη Βιβλιοθήκη</string>
+ <string name="whats_new_remove_library">Αφαίρεση από τη Βιβλιοθήκη</string>
<string name="recents_played_one">1 κομμάτι αναπαράχθηκε</string>
<string name="recents_played_many">%1$d κομμάτια αναπαράχθηκαν</string>
<string name="recents_saved_one">1 κομμάτι προστέθηκε</string>
diff --git a/base/app/src/main/res/values-es/myspoti_strings.xml b/base/app/src/main/res/values-es/myspoti_strings.xml
index 423d098e..6e9da91b 100644
--- a/base/app/src/main/res/values-es/myspoti_strings.xml
+++ b/base/app/src/main/res/values-es/myspoti_strings.xml
@@ -372,6 +372,14 @@
<string name="recents_filter_podcasts">Podcasts</string>
<string name="recents_today">Hoy</string>
<string name="recents_yesterday">Ayer</string>
+ <string name="whats_new_title">Novedades</string>
+ <string name="whats_new_subtitle">Los últimos lanzamientos y episodios de los artistas y programas que sigues.</string>
+ <string name="whats_new_section_new">Nuevo</string>
+ <string name="whats_new_section_earlier">Anterior</string>
+ <string name="whats_new_empty">Aún no hay novedades. Sigue a artistas y pódcasts para ver aquí sus nuevos lanzamientos y episodios.</string>
+ <string name="whats_new_failed">No se pudieron cargar las novedades (%1$s)</string>
+ <string name="whats_new_add_library">Añadir a Tu biblioteca</string>
+ <string name="whats_new_remove_library">Quitar de Tu biblioteca</string>
<string name="recents_played_one">1 canción reproducida</string>
<string name="recents_played_many">%1$d canciones reproducidas</string>
<string name="recents_saved_one">1 canción añadida</string>
diff --git a/base/app/src/main/res/values-fr/myspoti_strings.xml b/base/app/src/main/res/values-fr/myspoti_strings.xml
index 7c8a797a..debfbe3f 100644
--- a/base/app/src/main/res/values-fr/myspoti_strings.xml
+++ b/base/app/src/main/res/values-fr/myspoti_strings.xml
@@ -165,6 +165,14 @@
<string name="recents_filter_podcasts">Podcasts</string>
<string name="recents_today">Aujourd\'hui</string>
<string name="recents_yesterday">Hier</string>
+ <string name="whats_new_title">Nouveautés</string>
+ <string name="whats_new_subtitle">Les dernières sorties et les derniers épisodes des artistes et émissions que vous suivez.</string>
+ <string name="whats_new_section_new">Nouveau</string>
+ <string name="whats_new_section_earlier">Plus tôt</string>
+ <string name="whats_new_empty">Rien de nouveau pour l\'instant. Suivez des artistes et des podcasts pour voir ici leurs nouvelles sorties et leurs épisodes.</string>
+ <string name="whats_new_failed">Impossible de charger les nouveautés (%1$s)</string>
+ <string name="whats_new_add_library">Ajouter à la Bibliothèque</string>
+ <string name="whats_new_remove_library">Retirer de la Bibliothèque</string>
<string name="recents_played_one">1 titre lu</string>
<string name="recents_played_many">%1$d titres lus</string>
<string name="recents_saved_one">1 titre ajouté</string>
diff --git a/base/app/src/main/res/values-it/myspoti_strings.xml b/base/app/src/main/res/values-it/myspoti_strings.xml
index c6ed3412..1ce0ff4e 100644
--- a/base/app/src/main/res/values-it/myspoti_strings.xml
+++ b/base/app/src/main/res/values-it/myspoti_strings.xml
@@ -370,6 +370,14 @@
<string name="recents_filter_podcasts">Podcast</string>
<string name="recents_today">Oggi</string>
<string name="recents_yesterday">Ieri</string>
+ <string name="whats_new_title">Novità</string>
+ <string name="whats_new_subtitle">Le ultime uscite e gli ultimi episodi degli artisti e dei programmi che segui.</string>
+ <string name="whats_new_section_new">Nuovi</string>
+ <string name="whats_new_section_earlier">Meno recenti</string>
+ <string name="whats_new_empty">Ancora niente di nuovo. Segui artisti e podcast per vedere qui le loro nuove uscite e i nuovi episodi.</string>
+ <string name="whats_new_failed">Impossibile caricare le novità (%1$s)</string>
+ <string name="whats_new_add_library">Aggiungi a La tua libreria</string>
+ <string name="whats_new_remove_library">Rimuovi da La tua libreria</string>
<string name="recents_played_one">1 brano riprodotto</string>
<string name="recents_played_many">%1$d brani riprodotti</string>
<string name="recents_saved_one">1 brano aggiunto</string>
diff --git a/base/app/src/main/res/values-pl/myspoti_strings.xml b/base/app/src/main/res/values-pl/myspoti_strings.xml
index 4d3f59dd..1a285f6b 100644
--- a/base/app/src/main/res/values-pl/myspoti_strings.xml
+++ b/base/app/src/main/res/values-pl/myspoti_strings.xml
@@ -162,6 +162,14 @@
<string name="recents_filter_podcasts">Podcasty</string>
<string name="recents_today">Dziś</string>
<string name="recents_yesterday">Wczoraj</string>
+ <string name="whats_new_title">Nowości</string>
+ <string name="whats_new_subtitle">Najnowsze wydania i odcinki artystów i programów, które obserwujesz.</string>
+ <string name="whats_new_section_new">Nowe</string>
+ <string name="whats_new_section_earlier">Wcześniej</string>
+ <string name="whats_new_empty">Na razie nic nowego. Obserwuj artystów i podcasty, aby zobaczyć tutaj ich nowe wydania i odcinki.</string>
+ <string name="whats_new_failed">Nie udało się wczytać nowości (%1$s)</string>
+ <string name="whats_new_add_library">Dodaj do Biblioteki</string>
+ <string name="whats_new_remove_library">Usuń z Biblioteki</string>
<string name="recents_played_one">Odtworzono 1 utwór</string>
<string name="recents_played_many">Odtworzone utwory: %1$d</string>
<string name="recents_saved_one">Dodano 1 utwór</string>
diff --git a/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml b/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml
index 65c1854d..329e381d 100644
--- a/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml
+++ b/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml
@@ -156,6 +156,14 @@
<string name="recents_filter_podcasts">Podcasts</string>
<string name="recents_today">Hoje</string>
<string name="recents_yesterday">Ontem</string>
+ <string name="whats_new_title">Novidades</string>
+ <string name="whats_new_subtitle">Os lançamentos e episódios mais recentes dos artistas e programas que você segue.</string>
+ <string name="whats_new_section_new">Novo</string>
+ <string name="whats_new_section_earlier">Anteriores</string>
+ <string name="whats_new_empty">Ainda não há novidades. Siga artistas e podcasts para ver aqui os novos lançamentos e episódios deles.</string>
+ <string name="whats_new_failed">Não foi possível carregar as novidades (%1$s)</string>
+ <string name="whats_new_add_library">Adicionar à Sua Biblioteca</string>
+ <string name="whats_new_remove_library">Remover da Sua Biblioteca</string>
<string name="recents_played_one">1 faixa tocada</string>
<string name="recents_played_many">%1$d faixas tocadas</string>
<string name="recents_saved_one">1 faixa adicionada</string>
diff --git a/base/app/src/main/res/values-pt-rPT/myspoti_strings.xml b/base/app/src/main/res/values-pt-rPT/myspoti_strings.xml
index afdcbd9d..651531d7 100644
--- a/base/app/src/main/res/values-pt-rPT/myspoti_strings.xml
+++ b/base/app/src/main/res/values-pt-rPT/myspoti_strings.xml
@@ -363,6 +363,14 @@
<string name="recents_filter_podcasts">Podcasts</string>
<string name="recents_today">Hoje</string>
<string name="recents_yesterday">Ontem</string>
+ <string name="whats_new_title">Novidades</string>
+ <string name="whats_new_subtitle">Os lançamentos e episódios mais recentes dos artistas e programas que você segue.</string>
+ <string name="whats_new_section_new">Novo</string>
+ <string name="whats_new_section_earlier">Anteriores</string>
+ <string name="whats_new_empty">Ainda não há novidades. Siga artistas e podcasts para ver aqui os novos lançamentos e episódios deles.</string>
+ <string name="whats_new_failed">Não foi possível carregar as novidades (%1$s)</string>
+ <string name="whats_new_add_library">Adicionar à tua Biblioteca</string>
+ <string name="whats_new_remove_library">Remover da tua Biblioteca</string>
<string name="recents_played_one">1 música reproduzida</string>
<string name="recents_played_many">%1$d músicas reproduzidas</string>
<string name="recents_saved_one">1 música adicionada</string>
diff --git a/base/app/src/main/res/values-pt/myspoti_strings.xml b/base/app/src/main/res/values-pt/myspoti_strings.xml
index fff57dfb..454819bb 100644
--- a/base/app/src/main/res/values-pt/myspoti_strings.xml
+++ b/base/app/src/main/res/values-pt/myspoti_strings.xml
@@ -372,6 +372,14 @@
<string name="recents_filter_podcasts">Podcasts</string>
<string name="recents_today">Hoje</string>
<string name="recents_yesterday">Ontem</string>
+ <string name="whats_new_title">Novidades</string>
+ <string name="whats_new_subtitle">Os lançamentos e episódios mais recentes dos artistas e programas que você segue.</string>
+ <string name="whats_new_section_new">Novo</string>
+ <string name="whats_new_section_earlier">Anteriores</string>
+ <string name="whats_new_empty">Ainda não há novidades. Siga artistas e podcasts para ver aqui os novos lançamentos e episódios deles.</string>
+ <string name="whats_new_failed">Não foi possível carregar as novidades (%1$s)</string>
+ <string name="whats_new_add_library">Adicionar à Sua Biblioteca</string>
+ <string name="whats_new_remove_library">Remover da Sua Biblioteca</string>
<string name="recents_played_one">1 música reproduzida</string>
<string name="recents_played_many">%1$d músicas reproduzidas</string>
<string name="recents_saved_one">1 música adicionada</string>
diff --git a/base/app/src/main/res/values-ru/myspoti_strings.xml b/base/app/src/main/res/values-ru/myspoti_strings.xml
index 27362f09..083a9e62 100644
--- a/base/app/src/main/res/values-ru/myspoti_strings.xml
+++ b/base/app/src/main/res/values-ru/myspoti_strings.xml
@@ -162,6 +162,14 @@
<string name="recents_filter_podcasts">Подкасты</string>
<string name="recents_today">Сегодня</string>
<string name="recents_yesterday">Вчера</string>
+ <string name="whats_new_title">Что нового</string>
+ <string name="whats_new_subtitle">Последние релизы и выпуски исполнителей и подкастов, на которые вы подписаны.</string>
+ <string name="whats_new_section_new">Новое</string>
+ <string name="whats_new_section_earlier">Ранее</string>
+ <string name="whats_new_empty">Пока ничего нового. Подпишитесь на исполнителей и подкасты, чтобы видеть здесь их новые релизы и выпуски.</string>
+ <string name="whats_new_failed">Не удалось загрузить «Что нового» (%1$s)</string>
+ <string name="whats_new_add_library">Добавить в медиатеку</string>
+ <string name="whats_new_remove_library">Удалить из медиатеки</string>
<string name="recents_played_one">Прослушан 1 трек</string>
<string name="recents_played_many">Прослушано треков: %1$d</string>
<string name="recents_saved_one">Добавлен 1 трек</string>
diff --git a/base/app/src/main/res/values-zh/myspoti_strings.xml b/base/app/src/main/res/values-zh/myspoti_strings.xml
index 36fcdb96..7ca078a4 100644
--- a/base/app/src/main/res/values-zh/myspoti_strings.xml
+++ b/base/app/src/main/res/values-zh/myspoti_strings.xml
@@ -159,6 +159,14 @@
<string name="recents_filter_podcasts">播客</string>
<string name="recents_today">今天</string>
<string name="recents_yesterday">昨天</string>
+ <string name="whats_new_title">最新动态</string>
+ <string name="whats_new_subtitle">你关注的艺人和节目的最新发行和单集。</string>
+ <string name="whats_new_section_new">新内容</string>
+ <string name="whats_new_section_earlier">较早</string>
+ <string name="whats_new_empty">暂时没有新内容。关注艺人和播客,即可在这里看到他们的新发行和新单集。</string>
+ <string name="whats_new_failed">无法加载最新动态(%1$s)</string>
+ <string name="whats_new_add_library">添加到音乐库</string>
+ <string name="whats_new_remove_library">从音乐库中移除</string>
<string name="recents_played_one">播放了 1 首曲目</string>
<string name="recents_played_many">播放了 %1$d 首曲目</string>
<string name="recents_saved_one">添加了 1 首曲目</string>
diff --git a/base/app/src/main/res/values/myspoti_strings.xml b/base/app/src/main/res/values/myspoti_strings.xml
index 2c2fce75..3c3bd95e 100644
--- a/base/app/src/main/res/values/myspoti_strings.xml
+++ b/base/app/src/main/res/values/myspoti_strings.xml
@@ -165,6 +165,14 @@
<string name="recents_filter_podcasts">Podcasts</string>
<string name="recents_today">Today</string>
<string name="recents_yesterday">Yesterday</string>
+ <string name="whats_new_title">What\'s New</string>
+ <string name="whats_new_subtitle">The latest releases and episodes from the artists and shows you follow.</string>
+ <string name="whats_new_section_new">New</string>
+ <string name="whats_new_section_earlier">Earlier</string>
+ <string name="whats_new_empty">Nothing new yet. Follow artists and podcasts to see their new releases and episodes here.</string>
+ <string name="whats_new_failed">Could not load What\'s New (%1$s)</string>
+ <string name="whats_new_add_library">Add to Your Library</string>
+ <string name="whats_new_remove_library">Remove from Your Library</string>
<string name="recents_played_one">1 track played</string>
<string name="recents_played_many">%1$d tracks played</string>
<string name="recents_saved_one">1 track added</string>