summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-02-13 12:13:43 -0800
committerSunny Goyal <sunnygoyal@google.com>2017-02-16 11:19:01 -0800
commit9e76f682f3e52afa1f11172564b883c7dfda5063 (patch)
tree6e62354e0a5314ce2dea3a59850555a0ae1e220c
parenteb04b8415368ce28bacd100b8bffa85fede734a0 (diff)
downloadandroid_packages_apps_Trebuchet-9e76f682f3e52afa1f11172564b883c7dfda5063.tar.gz
android_packages_apps_Trebuchet-9e76f682f3e52afa1f11172564b883c7dfda5063.tar.bz2
android_packages_apps_Trebuchet-9e76f682f3e52afa1f11172564b883c7dfda5063.zip
Removing wrapper around ViewPropertyAnimator, and using ObjectAnimator
instead Bug: 35218222 Change-Id: Ic714cf7d20989cb45f07712e8a6f6659d0e3f30d
-rw-r--r--src/com/android/launcher3/CellLayout.java14
-rw-r--r--src/com/android/launcher3/LauncherViewPropertyAnimator.java275
-rw-r--r--src/com/android/launcher3/PagedView.java12
-rw-r--r--src/com/android/launcher3/PinchAnimationManager.java4
-rw-r--r--src/com/android/launcher3/WorkspaceStateTransitionAnimation.java23
-rw-r--r--src/com/android/launcher3/anim/AnimationLayerSet.java11
-rw-r--r--src/com/android/launcher3/anim/PropertyListBuilder.java50
-rw-r--r--src/com/android/launcher3/notification/NotificationFooterLayout.java12
-rw-r--r--src/com/android/launcher3/notification/NotificationMainView.java5
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java42
10 files changed, 119 insertions, 329 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 0df8e5a89..a7c2026c4 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -50,6 +50,7 @@ import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate;
import com.android.launcher3.accessibility.FolderAccessibilityHelper;
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
+import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.DragPreviewProvider;
@@ -2097,12 +2098,13 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
}
setInitialAnimationValues(true);
- a = new LauncherViewPropertyAnimator(child)
- .scaleX(initScale)
- .scaleY(initScale)
- .translationX(initDeltaX)
- .translationY(initDeltaY)
- .setDuration(REORDER_ANIMATION_DURATION);
+ a = LauncherAnimUtils.ofPropertyValuesHolder(child,
+ new PropertyListBuilder()
+ .scale(initScale)
+ .translationX(initDeltaX)
+ .translationY(initDeltaY)
+ .build())
+ .setDuration(REORDER_ANIMATION_DURATION);
a.setInterpolator(new android.view.animation.DecelerateInterpolator(1.5f));
a.start();
}
diff --git a/src/com/android/launcher3/LauncherViewPropertyAnimator.java b/src/com/android/launcher3/LauncherViewPropertyAnimator.java
deleted file mode 100644
index 4406a2c5c..000000000
--- a/src/com/android/launcher3/LauncherViewPropertyAnimator.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * 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.android.launcher3;
-
-import android.animation.Animator;
-import android.animation.Animator.AnimatorListener;
-import android.animation.TimeInterpolator;
-import android.view.View;
-import android.view.ViewPropertyAnimator;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-
-public class LauncherViewPropertyAnimator extends Animator implements AnimatorListener {
-
- enum Properties {
- TRANSLATION_X,
- TRANSLATION_Y,
- SCALE_X,
- SCALE_Y,
- ROTATION_Y,
- ALPHA,
- START_DELAY,
- DURATION,
- INTERPOLATOR,
- WITH_LAYER
- }
- EnumSet<Properties> mPropertiesToSet = EnumSet.noneOf(Properties.class);
- ViewPropertyAnimator mViewPropertyAnimator;
- View mTarget;
-
- float mTranslationX;
- float mTranslationY;
- float mScaleX;
- float mScaleY;
- float mRotationY;
- float mAlpha;
- long mStartDelay;
- long mDuration;
- TimeInterpolator mInterpolator;
- ArrayList<Animator.AnimatorListener> mListeners = new ArrayList<>();
- boolean mRunning = false;
- FirstFrameAnimatorHelper mFirstFrameHelper;
-
- public LauncherViewPropertyAnimator(View target) {
- mTarget = target;
- }
-
- @Override
- public void addListener(Animator.AnimatorListener listener) {
- mListeners.add(listener);
- }
-
- @Override
- public void cancel() {
- if (mViewPropertyAnimator != null) {
- mViewPropertyAnimator.cancel();
- }
- }
-
- @Override
- public Animator clone() {
- throw new RuntimeException("Not implemented");
- }
-
- @Override
- public void end() {
- throw new RuntimeException("Not implemented");
- }
-
- @Override
- public long getDuration() {
- return mDuration;
- }
-
- @Override
- public ArrayList<Animator.AnimatorListener> getListeners() {
- return mListeners;
- }
-
- @Override
- public long getStartDelay() {
- return mStartDelay;
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- for (int i = 0; i < mListeners.size(); i++) {
- Animator.AnimatorListener listener = mListeners.get(i);
- listener.onAnimationCancel(this);
- }
- mRunning = false;
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- for (int i = 0; i < mListeners.size(); i++) {
- Animator.AnimatorListener listener = mListeners.get(i);
- listener.onAnimationEnd(this);
- }
- mRunning = false;
- }
-
- @Override
- public void onAnimationRepeat(Animator animation) {
- for (int i = 0; i < mListeners.size(); i++) {
- Animator.AnimatorListener listener = mListeners.get(i);
- listener.onAnimationRepeat(this);
- }
- }
-
- @Override
- public void onAnimationStart(Animator animation) {
- // This is the first time we get a handle to the internal ValueAnimator
- // used by the ViewPropertyAnimator.
- mFirstFrameHelper.onAnimationStart(animation);
-
- for (int i = 0; i < mListeners.size(); i++) {
- Animator.AnimatorListener listener = mListeners.get(i);
- listener.onAnimationStart(this);
- }
- mRunning = true;
- }
-
- @Override
- public boolean isRunning() {
- return mRunning;
- }
-
- @Override
- public boolean isStarted() {
- return mViewPropertyAnimator != null;
- }
-
- @Override
- public void removeAllListeners() {
- mListeners.clear();
- }
-
- @Override
- public void removeListener(Animator.AnimatorListener listener) {
- mListeners.remove(listener);
- }
-
- @Override
- public Animator setDuration(long duration) {
- mPropertiesToSet.add(Properties.DURATION);
- mDuration = duration;
- return this;
- }
-
- @Override
- public void setInterpolator(TimeInterpolator value) {
- mPropertiesToSet.add(Properties.INTERPOLATOR);
- mInterpolator = value;
- }
-
- @Override
- public void setStartDelay(long startDelay) {
- mPropertiesToSet.add(Properties.START_DELAY);
- mStartDelay = startDelay;
- }
-
- @Override
- public void setTarget(Object target) {
- throw new RuntimeException("Not implemented");
- }
-
- @Override
- public void setupEndValues() {
-
- }
-
- @Override
- public void setupStartValues() {
- }
-
- @Override
- public void start() {
- mViewPropertyAnimator = mTarget.animate();
-
- // FirstFrameAnimatorHelper hooks itself up to the updates on the animator,
- // and then adjusts the play time to keep the first two frames jank-free
- mFirstFrameHelper = new FirstFrameAnimatorHelper(mViewPropertyAnimator, mTarget);
-
- if (mPropertiesToSet.contains(Properties.TRANSLATION_X)) {
- mViewPropertyAnimator.translationX(mTranslationX);
- }
- if (mPropertiesToSet.contains(Properties.TRANSLATION_Y)) {
- mViewPropertyAnimator.translationY(mTranslationY);
- }
- if (mPropertiesToSet.contains(Properties.SCALE_X)) {
- mViewPropertyAnimator.scaleX(mScaleX);
- }
- if (mPropertiesToSet.contains(Properties.ROTATION_Y)) {
- mViewPropertyAnimator.rotationY(mRotationY);
- }
- if (mPropertiesToSet.contains(Properties.SCALE_Y)) {
- mViewPropertyAnimator.scaleY(mScaleY);
- }
- if (mPropertiesToSet.contains(Properties.ALPHA)) {
- mViewPropertyAnimator.alpha(mAlpha);
- }
- if (mPropertiesToSet.contains(Properties.START_DELAY)) {
- mViewPropertyAnimator.setStartDelay(mStartDelay);
- }
- if (mPropertiesToSet.contains(Properties.DURATION)) {
- mViewPropertyAnimator.setDuration(mDuration);
- }
- if (mPropertiesToSet.contains(Properties.INTERPOLATOR)) {
- mViewPropertyAnimator.setInterpolator(mInterpolator);
- }
- if (mPropertiesToSet.contains(Properties.WITH_LAYER)) {
- mViewPropertyAnimator.withLayer();
- }
- mViewPropertyAnimator.setListener(this);
- mViewPropertyAnimator.start();
- LauncherAnimUtils.cancelOnDestroyActivity(this);
- }
-
- public LauncherViewPropertyAnimator translationX(float value) {
- mPropertiesToSet.add(Properties.TRANSLATION_X);
- mTranslationX = value;
- return this;
- }
-
- public LauncherViewPropertyAnimator translationY(float value) {
- mPropertiesToSet.add(Properties.TRANSLATION_Y);
- mTranslationY = value;
- return this;
- }
-
- public LauncherViewPropertyAnimator scaleX(float value) {
- mPropertiesToSet.add(Properties.SCALE_X);
- mScaleX = value;
- return this;
- }
-
- public LauncherViewPropertyAnimator scaleY(float value) {
- mPropertiesToSet.add(Properties.SCALE_Y);
- mScaleY = value;
- return this;
- }
-
- public LauncherViewPropertyAnimator rotationY(float value) {
- mPropertiesToSet.add(Properties.ROTATION_Y);
- mRotationY = value;
- return this;
- }
-
- public LauncherViewPropertyAnimator alpha(float value) {
- mPropertiesToSet.add(Properties.ALPHA);
- mAlpha = value;
- return this;
- }
-
- public LauncherViewPropertyAnimator withLayer() {
- mPropertiesToSet.add(Properties.WITH_LAYER);
- return this;
- }
-}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 76e2073f2..fb6a611e7 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -47,6 +47,7 @@ import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
+import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.util.LauncherEdgeEffect;
import com.android.launcher3.util.Thunk;
@@ -1998,11 +1999,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Animate the drag view back to the original position
private void animateDragViewToOriginalPosition() {
if (mDragView != null) {
- Animator anim = new LauncherViewPropertyAnimator(mDragView)
- .translationX(0)
- .translationY(0)
- .scaleX(1)
- .scaleY(1)
+ Animator anim = LauncherAnimUtils.ofPropertyValuesHolder(mDragView,
+ new PropertyListBuilder()
+ .scale(1)
+ .translationX(0)
+ .translationY(0)
+ .build())
.setDuration(REORDERING_DROP_REPOSITION_DURATION);
anim.addListener(new AnimatorListenerAdapter() {
@Override
diff --git a/src/com/android/launcher3/PinchAnimationManager.java b/src/com/android/launcher3/PinchAnimationManager.java
index bae246e9e..f8196e5f6 100644
--- a/src/com/android/launcher3/PinchAnimationManager.java
+++ b/src/com/android/launcher3/PinchAnimationManager.java
@@ -24,6 +24,7 @@ import android.util.Log;
import android.view.View;
import android.view.animation.LinearInterpolator;
+import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -211,7 +212,8 @@ public class PinchAnimationManager {
}
private void animateShowHideView(int index, final View view, boolean show) {
- Animator animator = new LauncherViewPropertyAnimator(view).alpha(show ? 1 : 0).withLayer();
+ Animator animator = ObjectAnimator.ofFloat(view, View.ALPHA, show ? 1 : 0);
+ animator.addListener(new AnimationLayerSet(view));
if (show) {
view.setVisibility(View.VISIBLE);
} else {
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 6a71befe4..482a2c93b 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -31,6 +31,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.DecelerateInterpolator;
import com.android.launcher3.anim.AnimationLayerSet;
+import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.util.Thunk;
@@ -337,10 +338,9 @@ public class WorkspaceStateTransitionAnimation {
if (animated) {
float oldBackgroundAlpha = cl.getBackgroundAlpha();
if (initialAlpha != finalAlpha) {
- LauncherViewPropertyAnimator alphaAnim =
- new LauncherViewPropertyAnimator(cl.getShortcutsAndWidgets());
- alphaAnim.alpha(finalAlpha)
- .setDuration(duration)
+ Animator alphaAnim = ObjectAnimator.ofFloat(
+ cl.getShortcutsAndWidgets(), View.ALPHA, finalAlpha);
+ alphaAnim.setDuration(duration)
.setInterpolator(mZoomInInterpolator);
mStateAnimator.play(alphaAnim);
}
@@ -377,17 +377,16 @@ public class WorkspaceStateTransitionAnimation {
.animateAlphaAtIndex(finalQsbAlpha, Workspace.QSB_ALPHA_INDEX_STATE_CHANGE);
if (animated) {
- LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(mWorkspace);
- scale.scaleX(mNewScale)
- .scaleY(mNewScale)
- .translationY(finalWorkspaceTranslationY)
- .setDuration(duration)
- .setInterpolator(mZoomInInterpolator);
+ Animator scale = LauncherAnimUtils.ofPropertyValuesHolder(mWorkspace,
+ new PropertyListBuilder().scale(mNewScale)
+ .translationY(finalWorkspaceTranslationY).build())
+ .setDuration(duration);
+ scale.setInterpolator(mZoomInInterpolator);
mStateAnimator.play(scale);
Animator hotseatAlpha = mWorkspace.createHotseatAlphaAnimator(finalHotseatAlpha);
- LauncherViewPropertyAnimator overviewPanelAlpha =
- new LauncherViewPropertyAnimator(overviewPanel).alpha(finalOverviewPanelAlpha);
+ Animator overviewPanelAlpha = ObjectAnimator.ofFloat(
+ overviewPanel, View.ALPHA, finalOverviewPanelAlpha);
overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel,
accessibilityEnabled));
diff --git a/src/com/android/launcher3/anim/AnimationLayerSet.java b/src/com/android/launcher3/anim/AnimationLayerSet.java
index d2f5e78a2..14bcd1718 100644
--- a/src/com/android/launcher3/anim/AnimationLayerSet.java
+++ b/src/com/android/launcher3/anim/AnimationLayerSet.java
@@ -29,7 +29,16 @@ import java.util.Map;
*/
public class AnimationLayerSet extends AnimatorListenerAdapter {
- private final HashMap<View, Integer> mViewsToLayerTypeMap = new HashMap<>();
+ private final HashMap<View, Integer> mViewsToLayerTypeMap;
+
+ public AnimationLayerSet() {
+ mViewsToLayerTypeMap = new HashMap<>();
+ }
+
+ public AnimationLayerSet(View v) {
+ mViewsToLayerTypeMap = new HashMap<>(1);
+ addView(v);
+ }
public void addView(View v) {
mViewsToLayerTypeMap.put(v, v.getLayerType());
diff --git a/src/com/android/launcher3/anim/PropertyListBuilder.java b/src/com/android/launcher3/anim/PropertyListBuilder.java
new file mode 100644
index 000000000..33e7f6659
--- /dev/null
+++ b/src/com/android/launcher3/anim/PropertyListBuilder.java
@@ -0,0 +1,50 @@
+package com.android.launcher3.anim;
+
+import android.animation.PropertyValuesHolder;
+import android.view.View;
+
+import java.util.ArrayList;
+
+/**
+ * Helper class to build a list of {@link PropertyValuesHolder} for view properties
+ */
+public class PropertyListBuilder {
+
+ private final ArrayList<PropertyValuesHolder> mProperties = new ArrayList<>();
+
+ public PropertyListBuilder translationX(float value) {
+ mProperties.add(PropertyValuesHolder.ofFloat(View.TRANSLATION_X, value));
+ return this;
+ }
+
+ public PropertyListBuilder translationY(float value) {
+ mProperties.add(PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, value));
+ return this;
+ }
+
+ public PropertyListBuilder scaleX(float value) {
+ mProperties.add(PropertyValuesHolder.ofFloat(View.SCALE_X, value));
+ return this;
+ }
+
+ public PropertyListBuilder scaleY(float value) {
+ mProperties.add(PropertyValuesHolder.ofFloat(View.SCALE_Y, value));
+ return this;
+ }
+
+ /**
+ * Helper method to set both scaleX and scaleY
+ */
+ public PropertyListBuilder scale(float value) {
+ return scaleX(value).scaleY(value);
+ }
+
+ public PropertyListBuilder alpha(float value) {
+ mProperties.add(PropertyValuesHolder.ofFloat(View.ALPHA, value));
+ return this;
+ }
+
+ public PropertyValuesHolder[] build() {
+ return mProperties.toArray(new PropertyValuesHolder[mProperties.size()]);
+ }
+}
diff --git a/src/com/android/launcher3/notification/NotificationFooterLayout.java b/src/com/android/launcher3/notification/NotificationFooterLayout.java
index 58789f6e2..57ec5d17c 100644
--- a/src/com/android/launcher3/notification/NotificationFooterLayout.java
+++ b/src/com/android/launcher3/notification/NotificationFooterLayout.java
@@ -19,6 +19,7 @@ package com.android.launcher3.notification;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Rect;
@@ -30,8 +31,8 @@ import android.widget.TextView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
-import com.android.launcher3.LauncherViewPropertyAnimator;
import com.android.launcher3.R;
+import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.graphics.IconPalette;
import com.android.launcher3.popup.PopupContainerWithArrow;
@@ -154,10 +155,9 @@ public class NotificationFooterLayout extends LinearLayout {
Rect fromBounds = sTempRect;
firstNotification.getGlobalVisibleRect(fromBounds);
float scale = (float) toBounds.height() / fromBounds.height();
- Animator moveAndScaleIcon = new LauncherViewPropertyAnimator(firstNotification)
- .translationY(toBounds.top - fromBounds.top
- + (fromBounds.height() * scale - fromBounds.height()) / 2)
- .scaleX(scale).scaleY(scale);
+ Animator moveAndScaleIcon = LauncherAnimUtils.ofPropertyValuesHolder(firstNotification,
+ new PropertyListBuilder().scale(scale).translationY(toBounds.top - fromBounds.top
+ + (fromBounds.height() * scale - fromBounds.height()) / 2).build());
moveAndScaleIcon.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
@@ -172,7 +172,7 @@ public class NotificationFooterLayout extends LinearLayout {
- (mOverflowNotifications.isEmpty() ? 0 : 1);
for (int i = 1; i < numIcons; i++) {
final View child = mIconRow.getChildAt(i);
- Animator shiftChild = new LauncherViewPropertyAnimator(child).translationX(-gapWidth);
+ Animator shiftChild = ObjectAnimator.ofFloat(child, TRANSLATION_X, -gapWidth);
shiftChild.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
diff --git a/src/com/android/launcher3/notification/NotificationMainView.java b/src/com/android/launcher3/notification/NotificationMainView.java
index a05fef352..b3425259b 100644
--- a/src/com/android/launcher3/notification/NotificationMainView.java
+++ b/src/com/android/launcher3/notification/NotificationMainView.java
@@ -32,7 +32,6 @@ import android.widget.TextView;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
-import com.android.launcher3.LauncherViewPropertyAnimator;
import com.android.launcher3.R;
import com.android.launcher3.graphics.IconPalette;
import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -102,8 +101,8 @@ public class NotificationMainView extends LinearLayout implements SwipeHelper.Ca
setTag(new ItemInfo());
if (animate) {
AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
- Animator textFade = new LauncherViewPropertyAnimator(mTextView).alpha(1);
- Animator titleFade = new LauncherViewPropertyAnimator(mTitleView).alpha(1);
+ Animator textFade = ObjectAnimator.ofFloat(mTextView, View.ALPHA, 1);
+ Animator titleFade = ObjectAnimator.ofFloat(mTitleView, View.ALPHA, 1);
ValueAnimator colorChange = ObjectAnimator.ofObject(mColorBackground, "color",
mArgbEvaluator, mIconPalette.secondaryColor, mIconPalette.backgroundColor);
animation.playTogether(textFade, titleFade, colorChange);
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 7fda8b531..d34727c8d 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -19,6 +19,7 @@ package com.android.launcher3.popup;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
@@ -53,12 +54,12 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
-import com.android.launcher3.LauncherViewPropertyAnimator;
import com.android.launcher3.LogAccelerateInterpolator;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate;
+import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
@@ -298,7 +299,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView
anim.setInterpolator(interpolator);
shortcutAnims.play(anim);
- Animator fadeAnim = new LauncherViewPropertyAnimator(popupItemView).alpha(1);
+ Animator fadeAnim = ObjectAnimator.ofFloat(popupItemView, View.ALPHA, 1);
fadeAnim.setInterpolator(fadeInterpolator);
// We want the shortcut to be fully opaque before the arrow starts animating.
fadeAnim.setDuration(arrowScaleDelay);
@@ -318,9 +319,8 @@ public class PopupContainerWithArrow extends AbstractFloatingView
// Animate the arrow
mArrow.setScaleX(0);
mArrow.setScaleY(0);
- Animator arrowScale = new LauncherViewPropertyAnimator(mArrow).scaleX(1).scaleY(1);
+ Animator arrowScale = createArrowScaleAnim(1).setDuration(arrowScaleDuration);
arrowScale.setStartDelay(arrowScaleDelay);
- arrowScale.setDuration(arrowScaleDuration);
shortcutAnims.play(arrowScale);
mOpenCloseAnimator = shortcutAnims;
@@ -603,7 +603,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView
removeNotification.play(removeMargin);
}
removeNotification.play(reduceHeight);
- Animator fade = new LauncherViewPropertyAnimator(notificationView).alpha(0)
+ Animator fade = ObjectAnimator.ofFloat(notificationView, ALPHA, 0)
.setDuration(duration);
fade.addListener(new AnimatorListenerAdapter() {
@Override
@@ -620,11 +620,9 @@ public class PopupContainerWithArrow extends AbstractFloatingView
removeNotification.play(fade);
final long arrowScaleDuration = getResources().getInteger(
R.integer.config_deepShortcutArrowOpenDuration);
- Animator hideArrow = new LauncherViewPropertyAnimator(mArrow)
- .scaleX(0).scaleY(0).setDuration(arrowScaleDuration);
+ Animator hideArrow = createArrowScaleAnim(0).setDuration(arrowScaleDuration);
hideArrow.setStartDelay(0);
- Animator showArrow = new LauncherViewPropertyAnimator(mArrow)
- .scaleX(1).scaleY(1).setDuration(arrowScaleDuration);
+ Animator showArrow = createArrowScaleAnim(1).setDuration(arrowScaleDuration);
showArrow.setStartDelay((long) (duration - arrowScaleDuration * 1.5));
removeNotification.playSequentially(hideArrow, showArrow);
removeNotification.start();
@@ -633,6 +631,10 @@ public class PopupContainerWithArrow extends AbstractFloatingView
notificationView.trimNotifications(badgeInfo.getNotificationKeys());
}
+ private ObjectAnimator createArrowScaleAnim(float scale) {
+ return LauncherAnimUtils.ofPropertyValuesHolder(
+ mArrow, new PropertyListBuilder().scale(scale).build());
+ }
/**
* Animates the translationY of this container if it is open above the icon.
* If it is below the icon, the container already shifts up when the height
@@ -640,8 +642,8 @@ public class PopupContainerWithArrow extends AbstractFloatingView
*/
public @Nullable Animator animateTranslationYBy(int translationY, int duration) {
if (mIsAboveIcon) {
- return new LauncherViewPropertyAnimator(this)
- .translationY(getTranslationY() + translationY).setDuration(duration);
+ return ObjectAnimator.ofFloat(this, TRANSLATION_Y, getTranslationY() + translationY)
+ .setDuration(duration);
}
return null;
}
@@ -744,7 +746,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView
: numOpenShortcuts - i - 1;
anim.setStartDelay(stagger * animationIndex);
- Animator fadeAnim = new LauncherViewPropertyAnimator(view).alpha(0);
+ Animator fadeAnim = ObjectAnimator.ofFloat(view, View.ALPHA, 0);
// Don't start fading until the arrow is gone.
fadeAnim.setStartDelay(stagger * animationIndex + arrowScaleDuration);
fadeAnim.setDuration(duration - arrowScaleDuration);
@@ -761,12 +763,13 @@ public class PopupContainerWithArrow extends AbstractFloatingView
view.setPivotY(iconCenter.y);
float scale = ((float) mLauncher.getDeviceProfile().iconSizePx) / view.getHeight();
- LauncherViewPropertyAnimator anim2 = new LauncherViewPropertyAnimator(view)
- .scaleX(scale)
- .scaleY(scale)
- .translationX(mIconShift.x)
- .translationY(mIconShift.y);
- anim2.setDuration(DragView.VIEW_ZOOM_DURATION);
+ Animator anim2 = LauncherAnimUtils.ofPropertyValuesHolder(view,
+ new PropertyListBuilder()
+ .scale(scale)
+ .translationX(mIconShift.x)
+ .translationY(mIconShift.y)
+ .build())
+ .setDuration(DragView.VIEW_ZOOM_DURATION);
shortcutAnims.play(anim2);
}
anim.addListener(new AnimatorListenerAdapter() {
@@ -777,8 +780,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView
});
shortcutAnims.play(anim);
}
- Animator arrowAnim = new LauncherViewPropertyAnimator(mArrow)
- .scaleX(0).scaleY(0).setDuration(arrowScaleDuration);
+ Animator arrowAnim = createArrowScaleAnim(0).setDuration(arrowScaleDuration);
arrowAnim.setStartDelay(0);
shortcutAnims.play(arrowAnim);