mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
add notification priority for lower API levels
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=193934212
This commit is contained in:
parent
7d6b0e1fda
commit
e0af050163
1 changed files with 42 additions and 0 deletions
|
|
@ -237,6 +237,17 @@ public class PlayerNotificationManager {
|
||||||
})
|
})
|
||||||
public @interface Visibility {}
|
public @interface Visibility {}
|
||||||
|
|
||||||
|
/** Priority of the notification (required for API 25 and lower). */
|
||||||
|
@Retention(SOURCE)
|
||||||
|
@IntDef({
|
||||||
|
NotificationCompat.PRIORITY_DEFAULT,
|
||||||
|
NotificationCompat.PRIORITY_MAX,
|
||||||
|
NotificationCompat.PRIORITY_HIGH,
|
||||||
|
NotificationCompat.PRIORITY_LOW,
|
||||||
|
NotificationCompat.PRIORITY_MIN
|
||||||
|
})
|
||||||
|
public @interface Priority {}
|
||||||
|
|
||||||
/** The default fast forward increment, in milliseconds. */
|
/** The default fast forward increment, in milliseconds. */
|
||||||
public static final int DEFAULT_FAST_FORWARD_MS = 15000;
|
public static final int DEFAULT_FAST_FORWARD_MS = 15000;
|
||||||
/** The default rewind increment, in milliseconds. */
|
/** The default rewind increment, in milliseconds. */
|
||||||
|
|
@ -274,6 +285,7 @@ public class PlayerNotificationManager {
|
||||||
private int color;
|
private int color;
|
||||||
private @DrawableRes int smallIconResourceId;
|
private @DrawableRes int smallIconResourceId;
|
||||||
private int visibility;
|
private int visibility;
|
||||||
|
private @Priority int priority;
|
||||||
private boolean ongoing;
|
private boolean ongoing;
|
||||||
private boolean useChronometer;
|
private boolean useChronometer;
|
||||||
private boolean wasPlayWhenReady;
|
private boolean wasPlayWhenReady;
|
||||||
|
|
@ -374,6 +386,7 @@ public class PlayerNotificationManager {
|
||||||
color = Color.TRANSPARENT;
|
color = Color.TRANSPARENT;
|
||||||
smallIconResourceId = R.drawable.exo_notification_small_icon;
|
smallIconResourceId = R.drawable.exo_notification_small_icon;
|
||||||
defaults = 0;
|
defaults = 0;
|
||||||
|
priority = NotificationCompat.PRIORITY_LOW;
|
||||||
fastForwardMs = DEFAULT_FAST_FORWARD_MS;
|
fastForwardMs = DEFAULT_FAST_FORWARD_MS;
|
||||||
rewindMs = DEFAULT_REWIND_MS;
|
rewindMs = DEFAULT_REWIND_MS;
|
||||||
setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL);
|
setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL);
|
||||||
|
|
@ -588,6 +601,34 @@ public class PlayerNotificationManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the priority of the notification required for API 25 and lower.
|
||||||
|
*
|
||||||
|
* <p>See {@link NotificationCompat.Builder#setPriority(int)}.
|
||||||
|
*
|
||||||
|
* @param priority The priority which can be one of {@link NotificationCompat#PRIORITY_DEFAULT},
|
||||||
|
* {@link NotificationCompat#PRIORITY_MAX}, {@link NotificationCompat#PRIORITY_HIGH}, {@link
|
||||||
|
* NotificationCompat#PRIORITY_LOW} or {@link NotificationCompat#PRIORITY_MIN}. If not set
|
||||||
|
* {@link NotificationCompat#PRIORITY_LOW} is used by default.
|
||||||
|
*/
|
||||||
|
public final void setPriority(@Priority int priority) {
|
||||||
|
if (this.priority == priority) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (priority) {
|
||||||
|
case NotificationCompat.PRIORITY_DEFAULT:
|
||||||
|
case NotificationCompat.PRIORITY_MAX:
|
||||||
|
case NotificationCompat.PRIORITY_HIGH:
|
||||||
|
case NotificationCompat.PRIORITY_LOW:
|
||||||
|
case NotificationCompat.PRIORITY_MIN:
|
||||||
|
this.priority = priority;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
maybeUpdateNotification();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the small icon of the notification which is also shown in the system status bar.
|
* Sets the small icon of the notification which is also shown in the system status bar.
|
||||||
*
|
*
|
||||||
|
|
@ -777,6 +818,7 @@ public class PlayerNotificationManager {
|
||||||
.setColorized(colorized)
|
.setColorized(colorized)
|
||||||
.setSmallIcon(smallIconResourceId)
|
.setSmallIcon(smallIconResourceId)
|
||||||
.setVisibility(visibility)
|
.setVisibility(visibility)
|
||||||
|
.setPriority(priority)
|
||||||
.setDefaults(defaults);
|
.setDefaults(defaults);
|
||||||
if (useChronometer
|
if (useChronometer
|
||||||
&& !player.isCurrentWindowDynamic()
|
&& !player.isCurrentWindowDynamic()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue