diff --git a/app/src/main/java/com/kabouzeid/gramophone/service/MusicService.java b/app/src/main/java/com/kabouzeid/gramophone/service/MusicService.java
index 1b8a5e1f..9c6fd13f 100644
--- a/app/src/main/java/com/kabouzeid/gramophone/service/MusicService.java
+++ b/app/src/main/java/com/kabouzeid/gramophone/service/MusicService.java
@@ -201,12 +201,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
registerReceiver(widgetIntentReceiver, new IntentFilter(APP_WIDGET_UPDATE));
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- playingNotification = new PlayingNotificationImpl24();
- } else {
- playingNotification = new PlayingNotificationImpl();
- }
- playingNotification.init(this);
+ initNotification();
mediaStoreObserver = new MediaStoreObserver(playerHandler);
throttledSeekHandler = new ThrottledSeekHandler(playerHandler);
@@ -557,8 +552,17 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
return (getAudioManager().requestAudioFocus(audioFocusListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN) == AudioManager.AUDIOFOCUS_REQUEST_GRANTED);
}
- private void updateNotification() {
- if (getCurrentSong().id != -1) {
+ public void initNotification() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance(this).classicNotification()) {
+ playingNotification = new PlayingNotificationImpl24();
+ } else {
+ playingNotification = new PlayingNotificationImpl();
+ }
+ playingNotification.init(this);
+ }
+
+ public void updateNotification() {
+ if (playingNotification != null && getCurrentSong().id != -1) {
playingNotification.update();
}
}
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 58725a0d..9f9c017b 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
@@ -26,8 +26,10 @@ import com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceFragment
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager;
+import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.preferences.NowPlayingScreenPreference;
import com.kabouzeid.gramophone.preferences.NowPlayingScreenPreferenceDialog;
+import com.kabouzeid.gramophone.service.MusicService;
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
import com.kabouzeid.gramophone.util.NavigationUtil;
import com.kabouzeid.gramophone.util.PreferenceUtil;
@@ -127,6 +129,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.pref_general);
addPreferencesFromResource(R.xml.pref_colors);
+ addPreferencesFromResource(R.xml.pref_notification);
addPreferencesFromResource(R.xml.pref_now_playing_screen);
addPreferencesFromResource(R.xml.pref_images);
addPreferencesFromResource(R.xml.pref_lockscreen);
@@ -198,7 +201,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
}
});
- ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference("primary_color");
+ final ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference("primary_color");
final int primaryColor = ThemeStore.primaryColor(getActivity());
primaryColorPref.setColor(primaryColor, ColorUtil.darkenColor(primaryColor));
primaryColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@@ -214,7 +217,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
}
});
- ATEColorPreference accentColorPref = (ATEColorPreference) findPreference("accent_color");
+ final ATEColorPreference accentColorPref = (ATEColorPreference) findPreference("accent_color");
final int accentColor = ThemeStore.accentColor(getActivity());
accentColorPref.setColor(accentColor, ColorUtil.darkenColor(accentColor));
accentColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@@ -248,7 +251,30 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
});
}
- TwoStatePreference colorAppShortcuts = (TwoStatePreference) findPreference("should_color_app_shortcuts");
+ final TwoStatePreference classicNotification = (TwoStatePreference) findPreference("classic_notification");
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
+ classicNotification.setEnabled(false);
+ classicNotification.setSummary(R.string.pref_only_nougat);
+ } else {
+ classicNotification.setChecked(PreferenceUtil.getInstance(getActivity()).classicNotification());
+ classicNotification.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ //Save preference
+ PreferenceUtil.getInstance(getActivity()).setClassicNotification((Boolean)newValue);
+
+ final MusicService service = MusicPlayerRemote.musicService;
+ if (service != null) {
+ service.initNotification();
+ service.updateNotification();
+ }
+
+ return true;
+ }
+ });
+ }
+
+ final TwoStatePreference colorAppShortcuts = (TwoStatePreference) findPreference("should_color_app_shortcuts");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
colorAppShortcuts.setEnabled(false);
colorAppShortcuts.setSummary(R.string.pref_only_nougat_mr1);
@@ -261,16 +287,14 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
PreferenceUtil.getInstance(getActivity()).setColoredAppShortcuts((Boolean)newValue);
//Update app shortcuts
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
- new DynamicShortcutManager(getActivity()).updateDynamicShortcuts();
- }
+ new DynamicShortcutManager(getActivity()).updateDynamicShortcuts();
return true;
}
});
}
- Preference equalizer = findPreference("equalizer");
+ final Preference equalizer = findPreference("equalizer");
if (!hasEqualizer()) {
equalizer.setEnabled(false);
equalizer.setSummary(getResources().getString(R.string.no_equalizer));
diff --git a/app/src/main/java/com/kabouzeid/gramophone/util/PreferenceUtil.java b/app/src/main/java/com/kabouzeid/gramophone/util/PreferenceUtil.java
index 63deb986..69800a43 100644
--- a/app/src/main/java/com/kabouzeid/gramophone/util/PreferenceUtil.java
+++ b/app/src/main/java/com/kabouzeid/gramophone/util/PreferenceUtil.java
@@ -44,6 +44,8 @@ public final class PreferenceUtil {
public static final String FORCE_SQUARE_ALBUM_COVER = "force_square_album_art";
public static final String COLORED_NOTIFICATION = "colored_notification";
+ public static final String CLASSIC_NOTIFICATION = "classic_notification";
+
public static final String COLORED_APP_SHORTCUTS = "colored_app_shortcuts";
public static final String AUDIO_DUCKING = "audio_ducking";
@@ -149,6 +151,16 @@ public final class PreferenceUtil {
return mPreferences.getBoolean(COLORED_NOTIFICATION, true);
}
+ public final boolean classicNotification() {
+ return mPreferences.getBoolean(CLASSIC_NOTIFICATION, false);
+ }
+
+ public void setClassicNotification(final boolean value) {
+ final SharedPreferences.Editor editor = mPreferences.edit();
+ editor.putBoolean(CLASSIC_NOTIFICATION, value);
+ editor.apply();
+ }
+
public void setColoredAppShortcuts(final boolean value) {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean(COLORED_APP_SHORTCUTS, value);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d30c60fd..b151bfc7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -118,6 +118,7 @@
General
Images
Lockscreen
+ Notification
Colored navigation bar
Colored app shortcuts
Start page
@@ -125,6 +126,7 @@
Auto download artist images
Blur album cover
Colored notification
+ Classic notification design
Ignore Media Store covers
Gapless playback
Square album cover
@@ -158,10 +160,12 @@
Empty
Playlist name
Song
- "Only available on Lollipop."
- "Only available on Nougat 7.1."
+ "Only available on Lollipop or above."
+ "Only available on Nougat 7.0 or above."
+ "Only available on Nougat 7.1 or above."
Uses the current songs album cover as lockscreen wallpaper.
Blurs the album cover on the lockscreen. Can cause problems with third party apps and widgets.
+ Use the classic notification design.
"Colors the notification in the album cover\u2019s vibrant color."
"Can cause playback issues on some devices."
Album covers in the now playing view are always squared.
diff --git a/app/src/main/res/xml/pref_colors.xml b/app/src/main/res/xml/pref_colors.xml
index 4ec32d77..e7701f96 100644
--- a/app/src/main/res/xml/pref_colors.xml
+++ b/app/src/main/res/xml/pref_colors.xml
@@ -14,12 +14,6 @@
android:summary="@string/accent_color_desc"
android:title="@string/accent_color" />
-
-
+
+
+
+
+
+
+
+
+
+