From c95194f7f1b700534375c648d5e5b25eb19708f0 Mon Sep 17 00:00:00 2001 From: Ido Ben-Hur Date: Wed, 10 Jun 2020 21:41:22 +0300 Subject: [PATCH] Cherish: Allow to flash on call only when entirely silent [3/3] and Add DND & Rate settings to flash on call [3/3] In addition improve the strings --- res/drawable/ic_call.xml | 7 ++++ res/drawable/ic_call_dnd.xml | 7 ++++ res/values/cherish_arrays.xml | 2 + res/values/cherish_strings.xml | 12 ++++-- res/xml/cherish_settings_notifications.xml | 21 ++++++++++ .../fragments/NotificationSettings.java | 41 ++++++++++++++++++- 6 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 res/drawable/ic_call.xml create mode 100644 res/drawable/ic_call_dnd.xml diff --git a/res/drawable/ic_call.xml b/res/drawable/ic_call.xml new file mode 100644 index 0000000..009f0c0 --- /dev/null +++ b/res/drawable/ic_call.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/res/drawable/ic_call_dnd.xml b/res/drawable/ic_call_dnd.xml new file mode 100644 index 0000000..0fb5e2a --- /dev/null +++ b/res/drawable/ic_call_dnd.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml index 33ac1af..8a781b5 100644 --- a/res/values/cherish_arrays.xml +++ b/res/values/cherish_arrays.xml @@ -657,6 +657,7 @@ @string/flashlight_on_call_disabled @string/flashlight_on_call_ringer + @string/flashlight_on_call_no_ringer @string/flashlight_on_call_silent @string/flashlight_on_call_always @@ -666,5 +667,6 @@ 1 2 3 + 4 diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index e6500d3..52a01ce 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -736,9 +736,15 @@ Whether to Center R style notification headers (Requires a SystemUI restart) - Blink Flashlight for call + Flashlight + Blink Flashlight for incoming call Disabled - Only in ringer mode - Only when ringer is silent + When ringing + When ringer is silent + When entirely silent (no ringer or vibrator) Always + Ignore DND + Whether to flash when in Do Not Disturb mode + Rate + Flashlight on call blink rate diff --git a/res/xml/cherish_settings_notifications.xml b/res/xml/cherish_settings_notifications.xml index 91af03d..4db0f2f 100644 --- a/res/xml/cherish_settings_notifications.xml +++ b/res/xml/cherish_settings_notifications.xml @@ -65,6 +65,9 @@ android:defaultValue="false" /> + + + + + + + diff --git a/src/com/cherish/settings/fragments/NotificationSettings.java b/src/com/cherish/settings/fragments/NotificationSettings.java index 59865a1..4122dda 100644 --- a/src/com/cherish/settings/fragments/NotificationSettings.java +++ b/src/com/cherish/settings/fragments/NotificationSettings.java @@ -14,14 +14,23 @@ import android.provider.Settings; import com.android.settings.SettingsPreferenceFragment; import com.cherish.settings.preferences.SystemSettingMasterSwitchPreference; +import com.cherish.settings.preferences.CustomSeekBarPreference; +import com.cherish.settings.preferences.SystemSettingListPreference; +import com.cherish.settings.preferences.SystemSettingSwitchPreference; import net.margaritov.preference.colorpicker.ColorPickerPreference; public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{ private static final String PULSE_AMBIENT_LIGHT = "pulse_ambient_light"; + private static final String PREF_FLASH_ON_CALL = "flashlight_on_call"; + private static final String PREF_FLASH_ON_CALL_DND = "flashlight_on_call_ignore_dnd"; + private static final String PREF_FLASH_ON_CALL_RATE = "flashlight_on_call_rate"; private Preference mChargingLeds; private SystemSettingMasterSwitchPreference mEdgePulse; + private SystemSettingListPreference mFlashOnCall; + private SystemSettingSwitchPreference mFlashOnCallIgnoreDND; + private CustomSeekBarPreference mFlashOnCallRate; @Override public void onCreate(Bundle icicle) { @@ -42,6 +51,24 @@ public class NotificationSettings extends SettingsPreferenceFragment implements int edgePulse = Settings.System.getInt(getContentResolver(), PULSE_AMBIENT_LIGHT, 0); mEdgePulse.setChecked(edgePulse != 0); + + mFlashOnCallRate = (CustomSeekBarPreference) + findPreference(PREF_FLASH_ON_CALL_RATE); + int value = Settings.System.getInt(resolver, + Settings.System.FLASHLIGHT_ON_CALL_RATE, 1); + mFlashOnCallRate.setValue(value); + mFlashOnCallRate.setOnPreferenceChangeListener(this); + + mFlashOnCallIgnoreDND = (SystemSettingSwitchPreference) + findPreference(PREF_FLASH_ON_CALL_DND); + value = Settings.System.getInt(resolver, + Settings.System.FLASHLIGHT_ON_CALL, 0); + mFlashOnCallIgnoreDND.setVisible(value > 1); + mFlashOnCallRate.setVisible(value != 0); + + mFlashOnCall = (SystemSettingListPreference) + findPreference(PREF_FLASH_ON_CALL); + mFlashOnCall.setOnPreferenceChangeListener(this); } @@ -53,7 +80,19 @@ public class NotificationSettings extends SettingsPreferenceFragment implements Settings.System.putInt(getContentResolver(), PULSE_AMBIENT_LIGHT, value ? 1 : 0); return true; - } + } else if (preference == mFlashOnCall) { + int value = Integer.parseInt((String) newValue); + Settings.System.putInt(resolver, + Settings.System.FLASHLIGHT_ON_CALL, value); + mFlashOnCallIgnoreDND.setVisible(value > 1); + mFlashOnCallRate.setVisible(value != 0); + return true; + } else if (preference == mFlashOnCallRate) { + int value = (Integer) newValue; + Settings.System.putInt(resolver, + Settings.System.FLASHLIGHT_ON_CALL_RATE, value); + return true; + } return false; }