summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson <winsonc@google.com>2015-08-20 19:23:52 (GMT)
committerWinson Chung <winsonc@google.com>2015-08-20 19:51:08 (GMT)
commit6779595bec64fa4503c22f75c8e245a449fe665d (patch)
tree69ae5104005143aa5d59a0b2f292dd44fecb3e29
parenta67cce2cb3b7d6fcf53ce1390238130194c393e5 (diff)
downloadandroid_packages_apps_Trebuchet-6779595bec64fa4503c22f75c8e245a449fe665d.zip
android_packages_apps_Trebuchet-6779595bec64fa4503c22f75c8e245a449fe665d.tar.gz
android_packages_apps_Trebuchet-6779595bec64fa4503c22f75c8e245a449fe665d.tar.bz2
Updating the scrollbar to make the fastscroller more visible.
Bug: 20035978 Change-Id: I56a865262cd07e6af11b4374a7e6354710116dcd
-rw-r--r--proguard.flags4
-rw-r--r--res/values/colors.xml2
-rw-r--r--res/values/dimens.xml6
-rw-r--r--src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java95
4 files changed, 70 insertions, 37 deletions
diff --git a/proguard.flags b/proguard.flags
index b4365fe..e6c4c51 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -5,8 +5,8 @@
-keep class com.android.launcher3.BaseRecyclerViewFastScrollBar {
public void setThumbWidth(int);
public int getThumbWidth();
- public void setTrackAlpha(int);
- public int getTrackAlpha();
+ public void setTrackWidth(int);
+ public int getTrackWidth();
}
-keep class com.android.launcher3.BaseRecyclerViewFastScrollPopup {
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 0add48c..6fe2ae1 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -39,7 +39,7 @@
<color name="outline_color">#FFFFFFFF</color>
<!-- Containers -->
- <color name="container_fastscroll_thumb_inactive_color">#42000000</color>
+ <color name="container_fastscroll_thumb_inactive_color">#009688</color>
<color name="container_fastscroll_thumb_active_color">#009688</color>
<!-- All Apps -->
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b9fb6e2..3f14151 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -55,9 +55,9 @@
<!-- Notes: container_bounds_inset - quantum_panel_outer_padding -->
<dimen name="container_bounds_minus_quantum_panel_padding_inset">4dp</dimen>
- <dimen name="container_fastscroll_thumb_min_width">4dp</dimen>
- <dimen name="container_fastscroll_thumb_max_width">8dp</dimen>
- <dimen name="container_fastscroll_thumb_height">64dp</dimen>
+ <dimen name="container_fastscroll_thumb_min_width">5dp</dimen>
+ <dimen name="container_fastscroll_thumb_max_width">9dp</dimen>
+ <dimen name="container_fastscroll_thumb_height">72dp</dimen>
<dimen name="container_fastscroll_thumb_touch_inset">-24dp</dimen>
<dimen name="container_fastscroll_popup_size">72dp</dimen>
<dimen name="container_fastscroll_popup_text_size">48dp</dimen>
diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
index 29e234d..f76aed7 100644
--- a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
+++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
@@ -23,6 +23,7 @@ import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.Path;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.MotionEvent;
@@ -51,11 +52,14 @@ public class BaseRecyclerViewFastScrollBar {
private int mThumbActiveColor;
@Thunk Point mThumbOffset = new Point(-1, -1);
@Thunk Paint mThumbPaint;
- private Paint mTrackPaint;
private int mThumbMinWidth;
private int mThumbMaxWidth;
@Thunk int mThumbWidth;
@Thunk int mThumbHeight;
+ private int mThumbCurvature;
+ private Path mThumbPath = new Path();
+ private Paint mTrackPaint;
+ private int mTrackWidth;
private float mLastTouchY;
// The inset is the buffer around which a point will still register as a click on the scrollbar
private int mTouchInset;
@@ -75,15 +79,18 @@ public class BaseRecyclerViewFastScrollBar {
mPopup = new BaseRecyclerViewFastScrollPopup(rv, res);
mTrackPaint = new Paint();
mTrackPaint.setColor(rv.getFastScrollerTrackColor(Color.BLACK));
- mTrackPaint.setAlpha(0);
+ mTrackPaint.setAlpha(MAX_TRACK_ALPHA);
mThumbInactiveColor = rv.getFastScrollerThumbInactiveColor(
res.getColor(R.color.container_fastscroll_thumb_inactive_color));
mThumbActiveColor = res.getColor(R.color.container_fastscroll_thumb_active_color);
mThumbPaint = new Paint();
+ mThumbPaint.setAntiAlias(true);
mThumbPaint.setColor(mThumbInactiveColor);
+ mThumbPaint.setStyle(Paint.Style.FILL);
mThumbWidth = mThumbMinWidth = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_min_width);
mThumbMaxWidth = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_max_width);
mThumbHeight = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_height);
+ mThumbCurvature = mThumbMaxWidth - mThumbMinWidth;
mTouchInset = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_touch_inset);
}
@@ -99,10 +106,12 @@ public class BaseRecyclerViewFastScrollBar {
if (mThumbOffset.x == x && mThumbOffset.y == y) {
return;
}
- mInvalidateRect.set(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth, mRv.getHeight());
+ mInvalidateRect.set(mThumbOffset.x - mThumbCurvature, mThumbOffset.y,
+ mThumbOffset.x + mThumbWidth, mThumbOffset.y + mThumbHeight);
mThumbOffset.set(x, y);
- mInvalidateRect.union(new Rect(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth,
- mRv.getHeight()));
+ updateThumbPath();
+ mInvalidateRect.union(mThumbOffset.x - mThumbCurvature, mThumbOffset.y,
+ mThumbOffset.x + mThumbWidth, mThumbOffset.y + mThumbHeight);
mRv.invalidate(mInvalidateRect);
}
@@ -110,12 +119,14 @@ public class BaseRecyclerViewFastScrollBar {
return mThumbOffset;
}
- // Setter/getter for the search bar width for animations
+ // Setter/getter for the thumb bar width for animations
public void setThumbWidth(int width) {
- mInvalidateRect.set(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth, mRv.getHeight());
+ mInvalidateRect.set(mThumbOffset.x - mThumbCurvature, mThumbOffset.y,
+ mThumbOffset.x + mThumbWidth, mThumbOffset.y + mThumbHeight);
mThumbWidth = width;
- mInvalidateRect.union(new Rect(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth,
- mRv.getHeight()));
+ updateThumbPath();
+ mInvalidateRect.union(mThumbOffset.x - mThumbCurvature, mThumbOffset.y,
+ mThumbOffset.x + mThumbWidth, mThumbOffset.y + mThumbHeight);
mRv.invalidate(mInvalidateRect);
}
@@ -123,15 +134,19 @@ public class BaseRecyclerViewFastScrollBar {
return mThumbWidth;
}
- // Setter/getter for the track background alpha for animations
- public void setTrackAlpha(int alpha) {
- mTrackPaint.setAlpha(alpha);
- mInvalidateRect.set(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth, mRv.getHeight());
+ // Setter/getter for the track bar width for animations
+ public void setTrackWidth(int width) {
+ mInvalidateRect.set(mThumbOffset.x - mThumbCurvature, 0, mThumbOffset.x + mThumbWidth,
+ mRv.getHeight());
+ mTrackWidth = width;
+ updateThumbPath();
+ mInvalidateRect.union(mThumbOffset.x - mThumbCurvature, 0, mThumbOffset.x + mThumbWidth,
+ mRv.getHeight());
mRv.invalidate(mInvalidateRect);
}
- public int getTrackAlpha() {
- return mTrackPaint.getAlpha();
+ public int getTrackWidth() {
+ return mTrackWidth;
}
public int getThumbHeight() {
@@ -217,8 +232,7 @@ public class BaseRecyclerViewFastScrollBar {
if (mTrackPaint.getAlpha() > 0) {
canvas.drawRect(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth, mRv.getHeight(), mTrackPaint);
}
- canvas.drawRect(mThumbOffset.x, mThumbOffset.y, mThumbOffset.x + mThumbWidth,
- mThumbOffset.y + mThumbHeight, mThumbPaint);
+ canvas.drawPath(mThumbPath, mThumbPaint);
// Draw the popup
mPopup.draw(canvas);
@@ -231,27 +245,46 @@ public class BaseRecyclerViewFastScrollBar {
if (mScrollbarAnimator != null) {
mScrollbarAnimator.cancel();
}
- ObjectAnimator trackAlphaAnim = ObjectAnimator.ofInt(this, "trackAlpha",
- isScrolling ? MAX_TRACK_ALPHA : 0);
+
+ mScrollbarAnimator = new AnimatorSet();
+ ObjectAnimator trackWidthAnim = ObjectAnimator.ofInt(this, "trackWidth",
+ isScrolling ? mThumbMaxWidth : mThumbMinWidth);
ObjectAnimator thumbWidthAnim = ObjectAnimator.ofInt(this, "thumbWidth",
isScrolling ? mThumbMaxWidth : mThumbMinWidth);
- ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
- mThumbPaint.getColor(), isScrolling ? mThumbActiveColor : mThumbInactiveColor);
- colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animator) {
- mThumbPaint.setColor((Integer) animator.getAnimatedValue());
- mRv.invalidate(mThumbOffset.x, mThumbOffset.y, mThumbOffset.x + mThumbWidth,
- mThumbOffset.y + mThumbHeight);
- }
- });
- mScrollbarAnimator = new AnimatorSet();
- mScrollbarAnimator.playTogether(trackAlphaAnim, thumbWidthAnim, colorAnimation);
+ mScrollbarAnimator.playTogether(trackWidthAnim, thumbWidthAnim);
+ if (mThumbActiveColor != mThumbInactiveColor) {
+ ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
+ mThumbPaint.getColor(), isScrolling ? mThumbActiveColor : mThumbInactiveColor);
+ colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animator) {
+ mThumbPaint.setColor((Integer) animator.getAnimatedValue());
+ mRv.invalidate(mThumbOffset.x, mThumbOffset.y, mThumbOffset.x + mThumbWidth,
+ mThumbOffset.y + mThumbHeight);
+ }
+ });
+ mScrollbarAnimator.play(colorAnimation);
+ }
mScrollbarAnimator.setDuration(SCROLL_BAR_VIS_DURATION);
mScrollbarAnimator.start();
}
/**
+ * Updates the path for the thumb drawable.
+ */
+ private void updateThumbPath() {
+ mThumbCurvature = mThumbMaxWidth - mThumbWidth;
+ mThumbPath.reset();
+ mThumbPath.moveTo(mThumbOffset.x + mThumbWidth, mThumbOffset.y); // tr
+ mThumbPath.lineTo(mThumbOffset.x + mThumbWidth, mThumbOffset.y + mThumbHeight); // br
+ mThumbPath.lineTo(mThumbOffset.x, mThumbOffset.y + mThumbHeight); // bl
+ mThumbPath.cubicTo(mThumbOffset.x, mThumbOffset.y + mThumbHeight,
+ mThumbOffset.x - mThumbCurvature, mThumbOffset.y + mThumbHeight / 2,
+ mThumbOffset.x, mThumbOffset.y); // bl2tl
+ mThumbPath.close();
+ }
+
+ /**
* Returns whether the specified points are near the scroll bar bounds.
*/
private boolean isNearPoint(int x, int y) {