From bf5f8ef21ae6415ae5b7a4ed2525fec1a1dc5420 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 2 Oct 2020 20:15:30 -0700 Subject: Add some compat info for new media style notification --- .../daneren2005/dsub/util/Notifications.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'app/src') 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; -- cgit v1.2.3