Cherish: Add DND & Rate settings to flash on call [3/3]
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -371,10 +371,15 @@
|
|||||||
<string name="qs_set_animation_interpolator">%1$s</string>
|
<string name="qs_set_animation_interpolator">%1$s</string>
|
||||||
|
|
||||||
<!-- Blink flashlight for incoming calls -->
|
<!-- Blink flashlight for incoming calls -->
|
||||||
|
<string name="flashlight_category">Flashlight</string>
|
||||||
<string name="flashlight_on_call_title">Blink Flashlight for incoming call</string>
|
<string name="flashlight_on_call_title">Blink Flashlight for incoming call</string>
|
||||||
<string name="flashlight_on_call_disabled">Disabled</string>
|
<string name="flashlight_on_call_disabled">Disabled</string>
|
||||||
<string name="flashlight_on_call_ringer">When ringing</string>
|
<string name="flashlight_on_call_ringer">When ringing</string>
|
||||||
<string name="flashlight_on_call_no_ringer">When ringer is silent</string>
|
<string name="flashlight_on_call_no_ringer">When ringer is silent</string>
|
||||||
<string name="flashlight_on_call_silent">When entirely silent (no ringer or vibrator)</string>
|
<string name="flashlight_on_call_silent">When entirely silent (no ringer or vibrator)</string>
|
||||||
<string name="flashlight_on_call_always">Always</string>
|
<string name="flashlight_on_call_always">Always</string>
|
||||||
|
<string name="flashlight_on_call_ignore_dnd_title">Ignore DND</string>
|
||||||
|
<string name="flashlight_on_call_ignore_dnd_summary">Whether to flash when in Do Not Disturb mode</string>
|
||||||
|
<string name="flashlight_on_call_rate_title">Rate</string>
|
||||||
|
<string name="flashlight_on_call_rate_summary">Flashlight on call blink rate</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -42,12 +42,31 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
<PreferenceCategory
|
||||||
android:key="flashlight_on_call"
|
android:title="@string/flashlight_category">
|
||||||
android:title="@string/flashlight_on_call_title"
|
|
||||||
android:entries="@array/flashlight_on_call_entries"
|
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||||
android:entryValues="@array/flashlight_on_call_values"
|
android:key="flashlight_on_call"
|
||||||
android:defaultValue="0" />
|
android:title="@string/flashlight_on_call_title"
|
||||||
|
android:entries="@array/flashlight_on_call_entries"
|
||||||
|
android:entryValues="@array/flashlight_on_call_values"
|
||||||
|
android:defaultValue="0" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
|
android:key="flashlight_on_call_ignore_dnd"
|
||||||
|
android:title="@string/flashlight_on_call_ignore_dnd_title"
|
||||||
|
android:summary="@string/flashlight_on_call_ignore_dnd_summary"
|
||||||
|
android:defaultValue="false" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.CustomSeekBarPreference
|
||||||
|
android:key="flashlight_on_call_rate"
|
||||||
|
android:title="@string/flashlight_on_call_rate_title"
|
||||||
|
android:summary="@string/flashlight_on_call_rate_summary"
|
||||||
|
android:max="5"
|
||||||
|
settings:min="1"
|
||||||
|
settings:defaultValue="1"
|
||||||
|
settings:units="Hz" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="notifications_general_category"
|
android:key="notifications_general_category"
|
||||||
|
|||||||
@@ -40,6 +40,13 @@ import java.util.List;
|
|||||||
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
|
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
|
||||||
|
|
||||||
private static final String INCALL_VIB_OPTIONS = "incall_vib_options";
|
private static final String INCALL_VIB_OPTIONS = "incall_vib_options";
|
||||||
|
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 SystemSettingListPreference mFlashOnCall;
|
||||||
|
private SystemSettingSwitchPreference mFlashOnCallIgnoreDND;
|
||||||
|
private CustomSeekBarPreference mFlashOnCallRate;
|
||||||
private Preference mChargingLeds;
|
private Preference mChargingLeds;
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
@@ -55,6 +62,24 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
prefScreen.removePreference(incallVibCategory);
|
prefScreen.removePreference(incallVibCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
mChargingLeds = (Preference) findPreference("charging_light");
|
mChargingLeds = (Preference) findPreference("charging_light");
|
||||||
if (mChargingLeds != null
|
if (mChargingLeds != null
|
||||||
&& !getResources().getBoolean(
|
&& !getResources().getBoolean(
|
||||||
@@ -66,6 +91,20 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
final ContentResolver resolver = getActivity().getContentResolver();
|
||||||
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user