Hide unsupported skip actions in clock widget music part
This commit is contained in:
parent
e4a599f234
commit
d5729006e4
@ -27,6 +27,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import de.mm20.launcher2.music.MusicService
|
import de.mm20.launcher2.music.MusicService
|
||||||
import de.mm20.launcher2.music.PlaybackState
|
import de.mm20.launcher2.music.PlaybackState
|
||||||
|
import de.mm20.launcher2.music.SupportedActions
|
||||||
import de.mm20.launcher2.preferences.Settings.ClockWidgetSettings.ClockWidgetLayout
|
import de.mm20.launcher2.preferences.Settings.ClockWidgetSettings.ClockWidgetLayout
|
||||||
import de.mm20.launcher2.ui.R
|
import de.mm20.launcher2.ui.R
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
@ -53,6 +54,7 @@ class MusicPartProvider : PartProvider, KoinComponent {
|
|||||||
val title by musicService.title.collectAsState(null)
|
val title by musicService.title.collectAsState(null)
|
||||||
val artist by musicService.artist.collectAsState(null)
|
val artist by musicService.artist.collectAsState(null)
|
||||||
val state by musicService.playbackState.collectAsState(PlaybackState.Stopped)
|
val state by musicService.playbackState.collectAsState(PlaybackState.Stopped)
|
||||||
|
val supportedActions by musicService.supportedActions.collectAsState(SupportedActions())
|
||||||
|
|
||||||
val playIcon = AnimatedImageVector.animatedVectorResource(R.drawable.anim_ic_play_pause)
|
val playIcon = AnimatedImageVector.animatedVectorResource(R.drawable.anim_ic_play_pause)
|
||||||
|
|
||||||
@ -101,11 +103,13 @@ class MusicPartProvider : PartProvider, KoinComponent {
|
|||||||
), contentDescription = null
|
), contentDescription = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
IconButton(onClick = { musicService.next() }) {
|
if (supportedActions.skipToNext) {
|
||||||
Icon(
|
IconButton(onClick = { musicService.next() }) {
|
||||||
imageVector = Icons.Rounded.SkipNext,
|
Icon(
|
||||||
contentDescription = null
|
imageVector = Icons.Rounded.SkipNext,
|
||||||
)
|
contentDescription = null
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,11 +153,13 @@ class MusicPartProvider : PartProvider, KoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row {
|
Row {
|
||||||
IconButton(onClick = { musicService.previous() }) {
|
if (supportedActions.skipToPrevious) {
|
||||||
Icon(
|
IconButton(onClick = { musicService.previous() }) {
|
||||||
imageVector = Icons.Rounded.SkipPrevious,
|
Icon(
|
||||||
contentDescription = null
|
imageVector = Icons.Rounded.SkipPrevious,
|
||||||
)
|
contentDescription = null
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
IconButton(onClick = { musicService.togglePause() }) {
|
IconButton(onClick = { musicService.togglePause() }) {
|
||||||
Icon(
|
Icon(
|
||||||
@ -163,11 +169,13 @@ class MusicPartProvider : PartProvider, KoinComponent {
|
|||||||
), contentDescription = null
|
), contentDescription = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
IconButton(onClick = { musicService.next() }) {
|
if (supportedActions.skipToPrevious) {
|
||||||
Icon(
|
IconButton(onClick = { musicService.next() }) {
|
||||||
imageVector = Icons.Rounded.SkipNext,
|
Icon(
|
||||||
contentDescription = null
|
imageVector = Icons.Rounded.SkipNext,
|
||||||
)
|
contentDescription = null
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user