Hide colored notification on O standard notification

This commit is contained in:
Karim Abou Zeid 2017-09-04 21:19:31 +02:00
commit f581b40f33
4 changed files with 33 additions and 7 deletions

View file

@ -101,7 +101,7 @@ public class PlayingNotificationImpl24 extends PlayingNotification {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setStyle(new MediaStyle().setMediaSession(service.getMediaSession().getSessionToken()).setShowActionsInCompactView(0, 1, 2))
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
if (PreferenceUtil.getInstance(service).coloredNotification())
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && PreferenceUtil.getInstance(service).coloredNotification())
builder.setColor(color);
}

View file

@ -294,6 +294,21 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
});
}
final TwoStatePreference coloredNotification = (TwoStatePreference) findPreference("colored_notification");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
coloredNotification.setEnabled(PreferenceUtil.getInstance(getActivity()).classicNotification());
} else {
coloredNotification.setChecked(PreferenceUtil.getInstance(getActivity()).coloredNotification());
coloredNotification.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// Save preference
PreferenceUtil.getInstance(getActivity()).setColoredNotification((Boolean) newValue);
return true;
}
});
}
final TwoStatePreference colorAppShortcuts = (TwoStatePreference) findPreference("should_color_app_shortcuts");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
colorAppShortcuts.setVisible(false);
@ -342,6 +357,11 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
case PreferenceUtil.NOW_PLAYING_SCREEN_ID:
updateNowPlayingScreenSummary();
break;
case PreferenceUtil.CLASSIC_NOTIFICATION:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
findPreference("colored_notification").setEnabled(sharedPreferences.getBoolean(key, false));
}
break;
}
}

View file

@ -158,6 +158,12 @@ public final class PreferenceUtil {
return mPreferences.getBoolean(CLASSIC_NOTIFICATION, false);
}
public void setColoredNotification(final boolean value) {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean(COLORED_NOTIFICATION, value);
editor.apply();
}
public void setClassicNotification(final boolean value) {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean(CLASSIC_NOTIFICATION, value);

View file

@ -2,18 +2,18 @@
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_notification">
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="true"
android:key="colored_notification"
android:summary="@string/pref_summary_colored_notification"
android:title="@string/pref_title_colored_notification" />
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false"
android:key="classic_notification"
android:summary="@string/pref_summary_classic_notification"
android:title="@string/pref_title_classic_notification" />
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="true"
android:key="colored_notification"
android:summary="@string/pref_summary_colored_notification"
android:title="@string/pref_title_colored_notification" />
</com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
</android.support.v7.preference.PreferenceScreen>