From 15c3c44e645b86934cf8b149715da6c2d337ef4d Mon Sep 17 00:00:00 2001 From: olly Date: Wed, 24 Feb 2021 17:09:39 +0000 Subject: [PATCH] Add group setting for the notification PiperOrigin-RevId: 359298960 --- RELEASENOTES.md | 1 + .../ui/PlayerNotificationManager.java | 28 +++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 48159a1fee..701810813f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -6,6 +6,7 @@ * Add support for MP4 and QuickTime meta atoms that are not full atoms. * UI: * Add builder for `PlayerNotificationManager`. + * Add group setting to `PlayerNotificationManager`. * Make conditions to enable UI actions consistent in `DefaultControlDispatcher`, `PlayerControlView`, `StyledPlayerControlView`, `PlayerNotificationManager` and diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java index 42933a66ea..f683a41cb8 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java @@ -320,6 +320,7 @@ public class PlayerNotificationManager { private int fastForwardActionIconResourceId; private int previousActionIconResourceId; private int nextActionIconResourceId; + @Nullable private String groupKey; /** * Creates an instance. @@ -514,6 +515,18 @@ public class PlayerNotificationManager { return this; } + /** + * The key of the group the media notification should belong to. + * + *

The default is {@code null} + * + * @return This builder. + */ + public Builder setGroup(String groupKey) { + this.groupKey = groupKey; + return this; + } + /** Builds the {@link PlayerNotificationManager}. */ public PlayerNotificationManager build() { if (channelNameResourceId != 0) { @@ -538,7 +551,8 @@ public class PlayerNotificationManager { rewindActionIconResourceId, fastForwardActionIconResourceId, previousActionIconResourceId, - nextActionIconResourceId); + nextActionIconResourceId, + groupKey); } } @@ -662,6 +676,7 @@ public class PlayerNotificationManager { private int visibility; @Priority private int priority; private boolean useChronometer; + @Nullable private String groupKey; /** @deprecated Use the {@link Builder} instead. */ @SuppressWarnings("deprecation") @@ -805,7 +820,8 @@ public class PlayerNotificationManager { R.drawable.exo_notification_rewind, R.drawable.exo_notification_fastforward, R.drawable.exo_notification_previous, - R.drawable.exo_notification_next); + R.drawable.exo_notification_next, + null); } private PlayerNotificationManager( @@ -822,7 +838,8 @@ public class PlayerNotificationManager { int rewindActionIconResourceId, int fastForwardActionIconResourceId, int previousActionIconResourceId, - int nextActionIconResourceId) { + int nextActionIconResourceId, + @Nullable String groupKey) { context = context.getApplicationContext(); this.context = context; this.channelId = channelId; @@ -831,6 +848,7 @@ public class PlayerNotificationManager { this.notificationListener = notificationListener; this.customActionReceiver = customActionReceiver; this.smallIconResourceId = smallIconResourceId; + this.groupKey = groupKey; controlDispatcher = new DefaultControlDispatcher(); window = new Timeline.Window(); instanceId = instanceIdCounter++; @@ -1407,6 +1425,10 @@ public class PlayerNotificationManager { setLargeIcon(builder, largeIcon); builder.setContentIntent(mediaDescriptionAdapter.createCurrentContentIntent(player)); + if (groupKey != null) { + builder.setGroup(groupKey); + } + return builder; }