Cherish:Add ambient pulse and aod notifications [2/2]
Co-authored-by: Ido Ben-Hur <idoybh2@gmail.com> Change-Id: I86ab495f83d36925b9173870a95277cc88af802b Signed-off-by: DennySPb <dennyspb@gmail.com> Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -1002,4 +1002,34 @@
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ambient_notification_light_timeout_entries" translatable="false">
|
||||
<item>@string/entry_infinite</item>
|
||||
<item>@string/entry_five_minute</item>
|
||||
<item>@string/entry_ten_minute</item>
|
||||
<item>@string/entry_fifteen_minute</item>
|
||||
<item>@string/entry_thirty_minute</item>
|
||||
<item>@string/entry_sixty_minute</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ambient_notification_light_timeout_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>300</item>
|
||||
<item>600</item>
|
||||
<item>900</item>
|
||||
<item>1800</item>
|
||||
<item>3600</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ambient_notification_light_color_mode_entries" translatable="false">
|
||||
<item>@string/ambient_notification_light_color_mode_automatic</item>
|
||||
<item>@string/ambient_notification_light_color_mode_accent</item>
|
||||
<item>@string/ambient_notification_light_color_mode_custom</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ambient_notification_light_color_mode_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -942,4 +942,30 @@
|
||||
<string name="gaming_mode_notifications_all_title">Show toasts and notification</string>
|
||||
<string name="gaming_mode_dynamic_title">Dynamic mode</string>
|
||||
<string name="gaming_mode_dynamic_summary">Try detecting and adding gaming apps automatically</string>
|
||||
|
||||
<!-- Ambient edge lighting -->
|
||||
<string name="pulse_ambient_light_category">Screen edge lighting</string>
|
||||
<string name="pulse_ambient_light_title">Show on new notifcation</string>
|
||||
<string name="pulse_ambient_light_summary">Show light pulse on new notification</string>
|
||||
<string name="ambient_notification_light_enabled_title">Show on always on</string>
|
||||
<string name="ambient_notification_light_enabled_summary">Show light pulse on new notification using always on</string>
|
||||
<string name="ambient_notification_light_color_title">Custom color</string>
|
||||
<string name="ambient_notification_light_color_summary">Default color for light pulse</string>
|
||||
<string name="ambient_notification_light_hide_aod_title">Only show light pulse</string>
|
||||
<string name="ambient_notification_light_hide_aod_summary">Hide all other display elements from always on</string>
|
||||
<string name="ambient_notification_light_timeout_title">Timeout for light pulse</string>
|
||||
<string name="entry_infinite">Infinite</string>
|
||||
<string name="entry_five_minute">5 minutes</string>
|
||||
<string name="entry_ten_minute">10 minutes</string>
|
||||
<string name="entry_thirty_minute">30 minutes</string>
|
||||
<string name="entry_sixty_minute">60 minutes</string>
|
||||
<string name="entry_fifteen_minute">15 minutes</string>
|
||||
<string name="ambient_notification_light_color_mode_title">Light pulse color</string>
|
||||
<string name="ambient_notification_light_color_mode_automatic">Notification color</string>
|
||||
<string name="ambient_notification_light_color_mode_accent">System accent color</string>
|
||||
<string name="ambient_notification_light_color_mode_custom">Custom color</string>
|
||||
<string name="pulse_ambient_light_duration_title">Duration</string>
|
||||
<string name="pulse_ambient_light_duration_summary">Sets the ambient light animation duration</string>
|
||||
<string name="pulse_ambient_light_repeat_count_title">Edge Light Repeat count</string>
|
||||
<string name="pulse_ambient_light_repeat_count_summary">Set max repeat count. 0 for infinite</string>
|
||||
</resources>
|
||||
|
||||
@@ -70,4 +70,78 @@
|
||||
android:summary="@string/notification_sound_vib_screen_on_summary"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pulse_ambient_light_category"
|
||||
android:title="@string/pulse_ambient_light_category" >
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
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="ambient_notification_light_enabled"
|
||||
android:title="@string/ambient_notification_light_enabled_title"
|
||||
android:summary="@string/ambient_notification_light_enabled_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<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_light_timeout"
|
||||
android:dialogTitle="@string/ambient_notification_light_timeout_title"
|
||||
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:defaultValue="0"
|
||||
android:dependency="ambient_notification_light_enabled"
|
||||
android:summary="%s" />
|
||||
|
||||
<ListPreference
|
||||
android:key="ambient_notification_light_color_mode"
|
||||
android:title="@string/ambient_notification_light_color_mode_title"
|
||||
android:persistent="false"
|
||||
android:entries="@array/ambient_notification_light_color_mode_entries"
|
||||
android:entryValues="@array/ambient_notification_light_color_mode_values"
|
||||
android:defaultValue="2" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="ambient_notification_light_color"
|
||||
android:summary="@string/ambient_notification_light_color_summary"
|
||||
android:title="@string/ambient_notification_light_color_title"
|
||||
ledPreview="true"
|
||||
settings:defaultColorValue="0xFF3980FF" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||
android:key="ambient_light_duration"
|
||||
android:title="@string/pulse_ambient_light_duration_title"
|
||||
android:summary="@string/pulse_ambient_light_duration_summary"
|
||||
android:persistent="false"
|
||||
android:defaultValue="2"
|
||||
android:max="10"
|
||||
settings:min="1"
|
||||
settings:units="sec"
|
||||
settings:interval="1"
|
||||
android:dependency="pulse_ambient_light" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||
android:key="ambient_light_repeat_count"
|
||||
android:title="@string/pulse_ambient_light_repeat_count_title"
|
||||
android:summary="@string/pulse_ambient_light_repeat_count_summary"
|
||||
android:persistent="false"
|
||||
android:defaultValue="0"
|
||||
android:max="10"
|
||||
settings:min="0"
|
||||
settings:interval="1"
|
||||
android:dependency="pulse_ambient_light" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -11,9 +11,11 @@ import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
import androidx.preference.ListPreference;
|
||||
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.cherish.settings.preferences.SystemSettingMasterSwitchPreference;
|
||||
import com.cherish.settings.preferences.SystemSettingSeekBarPreference;
|
||||
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
||||
import com.cherish.settings.preferences.SystemSettingListPreference;
|
||||
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
|
||||
@@ -21,7 +23,16 @@ import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||
|
||||
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
|
||||
|
||||
private Preference mChargingLeds;
|
||||
private static final String NOTIFICATION_PULSE_COLOR = "ambient_notification_light_color";
|
||||
private static final String AMBIENT_LIGHT_DURATION = "ambient_light_duration";
|
||||
private static final String AMBIENT_LIGHT_REPEAT_COUNT = "ambient_light_repeat_count";
|
||||
private static final String PULSE_COLOR_MODE_PREF = "ambient_notification_light_color_mode";
|
||||
|
||||
private Preference mChargingLeds;
|
||||
private ColorPickerPreference mEdgeLightColorPreference;
|
||||
private SystemSettingSeekBarPreference mEdgeLightDurationPreference;
|
||||
private SystemSettingSeekBarPreference mEdgeLightRepeatCountPreference;
|
||||
private ListPreference mColorMode;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -38,12 +49,97 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
||||
prefScreen.removePreference(mChargingLeds);
|
||||
}
|
||||
|
||||
mEdgeLightRepeatCountPreference = (SystemSettingSeekBarPreference) findPreference(AMBIENT_LIGHT_REPEAT_COUNT);
|
||||
mEdgeLightRepeatCountPreference.setOnPreferenceChangeListener(this);
|
||||
int rCount = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.AMBIENT_LIGHT_REPEAT_COUNT, 0);
|
||||
mEdgeLightRepeatCountPreference.setValue(rCount);
|
||||
|
||||
mEdgeLightDurationPreference = (SystemSettingSeekBarPreference) findPreference(AMBIENT_LIGHT_DURATION);
|
||||
mEdgeLightDurationPreference.setOnPreferenceChangeListener(this);
|
||||
int duration = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.AMBIENT_LIGHT_DURATION, 2);
|
||||
mEdgeLightDurationPreference.setValue(duration);
|
||||
|
||||
mColorMode = (ListPreference) findPreference(PULSE_COLOR_MODE_PREF);
|
||||
int value;
|
||||
boolean colorModeAutomatic = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR_AUTOMATIC, 0) != 0;
|
||||
boolean colorModeAccent = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_ACCENT, 0) != 0;
|
||||
if (colorModeAutomatic) {
|
||||
value = 0;
|
||||
} else if (colorModeAccent) {
|
||||
value = 1;
|
||||
} else {
|
||||
value = 2;
|
||||
}
|
||||
|
||||
mColorMode.setValue(Integer.toString(value));
|
||||
mColorMode.setSummary(mColorMode.getEntry());
|
||||
mColorMode.setOnPreferenceChangeListener(this);
|
||||
|
||||
mEdgeLightColorPreference = (ColorPickerPreference) findPreference(NOTIFICATION_PULSE_COLOR);
|
||||
int edgeLightColor = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR, 0xFF3980FF);
|
||||
mEdgeLightColorPreference.setNewPreviewColor(edgeLightColor);
|
||||
mEdgeLightColorPreference.setAlphaSliderEnabled(false);
|
||||
String edgeLightColorHex = String.format("#%08x", (0xFF3980FF & edgeLightColor));
|
||||
if (edgeLightColorHex.equals("#ff3980ff")) {
|
||||
mEdgeLightColorPreference.setSummary(R.string.color_default);
|
||||
} 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.color_default);
|
||||
} else {
|
||||
preference.setSummary(hex);
|
||||
}
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR, intHex);
|
||||
return true;
|
||||
} else if (preference == mEdgeLightRepeatCountPreference) {
|
||||
int value = (Integer) newValue;
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.AMBIENT_LIGHT_REPEAT_COUNT, value);
|
||||
return true;
|
||||
} else if (preference == mEdgeLightDurationPreference) {
|
||||
int value = (Integer) newValue;
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.AMBIENT_LIGHT_DURATION, value);
|
||||
return true;
|
||||
} else if (preference == mColorMode) {
|
||||
int value = Integer.valueOf((String) newValue);
|
||||
int index = mColorMode.findIndexOfValue((String) newValue);
|
||||
mColorMode.setSummary(mColorMode.getEntries()[index]);
|
||||
if (value == 0) {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR_AUTOMATIC, 1);
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_ACCENT, 0);
|
||||
} else if (value == 1) {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR_AUTOMATIC, 0);
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_ACCENT, 1);
|
||||
} else {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_COLOR_AUTOMATIC, 0);
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.NOTIFICATION_PULSE_ACCENT, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user