From 779cd94e4b232461f3ffd7b8b10fd385471fe73d Mon Sep 17 00:00:00 2001 From: DHD2280 Date: Tue, 30 Apr 2024 00:50:11 +0200 Subject: [PATCH] CHANGELOG: Added QS Animations --- .../dhd/oxygencustomizer/utils/Constants.java | 9 +- .../utils/PreferenceHelper.java | 15 ++ .../statusbar/QsTileCustomization.java | 140 ++++++++++++++++++ .../utils/viewpager/ABaseTransformer.java | 52 +++++++ .../utils/viewpager/AccordionTransformer.java | 10 ++ .../BackgroundToForegroundTransformer.java | 21 +++ .../utils/viewpager/CubeInTransformer.java | 15 ++ .../utils/viewpager/CubeOutTransformer.java | 19 +++ .../utils/viewpager/DepthPageTransformer.java | 26 ++++ .../utils/viewpager/FadeTransformer.java | 23 +++ .../ForegroundToBackgroundTransformer.java | 20 +++ .../viewpager/RotateDownTransformer.java | 20 +++ .../utils/viewpager/RotateUpTransformer.java | 20 +++ .../utils/viewpager/StackTransformer.java | 10 ++ .../utils/viewpager/TabletTransformer.java | 33 +++++ .../utils/viewpager/ZoomInTransformer.java | 18 +++ .../viewpager/ZoomOutSlideTransformer.java | 27 ++++ .../utils/viewpager/ZoomOutTransformer.java | 17 +++ app/src/main/res/values/arrays.xml | 72 +++++++++ app/src/main/res/values/strings.xml | 40 ++++- ...ck_settings_tiles_customizations_prefs.xml | 55 +++++++ 21 files changed, 658 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ABaseTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/AccordionTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/BackgroundToForegroundTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/CubeInTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/CubeOutTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/DepthPageTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/FadeTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ForegroundToBackgroundTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RotateDownTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RotateUpTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/StackTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/TabletTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomInTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomOutSlideTransformer.java create mode 100644 app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomOutTransformer.java diff --git a/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java b/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java index 7bd6b68bf..49a5b9543 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java @@ -1,5 +1,6 @@ package it.dhd.oxygencustomizer.utils; +import android.content.Context; import android.os.Environment; import java.util.Arrays; @@ -196,6 +197,11 @@ public static class QsTilesCustomization { public static final String QS_BRIGHTNESS_SLIDER_COLOR = "brightness_slider_color"; public static final String QS_BRIGHTNESS_SLIDER_BACKGROUND_ENABLED = "brightness_slider_background_color_enabled"; public static final String QS_BRIGHTNESS_SLIDER_BACKGROUND_COLOR = "brightness_slider_background_color"; + public static final String QS_TILE_ANIMATION_STYLE = "qs_tile_animation_style"; + public static final String QS_TILE_ANIMATION_INTERPOLATOR = "qs_tile_animation_interpolator"; + public static final String QS_TILE_ANIMATION_DURATION = "qs_tile_animation_duration"; + public static final String QS_TILE_ANIMATION_TRANSFORMATIONS_SWITCH = "qs_transitions_title_switch"; + public static final String QS_TILE_ANIMATION_TRANSFORMATIONS = "qs_tile_transformations"; public static final String[] QS_UPDATE_PREFS = { QS_TILE_ACTIVE_COLOR_ENABLED, @@ -532,7 +538,4 @@ public static final class SoundPrefs { public static final String CLOCK_TAG = "clock"; public static final String DATE_TAG = "date"; - public static final String LATEST_VERSION_URL = "https://raw.githubusercontent.com/DHD2280/Oxygen-Customizer/stable/latestVersion.json"; - public static final String LATEST_BETA_URL = "https://raw.githubusercontent.com/DHD2280/Oxygen-Customizer/beta/latestBeta.json"; - } diff --git a/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java b/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java index 1ac1f72cd..a5b531004 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java @@ -63,6 +63,11 @@ import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsHeaderImage.QS_HEADER_IMAGE_TINT_INTENSITY; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsHeaderImage.QS_HEADER_IMAGE_URI; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsHeaderImage.QS_HEADER_IMAGE_ZOOM_TO_FIT; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ANIMATION_DURATION; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ANIMATION_INTERPOLATOR; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ANIMATION_STYLE; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ANIMATION_TRANSFORMATIONS; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ANIMATION_TRANSFORMATIONS_SWITCH; import android.annotation.SuppressLint; import android.content.Context; @@ -241,6 +246,16 @@ public static boolean isVisible(String key) { case "brightness_slider_background_color" -> { return instance.mPreferences.getBoolean("brightness_slider_background_color_enabled", false); } + case QS_TILE_ANIMATION_INTERPOLATOR, + QS_TILE_ANIMATION_DURATION -> { + return !instance.mPreferences.getString(QS_TILE_ANIMATION_STYLE, "0").equals("0"); + } + case QS_TILE_ANIMATION_TRANSFORMATIONS -> { + return instance.mPreferences.getBoolean(QS_TILE_ANIMATION_TRANSFORMATIONS_SWITCH, false); + } + case "qs_tile_label" -> { + return instance.mPreferences.getBoolean("qs_tile_label_enabled", false); + } // Gesture Prefs case "gesture_left_height" -> { diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java index 54de8a715..cc400e3f1 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java @@ -18,6 +18,7 @@ import static it.dhd.oxygencustomizer.xposed.hooks.systemui.OpUtils.getPrimaryColor; import static it.dhd.oxygencustomizer.xposed.utils.ViewHelper.dp2px; +import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; import android.content.res.ColorStateList; @@ -28,8 +29,17 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.ShapeDrawable; +import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.AnticipateInterpolator; +import android.view.animation.AnticipateOvershootInterpolator; +import android.view.animation.BounceInterpolator; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.LinearInterpolator; +import android.view.animation.OvershootInterpolator; import android.widget.AbsSeekBar; import android.widget.CheckBox; import android.widget.FrameLayout; @@ -41,11 +51,14 @@ import androidx.core.content.res.ResourcesCompat; import androidx.core.graphics.ColorUtils; import androidx.core.graphics.drawable.DrawableCompat; +import androidx.viewpager.widget.ViewPager; import com.google.android.material.slider.Slider; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Objects; +import java.util.concurrent.ThreadLocalRandom; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.callbacks.XC_LoadPackage; @@ -54,6 +67,8 @@ import it.dhd.oxygencustomizer.xposed.XposedMods; import it.dhd.oxygencustomizer.xposed.utils.ShellUtils; import it.dhd.oxygencustomizer.xposed.utils.SystemUtils; +import it.dhd.oxygencustomizer.xposed.utils.viewpager.ABaseTransformer; +import it.dhd.oxygencustomizer.xposed.utils.viewpager.*; public class QsTileCustomization extends XposedMods { @@ -73,6 +88,11 @@ public class QsTileCustomization extends XposedMods { private ImageView mExpandIndicator = null; private boolean advancedCustom = true; private static final ArrayList qsViews = new ArrayList<>(); + private int mAnimStyle = 0; + private int mInterpolatorType = 0; + private int mAnimDuration = 0; + private boolean mTrasformationsEnabled = false; + private int mTrasformations = 1; public QsTileCustomization(Context context) { super(context); @@ -82,21 +102,33 @@ public QsTileCustomization(Context context) { public void updatePrefs(String... Key) { if (Xprefs == null) return; + // Qs Colors qsActiveColorEnabled = Xprefs.getBoolean(QS_TILE_ACTIVE_COLOR_ENABLED, false); qsActiveColor = Xprefs.getInt(QS_TILE_ACTIVE_COLOR, Color.RED); qsInactiveColorEnabled = Xprefs.getBoolean(QS_TILE_INACTIVE_COLOR_ENABLED, false); qsInactiveColor = Xprefs.getInt(QS_TILE_INACTIVE_COLOR, Color.GRAY); qsDisabledColorEnabled = Xprefs.getBoolean(QS_TILE_DISABLED_COLOR_ENABLED, false); qsDisabledColor = Xprefs.getInt(QS_TILE_DISABLED_COLOR, Color.DKGRAY); + + // Brightness Slider qsBrightnessSliderCustomize = Xprefs.getBoolean(QS_BRIGHTNESS_SLIDER_CUSTOMIZE, false); qsBrightnessSliderColorMode = Integer.parseInt(Xprefs.getString(QS_BRIGHTNESS_SLIDER_COLOR_MODE, "0")); qsBrightnessSliderColor = Xprefs.getInt(QS_BRIGHTNESS_SLIDER_COLOR, getPrimaryColor(mContext)); qsBrightnessBackgroundCustomize = Xprefs.getBoolean(QS_BRIGHTNESS_SLIDER_BACKGROUND_ENABLED, false); qsBrightnessBackgroundColor = Xprefs.getInt(QS_BRIGHTNESS_SLIDER_BACKGROUND_COLOR, Color.TRANSPARENT); + + // Labels qsLabelsHide = Xprefs.getBoolean(QS_TILE_HIDE_LABELS, false); qsLabelsColorEnabled = Xprefs.getBoolean(QS_TILE_LABELS_CUSTOM_COLOR_ENABLED, false); qsLabelsColor = Xprefs.getInt(QS_TILE_LABELS_CUSTOM_COLOR, Color.WHITE); + // Qs Animations + mAnimStyle = Integer.parseInt(Xprefs.getString(QS_TILE_ANIMATION_STYLE, "0")); + mInterpolatorType = Integer.parseInt(Xprefs.getString(QS_TILE_ANIMATION_INTERPOLATOR, "0")); + mAnimDuration = Xprefs.getSliderInt(QS_TILE_ANIMATION_DURATION, 1); + mTrasformationsEnabled = Xprefs.getBoolean(QS_TILE_ANIMATION_TRANSFORMATIONS_SWITCH, false); + mTrasformations = Integer.parseInt(Xprefs.getString(QS_TILE_ANIMATION_TRANSFORMATIONS, "1")); + if (Key.length > 0) { for(String k : QS_UPDATE_PREFS) { if (Key[0].equals(k)) { @@ -243,8 +275,18 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } }; + final XC_MethodHook animationHook = new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + View qsTile = (View) param.thisObject; + qsTile.post(()->getTileAnimation(qsTile)); + } + }; + hookAllMethods(OplusQSTileBaseView, "generateDrawable", colorHook); + hookAllMethods(OplusQSTileBaseView, "performClick", animationHook); + Class OplusQSHighlightTileView; try { OplusQSHighlightTileView = findClass("com.oplus.systemui.qs.qstileimpl.OplusQSHighlightTileView", lpparam.classLoader); @@ -252,6 +294,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { OplusQSHighlightTileView = findClass("com.oplusos.systemui.qs.qstileimpl.OplusQSHighlightTileView", lpparam.classLoader); } hookAllMethods(OplusQSHighlightTileView, "generateDrawable", colorHook); + hookAllMethods(OplusQSHighlightTileView, "performClick", animationHook); Class OplusQsMediaPanelView = findClass("com.oplus.systemui.qs.media.OplusQsMediaPanelView", lpparam.classLoader); @@ -382,6 +425,103 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } catch (Throwable ignored) {} + try { + Class PagedTileLayout = findClass("com.android.systemui.qs.PagedTileLayout", lpparam.classLoader); + hookAllConstructors(PagedTileLayout, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + + Object VPagerListener = getObjectField(param.thisObject, "mOnPageChangeListener"); + Object vPager = param.thisObject; + hookAllMethods(VPagerListener.getClass(), + "onPageScrolled", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + if (!mTrasformationsEnabled) return; + final int childCount = (int) callMethod(vPager, "getChildCount"); + for (int i = 0; i < childCount; i++) { + final View child = (View) callMethod(vPager, "getChildAt", i); + final Object lp = callMethod(child, "getLayoutParams"); + if (getBooleanField(lp, "isDecor")) continue; + final float transformPos = (float) (child.getLeft() - (int)callMethod(vPager, "getScrollX")) / child.getWidth(); + getCustomTransitions().transformPage(child, transformPos); + } + } + }); + } + }); + } catch (Throwable t) { + log(this.getClass().getSimpleName() + " error: " + t.getMessage()); + } + + } + + + private ViewPager.PageTransformer getCustomTransitions() { + return switch (mTrasformations) { + case 1 -> new CubeInTransformer(); + case 2 -> new CubeOutTransformer(); + case 3 -> new AccordionTransformer(); + case 4 -> new BackgroundToForegroundTransformer(); + case 5 -> new DepthPageTransformer(); + case 6 -> new FadeTransformer(); + case 7 -> new ForegroundToBackgroundTransformer(); + case 8 -> new RotateDownTransformer(); + case 9 -> new RotateUpTransformer(); + case 10 -> new StackTransformer(); + case 11 -> new TabletTransformer(); + case 12 -> new ZoomInTransformer(); + case 13 -> new ZoomOutTransformer(); + case 14 -> new ZoomOutSlideTransformer(); + default -> null; + }; + + } + + private void getTileAnimation(View v) { + ObjectAnimator animTile = null; + + switch (mAnimStyle) { + case 1: + animTile = ObjectAnimator.ofFloat(v, "rotationY", 0f, 360f); + break; + case 2: + animTile = ObjectAnimator.ofFloat(v, "rotation", 0f, 360f); + break; + default: + return; + } + + switch (mInterpolatorType) { + case 0: + animTile.setInterpolator(new LinearInterpolator()); + break; + case 1: + animTile.setInterpolator(new AccelerateInterpolator()); + break; + case 2: + animTile.setInterpolator(new DecelerateInterpolator()); + break; + case 3: + animTile.setInterpolator(new AccelerateDecelerateInterpolator()); + break; + case 4: + animTile.setInterpolator(new BounceInterpolator()); + break; + case 5: + animTile.setInterpolator(new OvershootInterpolator()); + break; + case 6: + animTile.setInterpolator(new AnticipateInterpolator()); + break; + case 7: + animTile.setInterpolator(new AnticipateOvershootInterpolator()); + break; + default: + break; + } + animTile.setDuration(mAnimDuration * 1000L); + animTile.start(); } @Override diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ABaseTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ABaseTransformer.java new file mode 100644 index 000000000..3071f2451 --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ABaseTransformer.java @@ -0,0 +1,52 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import androidx.annotation.NonNull; +import androidx.viewpager.widget.ViewPager; +import android.view.View; + +public abstract class ABaseTransformer implements ViewPager.PageTransformer { + protected abstract void onTransform(View view, float f); + + public void transformPage(@NonNull View page, float position) { + onPreTransform(page, position); + onTransform(page, position); + onPostTransform(page, position); + } + + protected boolean hideOffscreenPages() { + return true; + } + + protected boolean isPagingEnabled() { + return false; + } + + protected void onPreTransform(View page, float position) { + float f = 0.0f; + float width = (float) page.getWidth(); + page.setRotationX(0.0f); + page.setRotationY(0.0f); + page.setRotation(0.0f); + page.setScaleX(1.0f); + page.setScaleY(1.0f); + page.setPivotX(0.0f); + page.setPivotY(0.0f); + page.setTranslationY(0.0f); + page.setTranslationX(isPagingEnabled() ? 0.0f : (-width) * position); + if (hideOffscreenPages()) { + if (position > -1.0f && position < 1.0f) { + f = 1.0f; + } + page.setAlpha(f); + return; + } + page.setAlpha(1.0f); + } + + protected void onPostTransform(View page, float position) { + } + + protected static float min(float val, float min) { + return Math.max(val, min); + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/AccordionTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/AccordionTransformer.java new file mode 100644 index 000000000..8afb30840 --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/AccordionTransformer.java @@ -0,0 +1,10 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import android.view.View; + +public class AccordionTransformer extends ABaseTransformer { + protected void onTransform(View view, float position) { + view.setPivotX((float) (position < 0.0f ? 0 : view.getWidth())); + view.setScaleX(position < 0.0f ? 1.0f + position : 1.0f - position); + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/BackgroundToForegroundTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/BackgroundToForegroundTransformer.java new file mode 100644 index 000000000..5dbe3c635 --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/BackgroundToForegroundTransformer.java @@ -0,0 +1,21 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + + +import android.view.View; + +public class BackgroundToForegroundTransformer extends ABaseTransformer { + protected void onTransform(View view, float position) { + float f = 1.0f; + float height = (float) view.getHeight(); + float width = (float) view.getWidth(); + if (position >= 0.0f) { + f = Math.abs(1.0f - position); + } + float scale = min(f, 0.5f); + view.setScaleX(scale); + view.setScaleY(scale); + view.setPivotX(width * 0.5f); + view.setPivotY(height * 0.5f); + view.setTranslationX(position < 0.0f ? width * position : (-width) * position * 0.25f); + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/CubeInTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/CubeInTransformer.java new file mode 100644 index 000000000..b0ed6662d --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/CubeInTransformer.java @@ -0,0 +1,15 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import android.view.View; + +public class CubeInTransformer extends ABaseTransformer { + protected void onTransform(View view, float position) { + view.setPivotX((float) (position > 0.0f ? 0 : view.getWidth())); + view.setPivotY(0.0f); + view.setRotationY(-90.0f * position); + } + + public boolean isPagingEnabled() { + return true; + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/CubeOutTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/CubeOutTransformer.java new file mode 100644 index 000000000..20d59341c --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/CubeOutTransformer.java @@ -0,0 +1,19 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import android.view.View; + +public class CubeOutTransformer extends ABaseTransformer { + protected void onTransform(View view, float position) { + float f = 0.0f; + if (position < 0.0f) { + f = (float) view.getWidth(); + } + view.setPivotX(f); + view.setPivotY(((float) view.getHeight()) * 0.5f); + view.setRotationY(90.0f * position); + } + + public boolean isPagingEnabled() { + return true; + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/DepthPageTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/DepthPageTransformer.java new file mode 100644 index 000000000..f6b2bb07e --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/DepthPageTransformer.java @@ -0,0 +1,26 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import android.view.View; + +public class DepthPageTransformer extends ABaseTransformer { + private static final float MIN_SCALE = 0.75f; + + protected void onTransform(View view, float position) { + if (position <= 0.0f) { + view.setTranslationX(0.0f); + view.setScaleX(1.0f); + view.setScaleY(1.0f); + } else if (position <= 1.0f) { + float scaleFactor = MIN_SCALE + (0.25f * (1.0f - Math.abs(position))); + view.setAlpha(1.0f - position); + view.setPivotY(0.5f * ((float) view.getHeight())); + view.setTranslationX(((float) view.getWidth()) * (-position)); + view.setScaleX(scaleFactor); + view.setScaleY(scaleFactor); + } + } + + protected boolean isPagingEnabled() { + return true; + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/FadeTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/FadeTransformer.java new file mode 100644 index 000000000..cf511e93e --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/FadeTransformer.java @@ -0,0 +1,23 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + + +import android.view.View; + +public class FadeTransformer extends ABaseTransformer { + public void onTransform(View view, float position) { + float f = 0.0f; + if (position < 0.0f) { + f = (float) view.getWidth(); + } + view.setPivotX(f); + view.setPivotY(((float) view.getHeight()) * 0.5f); + view.setRotationY(20.0f * position); + float normalizedPosition = Math.abs(Math.abs(position) - 1.0f); + view.setScaleX((float) (((double) (normalizedPosition / 2.0f)) + 0.5d)); + view.setScaleY((float) (((double) (normalizedPosition / 2.0f)) + 0.5d)); + } + + public boolean isPagingEnabled() { + return true; + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ForegroundToBackgroundTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ForegroundToBackgroundTransformer.java new file mode 100644 index 000000000..101286492 --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ForegroundToBackgroundTransformer.java @@ -0,0 +1,20 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import android.view.View; + +public class ForegroundToBackgroundTransformer extends ABaseTransformer { + protected void onTransform(View view, float position) { + float f = 1.0f; + float height = (float) view.getHeight(); + float width = (float) view.getWidth(); + if (position <= 0.0f) { + f = Math.abs(1.0f + position); + } + float scale = min(f, 0.5f); + view.setScaleX(scale); + view.setScaleY(scale); + view.setPivotX(width * 0.5f); + view.setPivotY(height * 0.5f); + view.setTranslationX(position > 0.0f ? width * position : (-width) * position * 0.25f); + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RotateDownTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RotateDownTransformer.java new file mode 100644 index 000000000..03a60de24 --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RotateDownTransformer.java @@ -0,0 +1,20 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import android.view.View; + +public class RotateDownTransformer extends ABaseTransformer { + private static final float ROT_MOD = -15.0f; + + protected void onTransform(View view, float position) { + float width = (float) view.getWidth(); + float height = (float) view.getHeight(); + float rotation = ROT_MOD * position * -1.25f; + view.setPivotX(0.5f * width); + view.setPivotY(height); + view.setRotation(rotation); + } + + protected boolean isPagingEnabled() { + return true; + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RotateUpTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RotateUpTransformer.java new file mode 100644 index 000000000..b2acf4f45 --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RotateUpTransformer.java @@ -0,0 +1,20 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + + +import android.view.View; + +public class RotateUpTransformer extends ABaseTransformer { + private static final float ROT_MOD = -15.0f; + + protected void onTransform(View view, float position) { + float rotation = ROT_MOD * position; + view.setPivotX(0.5f * ((float) view.getWidth())); + view.setPivotY(0.0f); + view.setTranslationX(0.0f); + view.setRotation(rotation); + } + + protected boolean isPagingEnabled() { + return true; + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/StackTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/StackTransformer.java new file mode 100644 index 000000000..f0f6f66bb --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/StackTransformer.java @@ -0,0 +1,10 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + + +import android.view.View; + +public class StackTransformer extends ABaseTransformer { + protected void onTransform(View view, float position) { + view.setTranslationX(position >= 0f ? (((float) (-view.getWidth())) * position) : 0f); + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/TabletTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/TabletTransformer.java new file mode 100644 index 000000000..1f0f480f2 --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/TabletTransformer.java @@ -0,0 +1,33 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import android.graphics.Camera; +import android.graphics.Matrix; +import android.view.View; + +public class TabletTransformer extends ABaseTransformer { + private static final Camera OFFSET_CAMERA = new Camera(); + private static final Matrix OFFSET_MATRIX = new Matrix(); + private static final float[] OFFSET_TEMP_FLOAT = new float[2]; + + protected void onTransform(View view, float position) { + float rotation = (position < 0.0f ? 30.0f : -30.0f) * Math.abs(position); + view.setTranslationX(getOffsetXForRotation(rotation, view.getWidth(), view.getHeight())); + view.setPivotX(((float) view.getWidth()) * 0.5f); + view.setPivotY(0.0f); + view.setRotationY(rotation); + } + + protected static final float getOffsetXForRotation(float degrees, int width, int height) { + OFFSET_MATRIX.reset(); + OFFSET_CAMERA.save(); + OFFSET_CAMERA.rotateY(Math.abs(degrees)); + OFFSET_CAMERA.getMatrix(OFFSET_MATRIX); + OFFSET_CAMERA.restore(); + OFFSET_MATRIX.preTranslate(((float) (-width)) * 0.5f, ((float) (-height)) * 0.5f); + OFFSET_MATRIX.postTranslate(((float) width) * 0.5f, ((float) height) * 0.5f); + OFFSET_TEMP_FLOAT[0] = (float) width; + OFFSET_TEMP_FLOAT[1] = (float) height; + OFFSET_MATRIX.mapPoints(OFFSET_TEMP_FLOAT); + return (degrees > 0.0f ? 1.0f : -1.0f) * (((float) width) - OFFSET_TEMP_FLOAT[0]); + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomInTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomInTransformer.java new file mode 100644 index 000000000..bf56ed9ef --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomInTransformer.java @@ -0,0 +1,18 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import android.view.View; + +public class ZoomInTransformer extends ABaseTransformer { + protected void onTransform(View view, float position) { + float f = 0.0f; + float scale = position < 0.0f ? position + 1.0f : Math.abs(1.0f - position); + view.setScaleX(scale); + view.setScaleY(scale); + view.setPivotX(((float) view.getWidth()) * 0.5f); + view.setPivotY(((float) view.getHeight()) * 0.5f); + if (position >= -1.0f && position <= 1.0f) { + f = 1.0f - (scale - 1.0f); + } + view.setAlpha(f); + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomOutSlideTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomOutSlideTransformer.java new file mode 100644 index 000000000..6b0309918 --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomOutSlideTransformer.java @@ -0,0 +1,27 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + + +import android.view.View; + +public class ZoomOutSlideTransformer extends ABaseTransformer { + private static final float MIN_ALPHA = 0.5f; + private static final float MIN_SCALE = 0.85f; + + protected void onTransform(View view, float position) { + if (position >= -1.0f || position <= 1.0f) { + float height = (float) view.getHeight(); + float scaleFactor = Math.max(MIN_SCALE, 1.0f - Math.abs(position)); + float vertMargin = ((1.0f - scaleFactor) * height) / 2.0f; + float horzMargin = (((float) view.getWidth()) * (1.0f - scaleFactor)) / 2.0f; + view.setPivotY(MIN_ALPHA * height); + if (position < 0.0f) { + view.setTranslationX(horzMargin - (vertMargin / 2.0f)); + } else { + view.setTranslationX((-horzMargin) + (vertMargin / 2.0f)); + } + view.setScaleX(scaleFactor); + view.setScaleY(scaleFactor); + view.setAlpha((((scaleFactor - MIN_SCALE) / 0.14999998f) * MIN_ALPHA) + MIN_ALPHA); + } + } +} diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomOutTransformer.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomOutTransformer.java new file mode 100644 index 000000000..7edce7998 --- /dev/null +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ZoomOutTransformer.java @@ -0,0 +1,17 @@ +package it.dhd.oxygencustomizer.xposed.utils.viewpager; + +import android.view.View; + +public class ZoomOutTransformer extends ABaseTransformer { + protected void onTransform(View view, float position) { + float scale = 1.0f + Math.abs(position); + view.setScaleX(scale); + view.setScaleY(scale); + view.setPivotX(((float) view.getWidth()) * 0.5f); + view.setPivotY(((float) view.getHeight()) * 0.5f); + view.setAlpha((position < -1.0f || position > 1.0f) ? 0.0f : 1.0f - (scale - 1.0f)); + if (position == -1.0f) { + view.setTranslationX((float) (view.getWidth() * -1)); + } + } +} diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 04d6783b3..5c1553438 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -321,4 +321,76 @@ 1 + + + + @string/qs_tile_animation_style_off + @string/qs_tile_animation_style_flip + @string/qs_tile_animation_style_rotate + + + + 0 + 1 + 2 + + + + + @string/qs_tile_animation_interpolator_linearInterpolator + @string/qs_tile_animation_interpolator_accelerateInterpolator + @string/qs_tile_animation_interpolator_decelerateInterpolator + @string/qs_tile_animation_interpolator_accelerateDecelerateInterpolator + @string/qs_tile_animation_interpolator_bounceInterpolator + @string/qs_tile_animation_interpolator_overshootInterpolator + @string/qs_tile_animation_interpolator_anticipateInterpolator + @string/qs_tile_animation_interpolator_anticipateOvershootInterpolator + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + + + + + @string/qs_transitions_cube_in + @string/qs_transitions_cube_out + @string/qs_transitions_accordion + @string/qs_transitions_background_to_foreground + @string/qs_transitions_depth_page + @string/qs_transitions_fade + @string/qs_transitions_foreground_to_background + @string/qs_transitions_rotate_down + @string/qs_transitions_rotate_up + @string/qs_transitions_stack + @string/qs_transitions_tablet + @string/qs_transitions_zoom_in + @string/qs_transitions_zoom_out + @string/qs_transitions_zoom_out_slide + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1d886f2d2..30ae9c912 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -309,6 +309,44 @@ Brightness Slider Color Mode Customize background color + + Tiles animation + Animation style + Animation duration + Tiles animation interpolator + No animation + Flip + Rotate + Low + Default + Fast + Linear + Accelerate + Decelerate + Accelerate decelerate + Bounce + Overshoot + Anticipate + Anticipate overshoot + + + Enable QS Page Transitions + QS Page Transitions + Cube In + Cube Out + Accordion + Background to Foreground + Depth page + Fade + Foreground to Background + Rotate down + Rotate up + Stack + Tablet + Zoom in + Zoom out + Zoom out slide + Header image Select QS background header image @@ -667,7 +705,7 @@ Restart app - In addition to the normal text, dynamic variables are also available, like Date, Data usage and Temperature:\n\n$G\<format\> : Gregorian date, based on format*\n$P<format> : Persian date, based on format*\n$Nrx : Total Downloads in specified period ** ***\n$Ntx: Total Uploads in specified period ** ***\n$Nall : Total Traffic in specified period ** ***\n$Nssid : WiFi SSID name (if applicable)\n\n$T\<format\>[interval] : Temperature; \nformat can be b (for battery), c (for CPU), g (for GPU) and s (for skin) \nLastly, there is OPTIONAL number of update interval in seconds (default: 60 seconds)\n\n*for format documentation, search for "Java Date Format"\n**You can specify the statistics period in PixelXpert/Miscellaneous menu/Network Statistics Settings\n***If you replace $N with $Nc you will get with mobile data statistics (e.g. $Ncrx instead of Nrx) + In addition to the normal text, dynamic variables are also available, like Date, Data usage and Temperature:\n\n$G\<format\> : Gregorian date, based on format*\n$P<format> : Persian date, based on format*\n$Nrx : Total Downloads in specified period ** ***\n$Ntx: Total Uploads in specified period ** ***\n$Nall : Total Traffic in specified period ** ***\n$Nssid : WiFi SSID name (if applicable)\n\n$T\<format\>[interval] : Temperature; \nformat can be b (for battery), c (for CPU), g (for GPU) and s (for skin) \nLastly, there is OPTIONAL number of update interval in seconds (default: 60 seconds)\n\n*for format documentation, search for "Java Date Format"\n**You can specify the statistics period in Oxygen Customizer/Miscellaneous menu/Network Statistics Settings\n***If you replace $N with $Nc you will get with mobile data statistics (e.g. $Ncrx instead of Nrx) Updates Update downloaded Tap here to install diff --git a/app/src/main/res/xml/quick_settings_tiles_customizations_prefs.xml b/app/src/main/res/xml/quick_settings_tiles_customizations_prefs.xml index 9fe5c7c31..1060e1e59 100644 --- a/app/src/main/res/xml/quick_settings_tiles_customizations_prefs.xml +++ b/app/src/main/res/xml/quick_settings_tiles_customizations_prefs.xml @@ -45,6 +45,61 @@ app:iconSpaceReserved="false" /> + + + + + + + + + + + + + + + + +