summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLinus Lee <llee@cyngn.com>2014-12-12 23:27:16 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2014-12-12 23:27:16 +0000
commitc39e47d7f64598f301c1cda74fd3c143d2edd9f6 (patch)
tree7bcf62f37d0d3e650fbe7eab93a7818d9c782a3a /src
parenta2c41023951c7ba420a34138d960478796f9e5b8 (diff)
parent980e8fe4eb99aa4ad2805b4cd5d44ff3c6677360 (diff)
downloadandroid_packages_apps_Eleven-c39e47d7f64598f301c1cda74fd3c143d2edd9f6.tar.gz
android_packages_apps_Eleven-c39e47d7f64598f301c1cda74fd3c143d2edd9f6.tar.bz2
android_packages_apps_Eleven-c39e47d7f64598f301c1cda74fd3c143d2edd9f6.zip
Merge "Update Notification background color" into cm-12.0
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/eleven/MusicPlaybackService.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/com/cyanogenmod/eleven/MusicPlaybackService.java b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
index 85f45dd..e6af28f 100644
--- a/src/com/cyanogenmod/eleven/MusicPlaybackService.java
+++ b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
@@ -51,6 +51,7 @@ import android.os.SystemClock;
import android.provider.MediaStore;
import android.provider.MediaStore.Audio.AlbumColumns;
import android.provider.MediaStore.Audio.AudioColumns;
+import android.support.v7.graphics.Palette;
import android.text.TextUtils;
import android.util.Log;
@@ -486,6 +487,7 @@ public class MusicPlaybackService extends Service {
// to improve perf, instead of hitting the disk cache or file cache, store the bitmaps in memory
private String mCachedKey;
private Bitmap[] mCachedBitmap = new Bitmap[2];
+ private int mCachedBitmapAccentColor = 0;
/**
* Image cache
@@ -1482,16 +1484,18 @@ public class MusicPlaybackService extends Service {
Intent nowPlayingIntent = new Intent("com.cyanogenmod.eleven.AUDIO_PLAYER")
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent clickIntent = PendingIntent.getActivity(this, 0, nowPlayingIntent, 0);
+ Bitmap artwork = getAlbumArt(false);
// TODO: Add back a beter small icon when we have time
- Notification notification = new Notification.Builder(this)
+ Notification.Builder builder = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
- .setLargeIcon(getAlbumArt(false))
+ .setLargeIcon(artwork)
.setContentIntent(clickIntent)
.setContentTitle(getTrackName())
.setContentText(text)
.setShowWhen(false)
.setStyle(style)
+ .setShowWhen(false)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.addAction(R.drawable.btn_playback_previous,
getString(R.string.accessibility_prev),
@@ -1500,10 +1504,27 @@ public class MusicPlaybackService extends Service {
retrievePlaybackAction(TOGGLEPAUSE_ACTION))
.addAction(R.drawable.btn_playback_next,
getString(R.string.accessibility_next),
- retrievePlaybackAction(NEXT_ACTION))
- .build();
+ retrievePlaybackAction(NEXT_ACTION));
+
+ if (mCachedBitmapAccentColor == 0 && artwork != null) {
+ // Generate a new Palette from the current artwork
+ final Palette p = Palette.generate(artwork);
+ if (p != null) {
+ // Check for dark vibrant colors, then vibrant
+ Palette.Swatch swatch = p.getDarkVibrantSwatch();
+ if (swatch == null) {
+ swatch = p.getVibrantSwatch();
+ }
+ if (swatch != null) {
+ mCachedBitmapAccentColor = swatch.getRgb();
+ }
+ }
+ }
+ if (mCachedBitmapAccentColor != 0) {
+ builder.setColor(mCachedBitmapAccentColor);
+ }
- startForeground(hashCode(), notification);
+ startForeground(hashCode(), builder.build());
}
private final PendingIntent retrievePlaybackAction(final String action) {
@@ -2603,6 +2624,7 @@ public class MusicPlaybackService extends Service {
if (!key.equals(mCachedKey)) {
mCachedBitmap[0] = null;
mCachedBitmap[1] = null;
+ mCachedBitmapAccentColor = 0;
}
// store the new key and bitmap