diff --git a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java index 5569b8d06..92c6a3c86 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java @@ -244,7 +244,7 @@ public final class MainPlayer extends Service { } private void showNotificationAndStartForeground() { - NotificationUtil.getInstance().recreateBackgroundPlayerNotification(playerImpl, true); + NotificationUtil.getInstance().recreateNotification(playerImpl, true); NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 0, false); NotificationUtil.getInstance().startForegroundServiceWithNotification(this); } diff --git a/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java b/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java index bfa698cd6..5f7398089 100644 --- a/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java +++ b/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java @@ -81,7 +81,7 @@ public final class NotificationUtil { // NOTIFICATION ///////////////////////////////////////////////////// - NotificationCompat.Builder createBackgroundPlayerNotification(final VideoPlayerImpl player) { + NotificationCompat.Builder createNotification(final VideoPlayerImpl player) { notificationManager = (NotificationManager) player.context.getSystemService(NOTIFICATION_SERVICE); NotificationCompat.Builder builder = new NotificationCompat.Builder(player.context, @@ -183,10 +183,10 @@ public final class NotificationUtil { * @param player the player currently open, to take data from * @param playPauseDrawable if != -1, sets the drawable with that id on the play/pause button */ - synchronized void updateBackgroundPlayerNotification(final VideoPlayerImpl player, - @DrawableRes final int playPauseDrawable) { + synchronized void updateNotification(final VideoPlayerImpl player, + @DrawableRes final int playPauseDrawable) { if (DEBUG) { - Log.d(TAG, "N_ updateBackgroundPlayerNotification()"); + Log.d(TAG, "N_ updateNotification()"); } if (notificationBuilder == null) { @@ -232,15 +232,14 @@ public final class NotificationUtil { } } - void recreateBackgroundPlayerNotification(final VideoPlayerImpl player, - final boolean recreate) { + void recreateNotification(final VideoPlayerImpl player, final boolean recreate) { final boolean areOldNotificationsEnabled = player.sharedPreferences.getBoolean( player.context.getString(R.string.enable_old_notifications_key), false); if (notificationBuilder == null || recreate || areOldNotificationsEnabled) { if (DEBUG) { - Log.d(TAG, "N_ recreateBackgroundPlayerNotification(true)"); + Log.d(TAG, "N_ recreateNotification(true)"); } - notificationBuilder = createBackgroundPlayerNotification(player); + notificationBuilder = createNotification(player); } timesNotificationUpdated = 0; } diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index 1c89cc4b1..e9430be0b 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -652,7 +652,7 @@ public class VideoPlayerImpl extends VideoPlayer } if (NotificationUtil.getInstance().shouldRecreateOldNotification()) { - NotificationUtil.getInstance().recreateBackgroundPlayerNotification(this, false); + NotificationUtil.getInstance().recreateNotification(this, false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail()); @@ -664,7 +664,7 @@ public class VideoPlayerImpl extends VideoPlayer NotificationUtil.getInstance().setProgressbarOnOldNotifications(duration, currentProgress, false); - NotificationUtil.getInstance().updateBackgroundPlayerNotification(this, -1); + NotificationUtil.getInstance().updateNotification(this, -1); } } @@ -1083,8 +1083,8 @@ public class VideoPlayerImpl extends VideoPlayer animatePlayButtons(false, 100); getRootView().setKeepScreenOn(false); - NotificationUtil.getInstance().recreateBackgroundPlayerNotification(this, false); - NotificationUtil.getInstance().updateBackgroundPlayerNotification( + NotificationUtil.getInstance().recreateNotification(this, false); + NotificationUtil.getInstance().updateNotification( this, R.drawable.ic_play_arrow_white_24dp); } @@ -1101,7 +1101,7 @@ public class VideoPlayerImpl extends VideoPlayer isForwardPressed = false; isRewindPressed = false; } else { - NotificationUtil.getInstance().updateBackgroundPlayerNotification(this, -1); + NotificationUtil.getInstance().updateNotification(this, -1); } } } @@ -1154,8 +1154,8 @@ public class VideoPlayerImpl extends VideoPlayer animatePlayButtons(false, 100); getRootView().setKeepScreenOn(true); - NotificationUtil.getInstance().recreateBackgroundPlayerNotification(this, false); - NotificationUtil.getInstance().updateBackgroundPlayerNotification( + NotificationUtil.getInstance().recreateNotification(this, false); + NotificationUtil.getInstance().updateNotification( this, R.drawable.ic_play_arrow_white_24dp); } @@ -1170,10 +1170,10 @@ public class VideoPlayerImpl extends VideoPlayer getRootView().setKeepScreenOn(false); updateWindowFlags(IDLE_WINDOW_FLAGS); - NotificationUtil.getInstance().recreateBackgroundPlayerNotification(this, false); + NotificationUtil.getInstance().recreateNotification(this, false); NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 100, false); NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail()); - NotificationUtil.getInstance().updateBackgroundPlayerNotification( + NotificationUtil.getInstance().updateNotification( this, R.drawable.ic_replay_white_24dp); super.onCompleted(); @@ -1335,9 +1335,9 @@ public class VideoPlayerImpl extends VideoPlayer //////////////////////////////////////////////////////////////////////////*/ void resetNotification(final boolean recreate, @DrawableRes final int drawableId) { - NotificationUtil.getInstance().recreateBackgroundPlayerNotification(this, recreate); + NotificationUtil.getInstance().recreateNotification(this, recreate); NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail()); - NotificationUtil.getInstance().updateBackgroundPlayerNotification(this, drawableId); + NotificationUtil.getInstance().updateNotification(this, drawableId); } @Override