playback: rename loopmode to repeatmode

Rename LoopMode to RepeatMode, which is generally much clearer
than the previous name.

This changes all non-breaking instances of "loop" in the app with
"repeat".
This commit is contained in:
OxygenCobalt
2022-04-29 14:52:33 -06:00
parent c80af01d5c
commit 8e849feb7d
36 changed files with 174 additions and 166 deletions
@@ -55,12 +55,12 @@ object IntegerTable {
/** Intent request code */
const val REQUEST_CODE = 0xA0C0
/** LoopMode.NONE */
const val LOOP_MODE_NONE = 0xA100
/** LoopMode.ALL */
const val LOOP_MODE_ALL = 0xA101
/** LoopMode.TRACK */
const val LOOP_MODE_TRACK = 0xA102
/** RepeatMode.NONE */
const val REPEAT_MODE_NONE = 0xA100
/** RepeatMode.ALL */
const val REPEAT_MODE_ALL = 0xA101
/** RepeatMode.TRACK */
const val REPEAT_MODE_TRACK = 0xA102
/** PlaybackMode.IN_GENRE */
const val PLAYBACK_MODE_IN_GENRE = 0xA103
@@ -37,8 +37,8 @@ import org.oxycblt.auxio.util.getDrawableSafe
* doesn't require a whole new icon set.
*
* This view also enables use of an "indicator", which is a dot that can denote when a button is
* active. This is useful for the shuffle/loop buttons, as at times highlighting them is not enough
* to differentiate them.
* active. This is useful for the shuffle/repeat buttons, as at times highlighting them is not
* enough to differentiate them.
*/
class PlaybackButton
@JvmOverloads
@@ -32,7 +32,7 @@ import org.oxycblt.auxio.databinding.FragmentPlaybackPanelBinding
import org.oxycblt.auxio.music.MusicParent
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.music.toDuration
import org.oxycblt.auxio.playback.state.LoopMode
import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.ui.MainNavigationAction
import org.oxycblt.auxio.ui.NavigationViewModel
import org.oxycblt.auxio.ui.ViewBindingFragment
@@ -112,7 +112,7 @@ class PlaybackPanelFragment :
.stateList
}
binding.playbackLoop.setOnClickListener { playbackModel.incrementLoop() }
binding.playbackRepeat.setOnClickListener { playbackModel.incrementRepeatMode() }
binding.playbackSkipPrev.setOnClickListener { playbackModel.skipPrev() }
binding.playbackPlayPause.apply {
@@ -129,7 +129,7 @@ class PlaybackPanelFragment :
playbackModel.song.observe(viewLifecycleOwner, ::updateSong)
playbackModel.parent.observe(viewLifecycleOwner, ::updateParent)
playbackModel.positionSecs.observe(viewLifecycleOwner, ::updatePosition)
playbackModel.loopMode.observe(viewLifecycleOwner, ::updateLoop)
playbackModel.repeatMode.observe(viewLifecycleOwner, ::updateRepeat)
playbackModel.isPlaying.observe(viewLifecycleOwner, ::updatePlaying)
playbackModel.isShuffled.observe(viewLifecycleOwner, ::updateShuffled)
@@ -197,10 +197,10 @@ class PlaybackPanelFragment :
}
}
private fun updateLoop(loopMode: LoopMode) {
requireBinding().playbackLoop.apply {
isActivated = loopMode != LoopMode.NONE
setImageResource(loopMode.icon)
private fun updateRepeat(repeatMode: RepeatMode) {
requireBinding().playbackRepeat.apply {
isActivated = repeatMode != RepeatMode.NONE
setImageResource(repeatMode.icon)
}
}
@@ -30,9 +30,9 @@ import org.oxycblt.auxio.music.Genre
import org.oxycblt.auxio.music.MusicParent
import org.oxycblt.auxio.music.MusicStore
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.state.LoopMode
import org.oxycblt.auxio.playback.state.PlaybackMode
import org.oxycblt.auxio.playback.state.PlaybackStateManager
import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.settings.SettingsManager
import org.oxycblt.auxio.util.logD
import org.oxycblt.auxio.util.logE
@@ -62,7 +62,7 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
// States
private val mIsPlaying = MutableLiveData(false)
private val mPositionSecs = MutableLiveData(0L)
private val mLoopMode = MutableLiveData(LoopMode.NONE)
private val mRepeatMode = MutableLiveData(RepeatMode.NONE)
private val mIsShuffled = MutableLiveData(false)
// Queue
@@ -83,9 +83,9 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
/** The current playback position, in seconds */
val positionSecs: LiveData<Long>
get() = mPositionSecs
/** The current repeat mode, see [LoopMode] for more information */
val loopMode: LiveData<LoopMode>
get() = mLoopMode
/** The current repeat mode, see [RepeatMode] for more information */
val repeatMode: LiveData<RepeatMode>
get() = mRepeatMode
val isShuffled: LiveData<Boolean>
get() = mIsShuffled
@@ -263,9 +263,9 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
playbackManager.reshuffle(!playbackManager.isShuffled)
}
/** Increment the loop status, e.g from off to loop once */
fun incrementLoop() {
playbackManager.loopMode = playbackManager.loopMode.increment()
/** Increment the repeat mode, e.g from [RepeatMode.NONE] to [RepeatMode.ALL] */
fun incrementRepeatMode() {
playbackManager.repeatMode = playbackManager.repeatMode.increment()
}
// --- SAVE/RESTORE FUNCTIONS ---
@@ -312,7 +312,7 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
onPositionChanged(playbackManager.positionMs)
onPlayingChanged(playbackManager.isPlaying)
onShuffledChanged(playbackManager.isShuffled)
onLoopModeChanged(playbackManager.loopMode)
onRepeatChanged(playbackManager.repeatMode)
}
// --- OVERRIDES ---
@@ -349,7 +349,7 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
mIsShuffled.value = isShuffled
}
override fun onLoopModeChanged(loopMode: LoopMode) {
mLoopMode.value = loopMode
override fun onRepeatChanged(repeatMode: RepeatMode) {
mRepeatMode.value = repeatMode
}
}
@@ -83,7 +83,7 @@ class PlaybackStateDatabase(context: Context) :
.append("${StateColumns.COLUMN_QUEUE_INDEX} INTEGER NOT NULL,")
.append("${StateColumns.COLUMN_PLAYBACK_MODE} INTEGER NOT NULL,")
.append("${StateColumns.COLUMN_IS_SHUFFLED} BOOLEAN NOT NULL,")
.append("${StateColumns.COLUMN_LOOP_MODE} INTEGER NOT NULL)")
.append("${StateColumns.COLUMN_REPEAT_MODE} INTEGER NOT NULL)")
return command
}
@@ -119,7 +119,7 @@ class PlaybackStateDatabase(context: Context) :
val indexIndex = cursor.getColumnIndexOrThrow(StateColumns.COLUMN_QUEUE_INDEX)
val modeIndex = cursor.getColumnIndexOrThrow(StateColumns.COLUMN_PLAYBACK_MODE)
val shuffleIndex = cursor.getColumnIndexOrThrow(StateColumns.COLUMN_IS_SHUFFLED)
val loopModeIndex = cursor.getColumnIndexOrThrow(StateColumns.COLUMN_LOOP_MODE)
val repeatModeIndex = cursor.getColumnIndexOrThrow(StateColumns.COLUMN_REPEAT_MODE)
cursor.moveToFirst()
@@ -146,7 +146,8 @@ class PlaybackStateDatabase(context: Context) :
queueIndex = cursor.getInt(indexIndex),
playbackMode = mode,
isShuffled = cursor.getInt(shuffleIndex) == 1,
loopMode = LoopMode.fromIntCode(cursor.getInt(loopModeIndex)) ?: LoopMode.NONE,
repeatMode = RepeatMode.fromIntCode(cursor.getInt(repeatModeIndex))
?: RepeatMode.NONE,
)
logD("Successfully read playback state: $state")
@@ -173,7 +174,7 @@ class PlaybackStateDatabase(context: Context) :
put(StateColumns.COLUMN_QUEUE_INDEX, state.queueIndex)
put(StateColumns.COLUMN_PLAYBACK_MODE, state.playbackMode.intCode)
put(StateColumns.COLUMN_IS_SHUFFLED, state.isShuffled)
put(StateColumns.COLUMN_LOOP_MODE, state.loopMode.intCode)
put(StateColumns.COLUMN_REPEAT_MODE, state.repeatMode.intCode)
}
insert(TABLE_NAME_STATE, null, stateData)
@@ -262,7 +263,7 @@ class PlaybackStateDatabase(context: Context) :
val queueIndex: Int,
val playbackMode: PlaybackMode,
val isShuffled: Boolean,
val loopMode: LoopMode,
val repeatMode: RepeatMode,
)
private object StateColumns {
@@ -273,7 +274,7 @@ class PlaybackStateDatabase(context: Context) :
const val COLUMN_QUEUE_INDEX = "queue_index"
const val COLUMN_PLAYBACK_MODE = "playback_mode"
const val COLUMN_IS_SHUFFLED = "is_shuffling"
const val COLUMN_LOOP_MODE = "loop_mode"
const val COLUMN_REPEAT_MODE = "loop_mode"
}
private object QueueColumns {
@@ -71,11 +71,11 @@ class PlaybackStateManager private constructor() {
/** The current playback progress */
var positionMs = 0L
private set
/** The current [LoopMode] */
var loopMode = LoopMode.NONE
/** The current [RepeatMode] */
var repeatMode = RepeatMode.NONE
set(value) {
field = value
notifyLoopModeChanged()
notifyRepeatModeChanged()
}
/** Whether the queue is shuffled */
var isShuffled = false
@@ -153,11 +153,11 @@ class PlaybackStateManager private constructor() {
/** Go to the next song, along with doing all the checks that entails. */
fun next() {
// Increment the index, if it cannot be incremented any further, then
// loop and pause/resume playback depending on the setting
// repeat and pause/resume playback depending on the setting
if (index < mutableQueue.lastIndex) {
goto(++index, true)
} else {
goto(0, loopMode == LoopMode.ALL)
goto(0, repeatMode == RepeatMode.ALL)
}
}
@@ -302,8 +302,13 @@ class PlaybackStateManager private constructor() {
/** Rewind to the beginning of a song. */
fun rewind() = seekTo(0)
/** Loop playback around to the beginning. */
fun loop() = seekTo(0)
/** Repeat the current song (in line with the user configuration). */
fun repeat() {
seekTo(0)
if (settingsManager.pauseOnRepeat) {
isPlaying = false
}
}
// TODO: Rework these methods eventually
@@ -342,7 +347,7 @@ class PlaybackStateManager private constructor() {
index,
playbackMode,
isShuffled,
loopMode,
repeatMode,
))
database.writeQueue(mutableQueue)
@@ -377,12 +382,12 @@ class PlaybackStateManager private constructor() {
parent = playbackState.parent
mutableQueue = queue
index = playbackState.queueIndex
loopMode = playbackState.loopMode
repeatMode = playbackState.repeatMode
isShuffled = playbackState.isShuffled
notifyNewPlayback()
seekTo(playbackState.positionMs)
notifyLoopModeChanged()
notifyRepeatModeChanged()
notifyShuffledChanged()
}
@@ -423,9 +428,9 @@ class PlaybackStateManager private constructor() {
}
}
private fun notifyLoopModeChanged() {
private fun notifyRepeatModeChanged() {
for (callback in callbacks) {
callback.onLoopModeChanged(loopMode)
callback.onRepeatChanged(repeatMode)
}
}
@@ -452,7 +457,7 @@ class PlaybackStateManager private constructor() {
fun onPlayingChanged(isPlaying: Boolean) {}
fun onPositionChanged(positionMs: Long) {}
fun onLoopModeChanged(loopMode: LoopMode) {}
fun onRepeatChanged(repeatMode: RepeatMode) {}
fun onShuffledChanged(isShuffled: Boolean) {}
fun onSeek(positionMs: Long) {}
@@ -24,13 +24,13 @@ import org.oxycblt.auxio.R
* Enum that determines the playback repeat mode.
* @author OxygenCobalt
*/
enum class LoopMode {
enum class RepeatMode {
NONE,
ALL,
TRACK;
/** Increment the LoopMode, e.g from [NONE] to [ALL] */
fun increment(): LoopMode {
fun increment(): RepeatMode {
return when (this) {
NONE -> ALL
ALL -> TRACK
@@ -41,9 +41,9 @@ enum class LoopMode {
val icon: Int
get() =
when (this) {
NONE -> R.drawable.ic_loop
ALL -> R.drawable.ic_loop_on
TRACK -> R.drawable.ic_loop_one
NONE -> R.drawable.ic_repeat
ALL -> R.drawable.ic_repeat_on
TRACK -> R.drawable.ic_repeat_one
}
/**
@@ -53,18 +53,18 @@ enum class LoopMode {
val intCode: Int
get() =
when (this) {
NONE -> IntegerTable.LOOP_MODE_NONE
ALL -> IntegerTable.LOOP_MODE_ALL
TRACK -> IntegerTable.LOOP_MODE_TRACK
NONE -> IntegerTable.REPEAT_MODE_NONE
ALL -> IntegerTable.REPEAT_MODE_ALL
TRACK -> IntegerTable.REPEAT_MODE_TRACK
}
companion object {
/** Convert an int [constant] into a LoopMode, or null if it isn't valid. */
fun fromIntCode(constant: Int): LoopMode? {
fun fromIntCode(constant: Int): RepeatMode? {
return when (constant) {
IntegerTable.LOOP_MODE_NONE -> NONE
IntegerTable.LOOP_MODE_ALL -> ALL
IntegerTable.LOOP_MODE_TRACK -> TRACK
IntegerTable.REPEAT_MODE_NONE -> NONE
IntegerTable.REPEAT_MODE_ALL -> ALL
IntegerTable.REPEAT_MODE_TRACK -> TRACK
else -> null
}
}
@@ -31,7 +31,7 @@ import org.oxycblt.auxio.R
import org.oxycblt.auxio.coil.loadBitmap
import org.oxycblt.auxio.music.MusicParent
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.state.LoopMode
import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.util.newBroadcastIntent
import org.oxycblt.auxio.util.newMainIntent
@@ -52,7 +52,7 @@ private constructor(private val context: Context, mediaToken: MediaSessionCompat
setContentIntent(context.newMainIntent())
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
addAction(buildLoopAction(context, LoopMode.NONE))
addAction(buildRepeatAction(context, RepeatMode.NONE))
addAction(buildAction(context, PlaybackService.ACTION_SKIP_PREV, R.drawable.ic_skip_prev))
addAction(buildPlayPauseAction(context, true))
addAction(buildAction(context, PlaybackService.ACTION_SKIP_NEXT, R.drawable.ic_skip_next))
@@ -94,9 +94,9 @@ private constructor(private val context: Context, mediaToken: MediaSessionCompat
mActions[2] = buildPlayPauseAction(context, isPlaying)
}
/** Update the first action to reflect the [loopMode] given. */
fun setLoopMode(loopMode: LoopMode) {
mActions[0] = buildLoopAction(context, loopMode)
/** Update the first action to reflect the [repeatMode] given. */
fun setRepeatMode(repeatMode: RepeatMode) {
mActions[0] = buildRepeatAction(context, repeatMode)
}
/** Update the first action to reflect whether the queue is shuffled or not */
@@ -123,15 +123,18 @@ private constructor(private val context: Context, mediaToken: MediaSessionCompat
return buildAction(context, PlaybackService.ACTION_PLAY_PAUSE, drawableRes)
}
private fun buildLoopAction(context: Context, loopMode: LoopMode): NotificationCompat.Action {
private fun buildRepeatAction(
context: Context,
repeatMode: RepeatMode
): NotificationCompat.Action {
val drawableRes =
when (loopMode) {
LoopMode.NONE -> R.drawable.ic_remote_loop_off
LoopMode.ALL -> R.drawable.ic_loop
LoopMode.TRACK -> R.drawable.ic_loop_one
when (repeatMode) {
RepeatMode.NONE -> R.drawable.ic_remote_repeat_off
RepeatMode.ALL -> R.drawable.ic_repeat
RepeatMode.TRACK -> R.drawable.ic_repeat_one
}
return buildAction(context, PlaybackService.ACTION_LOOP, drawableRes)
return buildAction(context, PlaybackService.ACTION_INC_REPEAT_MODE, drawableRes)
}
private fun buildShuffleAction(
@@ -141,7 +144,7 @@ private constructor(private val context: Context, mediaToken: MediaSessionCompat
val drawableRes =
if (isShuffled) R.drawable.ic_shuffle else R.drawable.ic_remote_shuffle_off
return buildAction(context, PlaybackService.ACTION_SHUFFLE, drawableRes)
return buildAction(context, PlaybackService.ACTION_INVERT_SHUFFLE, drawableRes)
}
private fun buildAction(
@@ -52,7 +52,7 @@ import org.oxycblt.auxio.BuildConfig
import org.oxycblt.auxio.IntegerTable
import org.oxycblt.auxio.music.MusicParent
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.state.LoopMode
import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.playback.state.PlaybackStateManager
import org.oxycblt.auxio.settings.SettingsManager
import org.oxycblt.auxio.util.getSystemServiceSafe
@@ -146,8 +146,8 @@ class PlaybackService :
addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY)
addAction(AudioManager.ACTION_HEADSET_PLUG)
addAction(ACTION_LOOP)
addAction(ACTION_SHUFFLE)
addAction(ACTION_INC_REPEAT_MODE)
addAction(ACTION_INVERT_SHUFFLE)
addAction(ACTION_SKIP_PREV)
addAction(ACTION_PLAY_PAUSE)
addAction(ACTION_SKIP_NEXT)
@@ -215,8 +215,8 @@ class PlaybackService :
override fun onPlaybackStateChanged(state: Int) {
when (state) {
Player.STATE_ENDED -> {
if (playbackManager.loopMode == LoopMode.TRACK) {
playbackManager.loop()
if (playbackManager.repeatMode == RepeatMode.TRACK) {
playbackManager.repeat()
} else {
playbackManager.next()
}
@@ -286,9 +286,9 @@ class PlaybackService :
startForegroundOrNotify()
}
override fun onLoopModeChanged(loopMode: LoopMode) {
override fun onRepeatChanged(repeatMode: RepeatMode) {
if (!settingsManager.useAltNotifAction) {
notification.setLoopMode(loopMode)
notification.setRepeatMode(repeatMode)
startForegroundOrNotify()
}
}
@@ -317,7 +317,7 @@ class PlaybackService :
if (useAltAction) {
notification.setShuffled(playbackManager.isShuffled)
} else {
notification.setLoopMode(playbackManager.loopMode)
notification.setRepeatMode(playbackManager.repeatMode)
}
startForegroundOrNotify()
@@ -380,7 +380,7 @@ class PlaybackService :
onSongChanged(playbackManager.song)
onSeek(playbackManager.positionMs)
onShuffledChanged(playbackManager.isShuffled)
onLoopModeChanged(playbackManager.loopMode)
onRepeatChanged(playbackManager.repeatMode)
// Notify other classes that rely on this service to also update.
widgets.update()
@@ -450,8 +450,8 @@ class PlaybackService :
// --- AUXIO EVENTS ---
ACTION_PLAY_PAUSE -> playbackManager.isPlaying = !playbackManager.isPlaying
ACTION_LOOP -> playbackManager.loopMode = playbackManager.loopMode.increment()
ACTION_SHUFFLE -> playbackManager.reshuffle(!playbackManager.isShuffled)
ACTION_INC_REPEAT_MODE -> playbackManager.repeatMode = playbackManager.repeatMode.increment()
ACTION_INVERT_SHUFFLE -> playbackManager.reshuffle(!playbackManager.isShuffled)
ACTION_SKIP_PREV -> playbackManager.prev()
ACTION_SKIP_NEXT -> playbackManager.next()
ACTION_EXIT -> {
@@ -492,8 +492,8 @@ class PlaybackService :
companion object {
private const val POS_POLL_INTERVAL = 1000L
const val ACTION_LOOP = BuildConfig.APPLICATION_ID + ".action.LOOP"
const val ACTION_SHUFFLE = BuildConfig.APPLICATION_ID + ".action.SHUFFLE"
const val ACTION_INC_REPEAT_MODE = BuildConfig.APPLICATION_ID + ".action.LOOP"
const val ACTION_INVERT_SHUFFLE = BuildConfig.APPLICATION_ID + ".action.SHUFFLE"
const val ACTION_SKIP_PREV = BuildConfig.APPLICATION_ID + ".action.PREV"
const val ACTION_PLAY_PAUSE = BuildConfig.APPLICATION_ID + ".action.PLAY_PAUSE"
const val ACTION_SKIP_NEXT = BuildConfig.APPLICATION_ID + ".action.NEXT"
@@ -27,8 +27,8 @@ import com.google.android.exoplayer2.Player
import org.oxycblt.auxio.coil.loadBitmap
import org.oxycblt.auxio.music.MusicParent
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.state.LoopMode
import org.oxycblt.auxio.playback.state.PlaybackStateManager
import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.util.logD
/**
@@ -85,12 +85,12 @@ class PlaybackSessionConnector(
}
override fun onSetRepeatMode(repeatMode: Int) {
playbackManager.loopMode =
playbackManager.repeatMode =
when (repeatMode) {
PlaybackStateCompat.REPEAT_MODE_ALL -> LoopMode.ALL
PlaybackStateCompat.REPEAT_MODE_GROUP -> LoopMode.ALL
PlaybackStateCompat.REPEAT_MODE_ONE -> LoopMode.TRACK
else -> LoopMode.NONE
PlaybackStateCompat.REPEAT_MODE_ALL -> RepeatMode.ALL
PlaybackStateCompat.REPEAT_MODE_GROUP -> RepeatMode.ALL
PlaybackStateCompat.REPEAT_MODE_ONE -> RepeatMode.TRACK
else -> RepeatMode.NONE
}
}
@@ -119,10 +119,11 @@ class SettingsManager private constructor(context: Context) :
get() = prefs.getBoolean(KEY_PREV_REWIND, true)
/**
* Whether [org.oxycblt.auxio.playback.state.LoopMode.TRACK] should pause when the track repeats
* Whether [org.oxycblt.auxio.playback.state.RepeatMode.TRACK] should pause when the track
* repeats
*/
val pauseOnLoop: Boolean
get() = prefs.getBoolean(KEY_LOOP_PAUSE, false)
val pauseOnRepeat: Boolean
get() = prefs.getBoolean(KEY_PAUSE_ON_REPEAT, false)
/** The current filter mode of the search tab */
var searchFilterMode: DisplayMode?
@@ -272,7 +273,7 @@ class SettingsManager private constructor(context: Context) :
const val KEY_SONG_PLAYBACK_MODE = "KEY_SONG_PLAY_MODE2"
const val KEY_KEEP_SHUFFLE = "KEY_KEEP_SHUFFLE"
const val KEY_PREV_REWIND = "KEY_PREV_REWIND"
const val KEY_LOOP_PAUSE = "KEY_LOOP_PAUSE"
const val KEY_PAUSE_ON_REPEAT = "KEY_LOOP_PAUSE"
const val KEY_SAVE_STATE = "auxio_save_state"
const val KEY_RELOAD = "auxio_reload"
@@ -21,7 +21,7 @@ import android.content.Context
import android.widget.RemoteViews
import androidx.annotation.LayoutRes
import org.oxycblt.auxio.R
import org.oxycblt.auxio.playback.state.LoopMode
import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.playback.system.PlaybackService
import org.oxycblt.auxio.util.newBroadcastIntent
import org.oxycblt.auxio.util.newMainIntent
@@ -81,9 +81,7 @@ fun createLargeWidget(context: Context, state: WidgetState): RemoteViews {
private fun createViews(context: Context, @LayoutRes layout: Int): RemoteViews {
val views = RemoteViews(context.packageName, layout)
views.setOnClickPendingIntent(android.R.id.background, context.newMainIntent())
return views
}
@@ -141,10 +139,10 @@ private fun RemoteViews.applyFullControls(context: Context, state: WidgetState):
applyBasicControls(context, state)
setOnClickPendingIntent(
R.id.widget_loop, context.newBroadcastIntent(PlaybackService.ACTION_LOOP))
R.id.widget_repeat, context.newBroadcastIntent(PlaybackService.ACTION_INC_REPEAT_MODE))
setOnClickPendingIntent(
R.id.widget_shuffle, context.newBroadcastIntent(PlaybackService.ACTION_SHUFFLE))
R.id.widget_shuffle, context.newBroadcastIntent(PlaybackService.ACTION_INVERT_SHUFFLE))
// Like notifications, use the remote variants of icons since we really don't want to hack
// indicators.
@@ -154,15 +152,15 @@ private fun RemoteViews.applyFullControls(context: Context, state: WidgetState):
else -> R.drawable.ic_remote_shuffle_off
}
val loopRes =
when (state.loopMode) {
LoopMode.NONE -> R.drawable.ic_remote_loop_off
LoopMode.ALL -> R.drawable.ic_loop_on
LoopMode.TRACK -> R.drawable.ic_loop_one
val repeatRes =
when (state.repeatMode) {
RepeatMode.NONE -> R.drawable.ic_remote_repeat_off
RepeatMode.ALL -> R.drawable.ic_repeat_on
RepeatMode.TRACK -> R.drawable.ic_repeat_one
}
setImageViewResource(R.id.widget_shuffle, shuffleRes)
setImageViewResource(R.id.widget_loop, loopRes)
setImageViewResource(R.id.widget_repeat, repeatRes)
return this
}
@@ -20,8 +20,8 @@ package org.oxycblt.auxio.widgets
import android.content.Context
import org.oxycblt.auxio.music.MusicParent
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.state.LoopMode
import org.oxycblt.auxio.playback.state.PlaybackStateManager
import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.settings.SettingsManager
import org.oxycblt.auxio.util.logD
@@ -82,7 +82,7 @@ class WidgetController(private val context: Context) :
widget.update(context, playbackManager)
}
override fun onLoopModeChanged(loopMode: LoopMode) {
override fun onRepeatChanged(repeatMode: RepeatMode) {
widget.update(context, playbackManager)
}
@@ -74,7 +74,7 @@ class WidgetProvider : AppWidgetProvider() {
bitmap,
playbackManager.isPlaying,
playbackManager.isShuffled,
playbackManager.loopMode)
playbackManager.repeatMode)
// Map each widget form to the cells where it would look at least okay.
val views =
@@ -19,7 +19,7 @@ package org.oxycblt.auxio.widgets
import android.graphics.Bitmap
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.state.LoopMode
import org.oxycblt.auxio.playback.state.RepeatMode
/*
* An immutable condensed variant of the current playback state, used so that PlaybackStateManager
@@ -30,5 +30,5 @@ data class WidgetState(
val albumArt: Bitmap?,
val isPlaying: Boolean,
val isShuffled: Boolean,
val loopMode: LoopMode,
val repeatMode: RepeatMode,
)