diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml
index 86c0194..f2c30c7 100644
--- a/res/values/cherish_arrays.xml
+++ b/res/values/cherish_arrays.xml
@@ -293,4 +293,38 @@
- 2
+
+
+ - @string/ambient_notification_light_timeout_forever
+ - @string/ambient_notification_light_timeout_half_minute
+ - @string/ambient_notification_light_timeout_minute
+ - @string/ambient_notification_light_timeout_three_minutes
+ - @string/ambient_notification_light_timeout_five_minutes
+ - @string/ambient_notification_light_timeout_ten_minutes
+
+
+
+ - 0
+ - 30
+ - 60
+ - 180
+ - 300
+ - 600
+
+
+
+
+ - @string/ambient_notification_color_mode_accent
+ - @string/ambient_notification_color_mode_wall
+ - @string/ambient_notification_color_mode_notification
+ - @string/ambient_notification_color_mode_custom
+
+
+
+ - 0
+ - 1
+ - 2
+ - 3
+
+
diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml
index 976050c..efec236 100644
--- a/res/values/cherish_strings.xml
+++ b/res/values/cherish_strings.xml
@@ -14,6 +14,9 @@
Cherish Settings
+
+ seconds
+
Buttons
Hardware keys, Navigation bar
@@ -402,4 +405,30 @@
Turns on from sunset till a time
Turns on from a time till sunrise
+
+ Ambient edge lightning
+ Light ambient edges for pulsing notifications
+ Show on AOD
+ Keep showing edge lightning on AOD
+ Hide AOD content
+ Hide AOD content when edges are lighted
+ Duration
+ Time it takes for each animation to complete
+ Repeats
+ Amount of times the animation should show\n0 for infinite
+ Timeout
+ Forever
+ 30 seconds
+ 1 minute
+ 3 minutes
+ 5 minutes
+ 10 minutes
+ Set repeats to 0 to enable
+ Color mode
+ Accent color
+ Wallpaper dominant color
+ Notification icon color
+ @string/ambient_notification_light_color_title
+ Custom color
+
diff --git a/res/xml/cherish_settings_notifications.xml b/res/xml/cherish_settings_notifications.xml
index 6d235ce..7c73c0d 100644
--- a/res/xml/cherish_settings_notifications.xml
+++ b/res/xml/cherish_settings_notifications.xml
@@ -83,6 +83,14 @@
android:key="charging_light"
android:fragment="com.cherish.settings.fragments.BatteryLightSettings"
android:title="@string/battery_light_settings" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/cherish/settings/fragments/EdgeLightningSettings.java b/src/com/cherish/settings/fragments/EdgeLightningSettings.java
new file mode 100644
index 0000000..2e47756
--- /dev/null
+++ b/src/com/cherish/settings/fragments/EdgeLightningSettings.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2020 Yet Another AOSP Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cherish.settings.fragments;
+
+import android.content.ContentResolver;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.os.UserHandle;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+import android.provider.Settings;
+import android.util.TypedValue;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+
+import net.margaritov.preference.colorpicker.ColorPickerPreference;
+import com.cherish.settings.preferences.CustomSeekBarPreference;
+import com.cherish.settings.preferences.SystemSettingListPreference;
+import com.cherish.settings.preferences.SystemSettingSwitchPreference;
+
+public class EdgeLightningSettings extends SettingsPreferenceFragment implements
+ Preference.OnPreferenceChangeListener {
+
+ private static String KEY_DURATION = "ambient_notification_light_duration";
+ private static String KEY_REPEATS = "ambient_notification_light_repeats";
+ private static String KEY_TIMEOUT = "ambient_notification_light_timeout";
+ private static String KEY_COLOR_MODE = "ambient_notification_color_mode";
+ private static String KEY_COLOR = "ambient_notification_light_color";
+
+ private CustomSeekBarPreference mDurationPref;
+ private CustomSeekBarPreference mRepeatsPref;
+ private SystemSettingListPreference mTimeoutPref;
+ private SystemSettingListPreference mColorModePref;
+ private ColorPickerPreference mColorPref;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.edge_lightning_settings);
+ final ContentResolver resolver = getContentResolver();
+ final int accentColor = getAccentColor();
+
+ mDurationPref = (CustomSeekBarPreference) findPreference(KEY_DURATION);
+ int value = Settings.System.getIntForUser(resolver,
+ KEY_DURATION, 2, UserHandle.USER_CURRENT);
+ mDurationPref.setValue(value);
+ mDurationPref.setOnPreferenceChangeListener(this);
+
+ mRepeatsPref = (CustomSeekBarPreference) findPreference(KEY_REPEATS);
+ int repeats = Settings.System.getIntForUser(resolver,
+ KEY_REPEATS, 0, UserHandle.USER_CURRENT);
+ mRepeatsPref.setValue(repeats);
+ mRepeatsPref.setOnPreferenceChangeListener(this);
+
+ mTimeoutPref = (SystemSettingListPreference) findPreference(KEY_TIMEOUT);
+ value = Settings.System.getIntForUser(resolver,
+ KEY_TIMEOUT, accentColor, UserHandle.USER_CURRENT);
+ mTimeoutPref.setValue(Integer.toString(value));
+ mTimeoutPref.setSummary(mTimeoutPref.getEntry());
+ mTimeoutPref.setOnPreferenceChangeListener(this);
+ updateTimeoutEnablement(repeats);
+
+ mColorPref = (ColorPickerPreference) findPreference(KEY_COLOR);
+ value = Settings.System.getIntForUser(resolver,
+ KEY_COLOR, accentColor, UserHandle.USER_CURRENT);
+ mColorPref.setDefaultColor(accentColor);
+ String colorHex = String.format("#%08x", (0xFFFFFFFF & value));
+ if (value == accentColor) {
+ mColorPref.setSummary(R.string.default_string);
+ } else {
+ mColorPref.setSummary(colorHex);
+ }
+ mColorPref.setNewPreviewColor(value);
+ mColorPref.setOnPreferenceChangeListener(this);
+
+ mColorModePref = (SystemSettingListPreference) findPreference(KEY_COLOR_MODE);
+ value = Settings.System.getIntForUser(resolver,
+ KEY_COLOR_MODE, 0, UserHandle.USER_CURRENT);
+ mColorModePref.setValue(Integer.toString(value));
+ mColorModePref.setSummary(mColorModePref.getEntry());
+ mColorModePref.setOnPreferenceChangeListener(this);
+ mColorPref.setEnabled(value == 3);
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final ContentResolver resolver = getContentResolver();
+ if (preference == mDurationPref) {
+ int value = (Integer) newValue;
+ Settings.System.putIntForUser(resolver,
+ KEY_DURATION, value, UserHandle.USER_CURRENT);
+ return true;
+ } else if (preference == mRepeatsPref) {
+ int value = (Integer) newValue;
+ Settings.System.putIntForUser(resolver,
+ KEY_REPEATS, value, UserHandle.USER_CURRENT);
+ updateTimeoutEnablement(value);
+ return true;
+ } else if (preference == mTimeoutPref) {
+ int value = Integer.valueOf((String) newValue);
+ int index = mTimeoutPref.findIndexOfValue((String) newValue);
+ mTimeoutPref.setSummary(mTimeoutPref.getEntries()[index]);
+ Settings.System.putIntForUser(resolver,
+ KEY_TIMEOUT, value, UserHandle.USER_CURRENT);
+ return true;
+ } else if (preference == mColorModePref) {
+ int value = Integer.valueOf((String) newValue);
+ int index = mColorModePref.findIndexOfValue((String) newValue);
+ mColorModePref.setSummary(mColorModePref.getEntries()[index]);
+ Settings.System.putIntForUser(resolver,
+ KEY_COLOR_MODE, value, UserHandle.USER_CURRENT);
+ mColorPref.setEnabled(value == 3);
+ return true;
+ } else if (preference == mColorPref) {
+ int accentColor = getAccentColor();
+ String hex = ColorPickerPreference.convertToARGB(
+ Integer.valueOf(String.valueOf(newValue)));
+ if (hex.equals(String.format("#%08x", (0xFFFFFFFF & accentColor)))) {
+ preference.setSummary(R.string.default_string);
+ } else {
+ preference.setSummary(hex);
+ }
+ int color = ColorPickerPreference.convertToColorInt(hex);
+ Settings.System.putIntForUser(resolver,
+ KEY_COLOR, color, UserHandle.USER_CURRENT);
+ return true;
+ }
+ return false;
+ }
+
+ private int getAccentColor() {
+ final TypedValue value = new TypedValue();
+ getContext().getTheme().resolveAttribute(android.R.attr.colorAccent, value, true);
+ return value.data;
+ }
+
+ private void updateTimeoutEnablement(int repeats) {
+ if (repeats == 0) {
+ int value = Settings.System.getIntForUser(getContentResolver(),
+ KEY_TIMEOUT, 0, UserHandle.USER_CURRENT);
+ mTimeoutPref.setValue(Integer.toString(value));
+ mTimeoutPref.setSummary(mTimeoutPref.getEntry());
+ mTimeoutPref.setEnabled(true);
+ } else {
+ mTimeoutPref.setSummary(R.string.set_to_zero);
+ mTimeoutPref.setEnabled(false);
+ }
+ }
+}
diff --git a/src/com/cherish/settings/fragments/NotificationSettings.java b/src/com/cherish/settings/fragments/NotificationSettings.java
index 7496059..b8a311d 100644
--- a/src/com/cherish/settings/fragments/NotificationSettings.java
+++ b/src/com/cherish/settings/fragments/NotificationSettings.java
@@ -43,7 +43,9 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
private static final String PREF_FLASH_ON_CALL = "flashlight_on_call";
private static final String PREF_FLASH_ON_CALL_DND = "flashlight_on_call_ignore_dnd";
private static final String PREF_FLASH_ON_CALL_RATE = "flashlight_on_call_rate";
+ private static final String KEY_EDGE_LIGHTNING = "pulse_ambient_light";
+ private SystemSettingMasterSwitchPreference mEdgeLightning;
private SystemSettingListPreference mFlashOnCall;
private SystemSettingSwitchPreference mFlashOnCallIgnoreDND;
private CustomSeekBarPreference mFlashOnCallRate;
@@ -79,6 +81,13 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
mFlashOnCall = (SystemSettingListPreference)
findPreference(PREF_FLASH_ON_CALL);
mFlashOnCall.setOnPreferenceChangeListener(this);
+
+ mEdgeLightning = (SystemSettingMasterSwitchPreference)
+ findPreference(KEY_EDGE_LIGHTNING);
+ boolean enabled = Settings.System.getIntForUser(resolver,
+ KEY_EDGE_LIGHTNING, 0, UserHandle.USER_CURRENT) == 1;
+ mEdgeLightning.setChecked(enabled);
+ mEdgeLightning.setOnPreferenceChangeListener(this);
mChargingLeds = (Preference) findPreference("charging_light");
if (mChargingLeds != null
@@ -104,6 +113,11 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
Settings.System.putInt(resolver,
Settings.System.FLASHLIGHT_ON_CALL_RATE, value);
return true;
+ } else if (preference == mEdgeLightning) {
+ boolean value = (Boolean) newValue;
+ Settings.System.putIntForUser(resolver, KEY_EDGE_LIGHTNING,
+ value ? 1 : 0, UserHandle.USER_CURRENT);
+ return true;
}
return false;
}