diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml
index 1d7686c..fa2bd08 100644
--- a/res/values/cherish_arrays.xml
+++ b/res/values/cherish_arrays.xml
@@ -1002,4 +1002,34 @@
- 2
- 3
+
+
+ - @string/entry_infinite
+ - @string/entry_five_minute
+ - @string/entry_ten_minute
+ - @string/entry_fifteen_minute
+ - @string/entry_thirty_minute
+ - @string/entry_sixty_minute
+
+
+
+ - 0
+ - 300
+ - 600
+ - 900
+ - 1800
+ - 3600
+
+
+
+ - @string/ambient_notification_light_color_mode_automatic
+ - @string/ambient_notification_light_color_mode_accent
+ - @string/ambient_notification_light_color_mode_custom
+
+
+
+ - 0
+ - 1
+ - 2
+
diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml
index de3af81..cb0156e 100644
--- a/res/values/cherish_strings.xml
+++ b/res/values/cherish_strings.xml
@@ -942,4 +942,30 @@
Show toasts and notification
Dynamic mode
Try detecting and adding gaming apps automatically
+
+
+ Screen edge lighting
+ Show on new notifcation
+ Show light pulse on new notification
+ Show on always on
+ Show light pulse on new notification using always on
+ Custom color
+ Default color for light pulse
+ Only show light pulse
+ Hide all other display elements from always on
+ Timeout for light pulse
+ Infinite
+ 5 minutes
+ 10 minutes
+ 30 minutes
+ 60 minutes
+ 15 minutes
+ Light pulse color
+ Notification color
+ System accent color
+ Custom color
+ Duration
+ Sets the ambient light animation duration
+ Edge Light Repeat count
+ Set max repeat count. 0 for infinite
diff --git a/res/xml/cherish_settings_notifications.xml b/res/xml/cherish_settings_notifications.xml
index 3e1bb69..dca4692 100644
--- a/res/xml/cherish_settings_notifications.xml
+++ b/res/xml/cherish_settings_notifications.xml
@@ -70,4 +70,78 @@
android:summary="@string/notification_sound_vib_screen_on_summary"
android:defaultValue="true" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/cherish/settings/fragments/NotificationSettings.java b/src/com/cherish/settings/fragments/NotificationSettings.java
index 192c887..7a5e431 100644
--- a/src/com/cherish/settings/fragments/NotificationSettings.java
+++ b/src/com/cherish/settings/fragments/NotificationSettings.java
@@ -11,9 +11,11 @@ import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import android.provider.Settings;
+import androidx.preference.ListPreference;
import com.android.settings.SettingsPreferenceFragment;
import com.cherish.settings.preferences.SystemSettingMasterSwitchPreference;
+import com.cherish.settings.preferences.SystemSettingSeekBarPreference;
import com.cherish.settings.preferences.CustomSeekBarPreference;
import com.cherish.settings.preferences.SystemSettingListPreference;
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
@@ -21,7 +23,16 @@ import net.margaritov.preference.colorpicker.ColorPickerPreference;
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
- private Preference mChargingLeds;
+ private static final String NOTIFICATION_PULSE_COLOR = "ambient_notification_light_color";
+ private static final String AMBIENT_LIGHT_DURATION = "ambient_light_duration";
+ private static final String AMBIENT_LIGHT_REPEAT_COUNT = "ambient_light_repeat_count";
+ private static final String PULSE_COLOR_MODE_PREF = "ambient_notification_light_color_mode";
+
+ private Preference mChargingLeds;
+ private ColorPickerPreference mEdgeLightColorPreference;
+ private SystemSettingSeekBarPreference mEdgeLightDurationPreference;
+ private SystemSettingSeekBarPreference mEdgeLightRepeatCountPreference;
+ private ListPreference mColorMode;
@Override
public void onCreate(Bundle icicle) {
@@ -37,13 +48,98 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
com.android.internal.R.bool.config_intrusiveBatteryLed)) {
prefScreen.removePreference(mChargingLeds);
}
+
+ mEdgeLightRepeatCountPreference = (SystemSettingSeekBarPreference) findPreference(AMBIENT_LIGHT_REPEAT_COUNT);
+ mEdgeLightRepeatCountPreference.setOnPreferenceChangeListener(this);
+ int rCount = Settings.System.getInt(getContentResolver(),
+ Settings.System.AMBIENT_LIGHT_REPEAT_COUNT, 0);
+ mEdgeLightRepeatCountPreference.setValue(rCount);
+
+ mEdgeLightDurationPreference = (SystemSettingSeekBarPreference) findPreference(AMBIENT_LIGHT_DURATION);
+ mEdgeLightDurationPreference.setOnPreferenceChangeListener(this);
+ int duration = Settings.System.getInt(getContentResolver(),
+ Settings.System.AMBIENT_LIGHT_DURATION, 2);
+ mEdgeLightDurationPreference.setValue(duration);
+
+ mColorMode = (ListPreference) findPreference(PULSE_COLOR_MODE_PREF);
+ int value;
+ boolean colorModeAutomatic = Settings.System.getInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_COLOR_AUTOMATIC, 0) != 0;
+ boolean colorModeAccent = Settings.System.getInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_ACCENT, 0) != 0;
+ if (colorModeAutomatic) {
+ value = 0;
+ } else if (colorModeAccent) {
+ value = 1;
+ } else {
+ value = 2;
+ }
+
+ mColorMode.setValue(Integer.toString(value));
+ mColorMode.setSummary(mColorMode.getEntry());
+ mColorMode.setOnPreferenceChangeListener(this);
+
+ mEdgeLightColorPreference = (ColorPickerPreference) findPreference(NOTIFICATION_PULSE_COLOR);
+ int edgeLightColor = Settings.System.getInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_COLOR, 0xFF3980FF);
+ mEdgeLightColorPreference.setNewPreviewColor(edgeLightColor);
+ mEdgeLightColorPreference.setAlphaSliderEnabled(false);
+ String edgeLightColorHex = String.format("#%08x", (0xFF3980FF & edgeLightColor));
+ if (edgeLightColorHex.equals("#ff3980ff")) {
+ mEdgeLightColorPreference.setSummary(R.string.color_default);
+ } else {
+ mEdgeLightColorPreference.setSummary(edgeLightColorHex);
+ }
+ mEdgeLightColorPreference.setOnPreferenceChangeListener(this);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- ContentResolver resolver = getActivity().getContentResolver();
-
+ if (preference == mEdgeLightColorPreference) {
+ String hex = ColorPickerPreference.convertToARGB(
+ Integer.valueOf(String.valueOf(newValue)));
+ if (hex.equals("#ff3980ff")) {
+ preference.setSummary(R.string.color_default);
+ } else {
+ preference.setSummary(hex);
+ }
+ int intHex = ColorPickerPreference.convertToColorInt(hex);
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_COLOR, intHex);
+ return true;
+ } else if (preference == mEdgeLightRepeatCountPreference) {
+ int value = (Integer) newValue;
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.AMBIENT_LIGHT_REPEAT_COUNT, value);
+ return true;
+ } else if (preference == mEdgeLightDurationPreference) {
+ int value = (Integer) newValue;
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.AMBIENT_LIGHT_DURATION, value);
+ return true;
+ } else if (preference == mColorMode) {
+ int value = Integer.valueOf((String) newValue);
+ int index = mColorMode.findIndexOfValue((String) newValue);
+ mColorMode.setSummary(mColorMode.getEntries()[index]);
+ if (value == 0) {
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_COLOR_AUTOMATIC, 1);
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_ACCENT, 0);
+ } else if (value == 1) {
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_COLOR_AUTOMATIC, 0);
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_ACCENT, 1);
+ } else {
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_COLOR_AUTOMATIC, 0);
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.NOTIFICATION_PULSE_ACCENT, 0);
+ }
+ return true;
+ }
return false;
}