Cherish: Ambient Edge Pulse Customizations [2/2]
This commit is contained in:
@@ -629,4 +629,9 @@
|
|||||||
<string name="pulse_ambient_light_title">Edge lighting</string>
|
<string name="pulse_ambient_light_title">Edge lighting</string>
|
||||||
<string name="pulse_ambient_light_summary">Light up the side edges of the screen on notification pulse</string>
|
<string name="pulse_ambient_light_summary">Light up the side edges of the screen on notification pulse</string>
|
||||||
<string name="pulse_ambient_light_color_title">Edge light color</string>
|
<string name="pulse_ambient_light_color_title">Edge light color</string>
|
||||||
|
<string name="pulse_ambient_light_auto_color_title">Automatic color</string>
|
||||||
|
<string name="pulse_ambient_light_auto_color_summary">Sync color with wallpaper</string>
|
||||||
|
<string name="pulse_ambient_light_duration">Edge light pulse duration</string>
|
||||||
|
<string name="edgelight_left">Left Edge</string>
|
||||||
|
<string name="edgelight_right">Right Edge</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -35,19 +35,13 @@
|
|||||||
android:key="notification_screen"
|
android:key="notification_screen"
|
||||||
android:title="@string/notification_screen_title" >
|
android:title="@string/notification_screen_title" >
|
||||||
|
|
||||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
<com.cherish.settings.preferences.SystemSettingMasterSwitchPreference
|
||||||
android:key="pulse_ambient_light"
|
android:key="pulse_ambient_light"
|
||||||
android:icon="@drawable/ic_pulse"
|
android:icon="@drawable/ic_pulse"
|
||||||
android:title="@string/pulse_ambient_light_title"
|
android:title="@string/pulse_ambient_light_title"
|
||||||
android:summary="@string/pulse_ambient_light_summary"
|
android:summary="@string/pulse_ambient_light_summary"
|
||||||
|
android:fragment="com.cherish.settings.fragments.EdgePulse"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
|
||||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
|
||||||
android:key="pulse_ambient_light_color"
|
|
||||||
android:title="@string/pulse_ambient_light_color_title"
|
|
||||||
android:persistent="false"
|
|
||||||
android:dependency="pulse_ambient_light"
|
|
||||||
settings:defaultColorValue="0xFF3980FF" />
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
74
res/xml/edgepulse_settings.xml
Normal file
74
res/xml/edgepulse_settings.xml
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 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.
|
||||||
|
-->
|
||||||
|
<PreferenceScreen
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:title="@string/pulse_ambient_light_title"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="@string/edgelight_left" >
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
|
android:key="pulse_ambient_light_auto_color_left"
|
||||||
|
android:title="@string/pulse_ambient_light_auto_color_title"
|
||||||
|
android:summary="@string/pulse_ambient_light_auto_color_summary"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:disableDependentsState="true" />
|
||||||
|
|
||||||
|
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||||
|
android:key="pulse_ambient_light_color_left"
|
||||||
|
android:title="@string/pulse_ambient_light_color_title"
|
||||||
|
android:persistent="false"
|
||||||
|
android:dependency="pulse_ambient_light_auto_color_left"
|
||||||
|
settings:defaultColorValue="0xFF3980FF" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||||
|
android:key="pulse_ambient_light_left_duration"
|
||||||
|
android:title="@string/pulse_ambient_light_duration"
|
||||||
|
android:defaultValue="2000"
|
||||||
|
android:max="10000"
|
||||||
|
settings:min="500"
|
||||||
|
settings:interval="250"
|
||||||
|
settings:units="ms" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="@string/edgelight_right" >
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
|
android:key="pulse_ambient_light_auto_color_right"
|
||||||
|
android:title="@string/pulse_ambient_light_auto_color_title"
|
||||||
|
android:summary="@string/pulse_ambient_light_auto_color_summary"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:disableDependentsState="true" />
|
||||||
|
|
||||||
|
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||||
|
android:key="pulse_ambient_light_color_right"
|
||||||
|
android:title="@string/pulse_ambient_light_color_title"
|
||||||
|
android:persistent="false"
|
||||||
|
android:dependency="pulse_ambient_light_auto_color_right"
|
||||||
|
settings:defaultColorValue="0xFF3980FF" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||||
|
android:key="pulse_ambient_light_right_duration"
|
||||||
|
android:title="@string/pulse_ambient_light_duration"
|
||||||
|
android:defaultValue="2000"
|
||||||
|
android:max="10000"
|
||||||
|
settings:min="500"
|
||||||
|
settings:interval="250"
|
||||||
|
settings:units="ms" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
</PreferenceScreen>
|
||||||
113
src/com/cherish/settings/fragments/EdgePulse.java
Normal file
113
src/com/cherish/settings/fragments/EdgePulse.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,14 +13,15 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
import com.cherish.settings.preferences.SystemSettingMasterSwitchPreference;
|
||||||
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||||
|
|
||||||
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
|
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 Preference mChargingLeds;
|
||||||
private ColorPickerPreference mEdgeLightColorPreference;
|
private SystemSettingMasterSwitchPreference mEdgePulse;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
@@ -36,34 +37,21 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
prefScreen.removePreference(mChargingLeds);
|
prefScreen.removePreference(mChargingLeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
mEdgeLightColorPreference = (ColorPickerPreference) findPreference(PULSE_AMBIENT_LIGHT_COLOR);
|
mEdgePulse = (SystemSettingMasterSwitchPreference) findPreference(PULSE_AMBIENT_LIGHT);
|
||||||
mEdgeLightColorPreference.setOnPreferenceChangeListener(this);
|
mEdgePulse.setOnPreferenceChangeListener(this);
|
||||||
int edgeLightColor = Settings.System.getInt(getContentResolver(),
|
int edgePulse = Settings.System.getInt(getContentResolver(),
|
||||||
Settings.System.PULSE_AMBIENT_LIGHT_COLOR, 0xFF3980FF);
|
PULSE_AMBIENT_LIGHT, 0);
|
||||||
String edgeLightColorHex = String.format("#%08x", (0xFF3980FF & edgeLightColor));
|
mEdgePulse.setChecked(edgePulse != 0);
|
||||||
if (edgeLightColorHex.equals("#ff3980ff")) {
|
|
||||||
mEdgeLightColorPreference.setSummary(R.string.default_string);
|
|
||||||
} else {
|
|
||||||
mEdgeLightColorPreference.setSummary(edgeLightColorHex);
|
|
||||||
}
|
|
||||||
mEdgeLightColorPreference.setNewPreviewColor(edgeLightColor);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
ContentResolver resolver = getActivity().getContentResolver();
|
ContentResolver resolver = getActivity().getContentResolver();
|
||||||
if (preference == mEdgeLightColorPreference) {
|
if (preference == mEdgePulse) {
|
||||||
String hex = ColorPickerPreference.convertToARGB(
|
boolean value = (Boolean) newValue;
|
||||||
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.putInt(getContentResolver(),
|
||||||
Settings.System.PULSE_AMBIENT_LIGHT_COLOR, intHex);
|
PULSE_AMBIENT_LIGHT, value ? 1 : 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user