From 464fcd9c348b6902695d0ed8be10ac1575176399 Mon Sep 17 00:00:00 2001 From: Stevespear426 Date: Wed, 6 Nov 2019 21:12:19 +0700 Subject: [PATCH] Cherish: AOKP custom system animations [2/2] --- res/drawable/ic_settings_animations.xml | 9 + res/drawable/ic_settings_navbar.xml | 7 - res/values-vi/cherish_strings.xml | 2 +- res/values/cherish_strings.xml | 20 +- res/xml/cherish_settings.xml | 7 + res/xml/cherish_settings_animations.xml | 81 +++++ res/xml/cherish_settings_navigation.xml | 23 -- .../fragments/AnimationsSettings.java | 285 ++++++++++++++++++ .../settings/fragments/NavbarSettings.java | 57 ---- 9 files changed, 402 insertions(+), 89 deletions(-) create mode 100644 res/drawable/ic_settings_animations.xml delete mode 100644 res/drawable/ic_settings_navbar.xml create mode 100644 res/xml/cherish_settings_animations.xml delete mode 100644 res/xml/cherish_settings_navigation.xml create mode 100644 src/com/cherish/settings/fragments/AnimationsSettings.java delete mode 100644 src/com/cherish/settings/fragments/NavbarSettings.java diff --git a/res/drawable/ic_settings_animations.xml b/res/drawable/ic_settings_animations.xml new file mode 100644 index 0000000..980cdf2 --- /dev/null +++ b/res/drawable/ic_settings_animations.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/res/drawable/ic_settings_navbar.xml b/res/drawable/ic_settings_navbar.xml deleted file mode 100644 index fab0fb7..0000000 --- a/res/drawable/ic_settings_navbar.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/res/values-vi/cherish_strings.xml b/res/values-vi/cherish_strings.xml index 81215d3..af30348 100644 --- a/res/values-vi/cherish_strings.xml +++ b/res/values-vi/cherish_strings.xml @@ -18,7 +18,7 @@ Cử chỉ Màn hình khoá Khác - Thanh điều hướng + Hiệu ứng Trình đơn nguồn Cài đặt nhanh Ứng dụng gần đây diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index 7737564..f8121b9 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -19,7 +19,7 @@ Gestures Lock screen Miscellaneous - Navigation bar + Animations Power menu Themes Quick Settings @@ -399,5 +399,23 @@ Show notification headers Whether to show R style notification headers (Requires a SystemUI restart) + + + System + Activity open animation + Activity close animation + Task open animation + Task open behind animation + Task close animation + Move to front animation + Move to back animation + Wallpaper open animation + Wallpaper close animation + Wallpaper intra open animation + Wallpaper intra close animation + Animation duration + Prevent app overrides + Prevent apps from overriding transitions + Default diff --git a/res/xml/cherish_settings.xml b/res/xml/cherish_settings.xml index d88e7b7..3c02034 100644 --- a/res/xml/cherish_settings.xml +++ b/res/xml/cherish_settings.xml @@ -44,6 +44,13 @@ android:title="@string/button_title" android:icon="@drawable/ic_settings_buttons" android:fragment="com.android.settings.custom.buttons.ButtonSettings"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/xml/cherish_settings_navigation.xml b/res/xml/cherish_settings_navigation.xml deleted file mode 100644 index f9364d5..0000000 --- a/res/xml/cherish_settings_navigation.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - diff --git a/src/com/cherish/settings/fragments/AnimationsSettings.java b/src/com/cherish/settings/fragments/AnimationsSettings.java new file mode 100644 index 0000000..2c3d221 --- /dev/null +++ b/src/com/cherish/settings/fragments/AnimationsSettings.java @@ -0,0 +1,285 @@ +/* + * Copyright (C) 2014 TeamEos + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.cherish.settings.fragments; + +import android.content.Context; +import android.content.ContentResolver; +import android.database.ContentObserver; +import android.content.res.Resources; +import android.os.Bundle; +import android.os.Handler; +import android.os.UserHandle; +import android.provider.Settings; +import android.view.View; + +import androidx.preference.ListPreference; +import androidx.preference.Preference; +import androidx.preference.PreferenceCategory; +import androidx.preference.PreferenceScreen; +import androidx.preference.Preference.OnPreferenceChangeListener; +import androidx.preference.SwitchPreference; + +import com.android.internal.logging.nano.MetricsProto; +import com.android.internal.util.cherish.AwesomeAnimationHelper; + +import com.android.settings.R; +import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.Utils; + +import com.cherish.settings.preferences.CustomSeekBarPreference; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +public class AnimationsSettings extends SettingsPreferenceFragment implements OnPreferenceChangeListener { + + private static final String ANIMATION_DURATION = "animation_controls_duration"; + private static final String ACTIVITY_OPEN = "activity_open"; + private static final String ACTIVITY_CLOSE = "activity_close"; + private static final String TASK_OPEN = "task_open"; + private static final String TASK_OPEN_BEHIND = "task_open_behind"; + private static final String TASK_CLOSE = "task_close"; + private static final String TASK_MOVE_TO_FRONT = "task_move_to_front"; + private static final String TASK_MOVE_TO_BACK = "task_move_to_back"; + private static final String WALLPAPER_OPEN = "wallpaper_open"; + 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 CustomSeekBarPreference mAnimDuration; + + ListPreference mActivityOpenPref; + ListPreference mActivityClosePref; + ListPreference mTaskOpenPref; + ListPreference mTaskOpenBehind; + ListPreference mTaskClosePref; + ListPreference mTaskMoveToFrontPref; + ListPreference mTaskMoveToBackPref; + ListPreference mWallpaperOpen; + ListPreference mWallpaperClose; + ListPreference mWallpaperIntraOpen; + ListPreference mWallpaperIntraClose; + + private int[] mAnimations; + private String[] mAnimationsStrings; + private String[] mAnimationsNum; + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + addPreferencesFromResource(R.xml.cherish_settings_animations); + + ContentResolver resolver = getActivity().getContentResolver(); + + mAnimDuration = (CustomSeekBarPreference) findPreference(ANIMATION_DURATION); + int animdef = Settings.Global.getInt(resolver, + Settings.Global.ANIMATION_CONTROLS_DURATION, 0); + mAnimDuration.setValue(animdef); + mAnimDuration.setOnPreferenceChangeListener(this); + + mAnimations = AwesomeAnimationHelper.getAnimationsList(); + int animqty = mAnimations.length; + mAnimationsStrings = new String[animqty]; + mAnimationsNum = new String[animqty]; + for (int i = 0; i < animqty; i++) { + mAnimationsStrings[i] = AwesomeAnimationHelper.getProperName(getActivity().getApplicationContext(), mAnimations[i]); + mAnimationsNum[i] = String.valueOf(mAnimations[i]); + } + + mActivityOpenPref = (ListPreference) findPreference(ACTIVITY_OPEN); + mActivityOpenPref.setSummary(getProperSummary(mActivityOpenPref)); + mActivityOpenPref.setEntries(mAnimationsStrings); + mActivityOpenPref.setEntryValues(mAnimationsNum); + mActivityOpenPref.setOnPreferenceChangeListener(this); + + mActivityClosePref = (ListPreference) findPreference(ACTIVITY_CLOSE); + mActivityClosePref.setSummary(getProperSummary(mActivityClosePref)); + mActivityClosePref.setEntries(mAnimationsStrings); + mActivityClosePref.setEntryValues(mAnimationsNum); + mActivityClosePref.setOnPreferenceChangeListener(this); + + mTaskOpenPref = (ListPreference) findPreference(TASK_OPEN); + mTaskOpenPref.setSummary(getProperSummary(mTaskOpenPref)); + mTaskOpenPref.setEntries(mAnimationsStrings); + mTaskOpenPref.setEntryValues(mAnimationsNum); + mTaskOpenPref.setOnPreferenceChangeListener(this); + + mTaskOpenBehind = (ListPreference) findPreference(TASK_OPEN_BEHIND); + mTaskOpenBehind.setSummary(getProperSummary(mTaskOpenBehind)); + mTaskOpenBehind.setEntries(mAnimationsStrings); + mTaskOpenBehind.setEntryValues(mAnimationsNum); + mTaskOpenBehind.setOnPreferenceChangeListener(this); + + mTaskClosePref = (ListPreference) findPreference(TASK_CLOSE); + mTaskClosePref.setSummary(getProperSummary(mTaskClosePref)); + mTaskClosePref.setEntries(mAnimationsStrings); + mTaskClosePref.setEntryValues(mAnimationsNum); + mTaskClosePref.setOnPreferenceChangeListener(this); + + mTaskMoveToFrontPref = (ListPreference) findPreference(TASK_MOVE_TO_FRONT); + mTaskMoveToFrontPref.setSummary(getProperSummary(mTaskMoveToFrontPref)); + mTaskMoveToFrontPref.setEntries(mAnimationsStrings); + mTaskMoveToFrontPref.setEntryValues(mAnimationsNum); + mTaskMoveToFrontPref.setOnPreferenceChangeListener(this); + + mTaskMoveToBackPref = (ListPreference) findPreference(TASK_MOVE_TO_BACK); + mTaskMoveToBackPref.setSummary(getProperSummary(mTaskMoveToBackPref)); + mTaskMoveToBackPref.setEntries(mAnimationsStrings); + mTaskMoveToBackPref.setEntryValues(mAnimationsNum); + mTaskMoveToBackPref.setOnPreferenceChangeListener(this); + + mWallpaperOpen = (ListPreference) findPreference(WALLPAPER_OPEN); + mWallpaperOpen.setSummary(getProperSummary(mWallpaperOpen)); + mWallpaperOpen.setEntries(mAnimationsStrings); + mWallpaperOpen.setEntryValues(mAnimationsNum); + mWallpaperOpen.setOnPreferenceChangeListener(this); + + mWallpaperClose = (ListPreference) findPreference(WALLPAPER_CLOSE); + mWallpaperClose.setSummary(getProperSummary(mWallpaperClose)); + mWallpaperClose.setEntries(mAnimationsStrings); + mWallpaperClose.setEntryValues(mAnimationsNum); + mWallpaperClose.setOnPreferenceChangeListener(this); + + mWallpaperIntraOpen = (ListPreference) findPreference(WALLPAPER_INTRA_OPEN); + mWallpaperIntraOpen.setSummary(getProperSummary(mWallpaperIntraOpen)); + mWallpaperIntraOpen.setEntries(mAnimationsStrings); + mWallpaperIntraOpen.setEntryValues(mAnimationsNum); + mWallpaperIntraOpen.setOnPreferenceChangeListener(this); + + mWallpaperIntraClose = (ListPreference) findPreference(WALLPAPER_INTRA_CLOSE); + mWallpaperIntraClose.setSummary(getProperSummary(mWallpaperIntraClose)); + mWallpaperIntraClose.setEntries(mAnimationsStrings); + mWallpaperIntraClose.setEntryValues(mAnimationsNum); + mWallpaperIntraClose.setOnPreferenceChangeListener(this); + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + ContentResolver resolver = getActivity().getContentResolver(); + if (preference == mAnimDuration) { + int value = (Integer) newValue; + Settings.Global.putInt(resolver, + Settings.Global.ANIMATION_CONTROLS_DURATION, value); + return true; + } else if (preference == mActivityOpenPref) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[0], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mActivityClosePref) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[1], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mTaskOpenPref) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[2], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mTaskClosePref) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[3], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mTaskMoveToFrontPref) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[4], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mTaskMoveToBackPref) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[5], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mWallpaperOpen) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[6], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mWallpaperClose) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[7], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mWallpaperIntraOpen) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[8], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mWallpaperIntraClose) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[9], val); + preference.setSummary(getProperSummary(preference)); + return true; + } else if (preference == mTaskOpenBehind) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(resolver, + Settings.Global.ACTIVITY_ANIMATION_CONTROLS[10], val); + preference.setSummary(getProperSummary(preference)); + return true; + } + return false; + } + + private String getProperSummary(Preference preference) { + String mString = ""; + if (preference == mActivityOpenPref) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[0]; + } else if (preference == mActivityClosePref) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[1]; + } else if (preference == mTaskOpenPref) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[2]; + } else if (preference == mTaskClosePref) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[3]; + } else if (preference == mTaskMoveToFrontPref) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[4]; + } else if (preference == mTaskMoveToBackPref) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[5]; + } else if (preference == mWallpaperOpen) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[6]; + } else if (preference == mWallpaperClose) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[7]; + } else if (preference == mWallpaperIntraOpen) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[8]; + } else if (preference == mWallpaperIntraClose) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[9]; + } else if (preference == mTaskOpenBehind) { + mString = Settings.Global.ACTIVITY_ANIMATION_CONTROLS[10]; + } + + int mNum = Settings.Global.getInt(getActivity().getContentResolver(), + mString, 0); + return mAnimationsStrings[mNum]; + } + + @Override + public int getMetricsCategory() { + return MetricsProto.MetricsEvent.CHERISH_SETTINGS; + } +} diff --git a/src/com/cherish/settings/fragments/NavbarSettings.java b/src/com/cherish/settings/fragments/NavbarSettings.java deleted file mode 100644 index 4982be8..0000000 --- a/src/com/cherish/settings/fragments/NavbarSettings.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2014 TeamEos - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cherish.settings.fragments; - -import java.util.ArrayList; - -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; -import android.content.Intent; -import android.os.Bundle; -import android.os.UserHandle; -import androidx.preference.ListPreference; -import androidx.preference.SwitchPreference; -import androidx.preference.Preference; -import androidx.preference.PreferenceCategory; -import androidx.preference.PreferenceScreen; -import androidx.preference.Preference.OnPreferenceChangeListener; -import android.provider.Settings; - -import com.android.settings.SettingsPreferenceFragment; -import com.android.internal.logging.MetricsLogger; -import com.android.internal.logging.nano.MetricsProto; -import com.android.settings.R; - -public class NavbarSettings extends SettingsPreferenceFragment implements OnPreferenceChangeListener { - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - addPreferencesFromResource(R.xml.cherish_settings_navigation); - } - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - return false; - } - - @Override - public int getMetricsCategory() { - return MetricsProto.MetricsEvent.CHERISH_SETTINGS; - } -}