Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49e4227a authored by Seigo Nonaka's avatar Seigo Nonaka Committed by Android (Google) Code Review
Browse files

Merge "Don't use save/restore which stop drawing toggle switch drawables" into main

parents e33d43c7 70fb33ba
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -711,18 +711,21 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback
    public void draw(Canvas c, Path highlight, Paint highlightpaint,
                     int cursorOffset) {
        if (mDirect != null && highlight == null) {
            float leftShift = 0;
            if (getUseBoundsForWidth()) {
                c.save();
                RectF drawingRect = computeDrawingBoundingBox();
                if (drawingRect.left < 0) {
                    c.translate(-drawingRect.left, 0);
                    leftShift = -drawingRect.left;
                    c.translate(leftShift, 0);
                }
            }

            c.drawText(mDirect, 0, mBottom - mDesc, mPaint);

            if (getUseBoundsForWidth()) {
                c.restore();
            if (leftShift != 0) {
                // Manually translate back to the original position because of b/324498002, using
                // save/restore disappears the toggle switch drawables.
                c.translate(-leftShift, 0);
            }
        } else {
            super.draw(c, highlight, highlightpaint, cursorOffset);
+7 −4
Original line number Diff line number Diff line
@@ -464,11 +464,12 @@ public abstract class Layout {
            @Nullable Path selectionPath,
            @Nullable Paint selectionPaint,
            int cursorOffsetVertical) {
        float leftShift = 0;
        if (mUseBoundsForWidth) {
            canvas.save();
            RectF drawingRect = computeDrawingBoundingBox();
            if (drawingRect.left < 0) {
                canvas.translate(-drawingRect.left, 0);
                leftShift = -drawingRect.left;
                canvas.translate(leftShift, 0);
            }
        }
        final long lineRange = getLineRangeForDraw(canvas);
@@ -479,8 +480,10 @@ public abstract class Layout {
        drawWithoutText(canvas, highlightPaths, highlightPaints, selectionPath, selectionPaint,
                cursorOffsetVertical, firstLine, lastLine);
        drawText(canvas, firstLine, lastLine);
        if (mUseBoundsForWidth) {
            canvas.restore();
        if (leftShift != 0) {
            // Manually translate back to the original position because of b/324498002, using
            // save/restore disappears the toggle switch drawables.
            canvas.translate(-leftShift, 0);
        }
    }