Restore default theme when the queue is cleared
This commit is contained in:
@@ -153,7 +153,11 @@ class MainActivity : ComponentActivity() {
|
|||||||
binder?.setBitmapListener { bitmap: Bitmap? ->
|
binder?.setBitmapListener { bitmap: Bitmap? ->
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
val colorPalette =
|
val colorPalette =
|
||||||
colorPaletteOf(ColorPaletteName.Dynamic, colorPaletteMode, isSystemInDarkTheme)
|
colorPaletteOf(
|
||||||
|
ColorPaletteName.Dynamic,
|
||||||
|
colorPaletteMode,
|
||||||
|
isSystemInDarkTheme
|
||||||
|
)
|
||||||
|
|
||||||
setSystemBarAppearance(colorPalette.isDark)
|
setSystemBarAppearance(colorPalette.isDark)
|
||||||
|
|
||||||
@@ -170,7 +174,10 @@ class MainActivity : ComponentActivity() {
|
|||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
setSystemBarAppearance(it.isDark)
|
setSystemBarAppearance(it.isDark)
|
||||||
}
|
}
|
||||||
appearance = appearance.copy(colorPalette = it, typography = typographyOf(it.text))
|
appearance = appearance.copy(
|
||||||
|
colorPalette = it,
|
||||||
|
typography = typographyOf(it.text)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,10 +188,16 @@ class MainActivity : ComponentActivity() {
|
|||||||
when (key) {
|
when (key) {
|
||||||
colorPaletteNameKey, colorPaletteModeKey -> {
|
colorPaletteNameKey, colorPaletteModeKey -> {
|
||||||
val colorPaletteName =
|
val colorPaletteName =
|
||||||
sharedPreferences.getEnum(colorPaletteNameKey, ColorPaletteName.Dynamic)
|
sharedPreferences.getEnum(
|
||||||
|
colorPaletteNameKey,
|
||||||
|
ColorPaletteName.Dynamic
|
||||||
|
)
|
||||||
|
|
||||||
val colorPaletteMode =
|
val colorPaletteMode =
|
||||||
sharedPreferences.getEnum(colorPaletteModeKey, ColorPaletteMode.System)
|
sharedPreferences.getEnum(
|
||||||
|
colorPaletteModeKey,
|
||||||
|
ColorPaletteMode.System
|
||||||
|
)
|
||||||
|
|
||||||
if (colorPaletteName == ColorPaletteName.Dynamic) {
|
if (colorPaletteName == ColorPaletteName.Dynamic) {
|
||||||
setDynamicPalette(colorPaletteMode)
|
setDynamicPalette(colorPaletteMode)
|
||||||
@@ -311,13 +324,17 @@ class MainActivity : ComponentActivity() {
|
|||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
)
|
)
|
||||||
|
|
||||||
binder?.player?.let { player ->
|
DisposableEffect(binder?.player) {
|
||||||
ExpandPlayerOnPlaylistChange(
|
binder?.player?.listener(object : Player.Listener {
|
||||||
player = player,
|
override fun onMediaItemTransition(
|
||||||
expand = {
|
mediaItem: MediaItem?,
|
||||||
playerBottomSheetState.expand(tween(500))
|
reason: Int
|
||||||
|
) {
|
||||||
|
if (reason == Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED && mediaItem != null) {
|
||||||
|
playerBottomSheetState.expand(tween(500))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
}) ?: onDispose { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> IntentUriScreen(uri = uri)
|
else -> IntentUriScreen(uri = uri)
|
||||||
@@ -348,17 +365,4 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
val LocalPlayerServiceBinder = staticCompositionLocalOf<PlayerService.Binder?> { null }
|
val LocalPlayerServiceBinder = staticCompositionLocalOf<PlayerService.Binder?> { null }
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun ExpandPlayerOnPlaylistChange(player: Player, expand: () -> Unit) {
|
|
||||||
DisposableEffect(player, expand) {
|
|
||||||
player.listener(object : Player.Listener {
|
|
||||||
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
|
|
||||||
if (reason == Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED && mediaItem != null) {
|
|
||||||
expand()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val LocalPlayerAwarePaddingValues = staticCompositionLocalOf<PaddingValues> { TODO() }
|
val LocalPlayerAwarePaddingValues = staticCompositionLocalOf<PaddingValues> { TODO() }
|
||||||
|
|||||||
@@ -272,6 +272,10 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
|
|||||||
maybeRecoverPlaybackError()
|
maybeRecoverPlaybackError()
|
||||||
maybeNormalizeVolume()
|
maybeNormalizeVolume()
|
||||||
maybeProcessRadio()
|
maybeProcessRadio()
|
||||||
|
|
||||||
|
if (mediaItem == null) {
|
||||||
|
bitmapProvider.listener?.invoke(null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun maybeRecoverPlaybackError() {
|
private fun maybeRecoverPlaybackError() {
|
||||||
@@ -681,9 +685,6 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
|
|||||||
var isLoadingRadio by mutableStateOf(false)
|
var isLoadingRadio by mutableStateOf(false)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
val lastBitmap: Bitmap?
|
|
||||||
get() = bitmapProvider.lastBitmap
|
|
||||||
|
|
||||||
fun setBitmapListener(listener: ((Bitmap?) -> Unit)?) {
|
fun setBitmapListener(listener: ((Bitmap?) -> Unit)?) {
|
||||||
bitmapProvider.listener = listener
|
bitmapProvider.listener = listener
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user