Cherish: Add ambient pulse notification [2/2]

This commit is contained in:
SKULSHADY
2019-12-06 12:56:09 +07:00
committed by Hưng Phan
parent 89da1277f8
commit 772d5ec183
4 changed files with 63 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="M3,13H5.79L10.1,4.79L11.28,13.75L14.5,9.66L17.83,13H21V15H17L14.67,12.67L9.92,18.73L8.94,11.31L7,15H3V13Z" />
</vector>

View File

@@ -623,4 +623,10 @@
<string name="file_header_select_summary">Select an image from internal storage</string>
<string name="status_bar_custom_header_shadow_title">Darken image</string>
<string name="status_bar_custom_header_height_title">Image height offset</string>
<!-- Ambient edge lighting -->
<string name="notification_screen_title">Screen</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_color_title">Edge light color</string>
</resources>

View File

@@ -31,6 +31,26 @@
android:fragment="com.cherish.settings.fragments.BatteryLightSettings"
android:title="@string/battery_light_settings" />
<PreferenceCategory
android:key="notification_screen"
android:title="@string/notification_screen_title" >
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="pulse_ambient_light"
android:icon="@drawable/ic_pulse"
android:title="@string/pulse_ambient_light_title"
android:summary="@string/pulse_ambient_light_summary"
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>
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="force_expanded_notifications"
android:icon="@drawable/ic_notification"

View File

@@ -3,6 +3,7 @@ package com.cherish.settings.fragments;
import com.android.internal.logging.nano.MetricsProto;
import android.os.Bundle;
import android.content.ContentResolver;
import com.android.settings.R;
import android.content.res.Resources;
import androidx.preference.Preference;
@@ -16,9 +17,10 @@ import net.margaritov.preference.colorpicker.ColorPickerPreference;
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
private ColorPickerPreference mEdgeLightColorPreference;
private static final String PULSE_AMBIENT_LIGHT_COLOR = "pulse_ambient_light_color";
private Preference mChargingLeds;
private ColorPickerPreference mEdgeLightColorPreference;
@Override
public void onCreate(Bundle icicle) {
@@ -33,11 +35,38 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
com.android.internal.R.bool.config_intrusiveBatteryLed)) {
prefScreen.removePreference(mChargingLeds);
}
mEdgeLightColorPreference = (ColorPickerPreference) findPreference(PULSE_AMBIENT_LIGHT_COLOR);
int edgeLightColor = Settings.System.getInt(getContentResolver(),
Settings.System.PULSE_AMBIENT_LIGHT_COLOR, 0xFF3980FF);
mEdgeLightColorPreference.setNewPreviewColor(edgeLightColor);
mEdgeLightColorPreference.setAlphaSliderEnabled(false);
String edgeLightColorHex = String.format("#%08x", (0xFF3980FF & edgeLightColor));
if (edgeLightColorHex.equals("#ff3980ff")) {
mEdgeLightColorPreference.setSummary(R.string.default_string);
} 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.default_string);
} else {
preference.setSummary(hex);
}
int intHex = ColorPickerPreference.convertToColorInt(hex);
Settings.System.putInt(getContentResolver(),
Settings.System.PULSE_AMBIENT_LIGHT_COLOR, intHex);
return true;
}
return false;
}