OSDN Git Service

Make scroll bars more noticeable on round screens.
authorDanny Epstein <depstein@google.com>
Wed, 27 Jun 2018 20:04:14 +0000 (13:04 -0700)
committerDanny Epstein <depstein@google.com>
Fri, 29 Jun 2018 16:40:08 +0000 (16:40 +0000)
Increase alpha from 15 to 30% for the track and use Google Material
Grey 200 for the thumb. Fix the geometry so that the track and thumb
don't extend off the edge of the screen.

Bug: 80258942
Change-Id: I43e603e5fffb8a05f486af35194c801060dd0b51
(cherry picked from commit 97b00cbc039a090659aed75e47a172a70222b02f)

core/java/android/view/RoundScrollbarRenderer.java

index 1348510..df9e23e 100644 (file)
@@ -31,13 +31,14 @@ class RoundScrollbarRenderer {
     private static final int MAX_SCROLLBAR_ANGLE_SWIPE = 16;
     private static final int MIN_SCROLLBAR_ANGLE_SWIPE = 6;
     private static final float WIDTH_PERCENTAGE = 0.02f;
-    private static final int DEFAULT_THUMB_COLOR = 0x4CFFFFFF;
-    private static final int DEFAULT_TRACK_COLOR = 0x26FFFFFF;
+    private static final int DEFAULT_THUMB_COLOR = 0xFFE8EAED;
+    private static final int DEFAULT_TRACK_COLOR = 0x4CFFFFFF;
 
     private final Paint mThumbPaint = new Paint();
     private final Paint mTrackPaint = new Paint();
     private final RectF mRect = new RectF();
     private final View mParent;
+    private final int mMaskThickness;
 
     public RoundScrollbarRenderer(View parent) {
         // Paints for the round scrollbar.
@@ -52,6 +53,12 @@ class RoundScrollbarRenderer {
         mTrackPaint.setStyle(Paint.Style.STROKE);
 
         mParent = parent;
+
+        // Fetch the resource indicating the thickness of CircularDisplayMask, rounding in the same
+        // way WindowManagerService.showCircularMask does. The scroll bar is inset by this amount so
+        // that it doesn't get clipped.
+        mMaskThickness = parent.getContext().getResources().getDimensionPixelSize(
+                com.android.internal.R.dimen.circular_display_mask_thickness);
     }
 
     public void drawRoundScrollbars(Canvas canvas, float alpha, Rect bounds) {
@@ -82,13 +89,13 @@ class RoundScrollbarRenderer {
         startAngle = clamp(startAngle, -SCROLLBAR_ANGLE_RANGE / 2,
                 SCROLLBAR_ANGLE_RANGE / 2 - sweepAngle);
 
-        // Draw the track and the scroll bar.
+        // Draw the track and the thumb.
+        float inset = thumbWidth / 2 + mMaskThickness;
         mRect.set(
-                bounds.left - thumbWidth / 2,
-                bounds.top,
-                bounds.right - thumbWidth / 2,
-                bounds.bottom);
-
+                bounds.left + inset,
+                bounds.top + inset,
+                bounds.right - inset,
+                bounds.bottom - inset);
         canvas.drawArc(mRect, -SCROLLBAR_ANGLE_RANGE / 2, SCROLLBAR_ANGLE_RANGE, false,
                 mTrackPaint);
         canvas.drawArc(mRect, startAngle, sweepAngle, false, mThumbPaint);