[SQUASHED] Cherish: Add ambient pulse and aod notifications [2/2]
@/SKULSHADY - Clean up and adapted for A11 SDB: improvise the enabling/disabling of colorpicker preference to avoid fc Co-authored-by: maxwen <max.weninger@gmail.com> Co-authored-by: Ido Ben-Hur <idoybh2@gmail.com> Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -542,4 +542,53 @@
|
||||
<item>7</item>
|
||||
<item>8</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Ambient light -->
|
||||
<string-array name="pulse_ambient_light_color_mode_entries">
|
||||
<item>@string/pulse_ambient_light_color_mode_notification</item>
|
||||
<item>@string/pulse_ambient_light_color_mode_wall</item>
|
||||
<item>@string/pulse_ambient_light_color_mode_accent</item>
|
||||
<item>@string/pulse_ambient_light_color_mode_custom</item>
|
||||
</string-array>
|
||||
<string-array name="pulse_ambient_light_color_mode_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pulse_ambient_light_layout_entries">
|
||||
<item>@string/pulse_ambient_light_layout_faded</item>
|
||||
<item>@string/pulse_ambient_light_layout_solid</item>
|
||||
</string-array>
|
||||
<string-array name="pulse_ambient_light_layout_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
<string-array name="pulse_ambient_light_repeat_direction_entries">
|
||||
<item>@string/pulse_ambient_light_repeat_direction_restart</item>
|
||||
<item>@string/pulse_ambient_light_repeat_direction_reverse</item>
|
||||
</string-array>
|
||||
<string-array name="pulse_ambient_light_repeat_direction_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Edge lightning timeout -->
|
||||
<string-array name="ambient_notification_light_timeout_entries" translatable="false">
|
||||
<item>@string/ambient_notification_light_timeout_forever</item>
|
||||
<item>@string/ambient_notification_light_timeout_half_minute</item>
|
||||
<item>@string/ambient_notification_light_timeout_minute</item>
|
||||
<item>@string/ambient_notification_light_timeout_three_minutes</item>
|
||||
<item>@string/ambient_notification_light_timeout_five_minutes</item>
|
||||
<item>@string/ambient_notification_light_timeout_ten_minutes</item>
|
||||
</string-array>
|
||||
<string-array name="ambient_notification_light_timeout_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
<item>180</item>
|
||||
<item>300</item>
|
||||
<item>600</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -799,4 +799,36 @@
|
||||
<string name="smart_pixels_percent">Percent of pixels to disable</string>
|
||||
<string name="smart_pixels_shift_title">Burn-in protection</string>
|
||||
<string name="smart_pixels_shift_summary">Prevents burn-in on OLED devices by shifting pixels every so often</string>
|
||||
|
||||
<!-- Ambient edge lighting -->
|
||||
<string name="pulse_ambient_light_category">Screen 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_color_title">Custom color</string>
|
||||
<string name="pulse_ambient_light_color_mode_title">Light color</string>
|
||||
<string name="pulse_ambient_light_color_mode_notification">Automatic (Notification Based)</string>
|
||||
<string name="pulse_ambient_light_color_mode_wall">Automatic (Wallpaper Based)</string>
|
||||
<string name="pulse_ambient_light_color_mode_accent">Accent</string>
|
||||
<string name="pulse_ambient_light_color_mode_custom">Custom</string>
|
||||
<string name="pulse_ambient_light_duration_title">Light duration</string>
|
||||
<string name="pulse_ambient_light_repeat_count_title">Light repeat count</string>
|
||||
<string name="pulse_ambient_light_show_always_title">Show always</string>
|
||||
<string name="pulse_ambient_light_show_always_summary">Show lights for all doze events and not just notifications</string>
|
||||
<string name="pulse_ambient_light_repeat_direction_title">Light repeat mode</string>
|
||||
<string name="pulse_ambient_light_repeat_direction_restart">Restart</string>
|
||||
<string name="pulse_ambient_light_repeat_direction_reverse">Reverse</string>
|
||||
<string name="pulse_ambient_light_layout_title">Light view</string>
|
||||
<string name="pulse_ambient_light_layout_solid">Solid</string>
|
||||
<string name="pulse_ambient_light_layout_faded">Faded</string>
|
||||
<string name="ambient_notification_light_enabled_title">Show on AOD</string>
|
||||
<string name="ambient_notification_light_enabled_summary">Show lights on Always On Display</string>
|
||||
<string name="ambient_notification_light_hide_aod_title">Hide AOD content</string>
|
||||
<string name="ambient_notification_light_hide_aod_summary">Hide AOD content when lights are showing</string>
|
||||
<string name="ambient_notification_light_timeout_title">Timeout</string>
|
||||
<string name="ambient_notification_light_timeout_forever">Forever</string>
|
||||
<string name="ambient_notification_light_timeout_half_minute">30 seconds</string>
|
||||
<string name="ambient_notification_light_timeout_minute">1 minute</string>
|
||||
<string name="ambient_notification_light_timeout_three_minutes">3 minutes</string>
|
||||
<string name="ambient_notification_light_timeout_five_minutes">5 minutes</string>
|
||||
<string name="ambient_notification_light_timeout_ten_minutes">10 minutes</string>
|
||||
</resources>
|
||||
|
||||
@@ -18,29 +18,88 @@
|
||||
android:title="@string/notifications_title"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<!-- <PreferenceCategory
|
||||
android:key="incall_vib_options"
|
||||
android:title="@string/incall_vibration_category">
|
||||
<PreferenceCategory
|
||||
android:key="pulse_ambient_light_category"
|
||||
android:title="@string/pulse_ambient_light_category" >
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="vibrate_on_connect"
|
||||
android:icon="@drawable/ic_vibrate"
|
||||
android:title="@string/incall_vibrate_connect_title"
|
||||
android:defaultValue="true" />
|
||||
android:key="pulse_ambient_light"
|
||||
android:title="@string/pulse_ambient_light_title"
|
||||
android:summary="@string/pulse_ambient_light_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="vibrate_on_callwaiting"
|
||||
android:icon="@drawable/ic_vibrate"
|
||||
android:title="@string/incall_vibrate_call_wait_title"
|
||||
android:defaultValue="true" />
|
||||
android:key="ambient_light_pulse_for_all"
|
||||
android:title="@string/pulse_ambient_light_show_always_title"
|
||||
android:summary="@string/pulse_ambient_light_show_always_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="vibrate_on_disconnect"
|
||||
android:icon="@drawable/ic_vibrate"
|
||||
android:title="@string/incall_vibrate_disconnect_title"
|
||||
android:defaultValue="true" />
|
||||
android:key="ambient_notification_light_enabled"
|
||||
android:title="@string/ambient_notification_light_enabled_title"
|
||||
android:summary="@string/ambient_notification_light_enabled_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
</PreferenceCategory> -->
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="ambient_notification_light_hide_aod"
|
||||
android:title="@string/ambient_notification_light_hide_aod_title"
|
||||
android:summary="@string/ambient_notification_light_hide_aod_summary"
|
||||
android:defaultValue="false"
|
||||
android:dependency="ambient_notification_light_enabled" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="ambient_notification_color_mode"
|
||||
android:title="@string/pulse_ambient_light_color_mode_title"
|
||||
android:entries="@array/pulse_ambient_light_color_mode_entries"
|
||||
android:entryValues="@array/pulse_ambient_light_color_mode_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="0" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="ambient_notification_light_color"
|
||||
android:title="@string/pulse_ambient_light_color_title"
|
||||
android:defaultValue="0xFFFFFFFF" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="ambient_light_layout"
|
||||
android:title="@string/pulse_ambient_light_layout_title"
|
||||
android:entries="@array/pulse_ambient_light_layout_entries"
|
||||
android:entryValues="@array/pulse_ambient_light_layout_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="1" />
|
||||
|
||||
<com.cherish.settings.preferences.CustomSeekBarPreference
|
||||
android:key="ambient_notification_light_duration"
|
||||
android:title="@string/pulse_ambient_light_duration_title"
|
||||
android:max="5"
|
||||
settings:min="1"
|
||||
settings:defaultValue="2"
|
||||
settings:units="sec" />
|
||||
|
||||
<com.cherish.settings.preferences.CustomSeekBarPreference
|
||||
android:key="ambient_notification_light_repeats"
|
||||
android:title="@string/pulse_ambient_light_repeat_count_title"
|
||||
android:max="10"
|
||||
settings:min="0"
|
||||
settings:defaultValue="0" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="ambient_light_repeat_direction"
|
||||
android:title="@string/pulse_ambient_light_repeat_direction_title"
|
||||
android:entries="@array/pulse_ambient_light_repeat_direction_entries"
|
||||
android:entryValues="@array/pulse_ambient_light_repeat_direction_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="0" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="ambient_notification_light_timeout"
|
||||
android:title="@string/ambient_notification_light_timeout_title"
|
||||
android:entries="@array/ambient_notification_light_timeout_entries"
|
||||
android:entryValues="@array/ambient_notification_light_timeout_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="0" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:key="charging_light"
|
||||
|
||||
@@ -39,6 +39,16 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
private static final String INCALL_VIB_OPTIONS = "incall_vib_options";
|
||||
private static final String ALERT_SLIDER_PREF = "alert_slider_notifications";
|
||||
|
||||
private static final String AMBIENT_LIGHT_COLOR = "ambient_notification_color_mode";
|
||||
private static final String AMBIENT_LIGHT_CUSTOM_COLOR = "ambient_notification_light_color";
|
||||
private static final String AMBIENT_LIGHT_DURATION = "ambient_notification_light_duration";
|
||||
private static final String AMBIENT_LIGHT_REPEAT_COUNT = "ambient_notification_light_repeats";
|
||||
|
||||
private SystemSettingListPreference mEdgeLightColorMode;
|
||||
private ColorPickerPreference mEdgeLightColor;
|
||||
private CustomSeekBarPreference mEdgeLightDuration;
|
||||
private CustomSeekBarPreference mEdgeLightRepeatCount;
|
||||
|
||||
private Preference mChargingLeds;
|
||||
private Preference mAlertSlider;
|
||||
@@ -63,6 +73,39 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
||||
com.android.internal.R.bool.config_intrusiveBatteryLed)) {
|
||||
prefScreen.removePreference(mChargingLeds);
|
||||
}
|
||||
|
||||
Context context = getContext();
|
||||
|
||||
mEdgeLightColorMode = (SystemSettingListPreference) findPreference(AMBIENT_LIGHT_COLOR);
|
||||
int edgeLightColorMode = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR_MODE, 0, UserHandle.USER_CURRENT);
|
||||
mEdgeLightColorMode.setValue(String.valueOf(edgeLightColorMode));
|
||||
mEdgeLightColorMode.setSummary(mEdgeLightColorMode.getEntry());
|
||||
mEdgeLightColorMode.setOnPreferenceChangeListener(this);
|
||||
|
||||
mEdgeLightColor = (ColorPickerPreference) findPreference(AMBIENT_LIGHT_CUSTOM_COLOR);
|
||||
int edgeLightColor = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR, 0xFFFFFFFF);
|
||||
mEdgeLightColor.setNewPreviewColor(edgeLightColor);
|
||||
String edgeLightColorHex = String.format("#%08x", (0xFFFFFFFF & edgeLightColor));
|
||||
if (edgeLightColorHex.equals("#ffffffff")) {
|
||||
mEdgeLightColor.setSummary(R.string.default_string);
|
||||
} else {
|
||||
mEdgeLightColor.setSummary(edgeLightColorHex);
|
||||
}
|
||||
mEdgeLightColor.setOnPreferenceChangeListener(this);
|
||||
|
||||
mEdgeLightDuration = (CustomSeekBarPreference) findPreference(AMBIENT_LIGHT_DURATION);
|
||||
int lightDuration = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_DURATION, 2, UserHandle.USER_CURRENT);
|
||||
mEdgeLightDuration.setValue(lightDuration);
|
||||
mEdgeLightDuration.setOnPreferenceChangeListener(this);
|
||||
|
||||
mEdgeLightRepeatCount = (CustomSeekBarPreference) findPreference(AMBIENT_LIGHT_REPEAT_COUNT);
|
||||
int edgeLightRepeatCount = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_REPEATS, 0, UserHandle.USER_CURRENT);
|
||||
mEdgeLightRepeatCount.setValue(edgeLightRepeatCount);
|
||||
mEdgeLightRepeatCount.setOnPreferenceChangeListener(this);
|
||||
|
||||
PreferenceCategory incallVibCategory = (PreferenceCategory) findPreference(INCALL_VIB_OPTIONS);
|
||||
if (!CherishUtils.isVoiceCapable(getActivity())) {
|
||||
@@ -73,6 +116,42 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
if (preference == mEdgeLightColorMode) {
|
||||
int edgeLightColorMode = Integer.valueOf((String) newValue);
|
||||
int index = mEdgeLightColorMode.findIndexOfValue((String) newValue);
|
||||
Settings.System.putIntForUser(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR_MODE, edgeLightColorMode, UserHandle.USER_CURRENT);
|
||||
mEdgeLightColorMode.setSummary(mEdgeLightColorMode.getEntries()[index]);
|
||||
if (edgeLightColorMode == 3) {
|
||||
mEdgeLightColor.setEnabled(true);
|
||||
} else {
|
||||
mEdgeLightColor.setEnabled(false);
|
||||
}
|
||||
return true;
|
||||
} else if (preference == mEdgeLightColor) {
|
||||
String hex = ColorPickerPreference.convertToARGB(
|
||||
Integer.valueOf(String.valueOf(newValue)));
|
||||
if (hex.equals("#ffffffff")) {
|
||||
preference.setSummary(R.string.default_string);
|
||||
} else {
|
||||
preference.setSummary(hex);
|
||||
}
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR, intHex);
|
||||
return true;
|
||||
} else if (preference == mEdgeLightDuration) {
|
||||
int value = (Integer) newValue;
|
||||
Settings.System.putIntForUser(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_DURATION, value, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference == mEdgeLightRepeatCount) {
|
||||
int value = (Integer) newValue;
|
||||
Settings.System.putIntForUser(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_REPEATS, value, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user