Cherish: Toast Animations [2/2]

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
GwonHyeok
2018-09-13 20:38:34 +05:30
committed by Hưng Phan
parent 608b76ded5
commit 83f17e74d9
4 changed files with 81 additions and 1 deletions

View File

@@ -61,7 +61,9 @@ public class AnimationsSettings extends SettingsPreferenceFragment
private static final String WALLPAPER_CLOSE = "wallpaper_close";
private static final String WALLPAPER_INTRA_OPEN = "wallpaper_intra_open";
private static final String WALLPAPER_INTRA_CLOSE = "wallpaper_intra_close";
private static final String KEY_TOAST_ANIMATION = "toast_animation";
private ListPreference mToastAnimation;
ListPreference mActivityOpenPref;
ListPreference mActivityClosePref;
ListPreference mTaskOpenPref;
@@ -91,6 +93,13 @@ public class AnimationsSettings extends SettingsPreferenceFragment
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);
mAnimations = AwesomeAnimationHelper.getAnimationsList();
int animqty = mAnimations.length;
mAnimationsStrings = new String[animqty];
@@ -171,7 +180,13 @@ public class AnimationsSettings extends SettingsPreferenceFragment
ContentResolver resolver = getActivity().getContentResolver();
boolean result = false;
if (preference == mActivityOpenPref) {
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 == mActivityOpenPref) {
int val = Integer.parseInt((String) newValue);
result = Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.ACTIVITY_ANIMATION_CONTROLS[0], val);