Added custom actions
parent
6fde42ba11
commit
ce30e1ebbe
|
@ -52,6 +52,10 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
||||||
//view.setOnClickListener(v -> NavigationUtil.gotoNowPlayingActivity(getContext()));
|
//view.setOnClickListener(v -> NavigationUtil.gotoNowPlayingActivity(getContext()));
|
||||||
setUpMiniPlayer()
|
setUpMiniPlayer()
|
||||||
|
|
||||||
|
miniPlayerImage.setOnClickListener {
|
||||||
|
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||||
|
}
|
||||||
|
|
||||||
if (RetroUtil.isTablet()) {
|
if (RetroUtil.isTablet()) {
|
||||||
actionNext.visibility = View.VISIBLE
|
actionNext.visibility = View.VISIBLE
|
||||||
actionPrevious.visibility = View.VISIBLE
|
actionPrevious.visibility = View.VISIBLE
|
||||||
|
@ -96,12 +100,12 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
||||||
override fun onServiceConnected() {
|
override fun onServiceConnected() {
|
||||||
updateSongTitle()
|
updateSongTitle()
|
||||||
updatePlayPauseDrawableState()
|
updatePlayPauseDrawableState()
|
||||||
//updateIsFavorite()
|
updateIsFavorite()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPlayingMetaChanged() {
|
override fun onPlayingMetaChanged() {
|
||||||
updateSongTitle()
|
updateSongTitle()
|
||||||
//updateIsFavorite()
|
updateIsFavorite()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPlayStateChanged() {
|
override fun onPlayStateChanged() {
|
||||||
|
@ -166,7 +170,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
||||||
fun toggleFavorite(song: Song) {
|
fun toggleFavorite(song: Song) {
|
||||||
MusicUtil.toggleFavorite(requireActivity(), song)
|
MusicUtil.toggleFavorite(requireActivity(), song)
|
||||||
if (song.id == MusicPlayerRemote.currentSong.id) {
|
if (song.id == MusicPlayerRemote.currentSong.id) {
|
||||||
//updateIsFavorite()
|
updateIsFavorite()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,12 @@ import android.os.Bundle
|
||||||
import android.support.v4.media.session.MediaSessionCompat
|
import android.support.v4.media.session.MediaSessionCompat
|
||||||
import code.name.monkey.retromusic.auto.AutoMediaIDHelper
|
import code.name.monkey.retromusic.auto.AutoMediaIDHelper
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote.cycleRepeatMode
|
||||||
import code.name.monkey.retromusic.helper.ShuffleHelper
|
import code.name.monkey.retromusic.helper.ShuffleHelper
|
||||||
import code.name.monkey.retromusic.loaders.*
|
import code.name.monkey.retromusic.loaders.*
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.providers.MusicPlaybackQueueStore
|
import code.name.monkey.retromusic.providers.MusicPlaybackQueueStore
|
||||||
import code.name.monkey.retromusic.service.MusicService.TOGGLE_FAVORITE
|
import code.name.monkey.retromusic.service.MusicService.*
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ class MediaSessionCallback(private val context: Context,
|
||||||
|
|
||||||
override fun onCustomAction(action: String, extras: Bundle?) {
|
override fun onCustomAction(action: String, extras: Bundle?) {
|
||||||
when (action) {
|
when (action) {
|
||||||
/* CYCLE_REPEAT -> {
|
CYCLE_REPEAT -> {
|
||||||
cycleRepeatMode()
|
cycleRepeatMode()
|
||||||
musicService.updateMediaSessionPlaybackState()
|
musicService.updateMediaSessionPlaybackState()
|
||||||
}
|
}
|
||||||
|
@ -134,7 +135,6 @@ class MediaSessionCallback(private val context: Context,
|
||||||
musicService.toggleShuffle()
|
musicService.toggleShuffle()
|
||||||
musicService.updateMediaSessionPlaybackState()
|
musicService.updateMediaSessionPlaybackState()
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
TOGGLE_FAVORITE -> {
|
TOGGLE_FAVORITE -> {
|
||||||
MusicUtil.toggleFavorite(context, MusicPlayerRemote.currentSong)
|
MusicUtil.toggleFavorite(context, MusicPlayerRemote.currentSong)
|
||||||
musicService.updateMediaSessionPlaybackState()
|
musicService.updateMediaSessionPlaybackState()
|
||||||
|
|
|
@ -464,6 +464,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
unregisterReceiver(widgetIntentReceiver);
|
unregisterReceiver(widgetIntentReceiver);
|
||||||
|
unregisterReceiver(updateFavoriteReceiver);
|
||||||
if (becomingNoisyReceiverRegistered) {
|
if (becomingNoisyReceiverRegistered) {
|
||||||
unregisterReceiver(becomingNoisyReceiver);
|
unregisterReceiver(becomingNoisyReceiver);
|
||||||
becomingNoisyReceiverRegistered = false;
|
becomingNoisyReceiverRegistered = false;
|
||||||
|
|
|
@ -153,13 +153,13 @@ class PlayingNotificationOreo : PlayingNotification() {
|
||||||
val secondary = MaterialValueHelper.getSecondaryTextColor(service, dark)
|
val secondary = MaterialValueHelper.getSecondaryTextColor(service, dark)
|
||||||
|
|
||||||
val close = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_close_white_24dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
|
val close = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_close_white_24dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
|
||||||
val prev = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
|
val prev = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_round_white_32dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
|
||||||
val next = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
|
val next = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_round_white_32dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
|
||||||
val playPause = createBitmap(RetroUtil.getTintedVectorDrawable(service,
|
val playPause = createBitmap(RetroUtil.getTintedVectorDrawable(service,
|
||||||
if (isPlaying)
|
if (isPlaying)
|
||||||
R.drawable.ic_pause_white_24dp
|
R.drawable.ic_pause_white_48dp
|
||||||
else
|
else
|
||||||
R.drawable.ic_play_arrow_white_32dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
|
R.drawable.ic_play_arrow_white_48dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
|
||||||
|
|
||||||
notificationLayout.setTextColor(R.id.title, primary)
|
notificationLayout.setTextColor(R.id.title, primary)
|
||||||
notificationLayout.setTextColor(R.id.subtitle, secondary)
|
notificationLayout.setTextColor(R.id.subtitle, secondary)
|
||||||
|
|
Loading…
Reference in New Issue