From 6a2acfaa59b949fa8bb9a11e22f3836a09289e2f Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Fri, 19 Mar 2021 13:23:53 +0000 Subject: [PATCH] Add an 65% opacity for workspace elements drag over button drop target Also remove the draggable item hover top button color change. Test: Manual Bug: 183193201 Change-Id: Id80622b8c0152180c47c0c9ebff8aa8bc2a5c2be --- .../android/launcher3/ButtonDropTarget.java | 56 ++----------------- .../android/launcher3/DeleteDropTarget.java | 3 - .../launcher3/SecondaryDropTarget.java | 4 -- 3 files changed, 4 insertions(+), 59 deletions(-) diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java index 459b9a841e..4740079f9d 100644 --- a/src/com/android/launcher3/ButtonDropTarget.java +++ b/src/com/android/launcher3/ButtonDropTarget.java @@ -21,14 +21,9 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static com.android.launcher3.LauncherState.NORMAL; import android.animation.AnimatorSet; -import android.animation.FloatArrayEvaluator; -import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; -import android.graphics.ColorMatrix; -import android.graphics.ColorMatrixColorFilter; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.text.TextUtils; @@ -45,10 +40,7 @@ import com.android.launcher3.anim.Interpolators; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.dragndrop.DragOptions; -import com.android.launcher3.dragndrop.DragView; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.util.Themes; -import com.android.launcher3.util.Thunk; /** * Implements a DropTarget. @@ -72,6 +64,7 @@ public abstract class ButtonDropTarget extends TextView private static final int[] sTempCords = new int[2]; private static final int DRAG_VIEW_DROP_DURATION = 285; + private static final float DRAG_VIEW_HOVER_OVER_OPACITY = 0.65f; public static final int TOOLTIP_DEFAULT = 0; public static final int TOOLTIP_LEFT = 1; @@ -89,9 +82,6 @@ public abstract class ButtonDropTarget extends TextView /** An item must be dragged at least this many pixels before this drop target is enabled. */ private final int mDragDistanceThreshold; - /** The paint applied to the drag view on hover */ - protected int mHoverColor = 0; - protected CharSequence mText; protected ColorStateList mOriginalTextColor; protected Drawable mDrawable; @@ -101,7 +91,6 @@ public abstract class ButtonDropTarget extends TextView private int mToolTipLocation; private AnimatorSet mCurrentColorAnim; - @Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter; public ButtonDropTarget(Context context, AttributeSet attrs) { this(context, attrs, 0); @@ -177,8 +166,7 @@ public abstract class ButtonDropTarget extends TextView mToolTip.showAsDropDown(this, x, y); } - d.dragView.setColor(mHoverColor); - animateTextColor(mHoverColor); + d.dragView.setAlpha(DRAG_VIEW_HOVER_OVER_OPACITY); if (d.stateAnnouncer != null) { d.stateAnnouncer.cancel(); } @@ -190,51 +178,15 @@ public abstract class ButtonDropTarget extends TextView // Do nothing } - protected void resetHoverColor() { - animateTextColor(mOriginalTextColor.getDefaultColor()); - } - - private void animateTextColor(int targetColor) { - if (mCurrentColorAnim != null) { - mCurrentColorAnim.cancel(); - } - - mCurrentColorAnim = new AnimatorSet(); - mCurrentColorAnim.setDuration(DragView.COLOR_CHANGE_DURATION); - - if (mSrcFilter == null) { - mSrcFilter = new ColorMatrix(); - mDstFilter = new ColorMatrix(); - mCurrentFilter = new ColorMatrix(); - } - - int defaultTextColor = mOriginalTextColor.getDefaultColor(); - Themes.setColorChangeOnMatrix(defaultTextColor, getTextColor(), mSrcFilter); - Themes.setColorChangeOnMatrix(defaultTextColor, targetColor, mDstFilter); - - ValueAnimator anim1 = ValueAnimator.ofObject( - new FloatArrayEvaluator(mCurrentFilter.getArray()), - mSrcFilter.getArray(), mDstFilter.getArray()); - anim1.addUpdateListener((anim) -> { - mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter)); - invalidate(); - }); - - mCurrentColorAnim.play(anim1); - mCurrentColorAnim.play(ObjectAnimator.ofArgb(this, TEXT_COLOR, targetColor)); - mCurrentColorAnim.start(); - } - @Override public final void onDragExit(DragObject d) { hideTooltip(); if (!d.dragComplete) { d.dragView.setColor(0); - resetHoverColor(); + d.dragView.setAlpha(1f); } else { - // Restore the hover color - d.dragView.setColor(mHoverColor); + d.dragView.setAlpha(DRAG_VIEW_HOVER_OVER_OPACITY); } } diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java index cc119c9361..e46aad2bcf 100644 --- a/src/com/android/launcher3/DeleteDropTarget.java +++ b/src/com/android/launcher3/DeleteDropTarget.java @@ -53,9 +53,6 @@ public class DeleteDropTarget extends ButtonDropTarget { @Override protected void onFinishInflate() { super.onFinishInflate(); - // Get the hover color - mHoverColor = getResources().getColor(R.color.delete_target_hover_tint); - setDrawable(R.drawable.ic_remove_shadow); } diff --git a/src/com/android/launcher3/SecondaryDropTarget.java b/src/com/android/launcher3/SecondaryDropTarget.java index 8bc5ad0eb1..858b72eb18 100644 --- a/src/com/android/launcher3/SecondaryDropTarget.java +++ b/src/com/android/launcher3/SecondaryDropTarget.java @@ -44,7 +44,6 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.util.PackageManagerHelper; -import com.android.launcher3.util.Themes; import com.android.launcher3.widget.LauncherAppWidgetProviderInfo; import java.net.URISyntaxException; @@ -109,15 +108,12 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList mCurrentAccessibilityAction = action; if (action == UNINSTALL) { - mHoverColor = getResources().getColor(R.color.uninstall_target_hover_tint); setDrawable(R.drawable.ic_uninstall_shadow); updateText(R.string.uninstall_drop_target_label); } else if (action == DISMISS_PREDICTION) { - mHoverColor = Themes.getColorAccent(getContext()); setDrawable(R.drawable.ic_block_shadow); updateText(R.string.dismiss_prediction_label); } else if (action == RECONFIGURE) { - mHoverColor = Themes.getColorAccent(getContext()); setDrawable(R.drawable.ic_setup_shadow); updateText(R.string.gadget_setup_text); }