summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--proguard.flags6
-rw-r--r--res/values/config.xml3
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java49
-rw-r--r--src/com/android/launcher3/DragView.java61
4 files changed, 98 insertions, 21 deletions
diff --git a/proguard.flags b/proguard.flags
index e2a4b5b31..6eb594825 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -65,4 +65,8 @@
-keep class com.android.launcher3.AppsContainerRecyclerView {
public void setFastScrollerAlpha(float);
public float getFastScrollerAlpha();
-} \ No newline at end of file
+}
+
+-keep class com.android.launcher3.ButtonDropTarget {
+ public int getTextColor();
+}
diff --git a/res/values/config.xml b/res/values/config.xml
index 47394a1f8..7ce40594f 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -55,9 +55,6 @@
<integer name="config_appsCustomizeDragSlopeThreshold">150</integer>
<!-- Workspace -->
- <!-- The transition duration for the background of the drop targets -->
- <integer name="config_dropTargetBgTransitionDuration">0</integer>
-
<!-- The duration (in ms) of the fade animation on the object outlines, used when
we are dragging objects around on the home screen. -->
<integer name="config_dragOutlineFadeTime">900</integer>
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index fb49df5df..ee8710cd1 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -16,14 +16,16 @@
package com.android.launcher3;
+import android.animation.ObjectAnimator;
+import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
+import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
@@ -42,8 +44,6 @@ public abstract class ButtonDropTarget extends TextView
private static int DRAG_VIEW_DROP_DURATION = 285;
- protected final int mTransitionDuration;
-
protected Launcher mLauncher;
private int mBottomDragPadding;
protected TextView mText;
@@ -58,16 +58,15 @@ public abstract class ButtonDropTarget extends TextView
protected ColorStateList mOriginalTextColor;
protected TransitionDrawable mDrawable;
+ private ObjectAnimator mCurrentColorAnim;
+
public ButtonDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
-
- Resources r = getResources();
- mTransitionDuration = r.getInteger(R.integer.config_dropTargetBgTransitionDuration);
- mBottomDragPadding = r.getDimensionPixelSize(R.dimen.drop_target_drag_padding);
+ mBottomDragPadding = getResources().getDimensionPixelSize(R.dimen.drop_target_drag_padding);
}
@Override
@@ -123,8 +122,13 @@ public abstract class ButtonDropTarget extends TextView
@Override
public final void onDragEnter(DragObject d) {
d.dragView.setColor(mHoverColor);
- mDrawable.startTransition(mTransitionDuration);
- setTextColor(mHoverColor);
+ if (Utilities.isLmpOrAbove()) {
+ mDrawable.startTransition(DragView.COLOR_CHANGE_DURATION);
+ animateTextColor(mHoverColor);
+ } else {
+ mDrawable.startTransition(0);
+ setTextColor(mHoverColor);
+ }
}
@Override
@@ -133,8 +137,23 @@ public abstract class ButtonDropTarget extends TextView
}
protected void resetHoverColor() {
- mDrawable.resetTransition();
- setTextColor(mOriginalTextColor);
+ if (Utilities.isLmpOrAbove()) {
+ mDrawable.reverseTransition(DragView.COLOR_CHANGE_DURATION);
+ animateTextColor(mOriginalTextColor.getDefaultColor());
+ } else {
+ mDrawable.resetTransition();
+ setTextColor(mOriginalTextColor);
+ }
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ private void animateTextColor(int targetColor) {
+ if (mCurrentColorAnim != null) {
+ mCurrentColorAnim.cancel();
+ }
+ mCurrentColorAnim = ObjectAnimator.ofArgb(this, "textColor", targetColor);
+ mCurrentColorAnim.setDuration(DragView.COLOR_CHANGE_DURATION);
+ mCurrentColorAnim.start();
}
@Override
@@ -152,6 +171,10 @@ public abstract class ButtonDropTarget extends TextView
public final void onDragStart(DragSource source, Object info, int dragAction) {
mActive = supportsDrop(source, info);
mDrawable.resetTransition();
+ if (mCurrentColorAnim != null) {
+ mCurrentColorAnim.cancel();
+ mCurrentColorAnim = null;
+ }
setTextColor(mOriginalTextColor);
((ViewGroup) getParent()).setVisibility(mActive ? View.VISIBLE : View.GONE);
}
@@ -271,4 +294,8 @@ public abstract class ButtonDropTarget extends TextView
LauncherAppState.getInstance().getAccessibilityDelegate()
.handleAccessibleDrop(this, null, getAccessibilityDropConfirmation());
}
+
+ public int getTextColor() {
+ return getTextColors().getDefaultColor();
+ }
}
diff --git a/src/com/android/launcher3/DragView.java b/src/com/android/launcher3/DragView.java
index b1a6266cc..a4b6704ac 100644
--- a/src/com/android/launcher3/DragView.java
+++ b/src/com/android/launcher3/DragView.java
@@ -16,22 +16,30 @@
package com.android.launcher3;
+import android.animation.FloatArrayEvaluator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
+import android.annotation.TargetApi;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.Point;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
+import android.os.Build;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import com.android.launcher3.util.Thunk;
+import java.util.Arrays;
+
public class DragView extends View {
+ public static int COLOR_CHANGE_DURATION = 200;
+
@Thunk static float sDragAlpha = 1f;
private Bitmap mBitmap;
@@ -54,6 +62,9 @@ public class DragView extends View {
// size. This is ignored for non-icons.
private float mIntrinsicIconScale = 1f;
+ private float[] mCurrentFilter;
+ private ValueAnimator mFilterAnimator;
+
/**
* Construct the drag view.
* <p>
@@ -229,11 +240,50 @@ public class DragView extends View {
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
}
if (color != 0) {
- mPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
+ ColorMatrix m1 = new ColorMatrix();
+ m1.setSaturation(0);
+
+ ColorMatrix m2 = new ColorMatrix();
+ m2.setScale(Color.red(color) / 255f, Color.green(color) / 255f,
+ Color.blue(color) / 255f, Color.alpha(color) / 255f);
+ m1.postConcat(m2);
+
+ if (Utilities.isLmpOrAbove()) {
+ animateFilterTo(m1.getArray());
+ } else {
+ mPaint.setColorFilter(new ColorMatrixColorFilter(m1));
+ invalidate();
+ }
} else {
- mPaint.setColorFilter(null);
+ if (!Utilities.isLmpOrAbove() || mCurrentFilter == null) {
+ mPaint.setColorFilter(null);
+ invalidate();
+ } else {
+ animateFilterTo(new ColorMatrix().getArray());
+ }
}
- invalidate();
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ private void animateFilterTo(float[] targetFilter) {
+ float[] oldFilter = mCurrentFilter == null ? new ColorMatrix().getArray() : mCurrentFilter;
+ mCurrentFilter = Arrays.copyOf(oldFilter, oldFilter.length);
+
+ if (mFilterAnimator != null) {
+ mFilterAnimator.cancel();
+ }
+ mFilterAnimator = ValueAnimator.ofObject(new FloatArrayEvaluator(mCurrentFilter),
+ oldFilter, targetFilter);
+ mFilterAnimator.setDuration(COLOR_CHANGE_DURATION);
+ mFilterAnimator.addUpdateListener(new AnimatorUpdateListener() {
+
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ mPaint.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
+ invalidate();
+ }
+ });
+ mFilterAnimator.start();
}
public boolean hasDrawn() {
@@ -301,4 +351,3 @@ public class DragView extends View {
}
}
}
-