Rename notification functions: they are not background player only

This commit is contained in:
Stypox 2020-08-15 15:16:17 +02:00
parent 1a8ff81087
commit adef9a8acf
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
3 changed files with 19 additions and 20 deletions

View file

@ -244,7 +244,7 @@ public final class MainPlayer extends Service {
} }
private void showNotificationAndStartForeground() { private void showNotificationAndStartForeground() {
NotificationUtil.getInstance().recreateBackgroundPlayerNotification(playerImpl, true); NotificationUtil.getInstance().recreateNotification(playerImpl, true);
NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 0, false); NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 0, false);
NotificationUtil.getInstance().startForegroundServiceWithNotification(this); NotificationUtil.getInstance().startForegroundServiceWithNotification(this);
} }

View file

@ -81,7 +81,7 @@ public final class NotificationUtil {
// NOTIFICATION // NOTIFICATION
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
NotificationCompat.Builder createBackgroundPlayerNotification(final VideoPlayerImpl player) { NotificationCompat.Builder createNotification(final VideoPlayerImpl player) {
notificationManager = notificationManager =
(NotificationManager) player.context.getSystemService(NOTIFICATION_SERVICE); (NotificationManager) player.context.getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(player.context, 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 player the player currently open, to take data from
* @param playPauseDrawable if != -1, sets the drawable with that id on the play/pause button * @param playPauseDrawable if != -1, sets the drawable with that id on the play/pause button
*/ */
synchronized void updateBackgroundPlayerNotification(final VideoPlayerImpl player, synchronized void updateNotification(final VideoPlayerImpl player,
@DrawableRes final int playPauseDrawable) { @DrawableRes final int playPauseDrawable) {
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "N_ updateBackgroundPlayerNotification()"); Log.d(TAG, "N_ updateNotification()");
} }
if (notificationBuilder == null) { if (notificationBuilder == null) {
@ -232,15 +232,14 @@ public final class NotificationUtil {
} }
} }
void recreateBackgroundPlayerNotification(final VideoPlayerImpl player, void recreateNotification(final VideoPlayerImpl player, final boolean recreate) {
final boolean recreate) {
final boolean areOldNotificationsEnabled = player.sharedPreferences.getBoolean( final boolean areOldNotificationsEnabled = player.sharedPreferences.getBoolean(
player.context.getString(R.string.enable_old_notifications_key), false); player.context.getString(R.string.enable_old_notifications_key), false);
if (notificationBuilder == null || recreate || areOldNotificationsEnabled) { if (notificationBuilder == null || recreate || areOldNotificationsEnabled) {
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "N_ recreateBackgroundPlayerNotification(true)"); Log.d(TAG, "N_ recreateNotification(true)");
} }
notificationBuilder = createBackgroundPlayerNotification(player); notificationBuilder = createNotification(player);
} }
timesNotificationUpdated = 0; timesNotificationUpdated = 0;
} }

View file

@ -652,7 +652,7 @@ public class VideoPlayerImpl extends VideoPlayer
} }
if (NotificationUtil.getInstance().shouldRecreateOldNotification()) { if (NotificationUtil.getInstance().shouldRecreateOldNotification()) {
NotificationUtil.getInstance().recreateBackgroundPlayerNotification(this, false); NotificationUtil.getInstance().recreateNotification(this, false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail()); NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail());
@ -664,7 +664,7 @@ public class VideoPlayerImpl extends VideoPlayer
NotificationUtil.getInstance().setProgressbarOnOldNotifications(duration, NotificationUtil.getInstance().setProgressbarOnOldNotifications(duration,
currentProgress, false); currentProgress, false);
NotificationUtil.getInstance().updateBackgroundPlayerNotification(this, -1); NotificationUtil.getInstance().updateNotification(this, -1);
} }
} }
@ -1083,8 +1083,8 @@ public class VideoPlayerImpl extends VideoPlayer
animatePlayButtons(false, 100); animatePlayButtons(false, 100);
getRootView().setKeepScreenOn(false); getRootView().setKeepScreenOn(false);
NotificationUtil.getInstance().recreateBackgroundPlayerNotification(this, false); NotificationUtil.getInstance().recreateNotification(this, false);
NotificationUtil.getInstance().updateBackgroundPlayerNotification( NotificationUtil.getInstance().updateNotification(
this, R.drawable.ic_play_arrow_white_24dp); this, R.drawable.ic_play_arrow_white_24dp);
} }
@ -1101,7 +1101,7 @@ public class VideoPlayerImpl extends VideoPlayer
isForwardPressed = false; isForwardPressed = false;
isRewindPressed = false; isRewindPressed = false;
} else { } else {
NotificationUtil.getInstance().updateBackgroundPlayerNotification(this, -1); NotificationUtil.getInstance().updateNotification(this, -1);
} }
} }
} }
@ -1154,8 +1154,8 @@ public class VideoPlayerImpl extends VideoPlayer
animatePlayButtons(false, 100); animatePlayButtons(false, 100);
getRootView().setKeepScreenOn(true); getRootView().setKeepScreenOn(true);
NotificationUtil.getInstance().recreateBackgroundPlayerNotification(this, false); NotificationUtil.getInstance().recreateNotification(this, false);
NotificationUtil.getInstance().updateBackgroundPlayerNotification( NotificationUtil.getInstance().updateNotification(
this, R.drawable.ic_play_arrow_white_24dp); this, R.drawable.ic_play_arrow_white_24dp);
} }
@ -1170,10 +1170,10 @@ public class VideoPlayerImpl extends VideoPlayer
getRootView().setKeepScreenOn(false); getRootView().setKeepScreenOn(false);
updateWindowFlags(IDLE_WINDOW_FLAGS); updateWindowFlags(IDLE_WINDOW_FLAGS);
NotificationUtil.getInstance().recreateBackgroundPlayerNotification(this, false); NotificationUtil.getInstance().recreateNotification(this, false);
NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 100, false); NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 100, false);
NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail()); NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail());
NotificationUtil.getInstance().updateBackgroundPlayerNotification( NotificationUtil.getInstance().updateNotification(
this, R.drawable.ic_replay_white_24dp); this, R.drawable.ic_replay_white_24dp);
super.onCompleted(); super.onCompleted();
@ -1335,9 +1335,9 @@ public class VideoPlayerImpl extends VideoPlayer
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
void resetNotification(final boolean recreate, @DrawableRes final int drawableId) { 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().updateOldNotificationsThumbnail(getThumbnail());
NotificationUtil.getInstance().updateBackgroundPlayerNotification(this, drawableId); NotificationUtil.getInstance().updateNotification(this, drawableId);
} }
@Override @Override