diff options
author | Scott Jackson <daneren2005@gmail.com> | 2020-10-02 20:15:30 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2020-10-02 20:15:30 -0700 |
commit | bf5f8ef21ae6415ae5b7a4ed2525fec1a1dc5420 (patch) | |
tree | 89c3698cf798c750fa6a25e73e58e5ed73373108 /app/src/main/java | |
parent | 98664a8193e98689f9fdadeaa3111a0099e56a53 (diff) | |
download | dsub-bf5f8ef21ae6415ae5b7a4ed2525fec1a1dc5420.tar.gz dsub-bf5f8ef21ae6415ae5b7a4ed2525fec1a1dc5420.tar.bz2 dsub-bf5f8ef21ae6415ae5b7a4ed2525fec1a1dc5420.zip |
Add some compat info for new media style notification
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/Notifications.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java index 35ab505d..e1781c47 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java @@ -91,9 +91,29 @@ public final class Notifications { mediaStyle.setShowActionsInCompactView(0, 2, 4); } + String title = song.getTitle(); + String artist = song.getArtist(); + String album = song.getAlbum(); + NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, "now-playing-channel") - .setSmallIcon(R.drawable.stat_notify_playing) - .setStyle(mediaStyle); + .setSmallIcon(R.drawable.stat_notify_playing) + .setContentTitle(title) + .setContentText(artist + " - " + album) + .setStyle(mediaStyle); + + // Set the album art. + try { + ImageLoader imageLoader = SubsonicActivity.getStaticImageLoader(context); + if(imageLoader != null) { + Bitmap bitmap = imageLoader.getCachedImage(context, song, false); + + if(bitmap != null) { + notificationBuilder.setLargeIcon(bitmap); + } + } + } catch (Exception x) { + Log.w(TAG, "Failed to get notification cover art", x); + } PendingIntent prevIntent = null; PendingIntent nextIntent = null; |