summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/widget/SelectionActionModeHelper.java3
-rw-r--r--core/java/android/widget/SmartSelectSprite.java25
2 files changed, 21 insertions, 7 deletions
diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java
index e32a99e6ed38..a42efca057eb 100644
--- a/core/java/android/widget/SelectionActionModeHelper.java
+++ b/core/java/android/widget/SelectionActionModeHelper.java
@@ -232,9 +232,6 @@ final class SelectionActionModeHelper {
firstRectangle.centerY());
mSmartSelectSprite.startAnimation(
- // TODO replace with colorControlActivated taken from the view attributes
- // Color GBLUE700
- 0xFF3367D6,
halfPoint,
selectionRectangles,
onAnimationEndCallback);
diff --git a/core/java/android/widget/SmartSelectSprite.java b/core/java/android/widget/SmartSelectSprite.java
index 5eed985c36e7..e641a9bc5176 100644
--- a/core/java/android/widget/SmartSelectSprite.java
+++ b/core/java/android/widget/SmartSelectSprite.java
@@ -26,6 +26,7 @@ import android.annotation.ColorInt;
import android.annotation.FloatRange;
import android.annotation.IntDef;
import android.content.Context;
+import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
@@ -59,12 +60,19 @@ final class SmartSelectSprite {
private static final int CORNER_DURATION = 150;
private static final float STROKE_WIDTH_DP = 1.5F;
private static final int POINTS_PER_LINE = 4;
+
+ // GBLUE700
+ @ColorInt
+ private static final int DEFAULT_STROKE_COLOR = 0xFF3367D6;
+
private final Interpolator mExpandInterpolator;
private final Interpolator mCornerInterpolator;
private final float mStrokeWidth;
private final View mView;
private Animator mActiveAnimator = null;
+ @ColorInt
+ private final int mStrokeColor;
private Set<Drawable> mExistingAnimationDrawables = new HashSet<>();
/**
@@ -322,6 +330,7 @@ final class SmartSelectSprite {
context,
android.R.interpolator.fast_out_linear_in);
mStrokeWidth = dpToPixel(context, STROKE_WIDTH_DP);
+ mStrokeColor = getStrokeColor(context);
mView = view;
}
@@ -406,7 +415,6 @@ final class SmartSelectSprite {
/**
* Performs the Smart Select animation on the view bound to this SmartSelectSprite.
*
- * @param color The color of the stroke used.
* @param start The point from which the animation will start. Must be inside
* destinationRectangles.
* @param destinationRectangles The rectangles which the animation will fill out by its
@@ -418,7 +426,6 @@ final class SmartSelectSprite {
* @see #cancelAnimation()
*/
public void startAnimation(
- final @ColorInt int color,
final Pair<Float, Float> start,
final List<RectF> destinationRectangles,
final Runnable onAnimationEnd) throws IllegalArgumentException {
@@ -474,13 +481,13 @@ final class SmartSelectSprite {
final ShapeDrawable shapeDrawable = new ShapeDrawable(rectangleList);
final Paint paint = shapeDrawable.getPaint();
- paint.setColor(color);
+ paint.setColor(mStrokeColor);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(mStrokeWidth);
addToOverlay(shapeDrawable);
- mActiveAnimator = createAnimator(color, destinationRectangles, rectangleList,
+ mActiveAnimator = createAnimator(mStrokeColor, destinationRectangles, rectangleList,
startingOffsetLeft, startingOffsetRight, cornerAnimators, updateListener,
onAnimationEnd);
mActiveAnimator.start();
@@ -615,6 +622,16 @@ final class SmartSelectSprite {
context.getResources().getDisplayMetrics());
}
+ @ColorInt
+ private static int getStrokeColor(final Context context) {
+ final TypedValue typedValue = new TypedValue();
+ final TypedArray array = context.obtainStyledAttributes(typedValue.data, new int[]{
+ android.R.attr.colorControlActivated});
+ final int result = array.getColor(0, DEFAULT_STROKE_COLOR);
+ array.recycle();
+ return result;
+ }
+
private void addToOverlay(final Drawable drawable) {
mView.getOverlay().add(drawable);
mExistingAnimationDrawables.add(drawable);