From bfc987f81b482ecab1669c3c35f3bd5b5107f33f Mon Sep 17 00:00:00 2001 From: Peter Hindes Date: Mon, 14 Oct 2019 18:01:15 -0600 Subject: [PATCH 1/2] Revert "Revert "Added a restart song button to signle track expanded notification"" This reverts commit 646e327ed2972811c595cac6d0543baaad61e44b. --- .../schabi/newpipe/player/BackgroundPlayer.java | 14 ++++++++++++-- .../res/layout/player_notification_expanded.xml | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index ab07ded22..42ed546f1 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -219,20 +219,30 @@ public final class BackgroundPlayer extends Service { remoteViews.setOnClickPendingIntent(R.id.notificationContent, PendingIntent.getActivity(this, NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT)); - if (basePlayerImpl.playQueue != null && basePlayerImpl.playQueue.size() > 1) { + // Lets check if we are playing more than one song in the background + if (basePlayerImpl.playQueue != null && basePlayerImpl.playQueue.size() > 1) { // If we have more than one song + // Use track skiping for forward and back remoteViews.setInt(R.id.notificationFRewind, SET_IMAGE_RESOURCE_METHOD, R.drawable.exo_controls_previous); remoteViews.setInt(R.id.notificationFForward, SET_IMAGE_RESOURCE_METHOD, R.drawable.exo_controls_next); remoteViews.setOnClickPendingIntent(R.id.notificationFRewind, PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_PLAY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT)); remoteViews.setOnClickPendingIntent(R.id.notificationFForward, PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_PLAY_NEXT), PendingIntent.FLAG_UPDATE_CURRENT)); - } else { + // We dont need a restart track button (skip track backwards) + remoteViews.setViewVisibility(R.id.notificationRestartTrack, View.INVISIBLE); + } else { // But if we only have one song + // Use time skipping for fastforward/rewind remoteViews.setInt(R.id.notificationFRewind, SET_IMAGE_RESOURCE_METHOD, R.drawable.exo_controls_rewind); remoteViews.setInt(R.id.notificationFForward, SET_IMAGE_RESOURCE_METHOD, R.drawable.exo_controls_fastforward); remoteViews.setOnClickPendingIntent(R.id.notificationFRewind, PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_FAST_REWIND), PendingIntent.FLAG_UPDATE_CURRENT)); remoteViews.setOnClickPendingIntent(R.id.notificationFForward, PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_FAST_FORWARD), PendingIntent.FLAG_UPDATE_CURRENT)); + // Add a restart track button (skip track backwards) + remoteViews.setViewVisibility(R.id.notificationRestartTrack, View.VISIBLE); + remoteViews.setOnClickPendingIntent(R.id.notificationRestartTrack, + PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_PLAY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT)); + } setRepeatModeIcon(remoteViews, basePlayerImpl.getRepeatMode()); diff --git a/app/src/main/res/layout/player_notification_expanded.xml b/app/src/main/res/layout/player_notification_expanded.xml index 090642303..d8ed96bf0 100644 --- a/app/src/main/res/layout/player_notification_expanded.xml +++ b/app/src/main/res/layout/player_notification_expanded.xml @@ -116,6 +116,22 @@ android:src="@drawable/ic_repeat_white" tools:ignore="ContentDescription"/> + + Date: Tue, 15 Oct 2019 07:18:06 -0600 Subject: [PATCH 2/2] Fixes Improved --- .../playlist/model/PlaylistRemoteEntity.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistRemoteEntity.java b/app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistRemoteEntity.java index 2fc6cfde7..d51267220 100644 --- a/app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistRemoteEntity.java +++ b/app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistRemoteEntity.java @@ -16,8 +16,6 @@ import static org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity.RE import static org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity.REMOTE_PLAYLIST_TABLE; import static org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity.REMOTE_PLAYLIST_URL; -import android.text.TextUtils; - @Entity(tableName = REMOTE_PLAYLIST_TABLE, indices = { @Index(value = {REMOTE_PLAYLIST_NAME}), @@ -75,19 +73,18 @@ public class PlaylistRemoteEntity implements PlaylistLocalItem { @Ignore public boolean isIdenticalTo(final PlaylistInfo info) { /* - // Returns boolean comparing the online playlist and the local copy. - // (False if info changed such as playlist name or track count) - // [Note that we don't check if the playlist creator changed: - // getUploader().equals(info.getUploaderName()) - // because this would crash the app on playlists that are auto-generated with no creator, - // and the creator can not change to my knowledge. - // if you need this functionality back please use - // getUploader() == info.getUploaderName() - // instead as it will work with blank names (Null value if I remember correctly). + * Returns boolean comparing the online playlist and the local copy. + * (False if info changed such as playlist name or track count) + * [Note that + * getUploader().equals(info.getUploaderName()) + * crashes the app on playlists that are auto-generated with no creator, + * please use + * getUploader() == info.getUploaderName() + * instead as it will work with blank names (Null value if I remember correctly). */ return getServiceId() == info.getServiceId() && getName().equals(info.getName()) && getStreamCount() == info.getStreamCount() && getUrl().equals(info.getUrl()) && - getThumbnailUrl().equals(info.getThumbnailUrl()); + getThumbnailUrl().equals(info.getThumbnailUrl()) && getUploader() == info.getUploaderName(); } public long getUid() {