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
0b756a96
authored
Jul 18, 2019
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Merge pull request #6042 from Timbals:dev-v2
PiperOrigin-RevId: 258812820
parent
78d63932
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
15 deletions
RELEASENOTES.md
demos/main/src/main/java/com/google/android/exoplayer2/demo/DemoDownloadService.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadService.java
library/core/src/main/java/com/google/android/exoplayer2/util/NotificationUtil.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java
RELEASENOTES.md
View file @
0b756a96
...
...
@@ -13,6 +13,8 @@
*
Fix issue where invalid language tags were normalized to "und" instead of
keeping the original
(
[
#6153
](
https://github.com/google/ExoPlayer/issues/6153
)
).
*
Add ability to specify a description when creating notification channels via
ExoPlayer library classes.
### 2.10.3 ###
...
...
demos/main/src/main/java/com/google/android/exoplayer2/demo/DemoDownloadService.java
View file @
0b756a96
...
...
@@ -41,7 +41,8 @@ public class DemoDownloadService extends DownloadService {
FOREGROUND_NOTIFICATION_ID
,
DEFAULT_FOREGROUND_NOTIFICATION_UPDATE_INTERVAL
,
CHANNEL_ID
,
R
.
string
.
exo_download_notification_channel_name
);
R
.
string
.
exo_download_notification_channel_name
,
/* channelDescriptionResourceId= */
0
);
nextNotificationId
=
FOREGROUND_NOTIFICATION_ID
+
1
;
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadService.java
View file @
0b756a96
...
...
@@ -174,6 +174,7 @@ public abstract class DownloadService extends Service {
@Nullable
private
final
ForegroundNotificationUpdater
foregroundNotificationUpdater
;
@Nullable
private
final
String
channelId
;
@StringRes
private
final
int
channelNameResourceId
;
@StringRes
private
final
int
channelDescriptionResourceId
;
private
DownloadManager
downloadManager
;
private
int
lastStartId
;
...
...
@@ -214,7 +215,23 @@ public abstract class DownloadService extends Service {
foregroundNotificationId
,
foregroundNotificationUpdateInterval
,
/* channelId= */
null
,
/* channelNameResourceId= */
0
);
/* channelNameResourceId= */
0
,
/* channelDescriptionResourceId= */
0
);
}
/** @deprecated Use {@link #DownloadService(int, long, String, int, int)}. */
@Deprecated
protected
DownloadService
(
int
foregroundNotificationId
,
long
foregroundNotificationUpdateInterval
,
@Nullable
String
channelId
,
@StringRes
int
channelNameResourceId
)
{
this
(
foregroundNotificationId
,
foregroundNotificationUpdateInterval
,
channelId
,
channelNameResourceId
,
/* channelDescriptionResourceId= */
0
);
}
/**
...
...
@@ -230,25 +247,33 @@ public abstract class DownloadService extends Service {
* unique per package. The value may be truncated if it's too long. Ignored if {@code
* foregroundNotificationId} is {@link #FOREGROUND_NOTIFICATION_ID_NONE}.
* @param channelNameResourceId A string resource identifier for the user visible name of the
*
channel, if {@code channelId} is specified. The recommended maximum length is 40
*
characters. The value may be truncated if it is too long. Ignored
if {@code
*
notification channel. The recommended maximum length is 40 characters. The value may be
*
truncated if it's too long. Ignored if {@code channelId} is null or
if {@code
* foregroundNotificationId} is {@link #FOREGROUND_NOTIFICATION_ID_NONE}.
* @param channelDescriptionResourceId A string resource identifier for the user visible
* description of the notification channel, or 0 if no description is provided. The
* recommended maximum length is 300 characters. The value may be truncated if it is too long.
* Ignored if {@code channelId} is null or if {@code foregroundNotificationId} is {@link
* #FOREGROUND_NOTIFICATION_ID_NONE}.
*/
protected
DownloadService
(
int
foregroundNotificationId
,
long
foregroundNotificationUpdateInterval
,
@Nullable
String
channelId
,
@StringRes
int
channelNameResourceId
)
{
@StringRes
int
channelNameResourceId
,
@StringRes
int
channelDescriptionResourceId
)
{
if
(
foregroundNotificationId
==
FOREGROUND_NOTIFICATION_ID_NONE
)
{
this
.
foregroundNotificationUpdater
=
null
;
this
.
channelId
=
null
;
this
.
channelNameResourceId
=
0
;
this
.
channelDescriptionResourceId
=
0
;
}
else
{
this
.
foregroundNotificationUpdater
=
new
ForegroundNotificationUpdater
(
foregroundNotificationId
,
foregroundNotificationUpdateInterval
);
this
.
channelId
=
channelId
;
this
.
channelNameResourceId
=
channelNameResourceId
;
this
.
channelDescriptionResourceId
=
channelDescriptionResourceId
;
}
}
...
...
@@ -543,7 +568,11 @@ public abstract class DownloadService extends Service {
public
void
onCreate
()
{
if
(
channelId
!=
null
)
{
NotificationUtil
.
createNotificationChannel
(
this
,
channelId
,
channelNameResourceId
,
NotificationUtil
.
IMPORTANCE_LOW
);
this
,
channelId
,
channelNameResourceId
,
channelDescriptionResourceId
,
NotificationUtil
.
IMPORTANCE_LOW
);
}
Class
<?
extends
DownloadService
>
clazz
=
getClass
();
DownloadManagerHelper
downloadManagerHelper
=
downloadManagerListeners
.
get
(
clazz
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/util/NotificationUtil.java
View file @
0b756a96
...
...
@@ -61,6 +61,14 @@ public final class NotificationUtil {
/** @see NotificationManager#IMPORTANCE_HIGH */
public
static
final
int
IMPORTANCE_HIGH
=
NotificationManager
.
IMPORTANCE_HIGH
;
/** @deprecated Use {@link #createNotificationChannel(Context, String, int, int, int)}. */
@Deprecated
public
static
void
createNotificationChannel
(
Context
context
,
String
id
,
@StringRes
int
nameResourceId
,
@Importance
int
importance
)
{
createNotificationChannel
(
context
,
id
,
nameResourceId
,
/* descriptionResourceId= */
0
,
importance
);
}
/**
* Creates a notification channel that notifications can be posted to. See {@link
* NotificationChannel} and {@link
...
...
@@ -70,21 +78,33 @@ public final class NotificationUtil {
* @param id The id of the channel. Must be unique per package. The value may be truncated if it's
* too long.
* @param nameResourceId A string resource identifier for the user visible name of the channel.
* You can rename this channel when the system locale changes by listening for the {@link
* Intent#ACTION_LOCALE_CHANGED} broadcast. The recommended maximum length is 40 characters.
* The value may be truncated if it is too long.
* The recommended maximum length is 40 characters. The string may be truncated if it's too
* long. You can rename the channel when the system locale changes by listening for the {@link
* Intent#ACTION_LOCALE_CHANGED} broadcast.
* @param descriptionResourceId A string resource identifier for the user visible description of
* the channel, or 0 if no description is provided. The recommended maximum length is 300
* characters. The value may be truncated if it is too long. You can change the description of
* the channel when the system locale changes by listening for the {@link
* Intent#ACTION_LOCALE_CHANGED} broadcast.
* @param importance The importance of the channel. This controls how interruptive notifications
* posted to this channel are. One of {@link #IMPORTANCE_UNSPECIFIED}, {@link
* #IMPORTANCE_NONE}, {@link #IMPORTANCE_MIN}, {@link #IMPORTANCE_LOW}, {@link
* #IMPORTANCE_DEFAULT} and {@link #IMPORTANCE_HIGH}.
*/
public
static
void
createNotificationChannel
(
Context
context
,
String
id
,
@StringRes
int
nameResourceId
,
@Importance
int
importance
)
{
Context
context
,
String
id
,
@StringRes
int
nameResourceId
,
@StringRes
int
descriptionResourceId
,
@Importance
int
importance
)
{
if
(
Util
.
SDK_INT
>=
26
)
{
NotificationManager
notificationManager
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
NotificationChannel
channel
=
new
NotificationChannel
(
id
,
context
.
getString
(
nameResourceId
),
importance
);
if
(
descriptionResourceId
!=
0
)
{
channel
.
setDescription
(
context
.
getString
(
descriptionResourceId
));
}
notificationManager
.
createNotificationChannel
(
channel
);
}
}
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java
View file @
0b756a96
...
...
@@ -386,6 +386,26 @@ public class PlayerNotificationManager {
private
int
lastPlaybackState
;
/**
* @deprecated Use {@link #createWithNotificationChannel(Context, String, int, int, int,
* MediaDescriptionAdapter)}.
*/
@Deprecated
public
static
PlayerNotificationManager
createWithNotificationChannel
(
Context
context
,
String
channelId
,
@StringRes
int
channelName
,
int
notificationId
,
MediaDescriptionAdapter
mediaDescriptionAdapter
)
{
return
createWithNotificationChannel
(
context
,
channelId
,
channelName
,
/* channelDescription= */
0
,
notificationId
,
mediaDescriptionAdapter
);
}
/**
* Creates a notification manager and a low-priority notification channel with the specified
* {@code channelId} and {@code channelName}.
*
...
...
@@ -397,8 +417,12 @@ public class PlayerNotificationManager {
*
* @param context The {@link Context}.
* @param channelId The id of the notification channel.
* @param channelName A string resource identifier for the user visible name of the channel. The
* recommended maximum length is 40 characters; the value may be truncated if it is too long.
* @param channelName A string resource identifier for the user visible name of the notification
* channel. The recommended maximum length is 40 characters. The string may be truncated if
* it's too long.
* @param channelDescription A string resource identifier for the user visible description of the
* notification channel, or 0 if no description is provided. The recommended maximum length is
* 300 characters. The value may be truncated if it is too long.
* @param notificationId The id of the notification.
* @param mediaDescriptionAdapter The {@link MediaDescriptionAdapter}.
*/
...
...
@@ -406,15 +430,38 @@ public class PlayerNotificationManager {
Context
context
,
String
channelId
,
@StringRes
int
channelName
,
@StringRes
int
channelDescription
,
int
notificationId
,
MediaDescriptionAdapter
mediaDescriptionAdapter
)
{
NotificationUtil
.
createNotificationChannel
(
context
,
channelId
,
channelName
,
NotificationUtil
.
IMPORTANCE_LOW
);
context
,
channelId
,
channelName
,
channelDescription
,
NotificationUtil
.
IMPORTANCE_LOW
);
return
new
PlayerNotificationManager
(
context
,
channelId
,
notificationId
,
mediaDescriptionAdapter
);
}
/**
* @deprecated Use {@link #createWithNotificationChannel(Context, String, int, int, int,
* MediaDescriptionAdapter, NotificationListener)}.
*/
@Deprecated
public
static
PlayerNotificationManager
createWithNotificationChannel
(
Context
context
,
String
channelId
,
@StringRes
int
channelName
,
int
notificationId
,
MediaDescriptionAdapter
mediaDescriptionAdapter
,
@Nullable
NotificationListener
notificationListener
)
{
return
createWithNotificationChannel
(
context
,
channelId
,
channelName
,
/* channelDescription= */
0
,
notificationId
,
mediaDescriptionAdapter
,
notificationListener
);
}
/**
* Creates a notification manager and a low-priority notification channel with the specified
* {@code channelId} and {@code channelName}. The {@link NotificationListener} passed as the last
* parameter will be notified when the notification is created and cancelled.
...
...
@@ -422,7 +469,9 @@ public class PlayerNotificationManager {
* @param context The {@link Context}.
* @param channelId The id of the notification channel.
* @param channelName A string resource identifier for the user visible name of the channel. The
* recommended maximum length is 40 characters; the value may be truncated if it is too long.
* recommended maximum length is 40 characters. The string may be truncated if it's too long.
* @param channelDescription A string resource identifier for the user visible description of the
* channel, or 0 if no description is provided.
* @param notificationId The id of the notification.
* @param mediaDescriptionAdapter The {@link MediaDescriptionAdapter}.
* @param notificationListener The {@link NotificationListener}.
...
...
@@ -431,11 +480,12 @@ public class PlayerNotificationManager {
Context
context
,
String
channelId
,
@StringRes
int
channelName
,
@StringRes
int
channelDescription
,
int
notificationId
,
MediaDescriptionAdapter
mediaDescriptionAdapter
,
@Nullable
NotificationListener
notificationListener
)
{
NotificationUtil
.
createNotificationChannel
(
context
,
channelId
,
channelName
,
NotificationUtil
.
IMPORTANCE_LOW
);
context
,
channelId
,
channelName
,
channelDescription
,
NotificationUtil
.
IMPORTANCE_LOW
);
return
new
PlayerNotificationManager
(
context
,
channelId
,
notificationId
,
mediaDescriptionAdapter
,
notificationListener
);
}
...
...
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