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

Commit 3d6c2d9b authored by helencheuk's avatar helencheuk
Browse files

Draw outline inside the view so it would not be cut off

Before: https://screenshot.googleplex.com/C2iwZxYV3KocTQq
After: https://screenshot.googleplex.com/BC9YYtm8GngssNF

Bug: 310953377
Test: Manual, navigate to the folder icon by keyboard, press enter to open and go to the bottom row app icon
Flag: ACONFIG com.android.launcher3.enable_focus_outline Staging
Change-Id: Iad5a081ef3838d2728f8845c4fa2ef726b2c781b
parent 4b75bca8
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,