mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
skip the startup reveal animation and seed the first colour
The mini player and tab bar no longer expand or animate their inset when playback is restored at launch, and the first artwork colour lands without a 600ms fade from the base scheme. The last active artwork seed is persisted and read back synchronously so the mini player can paint with it on its first frame.
This commit is contained in:
@@ -55,6 +55,27 @@ class UserPreferencesTest {
|
||||
assertEquals(StreamQuality(320, null), prefs.streamQuality(NetworkMode.Wifi).first())
|
||||
assertEquals(StreamQuality(96, "opus"), prefs.streamQuality(NetworkMode.Mobile).first())
|
||||
|
||||
file.delete()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun lastSeedRoundTripsWithAndWithoutASecondary() =
|
||||
runTest {
|
||||
val file = File.createTempFile("user-prefs", ".preferences_pb").apply { delete() }
|
||||
val store = PreferenceDataStoreFactory.create(scope = backgroundScope) { file }
|
||||
val prefs = UserPreferences(store)
|
||||
|
||||
assertEquals(null, prefs.lastSeed())
|
||||
|
||||
prefs.setLastSeed(ArtworkSeedValue("art:1", 0xFF112233.toInt(), 0xFF445566.toInt()))
|
||||
assertEquals(
|
||||
ArtworkSeedValue("art:1", 0xFF112233.toInt(), 0xFF445566.toInt()),
|
||||
prefs.lastSeed(),
|
||||
)
|
||||
|
||||
prefs.setLastSeed(ArtworkSeedValue("art:2", 0xFF778899.toInt(), null))
|
||||
assertEquals(ArtworkSeedValue("art:2", 0xFF778899.toInt(), null), prefs.lastSeed())
|
||||
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.graphics.Color
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.graphics.luminance
|
||||
@@ -92,6 +93,24 @@ class ArtworkExtractionTest {
|
||||
assertEquals(42, state.value)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theFirstArtworkColourAppearsWithoutFadingFromTheBaseScheme() {
|
||||
val target = artworkColorsFromSeed(0xFF3A7BD5.toInt())
|
||||
val artwork = mutableStateOf<ArtworkColors?>(null)
|
||||
val seen = mutableListOf<androidx.compose.ui.graphics.Color>()
|
||||
composeRule.setContent {
|
||||
val colors = rememberAnimatedArtworkColors(artwork.value)
|
||||
SideEffect { seen += colors.scheme.background }
|
||||
}
|
||||
composeRule.waitForIdle()
|
||||
|
||||
composeRule.runOnIdle { artwork.value = target }
|
||||
composeRule.waitForIdle()
|
||||
|
||||
val firstPainting = seen.first { it != baseArtworkColors.scheme.background }
|
||||
assertEquals(target.scheme.background, firstPainting)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun keepsTheStoredSeedWhenTheArtCannotBeDecoded() {
|
||||
val key = "missing-${System.nanoTime()}"
|
||||
|
||||
Reference in New Issue
Block a user