diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-06-23 19:10:40 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-06-23 19:10:41 +0000 |
commit | 48f1135a6dbdee99ff1e981682e99d8755944062 (patch) | |
tree | 5b3e77eafcc867690ea24f0ba5c7a11e39ec84d7 | |
parent | 6828cbb7515eeaccd96f481232e252b9bc47d512 (diff) | |
parent | 4e5a878bc474c4aa77d48b3cd7f06f3c50013eb7 (diff) | |
download | android_packages_apps_Trebuchet-48f1135a6dbdee99ff1e981682e99d8755944062.tar.gz android_packages_apps_Trebuchet-48f1135a6dbdee99ff1e981682e99d8755944062.tar.bz2 android_packages_apps_Trebuchet-48f1135a6dbdee99ff1e981682e99d8755944062.zip |
Merge "Fixing two different implementations for animating text alpha" into ub-launcher3-dorval-polish
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 22 | ||||
-rw-r--r-- | src/com/android/launcher3/folder/FolderAnimationManager.java | 39 |
2 files changed, 17 insertions, 44 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 2306b1bf3..6f2c89779 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -16,7 +16,6 @@ package com.android.launcher3; -import android.animation.Animator; import android.animation.ObjectAnimator; import android.content.Context; import android.content.res.ColorStateList; @@ -70,7 +69,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { private final Launcher mLauncher; private Drawable mIcon; private final boolean mCenterVertically; - private OnLongClickListener mOnLongClickListener; + private final CheckLongPressHelper mLongPressHelper; private final HolographicOutlineHelper mOutlineHelper; private final StylusEventHelper mStylusEventHelper; @@ -107,7 +106,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { } }; - private static final Property<BubbleTextView, Integer> TEXT_ALPHA_PROPERTY + public static final Property<BubbleTextView, Integer> TEXT_ALPHA_PROPERTY = new Property<BubbleTextView, Integer>(Integer.class, "textAlpha") { @Override public Integer get(BubbleTextView bubbleTextView) { @@ -264,21 +263,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { return mIcon; } - /** Returns whether the layout is horizontal. */ - public boolean isLayoutHorizontal() { - return mLayoutHorizontal; - } - - @Override - public void setOnLongClickListener(OnLongClickListener l) { - super.setOnLongClickListener(l); - mOnLongClickListener = l; - } - - public OnLongClickListener getOnLongClickListener() { - return mOnLongClickListener; - } - @Override public boolean onTouchEvent(MotionEvent event) { // Call the superclass onTouchEvent first, because sometimes it changes the state to @@ -474,7 +458,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { * Creates an animator to fade the text in or out. * @param fadeIn Whether the text should fade in or fade out. */ - public Animator createTextAlphaAnimator(boolean fadeIn) { + public ObjectAnimator createTextAlphaAnimator(boolean fadeIn) { return ObjectAnimator.ofInt(this, TEXT_ALPHA_PROPERTY, fadeIn ? Color.alpha(mTextColor) : 0); } diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java index cb86b59f3..7e6205aba 100644 --- a/src/com/android/launcher3/folder/FolderAnimationManager.java +++ b/src/com/android/launcher3/folder/FolderAnimationManager.java @@ -37,6 +37,7 @@ import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.R; import com.android.launcher3.ShortcutAndWidgetContainer; import com.android.launcher3.Utilities; +import com.android.launcher3.anim.PropertyResetListener; import com.android.launcher3.anim.RoundedRectRevealOutlineProvider; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.util.Themes; @@ -87,23 +88,6 @@ public class FolderAnimationManager { } }; - private static final Property<List<BubbleTextView>, Integer> ITEMS_TEXT_COLOR_PROPERTY = - new Property<List<BubbleTextView>, Integer>(Integer.class, "textColor") { - @Override - public Integer get(List<BubbleTextView> items) { - return items.get(0).getCurrentTextColor(); - } - - @Override - public void set(List<BubbleTextView> items, Integer color) { - int size = items.size(); - - for (int i = 0; i < size; ++i) { - items.get(i).setTextColor(color); - } - } - }; - public FolderAnimationManager(Folder folder, boolean isOpening) { mFolder = folder; mContent = folder.mContent; @@ -183,12 +167,6 @@ public class FolderAnimationManager { ColorUtils.setAlphaComponent(finalColor, mPreviewBackground.getBackgroundAlpha()); mFolderBackground.setColor(mIsOpening ? initialColor : finalColor); - // Initialize the Folder items' text. - final List<BubbleTextView> items = mFolder.getItemsOnCurrentPage(); - final int finalTextColor = Themes.getAttrColor(mContext, android.R.attr.textColorSecondary); - ITEMS_TEXT_COLOR_PROPERTY.set(items, mIsOpening ? Color.TRANSPARENT - : finalTextColor); - // Set up the reveal animation that clips the Folder. int totalOffsetX = paddingOffsetX + previewItemOffsetX; Rect startRect = new Rect( @@ -203,10 +181,22 @@ public class FolderAnimationManager { // Create the animators. AnimatorSet a = LauncherAnimUtils.createAnimatorSet(); + // Initialize the Folder items' text. + PropertyResetListener colorResetListener = new PropertyResetListener( + BubbleTextView.TEXT_ALPHA_PROPERTY, + Color.alpha(Themes.getAttrColor(mContext, android.R.attr.textColorSecondary))); + for (BubbleTextView icon : mFolder.getItemsOnCurrentPage()) { + if (mIsOpening) { + icon.setTextVisibility(false); + } + ObjectAnimator anim = icon.createTextAlphaAnimator(mIsOpening); + anim.addListener(colorResetListener); + play(a, anim); + } + play(a, getAnimator(mFolder, View.TRANSLATION_X, xDistance, 0f)); play(a, getAnimator(mFolder, View.TRANSLATION_Y, yDistance, 0f)); play(a, getAnimator(mFolder, SCALE_PROPERTY, initialScale, finalScale)); - play(a, getAnimator(items, ITEMS_TEXT_COLOR_PROPERTY, Color.TRANSPARENT, finalTextColor)); play(a, getAnimator(mFolderBackground, "color", initialColor, finalColor)); play(a, mFolderIcon.mFolderName.createTextAlphaAnimator(!mIsOpening)); play(a, new RoundedRectRevealOutlineProvider(initialRadius, finalRadius, startRect, @@ -216,7 +206,6 @@ public class FolderAnimationManager { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); - ITEMS_TEXT_COLOR_PROPERTY.set(items, finalTextColor); mFolder.setTranslationX(0.0f); mFolder.setTranslationY(0.0f); mFolder.setScaleX(1f); |