Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
baf00406
authored
Apr 08, 2019
by
bachinger
Committed by
Oliver Woodman
Apr 13, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Provide option to include next/prev button in lock screen/compact mode.
Issue: #5616 PiperOrigin-RevId: 242452686
parent
a6d52d4a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
3 deletions
RELEASENOTES.md
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java
RELEASENOTES.md
View file @
baf00406
...
...
@@ -74,6 +74,8 @@
`PlayerNotificationManager`
has been fixed. Apps using
`DownloadNotificationUtil`
should switch to using
`DownloadNotificationHelper`
.
*
Provide flag to include next/prev buttons in compact mode of a notification
(
[
#5616
](
https://github.com/google/ExoPlayer/issues/5616
)
).
*
Move creation of dialogs for
`TrackSelectionView`
s to
`TrackSelectionDialogBuilder`
and add option to select multiple overrides.
*
MediaSessionConnector: Let apps intercept media button events
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java
View file @
baf00406
...
...
@@ -47,6 +47,7 @@ import java.lang.annotation.Documented;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -74,6 +75,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
* <li>Corresponding setter: {@link #setUseNavigationActions(boolean)}
* <li>Default: {@code true}
* </ul>
* <li><b>{@code useNavigationActionsInCompactView}</b> - Sets whether the navigation previous and
* next actions should are displayed in compact view (including the lock screen notification).
* <ul>
* <li>Corresponding setter: {@link #setUseNavigationActionsInCompactView(boolean)}
* <li>Default: {@code false}
* </ul>
* <li><b>{@code usePlayPauseActions}</b> - Sets whether the play and pause actions are displayed.
* <ul>
* <li>Corresponding setter: {@link #setUsePlayPauseActions(boolean)}
...
...
@@ -362,6 +369,7 @@ public class PlayerNotificationManager {
@Nullable
private
NotificationListener
notificationListener
;
@Nullable
private
MediaSessionCompat
.
Token
mediaSessionToken
;
private
boolean
useNavigationActions
;
private
boolean
useNavigationActionsInCompactView
;
private
boolean
usePlayPauseActions
;
private
boolean
useStopAction
;
private
long
fastForwardMs
;
...
...
@@ -688,6 +696,23 @@ public class PlayerNotificationManager {
}
/**
* Sets whether navigation actions should be displayed in compact view.
*
* <p>If {@link #useNavigationActions} is set to {@code false} navigation actions are displayed
* neither in compact nor in full view mode of the notification.
*
* @param useNavigationActionsInCompactView Whether the navigation actions should be displayed in
* compact view.
*/
public
final
void
setUseNavigationActionsInCompactView
(
boolean
useNavigationActionsInCompactView
)
{
if
(
this
.
useNavigationActionsInCompactView
!=
useNavigationActionsInCompactView
)
{
this
.
useNavigationActionsInCompactView
=
useNavigationActionsInCompactView
;
invalidate
();
}
}
/**
* Sets whether the play and pause actions should be used.
*
* @param usePlayPauseActions Whether to use play and pause actions.
...
...
@@ -1096,9 +1121,26 @@ public class PlayerNotificationManager {
protected
int
[]
getActionIndicesForCompactView
(
List
<
String
>
actionNames
,
Player
player
)
{
int
pauseActionIndex
=
actionNames
.
indexOf
(
ACTION_PAUSE
);
int
playActionIndex
=
actionNames
.
indexOf
(
ACTION_PLAY
);
return
pauseActionIndex
!=
-
1
?
new
int
[]
{
pauseActionIndex
}
:
(
playActionIndex
!=
-
1
?
new
int
[]
{
playActionIndex
}
:
new
int
[
0
]);
int
skipPreviousActionIndex
=
useNavigationActionsInCompactView
?
actionNames
.
indexOf
(
ACTION_PREVIOUS
)
:
-
1
;
int
skipNextActionIndex
=
useNavigationActionsInCompactView
?
actionNames
.
indexOf
(
ACTION_NEXT
)
:
-
1
;
int
[]
actionIndices
=
new
int
[
3
];
int
actionCounter
=
0
;
if
(
skipPreviousActionIndex
!=
-
1
)
{
actionIndices
[
actionCounter
++]
=
skipPreviousActionIndex
;
}
boolean
playWhenReady
=
player
.
getPlayWhenReady
();
if
(
pauseActionIndex
!=
-
1
&&
playWhenReady
)
{
actionIndices
[
actionCounter
++]
=
pauseActionIndex
;
}
else
if
(
playActionIndex
!=
-
1
&&
!
playWhenReady
)
{
actionIndices
[
actionCounter
++]
=
playActionIndex
;
}
if
(
skipNextActionIndex
!=
-
1
)
{
actionIndices
[
actionCounter
++]
=
skipNextActionIndex
;
}
return
Arrays
.
copyOf
(
actionIndices
,
actionCounter
);
}
/** Returns whether the generated notification should be ongoing. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment