summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/graphics/FastScrollThumbDrawable.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-06-14 15:35:16 -0700
committerSunny Goyal <sunnygoyal@google.com>2017-06-16 14:57:34 -0700
commit1a8f6fb736c36548a44db6c7018771e3a895dda0 (patch)
tree4ba5fa5fd04a426bbc2a6d32579a41db116bb14e /src/com/android/launcher3/graphics/FastScrollThumbDrawable.java
parent3f2418976d97770bc0cc9aa006e36d84a8e2d426 (diff)
downloadpackages_apps_Trebuchet-1a8f6fb736c36548a44db6c7018771e3a895dda0.tar.gz
packages_apps_Trebuchet-1a8f6fb736c36548a44db6c7018771e3a895dda0.tar.bz2
packages_apps_Trebuchet-1a8f6fb736c36548a44db6c7018771e3a895dda0.zip
Updating the fast scroll bar UI
Bug: 37015359 Change-Id: Iec0748f04ebe9a3eef13ff759da3cab6ff28c3a1
Diffstat (limited to 'src/com/android/launcher3/graphics/FastScrollThumbDrawable.java')
-rw-r--r--src/com/android/launcher3/graphics/FastScrollThumbDrawable.java89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/com/android/launcher3/graphics/FastScrollThumbDrawable.java b/src/com/android/launcher3/graphics/FastScrollThumbDrawable.java
new file mode 100644
index 000000000..6ebc74eeb
--- /dev/null
+++ b/src/com/android/launcher3/graphics/FastScrollThumbDrawable.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.graphics;
+
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.Matrix;
+import android.graphics.Outline;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.PixelFormat;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+
+public class FastScrollThumbDrawable extends Drawable {
+
+ private static final Matrix sMatrix = new Matrix();
+
+ private final Path mPath = new Path();
+ private final Paint mPaint;
+ private final boolean mIsRtl;
+
+ public FastScrollThumbDrawable(Paint paint, boolean isRtl) {
+ mPaint = paint;
+ mIsRtl = isRtl;
+ }
+
+ @Override
+ public void getOutline(Outline outline) {
+ if (mPath.isConvex()) {
+ outline.setConvexPath(mPath);
+ }
+ }
+
+ @Override
+ protected void onBoundsChange(Rect bounds) {
+ mPath.reset();
+
+ float r = bounds.height() * 0.5f;
+ // The path represents a rotate tear-drop shape, with radius of one corner is 1/5th of the
+ // other 3 corners.
+ float diameter = 2 * r;
+ float r2 = r / 5;
+ mPath.addRoundRect(bounds.left, bounds.top, bounds.left + diameter, bounds.top + diameter,
+ new float[] {r, r, r, r, r2, r2, r, r},
+ Path.Direction.CCW);
+
+ sMatrix.setRotate(-45, bounds.left + r, bounds.top + r);
+ if (mIsRtl) {
+ sMatrix.postTranslate(bounds.width(), 0);
+ sMatrix.postScale(-1, 1, bounds.width(), 0);
+ }
+ mPath.transform(sMatrix);
+ }
+
+ @Override
+ public void draw(Canvas canvas) {
+ canvas.drawPath(mPath, mPaint);
+ }
+
+ @Override
+ public void setAlpha(int i) {
+ // Not supported
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter colorFilter) {
+ // Not supported
+ }
+
+ @Override
+ public int getOpacity() {
+ return PixelFormat.TRANSLUCENT;
+ }
+}