Cherish:Cleanup for android 12

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Hưng Phan
2021-10-24 20:56:46 +07:00
parent 2ee28134b0
commit 3c58bb7cd8
144 changed files with 12 additions and 63182 deletions

View File

@@ -55,25 +55,6 @@ import java.util.List;
public class AnimationsSettings extends SettingsPreferenceFragment
implements OnPreferenceChangeListener {
private static final String KEY_TOAST_ANIMATION = "toast_animation";
private static final String KEY_LISTVIEW_ANIMATION = "listview_animation";
private static final String KEY_LISTVIEW_INTERPOLATOR = "listview_interpolator";
private static final String SCROLLINGCACHE_PREF = "pref_scrollingcache";
private static final String SCROLLINGCACHE_PERSIST_PROP = "persist.sys.scrollingcache";
private static final String SCROLLINGCACHE_DEFAULT = "2";
private static final String KEY_SCREEN_OFF_ANIMATION = "screen_off_animation";
private ListPreference mToastAnimation;
private ListPreference mScrollingCachePref;
private ListPreference mListViewAnimation;
private ListPreference mListViewInterpolator;
private ListPreference mScreenOffAnimation;
private int[] mAnimations;
private String[] mAnimationsStrings;
private String[] mAnimationsNum;
private Context mContext;
@Override
public int getMetricsCategory() {
return MetricsEvent.CHERISH_SETTINGS;
@@ -85,41 +66,6 @@ public class AnimationsSettings extends SettingsPreferenceFragment
addPreferencesFromResource(R.xml.cherish_settings_animations);
ContentResolver resolver = getActivity().getContentResolver();
PreferenceScreen prefs = getPreferenceScreen();
mContext = getActivity();
mToastAnimation = (ListPreference) findPreference(KEY_TOAST_ANIMATION);
mToastAnimation.setSummary(mToastAnimation.getEntry());
int CurrentToastAnimation = Settings.Global.getInt(getContentResolver(), Settings.Global.TOAST_ANIMATION, 1);
mToastAnimation.setValueIndex(CurrentToastAnimation); //set to index of default value
mToastAnimation.setSummary(mToastAnimation.getEntries()[CurrentToastAnimation]);
mToastAnimation.setOnPreferenceChangeListener(this);
mListViewAnimation = (ListPreference) findPreference(KEY_LISTVIEW_ANIMATION);
int listviewanimation = Settings.Global.getInt(getContentResolver(),
Settings.Global.LISTVIEW_ANIMATION, 0);
mListViewAnimation.setValue(String.valueOf(listviewanimation));
mListViewAnimation.setSummary(mListViewAnimation.getEntry());
mListViewAnimation.setOnPreferenceChangeListener(this);
mListViewInterpolator = (ListPreference) findPreference(KEY_LISTVIEW_INTERPOLATOR);
int listviewinterpolator = Settings.Global.getInt(getContentResolver(),
Settings.Global.LISTVIEW_INTERPOLATOR, 0);
mListViewInterpolator.setValue(String.valueOf(listviewinterpolator));
mListViewInterpolator.setSummary(mListViewInterpolator.getEntry());
mListViewInterpolator.setOnPreferenceChangeListener(this);
mListViewInterpolator.setEnabled(listviewanimation > 0);
mScrollingCachePref = (ListPreference) findPreference(SCROLLINGCACHE_PREF);
mScrollingCachePref.setValue(SystemProperties.get(SCROLLINGCACHE_PERSIST_PROP,
SystemProperties.get(SCROLLINGCACHE_PERSIST_PROP, SCROLLINGCACHE_DEFAULT)));
mScrollingCachePref.setOnPreferenceChangeListener(this);
mScreenOffAnimation = (ListPreference) findPreference(KEY_SCREEN_OFF_ANIMATION);
int screenOffAnimation = Settings.System.getInt(getContentResolver(),
Settings.System.SCREEN_OFF_ANIMATION, 0);
mScreenOffAnimation.setValue(Integer.toString(screenOffAnimation));
mScreenOffAnimation.setSummary(mScreenOffAnimation.getEntry());
mScreenOffAnimation.setOnPreferenceChangeListener(this);
}
@Override
@@ -130,39 +76,6 @@ public class AnimationsSettings extends SettingsPreferenceFragment
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
ContentResolver resolver = getActivity().getContentResolver();
if (preference == mToastAnimation) {
int index = mToastAnimation.findIndexOfValue((String) newValue);
Settings.Global.putString(getContentResolver(), Settings.Global.TOAST_ANIMATION, (String) newValue);
mToastAnimation.setSummary(mToastAnimation.getEntries()[index]);
Toast.makeText(mContext, "Toast Test", Toast.LENGTH_SHORT).show();
return true;
} else if (preference == mListViewAnimation) {
int value = Integer.parseInt((String) newValue);
int index = mListViewAnimation.findIndexOfValue((String) newValue);
Settings.Global.putInt(getContentResolver(),
Settings.Global.LISTVIEW_ANIMATION, value);
mListViewAnimation.setSummary(mListViewAnimation.getEntries()[index]);
mListViewInterpolator.setEnabled(value > 0);
return true;
} else if (preference == mListViewInterpolator) {
int value = Integer.parseInt((String) newValue);
int index = mListViewInterpolator.findIndexOfValue((String) newValue);
Settings.Global.putInt(getContentResolver(),
Settings.Global.LISTVIEW_INTERPOLATOR, value);
mListViewInterpolator.setSummary(mListViewInterpolator.getEntries()[index]);
return true;
} else if (preference == mScreenOffAnimation) {
int value = Integer.valueOf((String) newValue);
int index = mScreenOffAnimation.findIndexOfValue((String) newValue);
mScreenOffAnimation.setSummary(mScreenOffAnimation.getEntries()[index]);
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_ANIMATION, value);
return true;
} else if (preference == mScrollingCachePref) {
if (newValue != null) {
SystemProperties.set(SCROLLINGCACHE_PERSIST_PROP, (String) newValue);
}
return true;
}
return false;
}