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

Commit 8ede3c7d authored by Helen Cheuk's avatar Helen Cheuk Committed by Android (Google) Code Review
Browse files

Merge "Draw outline inside the view so it would not be cut off" into main

parents 0fb36489 3d6c2d9b
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -57,18 +57,7 @@ public abstract class FocusIndicatorHelper extends ItemFocusIndicatorHelper<View

        @Override
        public void viewToRect(View v, Rect outRect) {
            if (Flags.enableFocusOutline()) {
                // Ensure the left and top would not be negative and drawn outside of canvas
                outRect.set(Math.max(0, v.getLeft()), Math.max(0, v.getTop()), v.getRight(),
                        v.getBottom());
                // Stroke is drawn with half outside and half inside the view. Inset by half
                // stroke width to move the whole stroke inside the view and avoid other views
                // occluding it
                int halfStrokeWidth = (int) mPaint.getStrokeWidth() / 2;
                outRect.inset(halfStrokeWidth, halfStrokeWidth);
            } else {
            outRect.set(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
        }
    }
}
}
+7 −0
Original line number Diff line number Diff line
@@ -146,6 +146,13 @@ public abstract class ItemFocusIndicatorHelper<T> implements AnimatorUpdateListe

        Rect newRect = getDrawRect();
        if (newRect != null) {
            if (Flags.enableFocusOutline()) {
                // Stroke is drawn with half outside and half inside the view. Inset by half
                // stroke width to move the whole stroke inside the view and avoid other views
                // occluding it
                int halfStrokeWidth = (int) mPaint.getStrokeWidth() / 2;
                newRect.inset(halfStrokeWidth, halfStrokeWidth);
            }
            mDirtyRect.set(newRect);
            c.drawRoundRect((float) mDirtyRect.left, (float) mDirtyRect.top,
                    (float) mDirtyRect.right, (float) mDirtyRect.bottom,