Cherish:Intitial for Android 11
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -21,17 +21,6 @@ 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) {
|
||||
super.onCreate(icicle);
|
||||
@@ -39,61 +28,13 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
||||
addPreferencesFromResource(R.xml.cherish_settings_notifications);
|
||||
PreferenceScreen prefScreen = getPreferenceScreen();
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
|
||||
mChargingLeds = (Preference) findPreference("charging_light");
|
||||
if (mChargingLeds != null
|
||||
&& !getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_intrusiveBatteryLed)) {
|
||||
prefScreen.removePreference(mChargingLeds);
|
||||
}
|
||||
|
||||
mEdgePulse = (SystemSettingMasterSwitchPreference) findPreference(PULSE_AMBIENT_LIGHT);
|
||||
mEdgePulse.setOnPreferenceChangeListener(this);
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
if (preference == mEdgePulse) {
|
||||
boolean value = (Boolean) newValue;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user