Skip to content

Commit

Permalink
Add some compat info for new media style notification
Browse files Browse the repository at this point in the history
  • Loading branch information
daneren2005 committed Oct 3, 2020
1 parent 98664a8 commit bf5f8ef
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions app/src/main/java/github/daneren2005/dsub/util/Notifications.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,29 @@ public static void showPlayingNotification(final Context context, final Download
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;
Expand Down

0 comments on commit bf5f8ef

Please sign in to comment.