allow skipping forward/backward by pressing the current/max track progress
This commit is contained in:
parent
a086bad5d3
commit
714158d3e9
7 changed files with 30 additions and 28 deletions
|
@ -222,7 +222,7 @@ class MainActivity : SimpleActivity(), MainActivityInterface {
|
|||
}
|
||||
)
|
||||
|
||||
val tabLabels = arrayOf("PLAYER", "PLAYLISTS", "ARTISTS")
|
||||
val tabLabels = arrayOf("ARTISTS", "PLAYLISTS")
|
||||
main_tabs_holder.apply {
|
||||
setTabTextColors(config.backgroundColor.getContrastColor(), getAdjustedPrimaryColor())
|
||||
setSelectedTabIndicatorColor(getAdjustedPrimaryColor())
|
||||
|
@ -464,14 +464,14 @@ class MainActivity : SimpleActivity(), MainActivityInterface {
|
|||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun songChangedEvent(event: Events.TrackChanged) {
|
||||
fun trackChangedEvent(event: Events.TrackChanged) {
|
||||
if (wasInitialPlaylistSet) {
|
||||
getCurrentFragment()?.songChangedEvent(event.track)
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun songStateChanged(event: Events.SongStateChanged) {
|
||||
fun trackStateChanged(event: Events.TrackStateChanged) {
|
||||
getCurrentFragment()?.songStateChanged(event.isPlaying)
|
||||
}
|
||||
|
||||
|
|
|
@ -86,9 +86,11 @@ class TrackActivity : SimpleActivity() {
|
|||
activity_track_previous.setOnClickListener { sendIntent(PREVIOUS) }
|
||||
activity_track_play_pause.setOnClickListener { sendIntent(PLAYPAUSE) }
|
||||
activity_track_next.setOnClickListener { sendIntent(NEXT) }
|
||||
activity_track_repeat.setOnClickListener { toggleSongRepetition() }
|
||||
activity_track_progress_current.setOnClickListener { sendIntent(SKIP_BACKWARD) }
|
||||
activity_track_progress_max.setOnClickListener { sendIntent(SKIP_FORWARD) }
|
||||
activity_track_repeat.setOnClickListener { toggleTrackRepetition() }
|
||||
setupShuffleButton()
|
||||
setupSongRepetitionButton()
|
||||
setupTrackRepetitionButton()
|
||||
setupSeekbar()
|
||||
}
|
||||
|
||||
|
@ -127,19 +129,19 @@ class TrackActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun toggleSongRepetition() {
|
||||
val repeatSong = !config.repeatSong
|
||||
config.repeatSong = repeatSong
|
||||
toast(if (repeatSong) R.string.song_repetition_enabled else R.string.song_repetition_disabled)
|
||||
setupSongRepetitionButton()
|
||||
private fun toggleTrackRepetition() {
|
||||
val repeatTrack = !config.repeatTrack
|
||||
config.repeatTrack = repeatTrack
|
||||
toast(if (repeatTrack) R.string.song_repetition_enabled else R.string.song_repetition_disabled)
|
||||
setupTrackRepetitionButton()
|
||||
}
|
||||
|
||||
private fun setupSongRepetitionButton() {
|
||||
val repeatSong = config.repeatSong
|
||||
private fun setupTrackRepetitionButton() {
|
||||
val repeatTrack = config.repeatTrack
|
||||
activity_track_repeat.apply {
|
||||
applyColorFilter(if (repeatSong) getAdjustedPrimaryColor() else config.textColor)
|
||||
alpha = if (repeatSong) 1f else LOWER_ALPHA
|
||||
contentDescription = getString(if (repeatSong) R.string.disable_song_repetition else R.string.enable_song_repetition)
|
||||
applyColorFilter(if (repeatTrack) getAdjustedPrimaryColor() else config.textColor)
|
||||
alpha = if (repeatTrack) 1f else LOWER_ALPHA
|
||||
contentDescription = getString(if (repeatTrack) R.string.disable_song_repetition else R.string.enable_song_repetition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,13 +176,13 @@ class TrackActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun songStateChanged(event: Events.SongStateChanged) {
|
||||
fun trackStateChanged(event: Events.TrackStateChanged) {
|
||||
val drawableId = if (event.isPlaying) R.drawable.ic_pause_vector else R.drawable.ic_play_vector
|
||||
activity_track_play_pause.setImageDrawable(resources.getDrawable(drawableId))
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun songChangedEvent(event: Events.TrackChanged) {
|
||||
fun trackChangedEvent(event: Events.TrackChanged) {
|
||||
val track = event.track
|
||||
if (track == null) {
|
||||
finish()
|
||||
|
|
|
@ -430,8 +430,8 @@ class OldSongAdapter(activity: SimpleActivity, var songs: ArrayList<Track>, val
|
|||
shuffle_btn.applyColorFilter(if (config.isShuffleEnabled) adjustedPrimaryColor else textColor)
|
||||
shuffle_btn.alpha = if (config.isShuffleEnabled) 1f else LOWER_ALPHA
|
||||
|
||||
repeat_btn.applyColorFilter(if (config.repeatSong) adjustedPrimaryColor else textColor)
|
||||
repeat_btn.alpha = if (config.repeatSong) 1f else LOWER_ALPHA
|
||||
repeat_btn.applyColorFilter(if (config.repeatTrack) adjustedPrimaryColor else textColor)
|
||||
repeat_btn.alpha = if (config.repeatTrack) 1f else LOWER_ALPHA
|
||||
|
||||
song_info_title.setTextColor(textColor)
|
||||
song_info_artist.setTextColor(textColor)
|
||||
|
|
|
@ -165,8 +165,8 @@ class SongsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
}
|
||||
|
||||
override fun toggleSongRepetition() {
|
||||
val repeatSong = !config.repeatSong
|
||||
config.repeatSong = repeatSong
|
||||
val repeatSong = !config.repeatTrack
|
||||
config.repeatTrack = repeatSong
|
||||
repeat_btn.applyColorFilter(if (repeatSong) activity.getAdjustedPrimaryColor() else config.textColor)
|
||||
repeat_btn.alpha = if (repeatSong) 1f else LOWER_ALPHA
|
||||
repeat_btn.contentDescription = activity.getString(if (repeatSong) R.string.disable_song_repetition else R.string.enable_song_repetition)
|
||||
|
@ -189,8 +189,8 @@ class SongsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
shuffle_btn.applyColorFilter(if (config.isShuffleEnabled) activity.getAdjustedPrimaryColor() else config.textColor)
|
||||
shuffle_btn.alpha = if (config.isShuffleEnabled) 1f else LOWER_ALPHA
|
||||
|
||||
repeat_btn.applyColorFilter(if (config.repeatSong) activity.getAdjustedPrimaryColor() else config.textColor)
|
||||
repeat_btn.alpha = if (config.repeatSong) 1f else LOWER_ALPHA
|
||||
repeat_btn.applyColorFilter(if (config.repeatTrack) activity.getAdjustedPrimaryColor() else config.textColor)
|
||||
repeat_btn.alpha = if (config.repeatTrack) 1f else LOWER_ALPHA
|
||||
|
||||
getSongsAdapter()?.updateTextColor(textColor)
|
||||
songs_fastscroller.updatePrimaryColor()
|
||||
|
@ -198,7 +198,7 @@ class SongsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
|
||||
private fun setupIconDescriptions() {
|
||||
shuffle_btn.contentDescription = activity.getString(if (config.isShuffleEnabled) R.string.disable_shuffle else R.string.enable_shuffle)
|
||||
repeat_btn.contentDescription = activity.getString(if (config.repeatSong) R.string.disable_song_repetition else R.string.enable_song_repetition)
|
||||
repeat_btn.contentDescription = activity.getString(if (config.repeatTrack) R.string.disable_song_repetition else R.string.enable_song_repetition)
|
||||
}
|
||||
|
||||
private fun songPicked(pos: Int) {
|
||||
|
|
|
@ -20,7 +20,7 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getInt(CURRENT_PLAYLIST, ALL_TRACKS_PLAYLIST_ID)
|
||||
set(currentPlaylist) = prefs.edit().putInt(CURRENT_PLAYLIST, currentPlaylist).apply()
|
||||
|
||||
var repeatSong: Boolean
|
||||
var repeatTrack: Boolean
|
||||
get() = prefs.getBoolean(REPEAT_TRACK, false)
|
||||
set(repeat) = prefs.edit().putBoolean(REPEAT_TRACK, repeat).apply()
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.*
|
|||
|
||||
class Events {
|
||||
class TrackChanged(val track: Track?)
|
||||
class SongStateChanged(val isPlaying: Boolean)
|
||||
class TrackStateChanged(val isPlaying: Boolean)
|
||||
class PlaylistUpdated(val tracks: ArrayList<Track>)
|
||||
class ProgressUpdated(val progress: Int)
|
||||
class SleepTimerChanged(val seconds: Int)
|
||||
|
|
|
@ -709,7 +709,7 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
|
|||
return
|
||||
}
|
||||
|
||||
if (config.repeatSong) {
|
||||
if (config.repeatTrack) {
|
||||
restartTrack()
|
||||
} else if (mPlayer!!.currentPosition > 0) {
|
||||
mPlayer!!.reset()
|
||||
|
@ -753,7 +753,7 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
|
|||
|
||||
private fun broadcastTrackStateChange(isPlaying: Boolean) {
|
||||
broadcastUpdateWidgetTrackState(isPlaying)
|
||||
EventBus.getDefault().post(Events.SongStateChanged(isPlaying))
|
||||
EventBus.getDefault().post(Events.TrackStateChanged(isPlaying))
|
||||
}
|
||||
|
||||
// do not just return the album cover, but also a boolean to indicate if it a real cover, or just the placeholder
|
||||
|
|
Loading…
Reference in a new issue