Cherish:Cleanup for android 12
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -45,29 +45,12 @@ import java.util.List;
|
||||
public class MiscSettings extends SettingsPreferenceFragment implements
|
||||
OnPreferenceChangeListener {
|
||||
|
||||
private static final String SMART_PIXELS = "smart_pixels";
|
||||
private static final String SYSUI_ROUNDED_SIZE = "sysui_rounded_size";
|
||||
private static final String SYSUI_ROUNDED_FWVALS = "sysui_rounded_fwvals";
|
||||
private static final String KEY_PULSE_BRIGHTNESS = "ambient_pulse_brightness";
|
||||
private static final String KEY_DOZE_BRIGHTNESS = "ambient_doze_brightness";
|
||||
private static final String CUSTOM_STATUSBAR_PADDING_START = "custom_statusbar_padding_start";
|
||||
private static final String CUSTOM_STATUSBAR_PADDING_END = "custom_statusbar_padding_end";
|
||||
|
||||
private CustomSeekBarPreference mCornerRadius;
|
||||
private CustomSeekBarPreference mCustomStatusbarPaddingStart;
|
||||
private CustomSeekBarPreference mCustomStatusbarPaddingEnd;
|
||||
private CustomSeekBarPreference mContentPadding;
|
||||
private SecureSettingSwitchPreference mRoundedFwvals;
|
||||
private CustomSeekBarPreference mPulseBrightness;
|
||||
private CustomSeekBarPreference mDozeBrightness;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
|
||||
addPreferencesFromResource(R.xml.cherish_settings_misc);
|
||||
updateSmartPixelsPreference();
|
||||
|
||||
Resources res = null;
|
||||
Context ctx = getContext();
|
||||
@@ -79,110 +62,13 @@ public class MiscSettings extends SettingsPreferenceFragment implements
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Rounded Corner Radius
|
||||
mCornerRadius = (CustomSeekBarPreference) findPreference(SYSUI_ROUNDED_SIZE);
|
||||
int resourceIdRadius = (int) ctx.getResources().getDimension(com.android.internal.R.dimen.rounded_corner_radius);
|
||||
int cornerRadius = Settings.Secure.getIntForUser(ctx.getContentResolver(), Settings.Secure.SYSUI_ROUNDED_SIZE,
|
||||
((int) (resourceIdRadius / density)), UserHandle.USER_CURRENT);
|
||||
mCornerRadius.setValue(cornerRadius);
|
||||
mCornerRadius.setOnPreferenceChangeListener(this);
|
||||
|
||||
mCustomStatusbarPaddingStart = (CustomSeekBarPreference) findPreference(CUSTOM_STATUSBAR_PADDING_START);
|
||||
int customStatusbarPaddingStart = Settings.System.getIntForUser(ctx.getContentResolver(),
|
||||
Settings.System.CUSTOM_STATUSBAR_PADDING_START, res.getIdentifier("com.android.systemui:dimen/status_bar_padding_start", null, null), UserHandle.USER_CURRENT);
|
||||
mCustomStatusbarPaddingStart.setValue(customStatusbarPaddingStart);
|
||||
mCustomStatusbarPaddingStart.setOnPreferenceChangeListener(this);
|
||||
|
||||
mCustomStatusbarPaddingEnd = (CustomSeekBarPreference) findPreference(CUSTOM_STATUSBAR_PADDING_END);
|
||||
int customStatusbarPaddingEnd = Settings.System.getIntForUser(getActivity().getContentResolver(),
|
||||
Settings.System.CUSTOM_STATUSBAR_PADDING_END, res.getIdentifier("com.android.systemui:dimen/status_bar_padding_end", null, null), UserHandle.USER_CURRENT);
|
||||
mCustomStatusbarPaddingEnd.setValue(customStatusbarPaddingEnd);
|
||||
mCustomStatusbarPaddingEnd.setOnPreferenceChangeListener(this);
|
||||
|
||||
// Rounded use Framework Values
|
||||
mRoundedFwvals = (SecureSettingSwitchPreference) findPreference(SYSUI_ROUNDED_FWVALS);
|
||||
mRoundedFwvals.setOnPreferenceChangeListener(this);
|
||||
|
||||
int defaultDoze = getResources().getInteger(
|
||||
com.android.internal.R.integer.config_screenBrightnessDoze);
|
||||
int defaultPulse = getResources().getInteger(
|
||||
com.android.internal.R.integer.config_screenBrightnessPulse);
|
||||
if (defaultPulse == -1) {
|
||||
defaultPulse = defaultDoze;
|
||||
}
|
||||
|
||||
mPulseBrightness = (CustomSeekBarPreference) findPreference(KEY_PULSE_BRIGHTNESS);
|
||||
int value = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.PULSE_BRIGHTNESS, defaultPulse);
|
||||
mPulseBrightness.setValue(value);
|
||||
mPulseBrightness.setOnPreferenceChangeListener(this);
|
||||
|
||||
mDozeBrightness = (CustomSeekBarPreference) findPreference(KEY_DOZE_BRIGHTNESS);
|
||||
value = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.DOZE_BRIGHTNESS, defaultDoze);
|
||||
mDozeBrightness.setValue(value);
|
||||
mDozeBrightness.setOnPreferenceChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
private void updateSmartPixelsPreference() {
|
||||
PreferenceScreen prefSet = getPreferenceScreen();
|
||||
boolean enableSmartPixels = getContext().getResources().
|
||||
getBoolean(com.android.internal.R.bool.config_enableSmartPixels);
|
||||
Preference smartPixels = findPreference(SMART_PIXELS);
|
||||
|
||||
if (!enableSmartPixels){
|
||||
prefSet.removePreference(smartPixels);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object objValue) {
|
||||
if (preference == mCornerRadius) {
|
||||
Settings.Secure.putIntForUser(getContext().getContentResolver(), Settings.Secure.SYSUI_ROUNDED_SIZE,
|
||||
(int) objValue, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference == mRoundedFwvals) {
|
||||
restoreCorners();
|
||||
return true;
|
||||
} else if (preference == mPulseBrightness) {
|
||||
int value = (Integer) objValue;
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.PULSE_BRIGHTNESS, value);
|
||||
return true;
|
||||
} else if (preference == mDozeBrightness) {
|
||||
int value = (Integer) objValue;
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.DOZE_BRIGHTNESS, value);
|
||||
return true;
|
||||
} else if (preference == mCustomStatusbarPaddingStart) {
|
||||
int value = (Integer) objValue;
|
||||
Settings.System.putIntForUser(getContext().getContentResolver(),
|
||||
Settings.System.CUSTOM_STATUSBAR_PADDING_START, value, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference == mCustomStatusbarPaddingEnd) {
|
||||
int value = (Integer) objValue;
|
||||
Settings.System.putIntForUser(getContext().getContentResolver(),
|
||||
Settings.System.CUSTOM_STATUSBAR_PADDING_END, value, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void restoreCorners() {
|
||||
Resources res = null;
|
||||
float density = Resources.getSystem().getDisplayMetrics().density;
|
||||
Context ctx = getContext();
|
||||
|
||||
try {
|
||||
res = ctx.getPackageManager().getResourcesForApplication("com.android.systemui");
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
int resourceIdRadius = (int) ctx.getResources().getDimension(com.android.internal.R.dimen.rounded_corner_radius);
|
||||
mCornerRadius.setValue((int) (resourceIdRadius / density));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
|
||||
Reference in New Issue
Block a user