Cherish:Intitial for Android 11

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Hưng Phan
2020-09-26 12:29:26 +07:00
parent e1061bf1a5
commit e6308bab52
59 changed files with 20 additions and 9500 deletions

View File

@@ -36,67 +36,12 @@ import net.margaritov.preference.colorpicker.ColorPickerPreference;
public class BatteryLightSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
private ColorPickerPreference mLowColor;
private ColorPickerPreference mMediumColor;
private ColorPickerPreference mFullColor;
private ColorPickerPreference mReallyFullColor;
private SystemSettingSwitchPreference mLowBatteryBlinking;
private PreferenceCategory mColorCategory;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.battery_light_settings);
PreferenceScreen prefSet = getPreferenceScreen();
mColorCategory = (PreferenceCategory) findPreference("battery_light_cat");
mLowBatteryBlinking = (SystemSettingSwitchPreference)prefSet.findPreference("battery_light_low_blinking");
if (getResources().getBoolean(
com.android.internal.R.bool.config_ledCanPulse)) {
mLowBatteryBlinking.setChecked(Settings.System.getIntForUser(getContentResolver(),
Settings.System.BATTERY_LIGHT_LOW_BLINKING, 0, UserHandle.USER_CURRENT) == 1);
mLowBatteryBlinking.setOnPreferenceChangeListener(this);
} else {
prefSet.removePreference(mLowBatteryBlinking);
}
if (getResources().getBoolean(com.android.internal.R.bool.config_multiColorBatteryLed)) {
int color = Settings.System.getIntForUser(getContentResolver(),
Settings.System.BATTERY_LIGHT_LOW_COLOR, 0xFFFF0000,
UserHandle.USER_CURRENT);
mLowColor = (ColorPickerPreference) findPreference("battery_light_low_color");
mLowColor.setAlphaSliderEnabled(false);
mLowColor.setNewPreviewColor(color);
mLowColor.setOnPreferenceChangeListener(this);
color = Settings.System.getIntForUser(getContentResolver(),
Settings.System.BATTERY_LIGHT_MEDIUM_COLOR, 0xFFFFFF00,
UserHandle.USER_CURRENT);
mMediumColor = (ColorPickerPreference) findPreference("battery_light_medium_color");
mMediumColor.setAlphaSliderEnabled(false);
mMediumColor.setNewPreviewColor(color);
mMediumColor.setOnPreferenceChangeListener(this);
color = Settings.System.getIntForUser(getContentResolver(),
Settings.System.BATTERY_LIGHT_FULL_COLOR, 0xFFFFFF00,
UserHandle.USER_CURRENT);
mFullColor = (ColorPickerPreference) findPreference("battery_light_full_color");
mFullColor.setAlphaSliderEnabled(false);
mFullColor.setNewPreviewColor(color);
mFullColor.setOnPreferenceChangeListener(this);
color = Settings.System.getIntForUser(getContentResolver(),
Settings.System.BATTERY_LIGHT_REALLYFULL_COLOR, 0xFF00FF00,
UserHandle.USER_CURRENT);
mReallyFullColor = (ColorPickerPreference) findPreference("battery_light_reallyfull_color");
mReallyFullColor.setAlphaSliderEnabled(false);
mReallyFullColor.setNewPreviewColor(color);
mReallyFullColor.setOnPreferenceChangeListener(this);
} else {
prefSet.removePreference(mColorCategory);
}
}
@Override
@@ -105,38 +50,7 @@ public class BatteryLightSettings extends SettingsPreferenceFragment implements
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference.equals(mLowColor)) {
int color = ((Integer) newValue).intValue();
Settings.System.putIntForUser(getContentResolver(),
Settings.System.BATTERY_LIGHT_LOW_COLOR, color,
UserHandle.USER_CURRENT);
return true;
} else if (preference.equals(mMediumColor)) {
int color = ((Integer) newValue).intValue();
Settings.System.putIntForUser(getContentResolver(),
Settings.System.BATTERY_LIGHT_MEDIUM_COLOR, color,
UserHandle.USER_CURRENT);
return true;
} else if (preference.equals(mFullColor)) {
int color = ((Integer) newValue).intValue();
Settings.System.putIntForUser(getContentResolver(),
Settings.System.BATTERY_LIGHT_FULL_COLOR, color,
UserHandle.USER_CURRENT);
return true;
} else if (preference.equals(mReallyFullColor)) {
int color = ((Integer) newValue).intValue();
Settings.System.putIntForUser(getContentResolver(),
Settings.System.BATTERY_LIGHT_REALLYFULL_COLOR, color,
UserHandle.USER_CURRENT);
return true;
} else if (preference == mLowBatteryBlinking) {
boolean value = (Boolean) newValue;
Settings.System.putIntForUser(getActivity().getContentResolver(),
Settings.System.BATTERY_LIGHT_LOW_BLINKING, value ? 1 : 0,
UserHandle.USER_CURRENT);
mLowBatteryBlinking.setChecked(value);
return true;
}
return false;
}
}