From ce30e1ebbe2c99f7d1ee830fc70f6a74c4e93108 Mon Sep 17 00:00:00 2001 From: h4h13 Date: Sun, 4 Aug 2019 21:42:28 +0530 Subject: [PATCH] Added custom actions --- .../fragments/MiniPlayerFragment.kt | 10 +++++++--- .../service/MediaSessionCallback.kt | 20 +++++++++---------- .../retromusic/service/MusicService.java | 1 + .../notification/PlayingNotificationOreo.kt | 8 ++++---- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt index 32e0c014..fcd30d98 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt @@ -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() } } diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MediaSessionCallback.kt b/app/src/main/java/code/name/monkey/retromusic/service/MediaSessionCallback.kt index 06642b9c..38bc22ac 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/MediaSessionCallback.kt +++ b/app/src/main/java/code/name/monkey/retromusic/service/MediaSessionCallback.kt @@ -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() diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java index 9547121c..01bffe2d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java @@ -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; diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt index 84d3554a..36a7b784 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt +++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt @@ -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)