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() {
NotificationUtil.getInstance().recreateBackgroundPlayerNotification(playerImpl, true);
NotificationUtil.getInstance().recreateNotification(playerImpl, true);
NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 0, false);
NotificationUtil.getInstance().startForegroundServiceWithNotification(this);
}

View File

@ -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;
}

View File

@ -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