diff --git a/app/src/main/java/com/kabouzeid/gramophone/helper/PlayingNotificationHelper.java b/app/src/main/java/com/kabouzeid/gramophone/helper/PlayingNotificationHelper.java
index f401cb3d..d4e82998 100644
--- a/app/src/main/java/com/kabouzeid/gramophone/helper/PlayingNotificationHelper.java
+++ b/app/src/main/java/com/kabouzeid/gramophone/helper/PlayingNotificationHelper.java
@@ -8,9 +8,11 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.TaskStackBuilder;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.support.v4.app.NotificationCompat;
import android.support.v7.graphics.Palette;
@@ -34,6 +36,8 @@ public class PlayingNotificationHelper {
public static final String TAG = PlayingNotificationHelper.class.getSimpleName();
public static final int NOTIFICATION_ID = 1337;
+ public static final String ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED = "com.kabouzeid.gramophone.NOTIFICATION_COLOR_PREFERENCE_CHANGED";
+ public static final String EXTRA_NOTIFICATION_COLORED = "com.kabouzeid.gramophone.EXTRA_NOTIFICATION_COLORED";
private final MusicService service;
@@ -44,20 +48,53 @@ public class PlayingNotificationHelper {
private RemoteViews notificationLayoutExpanded;
private Song currentSong;
+ private boolean isPlaying;
private String currentAlbumArtUri;
+ private boolean isColored;
+ private boolean isReceiverRegistered;
+ private boolean isNotificationShown;
+
+ final IntentFilter intentFilter;
+
public PlayingNotificationHelper(final MusicService service) {
this.service = service;
notificationManager = (NotificationManager) service
.getSystemService(Context.NOTIFICATION_SERVICE);
+
+ intentFilter = new IntentFilter();
+ intentFilter.addAction(ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED);
}
+ private BroadcastReceiver notificationColorPreferenceChangedReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED)) {
+ boolean isColored = intent.getBooleanExtra(EXTRA_NOTIFICATION_COLORED, false);
+ if (isNotificationShown && PlayingNotificationHelper.this.isColored != isColored) {
+ buildNotification(currentSong, isPlaying, isColored);
+ }
+ }
+ }
+ };
+
public void buildNotification(final Song song, final boolean isPlaying) {
+ buildNotification(song, isPlaying, PreferenceUtils.getInstance(service).coloredNotification());
+ }
+
+ private void buildNotification(final Song song, final boolean isPlaying, final boolean isColored) {
+ this.isColored = isColored;
currentSong = song;
+ this.isPlaying = isPlaying;
+ if (!isReceiverRegistered)
+ service.registerReceiver(notificationColorPreferenceChangedReceiver, intentFilter);
+ isReceiverRegistered = true;
+ isNotificationShown = true;
+
notificationLayout = new RemoteViews(service.getPackageName(),
- R.layout.notification_controller);
+ isColored ? R.layout.notification_controller_colored : R.layout.notification_controller);
notificationLayoutExpanded = new RemoteViews(service.getPackageName(),
- R.layout.notification_controller_big);
+ isColored ? R.layout.notification_controller_big_colored : R.layout.notification_controller_big);
notification = new NotificationCompat.Builder(service)
.setSmallIcon(R.drawable.ic_notification)
@@ -73,8 +110,8 @@ public class PlayingNotificationHelper {
setUpCollapsedLayout();
setUpExpandedLayout();
loadAlbumArt();
- setUpPlaybackActions(isPlaying);
- setUpExpandedPlaybackActions(isPlaying);
+ setUpPlaybackActions();
+ setUpExpandedPlaybackActions();
service.startForeground(NOTIFICATION_ID, notification);
}
@@ -87,7 +124,7 @@ public class PlayingNotificationHelper {
return taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
}
- private void setUpExpandedPlaybackActions(boolean isPlaying) {
+ private void setUpExpandedPlaybackActions() {
notificationLayoutExpanded.setOnClickPendingIntent(R.id.action_play_pause,
retrievePlaybackActions(1));
@@ -104,7 +141,7 @@ public class PlayingNotificationHelper {
isPlaying ? R.drawable.ic_pause_white_36dp : R.drawable.ic_play_arrow_white_36dp);
}
- private void setUpPlaybackActions(boolean isPlaying) {
+ private void setUpPlaybackActions() {
notificationLayout.setOnClickPendingIntent(R.id.action_play_pause,
retrievePlaybackActions(1));
@@ -183,12 +220,14 @@ public class PlayingNotificationHelper {
}
private void setAlbumArt(Bitmap albumArt) {
- int defaultColor = service.getResources().getColor(R.color.default_notification_color);
+ int defaultColor = isColored ?
+ service.getResources().getColor(R.color.default_colored_notification_color) :
+ service.getResources().getColor(R.color.default_notification_color);
int newColor = defaultColor;
if (albumArt != null) {
notificationLayout.setImageViewBitmap(R.id.icon, albumArt);
notificationLayoutExpanded.setImageViewBitmap(R.id.icon, albumArt);
- if (PreferenceUtils.getInstance(service).coloredNotification())
+ if (isColored)
newColor = Palette.from(albumArt).generate().getVibrantColor(defaultColor);
} else {
notificationLayout.setImageViewResource(R.id.icon, R.drawable.default_album_art);
@@ -201,11 +240,17 @@ public class PlayingNotificationHelper {
}
public void killNotification() {
+ if (isReceiverRegistered)
+ service.unregisterReceiver(notificationColorPreferenceChangedReceiver);
+ isReceiverRegistered = false;
service.stopForeground(true);
notification = null;
+ isNotificationShown = false;
}
public void updatePlayState(final boolean isPlaying) {
+ this.isPlaying = isPlaying;
+
if (notification == null || notificationManager == null) {
return;
}
diff --git a/app/src/main/java/com/kabouzeid/gramophone/model/UIPreferenceChangedEvent.java b/app/src/main/java/com/kabouzeid/gramophone/model/UIPreferenceChangedEvent.java
index b1fea376..01e56e7d 100644
--- a/app/src/main/java/com/kabouzeid/gramophone/model/UIPreferenceChangedEvent.java
+++ b/app/src/main/java/com/kabouzeid/gramophone/model/UIPreferenceChangedEvent.java
@@ -13,6 +13,7 @@ public class UIPreferenceChangedEvent {
public static final int COLORED_NAVIGATION_BAR_CURRENT_PLAYING_CHANGED = 6;
public static final int COLORED_NAVIGATION_BAR_CHANGED = 10;
public static final int COLORED_NAVIGATION_BAR_OTHER_SCREENS_CHANGED = 7;
+ public static final int COLORED_NOTIFICATION_CHANGED = 11;
private final int action;
private final Object value;
diff --git a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/SettingsActivity.java b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/SettingsActivity.java
index 1f075472..a19d89ba 100644
--- a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/SettingsActivity.java
+++ b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/SettingsActivity.java
@@ -17,6 +17,7 @@ import com.afollestad.materialdialogs.util.DialogUtils;
import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
+import com.kabouzeid.gramophone.helper.PlayingNotificationHelper;
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
import com.kabouzeid.gramophone.prefs.ColorChooserPreference;
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
@@ -137,11 +138,13 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
}
Preference coloredNotification = findPreference("colored_notification");
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
- coloredNotification.setEnabled(false);
- coloredNotification.setWidgetLayoutResource(0);
- coloredNotification.setSummary(R.string.pref_only_lollipop);
- }
+ coloredNotification.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ getActivity().sendBroadcast(new Intent(PlayingNotificationHelper.ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED).putExtra(PlayingNotificationHelper.EXTRA_NOTIFICATION_COLORED, (boolean) newValue));
+ return true;
+ }
+ });
equalizer = findPreference("equalizer");
resolveEqualizer();
diff --git a/app/src/main/res/drawable-hdpi/ic_pause_black_36dp.png b/app/src/main/res/drawable-hdpi/ic_pause_black_36dp.png
index 8d1f8e76..fb4967bc 100644
Binary files a/app/src/main/res/drawable-hdpi/ic_pause_black_36dp.png and b/app/src/main/res/drawable-hdpi/ic_pause_black_36dp.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_play_arrow_black_36dp.png b/app/src/main/res/drawable-hdpi/ic_play_arrow_black_36dp.png
index a39ac1cc..6fd60570 100644
Binary files a/app/src/main/res/drawable-hdpi/ic_play_arrow_black_36dp.png and b/app/src/main/res/drawable-hdpi/ic_play_arrow_black_36dp.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_skip_next_black_36dp.png b/app/src/main/res/drawable-hdpi/ic_skip_next_black_36dp.png
index cce0a322..b66ad207 100644
Binary files a/app/src/main/res/drawable-hdpi/ic_skip_next_black_36dp.png and b/app/src/main/res/drawable-hdpi/ic_skip_next_black_36dp.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_skip_previous_black_36dp.png b/app/src/main/res/drawable-hdpi/ic_skip_previous_black_36dp.png
index 27ebe3e5..5ab79657 100644
Binary files a/app/src/main/res/drawable-hdpi/ic_skip_previous_black_36dp.png and b/app/src/main/res/drawable-hdpi/ic_skip_previous_black_36dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_pause_black_36dp.png b/app/src/main/res/drawable-mdpi/ic_pause_black_36dp.png
index 2403aa5e..4dffa8e5 100644
Binary files a/app/src/main/res/drawable-mdpi/ic_pause_black_36dp.png and b/app/src/main/res/drawable-mdpi/ic_pause_black_36dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_play_arrow_black_36dp.png b/app/src/main/res/drawable-mdpi/ic_play_arrow_black_36dp.png
index f8803e54..2e70b039 100644
Binary files a/app/src/main/res/drawable-mdpi/ic_play_arrow_black_36dp.png and b/app/src/main/res/drawable-mdpi/ic_play_arrow_black_36dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_skip_next_black_36dp.png b/app/src/main/res/drawable-mdpi/ic_skip_next_black_36dp.png
index dbf4f541..9354ad31 100644
Binary files a/app/src/main/res/drawable-mdpi/ic_skip_next_black_36dp.png and b/app/src/main/res/drawable-mdpi/ic_skip_next_black_36dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_skip_previous_black_36dp.png b/app/src/main/res/drawable-mdpi/ic_skip_previous_black_36dp.png
index c7e1dc89..ea3c3a40 100644
Binary files a/app/src/main/res/drawable-mdpi/ic_skip_previous_black_36dp.png and b/app/src/main/res/drawable-mdpi/ic_skip_previous_black_36dp.png differ
diff --git a/app/src/main/res/drawable-v21/colored_notification_selector.xml b/app/src/main/res/drawable-v21/colored_notification_selector.xml
new file mode 100644
index 00000000..1941b7a4
--- /dev/null
+++ b/app/src/main/res/drawable-v21/colored_notification_selector.xml
@@ -0,0 +1,7 @@
+
+
+ -
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v21/notification_selector.xml b/app/src/main/res/drawable-v21/notification_selector.xml
index b8dfa68e..95959882 100644
--- a/app/src/main/res/drawable-v21/notification_selector.xml
+++ b/app/src/main/res/drawable-v21/notification_selector.xml
@@ -1,6 +1,6 @@
+ android:color="@color/ripple_material_light">
-
diff --git a/app/src/main/res/drawable-xhdpi/ic_pause_black_36dp.png b/app/src/main/res/drawable-xhdpi/ic_pause_black_36dp.png
index 1b3371da..ec6617a7 100644
Binary files a/app/src/main/res/drawable-xhdpi/ic_pause_black_36dp.png and b/app/src/main/res/drawable-xhdpi/ic_pause_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_play_arrow_black_36dp.png b/app/src/main/res/drawable-xhdpi/ic_play_arrow_black_36dp.png
index 902760bc..91defe84 100644
Binary files a/app/src/main/res/drawable-xhdpi/ic_play_arrow_black_36dp.png and b/app/src/main/res/drawable-xhdpi/ic_play_arrow_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_skip_next_black_36dp.png b/app/src/main/res/drawable-xhdpi/ic_skip_next_black_36dp.png
index 59623648..94c2a3ca 100644
Binary files a/app/src/main/res/drawable-xhdpi/ic_skip_next_black_36dp.png and b/app/src/main/res/drawable-xhdpi/ic_skip_next_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_skip_previous_black_36dp.png b/app/src/main/res/drawable-xhdpi/ic_skip_previous_black_36dp.png
index f4040ad6..924fe054 100644
Binary files a/app/src/main/res/drawable-xhdpi/ic_skip_previous_black_36dp.png and b/app/src/main/res/drawable-xhdpi/ic_skip_previous_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_pause_black_36dp.png b/app/src/main/res/drawable-xxhdpi/ic_pause_black_36dp.png
index cfb2bcb9..b12904c0 100644
Binary files a/app/src/main/res/drawable-xxhdpi/ic_pause_black_36dp.png and b/app/src/main/res/drawable-xxhdpi/ic_pause_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_play_arrow_black_36dp.png b/app/src/main/res/drawable-xxhdpi/ic_play_arrow_black_36dp.png
index 2f8c6504..6f4ef0ed 100644
Binary files a/app/src/main/res/drawable-xxhdpi/ic_play_arrow_black_36dp.png and b/app/src/main/res/drawable-xxhdpi/ic_play_arrow_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_skip_next_black_36dp.png b/app/src/main/res/drawable-xxhdpi/ic_skip_next_black_36dp.png
index 0adad311..6c4d7c9f 100644
Binary files a/app/src/main/res/drawable-xxhdpi/ic_skip_next_black_36dp.png and b/app/src/main/res/drawable-xxhdpi/ic_skip_next_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_skip_previous_black_36dp.png b/app/src/main/res/drawable-xxhdpi/ic_skip_previous_black_36dp.png
index 36b017b0..401c515c 100644
Binary files a/app/src/main/res/drawable-xxhdpi/ic_skip_previous_black_36dp.png and b/app/src/main/res/drawable-xxhdpi/ic_skip_previous_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_pause_black_36dp.png b/app/src/main/res/drawable-xxxhdpi/ic_pause_black_36dp.png
index 59cdb01f..057caefe 100644
Binary files a/app/src/main/res/drawable-xxxhdpi/ic_pause_black_36dp.png and b/app/src/main/res/drawable-xxxhdpi/ic_pause_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_play_arrow_black_36dp.png b/app/src/main/res/drawable-xxxhdpi/ic_play_arrow_black_36dp.png
index 371a01f9..3df61f4f 100644
Binary files a/app/src/main/res/drawable-xxxhdpi/ic_play_arrow_black_36dp.png and b/app/src/main/res/drawable-xxxhdpi/ic_play_arrow_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_skip_next_black_36dp.png b/app/src/main/res/drawable-xxxhdpi/ic_skip_next_black_36dp.png
index 51540520..d25fcc04 100644
Binary files a/app/src/main/res/drawable-xxxhdpi/ic_skip_next_black_36dp.png and b/app/src/main/res/drawable-xxxhdpi/ic_skip_next_black_36dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_skip_previous_black_36dp.png b/app/src/main/res/drawable-xxxhdpi/ic_skip_previous_black_36dp.png
index 311229d3..9302f977 100644
Binary files a/app/src/main/res/drawable-xxxhdpi/ic_skip_previous_black_36dp.png and b/app/src/main/res/drawable-xxxhdpi/ic_skip_previous_black_36dp.png differ
diff --git a/app/src/main/res/drawable/colored_notification_selector.xml b/app/src/main/res/drawable/colored_notification_selector.xml
new file mode 100644
index 00000000..4cbc5ae3
--- /dev/null
+++ b/app/src/main/res/drawable/colored_notification_selector.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/notification_controller.xml b/app/src/main/res/layout/notification_controller.xml
index c2b3758a..d76a0a67 100644
--- a/app/src/main/res/layout/notification_controller.xml
+++ b/app/src/main/res/layout/notification_controller.xml
@@ -63,7 +63,7 @@
android:gravity="bottom"
android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification.Title"
- android:textColor="@color/notification_default_content_color"
+ android:textColor="@color/default_notification_content_color"
tools:ignore="NestedWeights" />
+ android:textColor="@color/default_notification_secondary_content_color" />
diff --git a/app/src/main/res/layout/notification_controller_big.xml b/app/src/main/res/layout/notification_controller_big.xml
index 472f7fe0..a134435f 100644
--- a/app/src/main/res/layout/notification_controller_big.xml
+++ b/app/src/main/res/layout/notification_controller_big.xml
@@ -41,7 +41,7 @@
android:layout_marginTop="2dp"
android:background="@drawable/notification_selector"
android:src="@drawable/ic_close_white_24dp"
- android:tint="@color/notification_default_content_color"
+ android:tint="@color/default_notification_content_color"
tools:ignore="ContentDescription" />
+ android:textColor="@color/default_notification_content_color" />
+ android:textColor="@color/default_notification_secondary_content_color" />
+ android:textColor="@color/default_notification_secondary_content_color" />
diff --git a/app/src/main/res/layout/notification_controller_big_colored.xml b/app/src/main/res/layout/notification_controller_big_colored.xml
new file mode 100644
index 00000000..18275707
--- /dev/null
+++ b/app/src/main/res/layout/notification_controller_big_colored.xml
@@ -0,0 +1,152 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/notification_controller_colored.xml b/app/src/main/res/layout/notification_controller_colored.xml
new file mode 100644
index 00000000..c831be06
--- /dev/null
+++ b/app/src/main/res/layout/notification_controller_colored.xml
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-v21/colors.xml b/app/src/main/res/values-v21/colors.xml
index 8269d51d..d19798df 100644
--- a/app/src/main/res/values-v21/colors.xml
+++ b/app/src/main/res/values-v21/colors.xml
@@ -1,7 +1,11 @@
- #de000000
- #aa000000
+ #de000000
+ #aa000000
+
+ @color/grey_800
+ #deFFFFFF
+ #aaFFFFFF
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
index 63cc3f58..0b4c2b3a 100644
--- a/app/src/main/res/values-v21/styles.xml
+++ b/app/src/main/res/values-v21/styles.xml
@@ -24,7 +24,7 @@