[Android] Fix notification content when no artist nor album

Geoffrey Métais git at videolan.org
Thu Nov 3 11:34:25 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov  2 09:53:23 2016 +0100| [19d2de79cdafcd66c1fcd8741b37904938ea29f1] | committer: Geoffrey Métais

Fix notification content when no artist nor album

> https://code.videolan.org/videolan/vlc-android/commit/19d2de79cdafcd66c1fcd8741b37904938ea29f1
---

 vlc-android/src/org/videolan/vlc/PlaybackService.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 3be9e4a..c35c582 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -841,11 +841,15 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
                     new Intent(ACTION_REMOTE_STOP), PendingIntent.FLAG_UPDATE_CURRENT);
 
             // add notification to status bar
+            StringBuilder contentBuilder = new StringBuilder(artist);
+            if (contentBuilder.length() > 0 && !TextUtils.isEmpty(album))
+                contentBuilder.append(" - ");
+            contentBuilder.append(album);
             NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
             builder.setSmallIcon(R.drawable.ic_stat_vlc)
                 .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
                 .setContentTitle(title)
-                .setContentText(artist + " - " + album)
+                .setContentText(contentBuilder.toString())
                 .setLargeIcon(cover)
                 .setTicker(title + " - " + artist)
                 .setAutoCancel(!mMediaPlayer.isPlaying())



More information about the Android mailing list