Added custom actions

This commit is contained in:
h4h13 2019-08-04 21:42:28 +05:30
parent 6fde42ba11
commit ce30e1ebbe
4 changed files with 22 additions and 17 deletions

View file

@ -52,6 +52,10 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
//view.setOnClickListener(v -> NavigationUtil.gotoNowPlayingActivity(getContext()));
setUpMiniPlayer()
miniPlayerImage.setOnClickListener {
toggleFavorite(MusicPlayerRemote.currentSong)
}
if (RetroUtil.isTablet()) {
actionNext.visibility = View.VISIBLE
actionPrevious.visibility = View.VISIBLE
@ -96,12 +100,12 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
override fun onServiceConnected() {
updateSongTitle()
updatePlayPauseDrawableState()
//updateIsFavorite()
updateIsFavorite()
}
override fun onPlayingMetaChanged() {
updateSongTitle()
//updateIsFavorite()
updateIsFavorite()
}
override fun onPlayStateChanged() {
@ -166,7 +170,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
fun toggleFavorite(song: Song) {
MusicUtil.toggleFavorite(requireActivity(), song)
if (song.id == MusicPlayerRemote.currentSong.id) {
//updateIsFavorite()
updateIsFavorite()
}
}

View file

@ -20,11 +20,12 @@ import android.os.Bundle
import android.support.v4.media.session.MediaSessionCompat
import code.name.monkey.retromusic.auto.AutoMediaIDHelper
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.loaders.*
import code.name.monkey.retromusic.model.Song
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 java.util.*
@ -125,16 +126,15 @@ class MediaSessionCallback(private val context: Context,
override fun onCustomAction(action: String, extras: Bundle?) {
when (action) {
/* CYCLE_REPEAT -> {
cycleRepeatMode()
musicService.updateMediaSessionPlaybackState()
}
CYCLE_REPEAT -> {
cycleRepeatMode()
musicService.updateMediaSessionPlaybackState()
}
TOGGLE_SHUFFLE -> {
musicService.toggleShuffle()
musicService.updateMediaSessionPlaybackState()
}
*/
TOGGLE_SHUFFLE -> {
musicService.toggleShuffle()
musicService.updateMediaSessionPlaybackState()
}
TOGGLE_FAVORITE -> {
MusicUtil.toggleFavorite(context, MusicPlayerRemote.currentSong)
musicService.updateMediaSessionPlaybackState()

View file

@ -464,6 +464,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
@Override
public void onDestroy() {
unregisterReceiver(widgetIntentReceiver);
unregisterReceiver(updateFavoriteReceiver);
if (becomingNoisyReceiverRegistered) {
unregisterReceiver(becomingNoisyReceiver);
becomingNoisyReceiverRegistered = false;

View file

@ -153,13 +153,13 @@ class PlayingNotificationOreo : PlayingNotification() {
val secondary = MaterialValueHelper.getSecondaryTextColor(service, dark)
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 next = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_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_round_white_32dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
val playPause = createBitmap(RetroUtil.getTintedVectorDrawable(service,
if (isPlaying)
R.drawable.ic_pause_white_24dp
R.drawable.ic_pause_white_48dp
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.subtitle, secondary)