diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml
index b8a3f18..e74c2b9 100644
--- a/res/values/cherish_strings.xml
+++ b/res/values/cherish_strings.xml
@@ -629,4 +629,9 @@
Edge lighting
Light up the side edges of the screen on notification pulse
Edge light color
+ Automatic color
+ Sync color with wallpaper
+ Edge light pulse duration
+ Left Edge
+ Right Edge
diff --git a/res/xml/cherish_settings_notifications.xml b/res/xml/cherish_settings_notifications.xml
index e4d47b0..7d0beee 100644
--- a/res/xml/cherish_settings_notifications.xml
+++ b/res/xml/cherish_settings_notifications.xml
@@ -35,19 +35,13 @@
android:key="notification_screen"
android:title="@string/notification_screen_title" >
-
-
-
diff --git a/res/xml/edgepulse_settings.xml b/res/xml/edgepulse_settings.xml
new file mode 100644
index 0000000..f83cde2
--- /dev/null
+++ b/res/xml/edgepulse_settings.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/cherish/settings/fragments/EdgePulse.java b/src/com/cherish/settings/fragments/EdgePulse.java
new file mode 100644
index 0000000..ceb2216
--- /dev/null
+++ b/src/com/cherish/settings/fragments/EdgePulse.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2020 CherishOS
+ *
+ * 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.Context;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.provider.Settings;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceChangeListener;
+import androidx.preference.SwitchPreference;
+
+import com.android.internal.logging.nano.MetricsProto;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+
+import net.margaritov.preference.colorpicker.ColorPickerPreference;
+
+public class EdgePulse extends SettingsPreferenceFragment implements
+ OnPreferenceChangeListener {
+
+ private static final String PULSE_AMBIENT_LIGHT_COLOR_LEFT = "pulse_ambient_light_color_left";
+ private static final String PULSE_AMBIENT_LIGHT_COLOR_RIGHT = "pulse_ambient_light_color_right";
+
+ private ColorPickerPreference mLeftEdgeLightColorPreference;
+ private ColorPickerPreference mRightEdgeLightColorPreference;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.edgepulse_settings);
+
+ ContentResolver resolver = getActivity().getContentResolver();
+
+ mLeftEdgeLightColorPreference = (ColorPickerPreference) findPreference(PULSE_AMBIENT_LIGHT_COLOR_LEFT);
+ mLeftEdgeLightColorPreference.setOnPreferenceChangeListener(this);
+ int leftEdgeLightColor = Settings.System.getInt(getContentResolver(),
+ Settings.System.PULSE_AMBIENT_LIGHT_COLOR_LEFT, 0xFF3980FF);
+ String leftEdgeLightColorHex = String.format("#%08x", (0xFF3980FF & leftEdgeLightColor));
+ if (leftEdgeLightColorHex.equals("#ff3980ff")) {
+ mLeftEdgeLightColorPreference.setSummary(R.string.default_string);
+ } else {
+ mLeftEdgeLightColorPreference.setSummary(leftEdgeLightColorHex);
+ }
+ mLeftEdgeLightColorPreference.setNewPreviewColor(leftEdgeLightColor);
+
+ mRightEdgeLightColorPreference = (ColorPickerPreference) findPreference(PULSE_AMBIENT_LIGHT_COLOR_RIGHT);
+ mRightEdgeLightColorPreference.setOnPreferenceChangeListener(this);
+ int rightEdgeLightColor = Settings.System.getInt(getContentResolver(),
+ Settings.System.PULSE_AMBIENT_LIGHT_COLOR_RIGHT, 0xFF3980FF);
+ String rightEdgeLightColorHex = String.format("#%08x", (0xFF3980FF & rightEdgeLightColor));
+ if (rightEdgeLightColorHex.equals("#ff3980ff")) {
+ mRightEdgeLightColorPreference.setSummary(R.string.default_string);
+ } else {
+ mRightEdgeLightColorPreference.setSummary(rightEdgeLightColorHex);
+ }
+ mRightEdgeLightColorPreference.setNewPreviewColor(rightEdgeLightColor);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ ContentResolver resolver = getActivity().getContentResolver();
+ if (preference == mLeftEdgeLightColorPreference) {
+ String hex = ColorPickerPreference.convertToARGB(
+ Integer.valueOf(String.valueOf(newValue)));
+ if (hex.equals("#ff3980ff")) {
+ preference.setSummary(R.string.default_string);
+ } else {
+ preference.setSummary(hex);
+ }
+ int intHex = ColorPickerPreference.convertToColorInt(hex);
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.PULSE_AMBIENT_LIGHT_COLOR_LEFT, intHex);
+ return true;
+ } else if (preference == mRightEdgeLightColorPreference) {
+ String hex = ColorPickerPreference.convertToARGB(
+ Integer.valueOf(String.valueOf(newValue)));
+ if (hex.equals("#ff3980ff")) {
+ preference.setSummary(R.string.default_string);
+ } else {
+ preference.setSummary(hex);
+ }
+ int intHex = ColorPickerPreference.convertToColorInt(hex);
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.PULSE_AMBIENT_LIGHT_COLOR_RIGHT, intHex);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
+ }
+}
diff --git a/src/com/cherish/settings/fragments/NotificationSettings.java b/src/com/cherish/settings/fragments/NotificationSettings.java
index ccbb182..59865a1 100644
--- a/src/com/cherish/settings/fragments/NotificationSettings.java
+++ b/src/com/cherish/settings/fragments/NotificationSettings.java
@@ -13,14 +13,15 @@ import androidx.preference.PreferenceScreen;
import android.provider.Settings;
import com.android.settings.SettingsPreferenceFragment;
+import com.cherish.settings.preferences.SystemSettingMasterSwitchPreference;
import net.margaritov.preference.colorpicker.ColorPickerPreference;
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
- private static final String PULSE_AMBIENT_LIGHT_COLOR = "pulse_ambient_light_color";
+ private static final String PULSE_AMBIENT_LIGHT = "pulse_ambient_light";
private Preference mChargingLeds;
- private ColorPickerPreference mEdgeLightColorPreference;
+ private SystemSettingMasterSwitchPreference mEdgePulse;
@Override
public void onCreate(Bundle icicle) {
@@ -36,34 +37,21 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
prefScreen.removePreference(mChargingLeds);
}
- mEdgeLightColorPreference = (ColorPickerPreference) findPreference(PULSE_AMBIENT_LIGHT_COLOR);
- mEdgeLightColorPreference.setOnPreferenceChangeListener(this);
- int edgeLightColor = Settings.System.getInt(getContentResolver(),
- Settings.System.PULSE_AMBIENT_LIGHT_COLOR, 0xFF3980FF);
- String edgeLightColorHex = String.format("#%08x", (0xFF3980FF & edgeLightColor));
- if (edgeLightColorHex.equals("#ff3980ff")) {
- mEdgeLightColorPreference.setSummary(R.string.default_string);
- } else {
- mEdgeLightColorPreference.setSummary(edgeLightColorHex);
- }
- mEdgeLightColorPreference.setNewPreviewColor(edgeLightColor);
+ mEdgePulse = (SystemSettingMasterSwitchPreference) findPreference(PULSE_AMBIENT_LIGHT);
+ mEdgePulse.setOnPreferenceChangeListener(this);
+ int edgePulse = Settings.System.getInt(getContentResolver(),
+ PULSE_AMBIENT_LIGHT, 0);
+ mEdgePulse.setChecked(edgePulse != 0);
}
@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.default_string);
- } else {
- preference.setSummary(hex);
- }
- int intHex = ColorPickerPreference.convertToColorInt(hex);
+ if (preference == mEdgePulse) {
+ boolean value = (Boolean) newValue;
Settings.System.putInt(getContentResolver(),
- Settings.System.PULSE_AMBIENT_LIGHT_COLOR, intHex);
+ PULSE_AMBIENT_LIGHT, value ? 1 : 0);
return true;
}
return false;