diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-09-18 16:17:22 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-09-21 18:21:04 +0000 |
commit | 55bdeed7bb4ecf20f22a721b2c8e2e56b4f9f9f5 (patch) | |
tree | d8f4435b7ecc3c844e9746be29d21a2c7eb92666 /src/com/android/launcher3 | |
parent | 194f58525a28150fa0757fcbe831b03b4daa4180 (diff) | |
download | packages_apps_Trebuchet-55bdeed7bb4ecf20f22a721b2c8e2e56b4f9f9f5.tar.gz packages_apps_Trebuchet-55bdeed7bb4ecf20f22a721b2c8e2e56b4f9f9f5.tar.bz2 packages_apps_Trebuchet-55bdeed7bb4ecf20f22a721b2c8e2e56b4f9f9f5.zip |
Removing various reflection based animations, to allow for better proguarding
Change-Id: If9df24ea4170e8a3d336057d1c3dc800934fc1ac
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r-- | src/com/android/launcher3/AppWidgetResizeFrame.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher3/ButtonDropTarget.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher3/CellLayout.java | 32 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherAnimUtils.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher3/views/BaseDragLayer.java | 59 |
6 files changed, 80 insertions, 73 deletions
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index 0f5317be7..8e2ffe923 100644 --- a/src/com/android/launcher3/AppWidgetResizeFrame.java +++ b/src/com/android/launcher3/AppWidgetResizeFrame.java @@ -1,5 +1,10 @@ package com.android.launcher3; +import static com.android.launcher3.LauncherAnimUtils.LAYOUT_HEIGHT; +import static com.android.launcher3.LauncherAnimUtils.LAYOUT_WIDTH; +import static com.android.launcher3.views.BaseDragLayer.LAYOUT_X; +import static com.android.launcher3.views.BaseDragLayer.LAYOUT_Y; + import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; @@ -429,10 +434,10 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O requestLayout(); } else { ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(lp, - PropertyValuesHolder.ofInt("width", lp.width, newWidth), - PropertyValuesHolder.ofInt("height", lp.height, newHeight), - PropertyValuesHolder.ofInt("x", lp.x, newX), - PropertyValuesHolder.ofInt("y", lp.y, newY)); + PropertyValuesHolder.ofInt(LAYOUT_WIDTH, lp.width, newWidth), + PropertyValuesHolder.ofInt(LAYOUT_HEIGHT, lp.height, newHeight), + PropertyValuesHolder.ofInt(LAYOUT_X, lp.x, newX), + PropertyValuesHolder.ofInt(LAYOUT_Y, lp.y, newY)); mFirstFrameAnimatorHelper.addTo(oa).addUpdateListener(a -> requestLayout()); AnimatorSet set = new AnimatorSet(); diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java index dd63ebce0..2b0da434a 100644 --- a/src/com/android/launcher3/ButtonDropTarget.java +++ b/src/com/android/launcher3/ButtonDropTarget.java @@ -33,6 +33,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.text.TextUtils; import android.util.AttributeSet; +import android.util.Property; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -55,6 +56,20 @@ import com.android.launcher3.util.Thunk; public abstract class ButtonDropTarget extends TextView implements DropTarget, DragController.DragListener, OnClickListener { + private static final Property<ButtonDropTarget, Integer> TEXT_COLOR = + new Property<ButtonDropTarget, Integer>(Integer.TYPE, "textColor") { + + @Override + public Integer get(ButtonDropTarget target) { + return target.getTextColor(); + } + + @Override + public void set(ButtonDropTarget target, Integer value) { + target.setTextColor(value); + } + }; + private static final int[] sTempCords = new int[2]; private static final int DRAG_VIEW_DROP_DURATION = 285; @@ -206,7 +221,7 @@ public abstract class ButtonDropTarget extends TextView }); mCurrentColorAnim.play(anim1); - mCurrentColorAnim.play(ObjectAnimator.ofArgb(this, "textColor", targetColor)); + mCurrentColorAnim.play(ObjectAnimator.ofArgb(this, TEXT_COLOR, targetColor)); mCurrentColorAnim.start(); } diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index f6f149631..a42238e5b 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -2678,38 +2678,6 @@ public class CellLayout extends ViewGroup { public String toString() { return "(" + this.cellX + ", " + this.cellY + ")"; } - - public void setWidth(int width) { - this.width = width; - } - - public int getWidth() { - return width; - } - - public void setHeight(int height) { - this.height = height; - } - - public int getHeight() { - return height; - } - - public void setX(int x) { - this.x = x; - } - - public int getX() { - return x; - } - - public void setY(int y) { - this.y = y; - } - - public int getY() { - return y; - } } // This class stores info for two purposes: diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java index ac07e8887..aad344976 100644 --- a/src/com/android/launcher3/LauncherAnimUtils.java +++ b/src/com/android/launcher3/LauncherAnimUtils.java @@ -19,6 +19,7 @@ package com.android.launcher3; import android.graphics.drawable.Drawable; import android.util.Property; import android.view.View; +import android.view.ViewGroup.LayoutParams; public class LauncherAnimUtils { /** @@ -64,4 +65,30 @@ public class LauncherAnimUtils { public static int blockedFlingDurationFactor(float velocity) { return (int) Utilities.boundToRange(Math.abs(velocity) / 2, 2f, 6f); } + + public static final Property<LayoutParams, Integer> LAYOUT_WIDTH = + new Property<LayoutParams, Integer>(Integer.TYPE, "width") { + @Override + public Integer get(LayoutParams lp) { + return lp.width; + } + + @Override + public void set(LayoutParams lp, Integer width) { + lp.width = width; + } + }; + + public static final Property<LayoutParams, Integer> LAYOUT_HEIGHT = + new Property<LayoutParams, Integer>(Integer.TYPE, "height") { + @Override + public Integer get(LayoutParams lp) { + return lp.height; + } + + @Override + public void set(LayoutParams lp, Integer height) { + lp.height = height; + } + }; } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 353916fbb..b5a770f6c 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -671,9 +671,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> private void fadeAndRemoveEmptyScreen(int delay, int duration, final Runnable onComplete, final boolean stripEmptyScreens) { // XXX: Do we need to update LM workspace screens below? - PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f); - PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f); - final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID); mRemoveEmptyScreenRunnable = new Runnable() { @@ -692,7 +689,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> } }; - ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(cl, alpha, bgAlpha); + ObjectAnimator oa = ObjectAnimator.ofFloat(cl, ALPHA, 0f); oa.setDuration(duration); oa.setStartDelay(delay); oa.addListener(new AnimatorListenerAdapter() { diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index e8a879fcc..1faca152b 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -21,6 +21,7 @@ import static com.android.launcher3.Utilities.SINGLE_FRAME_MS; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; +import android.util.Property; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -42,6 +43,32 @@ import java.util.ArrayList; public abstract class BaseDragLayer<T extends Context & ActivityContext> extends InsettableFrameLayout { + public static final Property<LayoutParams, Integer> LAYOUT_X = + new Property<LayoutParams, Integer>(Integer.TYPE, "x") { + @Override + public Integer get(LayoutParams lp) { + return lp.x; + } + + @Override + public void set(LayoutParams lp, Integer x) { + lp.x = x; + } + }; + + public static final Property<LayoutParams, Integer> LAYOUT_Y = + new Property<LayoutParams, Integer>(Integer.TYPE, "y") { + @Override + public Integer get(LayoutParams lp) { + return lp.y; + } + + @Override + public void set(LayoutParams lp, Integer y) { + lp.y = y; + } + }; + protected final int[] mTmpXY = new int[2]; protected final Rect mHitRect = new Rect(); @@ -307,38 +334,6 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext> public LayoutParams(ViewGroup.LayoutParams lp) { super(lp); } - - public void setWidth(int width) { - this.width = width; - } - - public int getWidth() { - return width; - } - - public void setHeight(int height) { - this.height = height; - } - - public int getHeight() { - return height; - } - - public void setX(int x) { - this.x = x; - } - - public int getX() { - return x; - } - - public void setY(int y) { - this.y = y; - } - - public int getY() { - return y; - } } protected void onLayout(boolean changed, int l, int t, int r, int b) { |