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
@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