OSDN Git Service

Fix RTL mobile signal drawing out of bounds in QS Edit
authorEvan Laird <evanlaird@google.com>
Thu, 6 Jul 2017 15:41:21 +0000 (11:41 -0400)
committerEvan Laird <evanlaird@google.com>
Thu, 6 Jul 2017 15:41:21 +0000 (11:41 -0400)
For some reason, the canvas is twice the size of the drawable's bounds,
and our RTL code was taking the whole canvas, shifting by its own width
and reversing the x-coords. When the canvas is too wide, it causes the
signal to draw outside of the bounds. To fix it, just shift the
coordinates by the width of the drawable itself. I.e., reverse in the
drawable's own bounds.

Note that there is still an issue where sometimes a non-reversed signal
drawable is used. This doesn't fix that.

Change-Id: I6cfda0ab6b9f50c969410dd4f89499b66854ebbe
Fixes: 63164522
Test: visual

packages/SystemUI/src/com/android/systemui/statusbar/phone/SignalDrawable.java

index 7a7efbd..d537cda 100644 (file)
@@ -230,18 +230,19 @@ public class SignalDrawable extends Drawable {
 
     @Override
     public void draw(@NonNull Canvas canvas) {
+        final float width = getBounds().width();
+        final float height = getBounds().height();
+
         boolean isRtl = getLayoutDirection() == LayoutDirection.RTL;
         if (isRtl) {
             canvas.save();
             // Mirror the drawable
-            canvas.translate(canvas.getWidth(), 0);
+            canvas.translate(width, 0);
             canvas.scale(-1.0f, 1.0f);
         }
         mFullPath.reset();
         mFullPath.setFillType(FillType.WINDING);
 
-        final float width = getBounds().width();
-        final float height = getBounds().height();
         final float padding = Math.round(PAD * width);
         final float cornerRadius = RADIUS_RATIO * height;
         // Offset from circle where the hypotenuse meets the circle