Completely remove old player notification
This commit is contained in:
parent
adef9a8acf
commit
e08480f345
7 changed files with 140 additions and 349 deletions
|
@ -244,8 +244,7 @@ public final class MainPlayer extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showNotificationAndStartForeground() {
|
private void showNotificationAndStartForeground() {
|
||||||
NotificationUtil.getInstance().recreateNotification(playerImpl, true);
|
NotificationUtil.getInstance().createNotificationIfNeeded(playerImpl, true);
|
||||||
NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 0, false);
|
|
||||||
NotificationUtil.getInstance().startForegroundServiceWithNotification(this);
|
NotificationUtil.getInstance().startForegroundServiceWithNotification(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,13 @@ import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.os.Build;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.RemoteViews;
|
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import org.schabi.newpipe.BuildConfig;
|
|
||||||
import org.schabi.newpipe.MainActivity;
|
import org.schabi.newpipe.MainActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
|
@ -34,8 +31,6 @@ import static org.schabi.newpipe.player.MainPlayer.ACTION_PLAY_PAUSE;
|
||||||
import static org.schabi.newpipe.player.MainPlayer.ACTION_PLAY_PREVIOUS;
|
import static org.schabi.newpipe.player.MainPlayer.ACTION_PLAY_PREVIOUS;
|
||||||
import static org.schabi.newpipe.player.MainPlayer.ACTION_REPEAT;
|
import static org.schabi.newpipe.player.MainPlayer.ACTION_REPEAT;
|
||||||
import static org.schabi.newpipe.player.MainPlayer.ACTION_SHUFFLE;
|
import static org.schabi.newpipe.player.MainPlayer.ACTION_SHUFFLE;
|
||||||
import static org.schabi.newpipe.player.MainPlayer.SET_IMAGE_RESOURCE_METHOD;
|
|
||||||
import static org.schabi.newpipe.player.helper.PlayerHelper.getTimeString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a utility class for player notifications.
|
* This is a utility class for player notifications.
|
||||||
|
@ -46,8 +41,6 @@ public final class NotificationUtil {
|
||||||
private static final String TAG = "NotificationUtil";
|
private static final String TAG = "NotificationUtil";
|
||||||
private static final boolean DEBUG = BasePlayer.DEBUG;
|
private static final boolean DEBUG = BasePlayer.DEBUG;
|
||||||
private static final int NOTIFICATION_ID = 123789;
|
private static final int NOTIFICATION_ID = 123789;
|
||||||
// only used for old notifications
|
|
||||||
private static final int NOTIFICATION_UPDATES_BEFORE_RESET = 60;
|
|
||||||
|
|
||||||
@Nullable private static NotificationUtil instance = null;
|
@Nullable private static NotificationUtil instance = null;
|
||||||
|
|
||||||
|
@ -58,14 +51,8 @@ public final class NotificationUtil {
|
||||||
private String notificationSlot4 = "close";
|
private String notificationSlot4 = "close";
|
||||||
|
|
||||||
private NotificationManager notificationManager;
|
private NotificationManager notificationManager;
|
||||||
private RemoteViews notificationRemoteView; // always null when new notifications are used
|
|
||||||
private RemoteViews bigNotificationRemoteView; // always null when new notifications are used
|
|
||||||
private NotificationCompat.Builder notificationBuilder;
|
private NotificationCompat.Builder notificationBuilder;
|
||||||
|
|
||||||
private int cachedDuration; // only used for old notifications
|
|
||||||
private String cachedDurationString; // only used for old notifications
|
|
||||||
private int timesNotificationUpdated; // only used for old notifications
|
|
||||||
|
|
||||||
private NotificationUtil() {
|
private NotificationUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,110 +68,13 @@ public final class NotificationUtil {
|
||||||
// NOTIFICATION
|
// NOTIFICATION
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
NotificationCompat.Builder createNotification(final VideoPlayerImpl player) {
|
|
||||||
notificationManager =
|
|
||||||
(NotificationManager) player.context.getSystemService(NOTIFICATION_SERVICE);
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(player.context,
|
|
||||||
player.context.getString(R.string.notification_channel_id));
|
|
||||||
|
|
||||||
final boolean areOldNotificationsEnabled = player.sharedPreferences.getBoolean(
|
|
||||||
player.context.getString(R.string.enable_old_notifications_key), false);
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || areOldNotificationsEnabled) {
|
|
||||||
notificationRemoteView = new RemoteViews(BuildConfig.APPLICATION_ID,
|
|
||||||
R.layout.player_notification);
|
|
||||||
bigNotificationRemoteView = new RemoteViews(BuildConfig.APPLICATION_ID,
|
|
||||||
R.layout.player_notification_expanded);
|
|
||||||
|
|
||||||
setupOldNotification(notificationRemoteView, player);
|
|
||||||
setupOldNotification(bigNotificationRemoteView, player);
|
|
||||||
|
|
||||||
builder
|
|
||||||
.setOngoing(true)
|
|
||||||
.setSmallIcon(R.drawable.ic_newpipe_triangle_white)
|
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
|
||||||
.setCustomContentView(notificationRemoteView)
|
|
||||||
.setCustomBigContentView(bigNotificationRemoteView)
|
|
||||||
.setPriority(NotificationCompat.PRIORITY_MAX);
|
|
||||||
} else {
|
|
||||||
final String compactView = player.sharedPreferences.getString(player.context.getString(
|
|
||||||
R.string.settings_notifications_compact_view_key), "0,1,2");
|
|
||||||
int compactSlot0 = 0;
|
|
||||||
int compactSlot1 = 1;
|
|
||||||
int compactSlot2 = 2;
|
|
||||||
try {
|
|
||||||
if (compactView != null) {
|
|
||||||
final String[] parts = compactView.split(",");
|
|
||||||
compactSlot0 = Integer.parseInt(parts[0]);
|
|
||||||
compactSlot1 = Integer.parseInt(parts[1]);
|
|
||||||
compactSlot2 = Integer.parseInt(parts[2]);
|
|
||||||
if (compactSlot0 > 4) {
|
|
||||||
compactSlot0 = 0;
|
|
||||||
}
|
|
||||||
if (compactSlot1 > 4) {
|
|
||||||
compactSlot1 = 1;
|
|
||||||
}
|
|
||||||
if (compactSlot2 > 4) {
|
|
||||||
compactSlot2 = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
|
|
||||||
.setMediaSession(player.mediaSessionManager.getSessionToken())
|
|
||||||
.setShowCancelButton(false)
|
|
||||||
.setShowActionsInCompactView(compactSlot0, compactSlot1, compactSlot2))
|
|
||||||
.setOngoing(false)
|
|
||||||
.setContentIntent(PendingIntent.getActivity(player.context, NOTIFICATION_ID,
|
|
||||||
getIntentForNotification(player), FLAG_UPDATE_CURRENT))
|
|
||||||
.setSmallIcon(R.drawable.ic_newpipe_triangle_white)
|
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
|
||||||
.setContentTitle(player.getVideoTitle())
|
|
||||||
.setContentText(player.getUploaderName())
|
|
||||||
.setDeleteIntent(PendingIntent.getActivity(player.context, NOTIFICATION_ID,
|
|
||||||
new Intent(ACTION_CLOSE), FLAG_UPDATE_CURRENT))
|
|
||||||
.setColor(ContextCompat.getColor(player.context, R.color.gray))
|
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH);
|
|
||||||
final boolean scaleImageToSquareAspectRatio = player.sharedPreferences.getBoolean(
|
|
||||||
player.context.getString(R.string.scale_to_square_image_in_notifications_key),
|
|
||||||
false);
|
|
||||||
if (scaleImageToSquareAspectRatio) {
|
|
||||||
builder.setLargeIcon(getBitmapWithSquareAspectRatio(player.getThumbnail()));
|
|
||||||
} else {
|
|
||||||
builder.setLargeIcon(player.getThumbnail());
|
|
||||||
}
|
|
||||||
|
|
||||||
notificationSlot0 = player.sharedPreferences.getString(
|
|
||||||
player.context.getString(R.string.notification_slot_0_key), notificationSlot0);
|
|
||||||
notificationSlot1 = player.sharedPreferences.getString(
|
|
||||||
player.context.getString(R.string.notification_slot_1_key), notificationSlot1);
|
|
||||||
notificationSlot2 = player.sharedPreferences.getString(
|
|
||||||
player.context.getString(R.string.notification_slot_2_key), notificationSlot2);
|
|
||||||
notificationSlot3 = player.sharedPreferences.getString(
|
|
||||||
player.context.getString(R.string.notification_slot_3_key), notificationSlot3);
|
|
||||||
notificationSlot4 = player.sharedPreferences.getString(
|
|
||||||
player.context.getString(R.string.notification_slot_4_key), notificationSlot4);
|
|
||||||
|
|
||||||
addAction(builder, player, notificationSlot0);
|
|
||||||
addAction(builder, player, notificationSlot1);
|
|
||||||
addAction(builder, player, notificationSlot2);
|
|
||||||
addAction(builder, player, notificationSlot3);
|
|
||||||
addAction(builder, player, notificationSlot4);
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the notification, and the button icons depending on the playback state.
|
* Updates the notification, and the button icons depending on the playback state.
|
||||||
* On old notifications used for changes on the remoteView
|
* On old notifications used for changes on the remoteView
|
||||||
*
|
*
|
||||||
* @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
|
|
||||||
*/
|
*/
|
||||||
synchronized void updateNotification(final VideoPlayerImpl player,
|
synchronized void updateNotification(final VideoPlayerImpl player) {
|
||||||
@DrawableRes final int playPauseDrawable) {
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "N_ updateNotification()");
|
Log.d(TAG, "N_ updateNotification()");
|
||||||
}
|
}
|
||||||
|
@ -192,56 +82,116 @@ public final class NotificationUtil {
|
||||||
if (notificationBuilder == null) {
|
if (notificationBuilder == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (playPauseDrawable != -1) {
|
|
||||||
if (notificationRemoteView != null) {
|
notificationBuilder.setContentTitle(player.getVideoTitle());
|
||||||
notificationRemoteView
|
notificationBuilder.setContentText(player.getUploaderName());
|
||||||
.setImageViewResource(R.id.notificationPlayPause, playPauseDrawable);
|
final boolean scaleImageToSquareAspectRatio = player.sharedPreferences.getBoolean(
|
||||||
}
|
player.context.getString(R.string.scale_to_square_image_in_notifications_key),
|
||||||
if (bigNotificationRemoteView != null) {
|
false);
|
||||||
bigNotificationRemoteView
|
if (scaleImageToSquareAspectRatio) {
|
||||||
.setImageViewResource(R.id.notificationPlayPause, playPauseDrawable);
|
notificationBuilder.setLargeIcon(
|
||||||
}
|
getBitmapWithSquareAspectRatio(player.getThumbnail()));
|
||||||
|
} else {
|
||||||
|
notificationBuilder.setLargeIcon(player.getThumbnail());
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean areOldNotificationsEnabled = player.sharedPreferences.getBoolean(
|
setAction(player, notificationSlot0, 0);
|
||||||
player.context.getString(R.string.enable_old_notifications_key), false);
|
setAction(player, notificationSlot1, 1);
|
||||||
if (!areOldNotificationsEnabled) {
|
setAction(player, notificationSlot2, 2);
|
||||||
notificationBuilder.setContentTitle(player.getVideoTitle());
|
setAction(player, notificationSlot3, 3);
|
||||||
notificationBuilder.setContentText(player.getUploaderName());
|
setAction(player, notificationSlot4, 4);
|
||||||
final boolean scaleImageToSquareAspectRatio = player.sharedPreferences.getBoolean(
|
|
||||||
player.context.getString(R.string.scale_to_square_image_in_notifications_key),
|
|
||||||
false);
|
|
||||||
if (scaleImageToSquareAspectRatio) {
|
|
||||||
notificationBuilder.setLargeIcon(
|
|
||||||
getBitmapWithSquareAspectRatio(player.getThumbnail()));
|
|
||||||
} else {
|
|
||||||
notificationBuilder.setLargeIcon(player.getThumbnail());
|
|
||||||
}
|
|
||||||
|
|
||||||
setAction(player, notificationSlot0, 0);
|
|
||||||
setAction(player, notificationSlot1, 1);
|
|
||||||
setAction(player, notificationSlot2, 2);
|
|
||||||
setAction(player, notificationSlot3, 3);
|
|
||||||
setAction(player, notificationSlot4, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
|
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
|
||||||
|
|
||||||
if (areOldNotificationsEnabled) {
|
|
||||||
timesNotificationUpdated++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void recreateNotification(final VideoPlayerImpl player, final boolean recreate) {
|
/**
|
||||||
final boolean areOldNotificationsEnabled = player.sharedPreferences.getBoolean(
|
* Creates the notification, if it does not exist already or unless forceRecreate is true.
|
||||||
player.context.getString(R.string.enable_old_notifications_key), false);
|
* @param player the player currently open, to take data from
|
||||||
if (notificationBuilder == null || recreate || areOldNotificationsEnabled) {
|
* @param forceRecreate whether to force the recreation of the notification even if it already
|
||||||
|
* exists
|
||||||
|
*/
|
||||||
|
void createNotificationIfNeeded(final VideoPlayerImpl player, final boolean forceRecreate) {
|
||||||
|
if (notificationBuilder == null || forceRecreate) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "N_ recreateNotification(true)");
|
Log.d(TAG, "N_ createNotificationIfNeeded(true)");
|
||||||
}
|
}
|
||||||
notificationBuilder = createNotification(player);
|
notificationBuilder = createNotification(player);
|
||||||
}
|
}
|
||||||
timesNotificationUpdated = 0;
|
}
|
||||||
|
|
||||||
|
private NotificationCompat.Builder createNotification(final VideoPlayerImpl player) {
|
||||||
|
notificationManager =
|
||||||
|
(NotificationManager) player.context.getSystemService(NOTIFICATION_SERVICE);
|
||||||
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(player.context,
|
||||||
|
player.context.getString(R.string.notification_channel_id));
|
||||||
|
|
||||||
|
final String compactView = player.sharedPreferences.getString(player.context.getString(
|
||||||
|
R.string.settings_notifications_compact_view_key), "0,1,2");
|
||||||
|
int compactSlot0 = 0;
|
||||||
|
int compactSlot1 = 1;
|
||||||
|
int compactSlot2 = 2;
|
||||||
|
try {
|
||||||
|
if (compactView != null) {
|
||||||
|
final String[] parts = compactView.split(",");
|
||||||
|
compactSlot0 = Integer.parseInt(parts[0]);
|
||||||
|
compactSlot1 = Integer.parseInt(parts[1]);
|
||||||
|
compactSlot2 = Integer.parseInt(parts[2]);
|
||||||
|
if (compactSlot0 > 4) {
|
||||||
|
compactSlot0 = 0;
|
||||||
|
}
|
||||||
|
if (compactSlot1 > 4) {
|
||||||
|
compactSlot1 = 1;
|
||||||
|
}
|
||||||
|
if (compactSlot2 > 4) {
|
||||||
|
compactSlot2 = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
|
||||||
|
.setMediaSession(player.mediaSessionManager.getSessionToken())
|
||||||
|
.setShowCancelButton(false)
|
||||||
|
.setShowActionsInCompactView(compactSlot0, compactSlot1, compactSlot2))
|
||||||
|
.setOngoing(false)
|
||||||
|
.setContentIntent(PendingIntent.getActivity(player.context, NOTIFICATION_ID,
|
||||||
|
getIntentForNotification(player), FLAG_UPDATE_CURRENT))
|
||||||
|
.setSmallIcon(R.drawable.ic_newpipe_triangle_white)
|
||||||
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
|
.setContentTitle(player.getVideoTitle())
|
||||||
|
.setContentText(player.getUploaderName())
|
||||||
|
.setDeleteIntent(PendingIntent.getActivity(player.context, NOTIFICATION_ID,
|
||||||
|
new Intent(ACTION_CLOSE), FLAG_UPDATE_CURRENT))
|
||||||
|
.setColor(ContextCompat.getColor(player.context, R.color.gray))
|
||||||
|
.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||||
|
final boolean scaleImageToSquareAspectRatio = player.sharedPreferences.getBoolean(
|
||||||
|
player.context.getString(R.string.scale_to_square_image_in_notifications_key),
|
||||||
|
false);
|
||||||
|
if (scaleImageToSquareAspectRatio) {
|
||||||
|
builder.setLargeIcon(getBitmapWithSquareAspectRatio(player.getThumbnail()));
|
||||||
|
} else {
|
||||||
|
builder.setLargeIcon(player.getThumbnail());
|
||||||
|
}
|
||||||
|
|
||||||
|
notificationSlot0 = player.sharedPreferences.getString(
|
||||||
|
player.context.getString(R.string.notification_slot_0_key), notificationSlot0);
|
||||||
|
notificationSlot1 = player.sharedPreferences.getString(
|
||||||
|
player.context.getString(R.string.notification_slot_1_key), notificationSlot1);
|
||||||
|
notificationSlot2 = player.sharedPreferences.getString(
|
||||||
|
player.context.getString(R.string.notification_slot_2_key), notificationSlot2);
|
||||||
|
notificationSlot3 = player.sharedPreferences.getString(
|
||||||
|
player.context.getString(R.string.notification_slot_3_key), notificationSlot3);
|
||||||
|
notificationSlot4 = player.sharedPreferences.getString(
|
||||||
|
player.context.getString(R.string.notification_slot_4_key), notificationSlot4);
|
||||||
|
|
||||||
|
addAction(builder, player, notificationSlot0);
|
||||||
|
addAction(builder, player, notificationSlot1);
|
||||||
|
addAction(builder, player, notificationSlot2);
|
||||||
|
addAction(builder, player, notificationSlot3);
|
||||||
|
addAction(builder, player, notificationSlot4);
|
||||||
|
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,65 +201,18 @@ public final class NotificationUtil {
|
||||||
|
|
||||||
|
|
||||||
boolean hasSlotWithBuffering() {
|
boolean hasSlotWithBuffering() {
|
||||||
return notificationSlot0.contains("buffering")
|
return notificationSlot0.equals("play_pause_buffering")
|
||||||
|| notificationSlot1.contains("buffering")
|
|| notificationSlot1.equals("play_pause_buffering")
|
||||||
|| notificationSlot2.contains("buffering")
|
|| notificationSlot2.equals("play_pause_buffering")
|
||||||
|| notificationSlot3.contains("buffering")
|
|| notificationSlot3.equals("play_pause_buffering")
|
||||||
|| notificationSlot4.contains("buffering");
|
|| notificationSlot4.equals("play_pause_buffering");
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
// OLD NOTIFICATION
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
boolean shouldRecreateOldNotification() {
|
|
||||||
return timesNotificationUpdated > NOTIFICATION_UPDATES_BEFORE_RESET;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bitmap if null, the thumbnail will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated // only used for old notifications
|
|
||||||
void updateOldNotificationsThumbnail(@Nullable final Bitmap bitmap) {
|
|
||||||
if (notificationRemoteView != null) {
|
|
||||||
notificationRemoteView.setImageViewBitmap(R.id.notificationCover, bitmap);
|
|
||||||
}
|
|
||||||
if (bigNotificationRemoteView != null) {
|
|
||||||
bigNotificationRemoteView.setImageViewBitmap(R.id.notificationCover, bitmap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated // only used for old notifications
|
|
||||||
void setProgressbarOnOldNotifications(final int max, final int progress,
|
|
||||||
final boolean indeterminate) {
|
|
||||||
if (bigNotificationRemoteView != null) { //FIXME put in Util and turn into a method
|
|
||||||
bigNotificationRemoteView.setProgressBar(R.id.notificationProgressBar, max, progress,
|
|
||||||
indeterminate);
|
|
||||||
}
|
|
||||||
if (notificationRemoteView != null) {
|
|
||||||
notificationRemoteView.setProgressBar(R.id.notificationProgressBar, max, progress,
|
|
||||||
indeterminate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated // only used for old notifications
|
|
||||||
void setCachedDuration(final int currentProgress, final int duration) {
|
|
||||||
if (bigNotificationRemoteView != null) {
|
|
||||||
if (cachedDuration != duration) {
|
|
||||||
cachedDuration = duration;
|
|
||||||
cachedDurationString = getTimeString(duration);
|
|
||||||
}
|
|
||||||
bigNotificationRemoteView.setTextViewText(R.id.notificationTime,
|
|
||||||
getTimeString(currentProgress) + " / " + cachedDurationString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelNotification() {
|
public void cancelNotification() {
|
||||||
try {
|
try {
|
||||||
if (notificationManager != null) {
|
if (notificationManager != null) {
|
||||||
notificationManager.cancel(NOTIFICATION_ID);
|
notificationManager.cancel(NOTIFICATION_ID);
|
||||||
|
notificationManager = null;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("NotificationUtil", "Exception", e);
|
Log.e("NotificationUtil", "Exception", e);
|
||||||
|
@ -317,64 +220,6 @@ public final class NotificationUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
// OLD NOTIFICATION UTILS
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Deprecated // only used for old notifications
|
|
||||||
private void setupOldNotification(final RemoteViews remoteViews,
|
|
||||||
final VideoPlayerImpl player) {
|
|
||||||
remoteViews.setTextViewText(R.id.notificationSongName, player.getVideoTitle());
|
|
||||||
remoteViews.setTextViewText(R.id.notificationArtist, player.getUploaderName());
|
|
||||||
remoteViews.setImageViewBitmap(R.id.notificationCover, player.getThumbnail());
|
|
||||||
|
|
||||||
remoteViews.setOnClickPendingIntent(R.id.notificationPlayPause,
|
|
||||||
PendingIntent.getBroadcast(player.context, NOTIFICATION_ID,
|
|
||||||
new Intent(ACTION_PLAY_PAUSE), FLAG_UPDATE_CURRENT));
|
|
||||||
remoteViews.setOnClickPendingIntent(R.id.notificationStop,
|
|
||||||
PendingIntent.getBroadcast(player.context, NOTIFICATION_ID,
|
|
||||||
new Intent(ACTION_CLOSE), FLAG_UPDATE_CURRENT));
|
|
||||||
remoteViews.setOnClickPendingIntent(R.id.notificationRepeat,
|
|
||||||
PendingIntent.getBroadcast(player.context, NOTIFICATION_ID,
|
|
||||||
new Intent(ACTION_REPEAT), FLAG_UPDATE_CURRENT));
|
|
||||||
remoteViews.setOnClickPendingIntent(R.id.notificationContent,
|
|
||||||
PendingIntent.getBroadcast(player.context, NOTIFICATION_ID,
|
|
||||||
getIntentForNotification(player), FLAG_UPDATE_CURRENT));
|
|
||||||
|
|
||||||
if (player.playQueue != null && player.playQueue.size() > 1) {
|
|
||||||
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(player.context, NOTIFICATION_ID,
|
|
||||||
new Intent(ACTION_PLAY_PREVIOUS), FLAG_UPDATE_CURRENT));
|
|
||||||
remoteViews.setOnClickPendingIntent(R.id.notificationFForward,
|
|
||||||
PendingIntent.getBroadcast(player.context, NOTIFICATION_ID,
|
|
||||||
new Intent(ACTION_PLAY_NEXT), FLAG_UPDATE_CURRENT));
|
|
||||||
} else {
|
|
||||||
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(player.context, NOTIFICATION_ID,
|
|
||||||
new Intent(ACTION_FAST_REWIND), FLAG_UPDATE_CURRENT));
|
|
||||||
remoteViews.setOnClickPendingIntent(R.id.notificationFForward,
|
|
||||||
PendingIntent.getBroadcast(player.context, NOTIFICATION_ID,
|
|
||||||
new Intent(ACTION_FAST_FORWARD), FLAG_UPDATE_CURRENT));
|
|
||||||
}
|
|
||||||
|
|
||||||
setRepeatModeIcon(remoteViews, player.getRepeatMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated // only used for old notifications
|
|
||||||
private void setRepeatModeIcon(final RemoteViews remoteViews, final int repeatMode) {
|
|
||||||
remoteViews.setInt(R.id.notificationRepeat, SET_IMAGE_RESOURCE_METHOD,
|
|
||||||
getRepeatModeDrawable(repeatMode));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
// ACTIONS
|
// ACTIONS
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
@ -401,11 +246,11 @@ public final class NotificationUtil {
|
||||||
|| player.getCurrentState() == BasePlayer.STATE_BLOCKED
|
|| player.getCurrentState() == BasePlayer.STATE_BLOCKED
|
||||||
|| player.getCurrentState() == BasePlayer.STATE_BUFFERING) {
|
|| player.getCurrentState() == BasePlayer.STATE_BUFFERING) {
|
||||||
builder.setSmallIcon(android.R.drawable.stat_sys_download);
|
builder.setSmallIcon(android.R.drawable.stat_sys_download);
|
||||||
return getAction(builder, player, R.drawable.ic_file_download_white_24dp,
|
return getAction(player, R.drawable.ic_file_download_white_24dp,
|
||||||
"Buffering", ACTION_BUFFERING);
|
"Buffering", ACTION_BUFFERING);
|
||||||
} else {
|
} else {
|
||||||
builder.setSmallIcon(R.drawable.ic_newpipe_triangle_white);
|
builder.setSmallIcon(R.drawable.ic_newpipe_triangle_white);
|
||||||
return getAction(builder, player,
|
return getAction(player,
|
||||||
player.isPlaying() ? R.drawable.exo_notification_pause
|
player.isPlaying() ? R.drawable.exo_notification_pause
|
||||||
: R.drawable.exo_notification_play,
|
: R.drawable.exo_notification_play,
|
||||||
player.isPlaying() ? "Pause" : "Play",
|
player.isPlaying() ? "Pause" : "Play",
|
||||||
|
@ -416,51 +261,51 @@ public final class NotificationUtil {
|
||||||
|| player.getCurrentState() == BasePlayer.STATE_PREFLIGHT
|
|| player.getCurrentState() == BasePlayer.STATE_PREFLIGHT
|
||||||
|| player.getCurrentState() == BasePlayer.STATE_BLOCKED
|
|| player.getCurrentState() == BasePlayer.STATE_BLOCKED
|
||||||
|| player.getCurrentState() == BasePlayer.STATE_BUFFERING;
|
|| player.getCurrentState() == BasePlayer.STATE_BUFFERING;
|
||||||
return getAction(builder, player,
|
return getAction(player,
|
||||||
pauseOrPlay ? R.drawable.exo_notification_pause
|
pauseOrPlay ? R.drawable.exo_notification_pause
|
||||||
: R.drawable.exo_notification_play,
|
: R.drawable.exo_notification_play,
|
||||||
pauseOrPlay ? "Pause" : "Play",
|
pauseOrPlay ? "Pause" : "Play",
|
||||||
ACTION_PLAY_PAUSE);
|
ACTION_PLAY_PAUSE);
|
||||||
case "rewind":
|
case "rewind":
|
||||||
return getAction(builder, player, R.drawable.exo_controls_rewind,
|
return getAction(player, R.drawable.exo_controls_rewind,
|
||||||
"Rewind", ACTION_FAST_REWIND);
|
"Rewind", ACTION_FAST_REWIND);
|
||||||
case "smart_rewind_prev":
|
case "smart_rewind_prev":
|
||||||
if (player.playQueue != null && player.playQueue.size() > 1) {
|
if (player.playQueue != null && player.playQueue.size() > 1) {
|
||||||
return getAction(builder, player, R.drawable.exo_notification_previous,
|
return getAction(player, R.drawable.exo_notification_previous,
|
||||||
"Prev", ACTION_PLAY_PREVIOUS);
|
"Prev", ACTION_PLAY_PREVIOUS);
|
||||||
} else {
|
} else {
|
||||||
return getAction(builder, player, R.drawable.exo_controls_rewind,
|
return getAction(player, R.drawable.exo_controls_rewind,
|
||||||
"Rewind", ACTION_FAST_REWIND);
|
"Rewind", ACTION_FAST_REWIND);
|
||||||
}
|
}
|
||||||
case "forward":
|
case "forward":
|
||||||
return getAction(builder, player, R.drawable.exo_controls_fastforward,
|
return getAction(player, R.drawable.exo_controls_fastforward,
|
||||||
"Forward", ACTION_FAST_FORWARD);
|
"Forward", ACTION_FAST_FORWARD);
|
||||||
case "smart_forward_next":
|
case "smart_forward_next":
|
||||||
if (player.playQueue != null && player.playQueue.size() > 1) {
|
if (player.playQueue != null && player.playQueue.size() > 1) {
|
||||||
return getAction(builder, player, R.drawable.exo_notification_next,
|
return getAction(player, R.drawable.exo_notification_next,
|
||||||
"Next", ACTION_PLAY_NEXT);
|
"Next", ACTION_PLAY_NEXT);
|
||||||
} else {
|
} else {
|
||||||
return getAction(builder, player, R.drawable.exo_controls_fastforward,
|
return getAction(player, R.drawable.exo_controls_fastforward,
|
||||||
"Forward", ACTION_FAST_FORWARD);
|
"Forward", ACTION_FAST_FORWARD);
|
||||||
}
|
}
|
||||||
case "next":
|
case "next":
|
||||||
return getAction(builder, player, R.drawable.exo_notification_next,
|
return getAction(player, R.drawable.exo_notification_next,
|
||||||
"Next", ACTION_PLAY_NEXT);
|
"Next", ACTION_PLAY_NEXT);
|
||||||
case "prev":
|
case "prev":
|
||||||
return getAction(builder, player, R.drawable.exo_notification_previous,
|
return getAction(player, R.drawable.exo_notification_previous,
|
||||||
"Prev", ACTION_PLAY_PREVIOUS);
|
"Prev", ACTION_PLAY_PREVIOUS);
|
||||||
case "repeat":
|
case "repeat":
|
||||||
return getAction(builder, player, getRepeatModeDrawable(player.getRepeatMode()),
|
return getAction(player, getRepeatModeDrawable(player.getRepeatMode()),
|
||||||
getRepeatModeTitle(player.getRepeatMode()), ACTION_REPEAT);
|
getRepeatModeTitle(player.getRepeatMode()), ACTION_REPEAT);
|
||||||
case "shuffle":
|
case "shuffle":
|
||||||
final boolean shuffled = player.playQueue != null && player.playQueue.isShuffled();
|
final boolean shuffled = player.playQueue != null && player.playQueue.isShuffled();
|
||||||
return getAction(builder, player,
|
return getAction(player,
|
||||||
shuffled ? R.drawable.exo_controls_shuffle_on
|
shuffled ? R.drawable.exo_controls_shuffle_on
|
||||||
: R.drawable.exo_controls_shuffle_off,
|
: R.drawable.exo_controls_shuffle_off,
|
||||||
shuffled ? "ShuffleOn" : "ShuffleOff",
|
shuffled ? "ShuffleOn" : "ShuffleOff",
|
||||||
ACTION_SHUFFLE);
|
ACTION_SHUFFLE);
|
||||||
case "close":
|
case "close":
|
||||||
return getAction(builder, player, R.drawable.ic_close_white_24dp,
|
return getAction(player, R.drawable.ic_close_white_24dp,
|
||||||
"Close", ACTION_CLOSE);
|
"Close", ACTION_CLOSE);
|
||||||
case "n/a":
|
case "n/a":
|
||||||
default:
|
default:
|
||||||
|
@ -469,8 +314,7 @@ public final class NotificationUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private NotificationCompat.Action getAction(final NotificationCompat.Builder builder,
|
private NotificationCompat.Action getAction(final VideoPlayerImpl player,
|
||||||
final VideoPlayerImpl player,
|
|
||||||
@DrawableRes final int drawable,
|
@DrawableRes final int drawable,
|
||||||
final String title,
|
final String title,
|
||||||
final String intentAction) {
|
final String intentAction) {
|
||||||
|
|
|
@ -57,7 +57,6 @@ import android.widget.RelativeLayout;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
@ -577,7 +576,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
void onShuffleOrRepeatModeChanged() {
|
void onShuffleOrRepeatModeChanged() {
|
||||||
updatePlaybackButtons();
|
updatePlaybackButtons();
|
||||||
updatePlayback();
|
updatePlayback();
|
||||||
resetNotification(false, -1);
|
resetNotification(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -614,7 +613,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
titleTextView.setText(tag.getMetadata().getName());
|
titleTextView.setText(tag.getMetadata().getName());
|
||||||
channelTextView.setText(tag.getMetadata().getUploaderName());
|
channelTextView.setText(tag.getMetadata().getUploaderName());
|
||||||
|
|
||||||
resetNotification(false, -1);
|
resetNotification(false);
|
||||||
updateMetadata();
|
updateMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,30 +641,6 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
// setMetadata only updates the metadata when any of the metadata keys are null
|
// setMetadata only updates the metadata when any of the metadata keys are null
|
||||||
mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(), getThumbnail(),
|
mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(), getThumbnail(),
|
||||||
duration);
|
duration);
|
||||||
|
|
||||||
final boolean areOldNotificationsEnabled = sharedPreferences.getBoolean(
|
|
||||||
context.getString(R.string.enable_old_notifications_key), false);
|
|
||||||
if (areOldNotificationsEnabled) {
|
|
||||||
if (!shouldUpdateOnProgress || getCurrentState() == BasePlayer.STATE_COMPLETED
|
|
||||||
|| getCurrentState() == BasePlayer.STATE_PAUSED || getPlayQueue() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NotificationUtil.getInstance().shouldRecreateOldNotification()) {
|
|
||||||
NotificationUtil.getInstance().recreateNotification(this, false);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NotificationUtil.getInstance().setCachedDuration(currentProgress, duration);
|
|
||||||
NotificationUtil.getInstance().setProgressbarOnOldNotifications(duration,
|
|
||||||
currentProgress, false);
|
|
||||||
|
|
||||||
NotificationUtil.getInstance().updateNotification(this, -1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1083,9 +1058,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
animatePlayButtons(false, 100);
|
animatePlayButtons(false, 100);
|
||||||
getRootView().setKeepScreenOn(false);
|
getRootView().setKeepScreenOn(false);
|
||||||
|
|
||||||
NotificationUtil.getInstance().recreateNotification(this, false);
|
NotificationUtil.getInstance().createNotificationIfNeeded(this, false);
|
||||||
NotificationUtil.getInstance().updateNotification(
|
NotificationUtil.getInstance().updateNotification(
|
||||||
this, R.drawable.ic_play_arrow_white_24dp);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1101,7 +1076,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
isForwardPressed = false;
|
isForwardPressed = false;
|
||||||
isRewindPressed = false;
|
isRewindPressed = false;
|
||||||
} else {
|
} else {
|
||||||
NotificationUtil.getInstance().updateNotification(this, -1);
|
NotificationUtil.getInstance().updateNotification(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1121,7 +1096,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
checkLandscape();
|
checkLandscape();
|
||||||
getRootView().setKeepScreenOn(true);
|
getRootView().setKeepScreenOn(true);
|
||||||
|
|
||||||
resetNotification(false, R.drawable.ic_pause_white_24dp);
|
resetNotification(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1137,7 +1112,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
|
|
||||||
updateWindowFlags(IDLE_WINDOW_FLAGS);
|
updateWindowFlags(IDLE_WINDOW_FLAGS);
|
||||||
|
|
||||||
resetNotification(false, R.drawable.ic_play_arrow_white_24dp);
|
resetNotification(false);
|
||||||
|
|
||||||
// Remove running notification when user don't want music (or video in popup)
|
// Remove running notification when user don't want music (or video in popup)
|
||||||
// to be played in background
|
// to be played in background
|
||||||
|
@ -1154,9 +1129,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
animatePlayButtons(false, 100);
|
animatePlayButtons(false, 100);
|
||||||
getRootView().setKeepScreenOn(true);
|
getRootView().setKeepScreenOn(true);
|
||||||
|
|
||||||
NotificationUtil.getInstance().recreateNotification(this, false);
|
NotificationUtil.getInstance().createNotificationIfNeeded(this, false);
|
||||||
NotificationUtil.getInstance().updateNotification(
|
NotificationUtil.getInstance().updateNotification(
|
||||||
this, R.drawable.ic_play_arrow_white_24dp);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1170,11 +1145,8 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
getRootView().setKeepScreenOn(false);
|
getRootView().setKeepScreenOn(false);
|
||||||
updateWindowFlags(IDLE_WINDOW_FLAGS);
|
updateWindowFlags(IDLE_WINDOW_FLAGS);
|
||||||
|
|
||||||
NotificationUtil.getInstance().recreateNotification(this, false);
|
NotificationUtil.getInstance().createNotificationIfNeeded(this, false);
|
||||||
NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 100, false);
|
NotificationUtil.getInstance().updateNotification(this);
|
||||||
NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail());
|
|
||||||
NotificationUtil.getInstance().updateNotification(
|
|
||||||
this, R.drawable.ic_replay_white_24dp);
|
|
||||||
|
|
||||||
super.onCompleted();
|
super.onCompleted();
|
||||||
}
|
}
|
||||||
|
@ -1182,8 +1154,6 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
super.destroy();
|
super.destroy();
|
||||||
|
|
||||||
NotificationUtil.getInstance().updateOldNotificationsThumbnail(null);
|
|
||||||
service.getContentResolver().unregisterContentObserver(settingsContentObserver);
|
service.getContentResolver().unregisterContentObserver(settingsContentObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1334,10 +1304,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
// Thumbnail Loading
|
// Thumbnail Loading
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
void resetNotification(final boolean recreate, @DrawableRes final int drawableId) {
|
void resetNotification(final boolean recreate) {
|
||||||
NotificationUtil.getInstance().recreateNotification(this, recreate);
|
NotificationUtil.getInstance().createNotificationIfNeeded(this, recreate);
|
||||||
NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail());
|
NotificationUtil.getInstance().updateNotification(this);
|
||||||
NotificationUtil.getInstance().updateNotification(this, drawableId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1347,7 +1316,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
// rebuild OLD notification here since remote view does not release bitmaps,
|
// rebuild OLD notification here since remote view does not release bitmaps,
|
||||||
// causing memory leaks
|
// causing memory leaks
|
||||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||||
resetNotification(true, -1);
|
resetNotification(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1355,13 +1324,13 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
final View view,
|
final View view,
|
||||||
final FailReason failReason) {
|
final FailReason failReason) {
|
||||||
super.onLoadingFailed(imageUri, view, failReason);
|
super.onLoadingFailed(imageUri, view, failReason);
|
||||||
resetNotification(true, -1);
|
resetNotification(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadingCancelled(final String imageUri, final View view) {
|
public void onLoadingCancelled(final String imageUri, final View view) {
|
||||||
super.onLoadingCancelled(imageUri, view);
|
super.onLoadingCancelled(imageUri, view);
|
||||||
resetNotification(true, -1);
|
resetNotification(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -11,7 +11,6 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.player.NotificationUtil;
|
|
||||||
import org.schabi.newpipe.util.Constants;
|
import org.schabi.newpipe.util.Constants;
|
||||||
|
|
||||||
public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
||||||
|
@ -53,18 +52,8 @@ public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
||||||
final Preference captionSettings = findPreference(captionSettingsKey);
|
final Preference captionSettings = findPreference(captionSettingsKey);
|
||||||
getPreferenceScreen().removePreference(captionSettings);
|
getPreferenceScreen().removePreference(captionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
findPreference(getString(R.string.enable_old_notifications_key))
|
|
||||||
.setOnPreferenceChangeListener(oldNotificationsOnPreferenceChangeListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preference.OnPreferenceChangeListener oldNotificationsOnPreferenceChangeListener
|
|
||||||
= (preference, newValue) -> {
|
|
||||||
// kill player notification
|
|
||||||
NotificationUtil.getInstance().cancelNotification();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||||
addPreferencesFromResource(R.xml.appearance_settings);
|
addPreferencesFromResource(R.xml.appearance_settings);
|
||||||
|
|
|
@ -114,7 +114,6 @@
|
||||||
<item>144p</item>
|
<item>144p</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string name="enable_old_notifications_key" translatable="false">enable_old_notifications</string>
|
|
||||||
<string name="settings_notifications_compact_view_key" translatable="false">notifications_compact_view</string>
|
<string name="settings_notifications_compact_view_key" translatable="false">notifications_compact_view</string>
|
||||||
<string name="settings_notifications_compact_view_default_value" translatable="false">0,1,2</string>
|
<string name="settings_notifications_compact_view_default_value" translatable="false">0,1,2</string>
|
||||||
<string name="scale_to_square_image_in_notifications_key" translatable="false">scale_to_square_image_in_notifications</string>
|
<string name="scale_to_square_image_in_notifications_key" translatable="false">scale_to_square_image_in_notifications</string>
|
||||||
|
|
|
@ -58,8 +58,6 @@
|
||||||
<string name="kore_package" translatable="false">org.xbmc.kore</string>
|
<string name="kore_package" translatable="false">org.xbmc.kore</string>
|
||||||
<string name="show_play_with_kodi_title">Show \"Play with Kodi\" option</string>
|
<string name="show_play_with_kodi_title">Show \"Play with Kodi\" option</string>
|
||||||
<string name="show_play_with_kodi_summary">Display an option to play a video via Kodi media center</string>
|
<string name="show_play_with_kodi_summary">Display an option to play a video via Kodi media center</string>
|
||||||
<string name="enable_old_notifications_title">Enable old notifications</string>
|
|
||||||
<string name="enable_old_notifications_summary">This enables the old \"Custom RemoteViews\" notifications. If disabled modern MediaStyle notifications will be used.</string>
|
|
||||||
<string name="scale_to_square_image_in_notifications_title">Scale image to 1:1 aspect ratio</string>
|
<string name="scale_to_square_image_in_notifications_title">Scale image to 1:1 aspect ratio</string>
|
||||||
<string name="scale_to_square_image_in_notifications_summary">This will scale the notification image from 16:9 to 1:1 aspect ratio</string>
|
<string name="scale_to_square_image_in_notifications_summary">This will scale the notification image from 16:9 to 1:1 aspect ratio</string>
|
||||||
<string name="default_notification_slot_0_title">Notification slot 0</string>
|
<string name="default_notification_slot_0_title">Notification slot 0</string>
|
||||||
|
|
|
@ -39,13 +39,6 @@
|
||||||
android:title="@string/settings_category_notifications_title"
|
android:title="@string/settings_category_notifications_title"
|
||||||
app:iconSpaceReserved="false">
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/enable_old_notifications_key"
|
|
||||||
android:summary="@string/enable_old_notifications_summary"
|
|
||||||
android:title="@string/enable_old_notifications_title"
|
|
||||||
app:iconSpaceReserved="false" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="@string/scale_to_square_image_in_notifications_key"
|
android:key="@string/scale_to_square_image_in_notifications_key"
|
||||||
|
|
Loading…
Reference in a new issue