Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Casanowow Life for love
VLC-Android
Commits
214cdaf8
Commit
214cdaf8
authored
Aug 24, 2017
by
Geoffrey Métais
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine notification channels management
parent
881bf973
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
12 deletions
+24
-12
vlc-android/res/values/strings.xml
vlc-android/res/values/strings.xml
+4
-0
vlc-android/src/org/videolan/vlc/PlaybackService.java
vlc-android/src/org/videolan/vlc/PlaybackService.java
+0
-2
vlc-android/src/org/videolan/vlc/VLCApplication.java
vlc-android/src/org/videolan/vlc/VLCApplication.java
+1
-1
vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.java
.../src/org/videolan/vlc/gui/helpers/NotificationHelper.java
+19
-9
No files found.
vlc-android/res/values/strings.xml
View file @
214cdaf8
...
...
@@ -28,6 +28,10 @@
</plurals>
<string
name=
"play"
>
Play
</string>
<string
name=
"playback"
>
Playback
</string>
<string
name=
"playback_controls"
>
Playback controls
</string>
<string
name=
"medialibrary_scan"
>
Media library scan
</string>
<string
name=
"Medialibrary_progress"
>
Media library scanning progress updates
</string>
<string
name=
"play_from_start"
>
Play from start
</string>
<string
name=
"play_as_audio"
>
Play as audio
</string>
<string
name=
"play_as_video"
>
Play as video
</string>
...
...
vlc-android/src/org/videolan/vlc/PlaybackService.java
View file @
214cdaf8
...
...
@@ -908,8 +908,6 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
Notification
notification
=
NotificationHelper
.
createPlaybackNotification
(
PlaybackService
.
this
,
mw
.
hasFlag
(
MediaWrapper
.
MEDIA_FORCE_AUDIO
),
title
,
artist
,
album
,
cover
,
playing
,
sessionToken
,
getSessionPendingIntent
());
startService
(
new
Intent
(
ctx
,
PlaybackService
.
class
));
if
(!
AndroidUtil
.
isLolliPopOrLater
||
playing
)
PlaybackService
.
this
.
startForeground
(
3
,
notification
);
else
{
...
...
vlc-android/src/org/videolan/vlc/VLCApplication.java
View file @
214cdaf8
...
...
@@ -96,7 +96,7 @@ public class VLCApplication extends Application {
@Override
public
void
run
()
{
if
(
AndroidUtil
.
isOOrLater
)
NotificationHelper
.
createNotificationChannel
();
NotificationHelper
.
createNotificationChannel
s
();
// Prepare cache folder constants
AudioUtil
.
prepareCacheFolder
(
instance
);
...
...
vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.java
View file @
214cdaf8
...
...
@@ -58,7 +58,7 @@ public class NotificationHelper {
final
PendingIntent
piPlay
=
PendingIntent
.
getBroadcast
(
ctx
,
0
,
new
Intent
(
PlaybackService
.
ACTION_REMOTE_PLAYPAUSE
),
PendingIntent
.
FLAG_UPDATE_CURRENT
);
final
PendingIntent
piForward
=
PendingIntent
.
getBroadcast
(
ctx
,
0
,
new
Intent
(
PlaybackService
.
ACTION_REMOTE_FORWARD
),
PendingIntent
.
FLAG_UPDATE_CURRENT
);
if
(
AndroidUtil
.
isOOrLater
)
{
final
Notification
.
Builder
builder
=
new
Notification
.
Builder
(
ctx
,
"vlc_
channel
"
);
final
Notification
.
Builder
builder
=
new
Notification
.
Builder
(
ctx
,
"vlc_
playback
"
);
builder
.
setSmallIcon
(
video
?
R
.
drawable
.
ic_notif_video
:
R
.
drawable
.
ic_notif_audio
)
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PUBLIC
)
.
setContentTitle
(
title
)
...
...
@@ -83,6 +83,7 @@ public class NotificationHelper {
.
setShowActionsInCompactView
(
0
,
1
,
2
)
);
}
ctx
.
startForegroundService
(
new
Intent
(
ctx
,
PlaybackService
.
class
));
return
builder
.
build
();
}
else
{
final
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
ctx
);
...
...
@@ -111,6 +112,7 @@ public class NotificationHelper {
.
setCancelButtonIntent
(
piStop
)
);
}
ctx
.
startService
(
new
Intent
(
ctx
,
PlaybackService
.
class
));
return
builder
.
build
();
}
}
...
...
@@ -121,7 +123,7 @@ public class NotificationHelper {
public
static
Notification
createScanNotification
(
Context
ctx
,
String
progressText
,
boolean
updateActions
,
boolean
paused
)
{
if
(
AndroidUtil
.
isOOrLater
)
{
if
(
scanBuilder
==
null
)
{
scanBuilder
=
new
Notification
.
Builder
(
ctx
,
"vlc_
channel
"
)
scanBuilder
=
new
Notification
.
Builder
(
ctx
,
"vlc_
medialibrary
"
)
.
setContentIntent
(
PendingIntent
.
getActivity
(
ctx
,
0
,
new
Intent
(
ctx
,
StartActivity
.
class
),
PendingIntent
.
FLAG_UPDATE_CURRENT
))
.
setSmallIcon
(
R
.
drawable
.
ic_notif_scan
)
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PUBLIC
)
...
...
@@ -168,14 +170,22 @@ public class NotificationHelper {
private
static
NotificationManager
sNotificationManager
;
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
O
)
public
static
void
createNotificationChannel
()
{
public
static
void
createNotificationChannel
s
()
{
if
(
sNotificationManager
==
null
)
sNotificationManager
=
(
NotificationManager
)
VLCApplication
.
getAppContext
().
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
final
CharSequence
name
=
VLCApplication
.
getAppResources
().
getString
(
R
.
string
.
app_name
);
final
String
description
=
VLCApplication
.
getAppResources
().
getString
(
R
.
string
.
app_name_full
);
final
int
importance
=
NotificationManager
.
IMPORTANCE_DEFAULT
;
NotificationChannel
mChannel
=
new
NotificationChannel
(
"vlc_channel"
,
name
,
importance
);
mChannel
.
setDescription
(
description
);
sNotificationManager
.
createNotificationChannel
(
mChannel
);
// Playback channel
CharSequence
name
=
VLCApplication
.
getAppResources
().
getString
(
R
.
string
.
playback
);
String
description
=
VLCApplication
.
getAppResources
().
getString
(
R
.
string
.
playback_controls
);
NotificationChannel
channel
=
new
NotificationChannel
(
"vlc_playback"
,
name
,
NotificationManager
.
IMPORTANCE_DEFAULT
);
channel
.
setDescription
(
description
);
channel
.
setLockscreenVisibility
(
Notification
.
VISIBILITY_PUBLIC
);
sNotificationManager
.
createNotificationChannel
(
channel
);
// Scan channel
name
=
VLCApplication
.
getAppResources
().
getString
(
R
.
string
.
medialibrary_scan
);
description
=
VLCApplication
.
getAppResources
().
getString
(
R
.
string
.
Medialibrary_progress
);
channel
=
new
NotificationChannel
(
"vlc_medialibrary"
,
name
,
NotificationManager
.
IMPORTANCE_DEFAULT
);
channel
.
setDescription
(
description
);
channel
.
setLockscreenVisibility
(
Notification
.
VISIBILITY_PUBLIC
);
sNotificationManager
.
createNotificationChannel
(
channel
);
}
}
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