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
This commit is contained in:
helencheuk committed 2024-01-29 12:15:22 +00:00
1 parent 4b75bca8c9
commit 3d6c2d9bc0
2 files changed
+8 -12

No files matched your search

@@ -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());
}
outRect.set(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
}
}
}