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

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

Merge "Change single stroke focus outline to double stroke" into main

parents 0e9901eb 7b83b8e0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
    <attr name="popupNotificationDotColor" format="color" />
    <attr name="notificationDotColor" format="color" />
    <attr name="focusOutlineColor" format="color" />
    <attr name="focusInnerOutlineColor" format="color" />

    <attr name="pageIndicatorDotColor" format="color" />
    <attr name="folderPreviewColor" format="color" />
+5 −1
Original line number Diff line number Diff line
@@ -451,7 +451,11 @@
    <dimen name="split_instructions_start_margin_cancel">8dp</dimen>

    <dimen name="focus_outline_radius">16dp</dimen>
    <dimen name="focus_outline_stroke_width">3dp</dimen>
    <dimen name="focus_inner_outline_radius">14dp</dimen>
    <dimen name="focus_outline_stroke_width">2dp</dimen>
    <!-- -4dp for double stroke focus outlines, -2dp for padding between outline and widget,
    make it negative to outset the rect and leave space for drawing focus outline and padding -->
    <dimen name="focus_rect_widget_outsets">-6dp</dimen>

    <!-- Workspace grid visualization parameters -->
    <dimen name="grid_visualization_rounding_radius">16dp</dimen>
+2 −1
Original line number Diff line number Diff line
@@ -53,7 +53,8 @@
        <item name="workspaceKeyShadowColor">#89000000</item>
        <item name="widgetsTheme">@style/WidgetContainerTheme</item>
        <item name="pageIndicatorDotColor">@color/page_indicator_dot_color_light</item>
        <item name="focusOutlineColor">@color/material_color_on_secondary_container</item>
        <item name="focusOutlineColor">@color/material_color_secondary_fixed</item>
        <item name="focusInnerOutlineColor">@color/material_color_on_secondary_fixed_variant</item>
        <item name="folderPreviewColor">@color/folder_preview_light</item>
        <item name="folderBackgroundColor">@color/folder_background_light</item>
        <item name="folderIconBorderColor">?android:attr/colorPrimary</item>
+5 −3
Original line number Diff line number Diff line
@@ -31,9 +31,11 @@ public abstract class FocusIndicatorHelper extends ItemFocusIndicatorHelper<View
        implements OnFocusChangeListener {

    public FocusIndicatorHelper(View container) {
        super(container, Flags.enableFocusOutline() ? Themes.getAttrColor(container.getContext(),
                R.attr.focusOutlineColor)
                : container.getResources().getColor(R.color.focused_background));
        super(container,
                Flags.enableFocusOutline() ? new int[]{Themes.getAttrColor(container.getContext(),
                        R.attr.focusOutlineColor), Themes.getAttrColor(container.getContext(),
                        R.attr.focusInnerOutlineColor)}
                        : new int[]{container.getResources().getColor(R.color.focused_background)});
    }

    @Override
+27 −11
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ public abstract class ItemFocusIndicatorHelper<T> implements AnimatorUpdateListe
    private static final Rect sTempRect2 = new Rect();

    private final View mContainer;
    protected final Paint mPaint;
    protected final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    private final Paint mInnerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    private final int mMaxAlpha;

    private final Rect mDirtyRect = new Rect();
@@ -93,24 +94,31 @@ public abstract class ItemFocusIndicatorHelper<T> implements AnimatorUpdateListe
    private ObjectAnimator mCurrentAnimation;
    private float mAlpha;
    private float mRadius;
    private float mInnerRadius;

    public ItemFocusIndicatorHelper(View container, int color) {
    public ItemFocusIndicatorHelper(View container, int... colors) {
        mContainer = container;

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(0xFF000000 | color);
        if (Flags.enableFocusOutline()) {
        mPaint.setColor(0xFF000000 | colors[0]);
        if (Flags.enableFocusOutline() && colors.length > 1) {
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setStrokeWidth(container.getResources().getDimensionPixelSize(
                    R.dimen.focus_outline_stroke_width));
            mRadius = container.getResources().getDimensionPixelSize(
                    R.dimen.focus_outline_radius);

            mInnerPaint.setStyle(Paint.Style.STROKE);
            mInnerPaint.setColor(0xFF000000 | colors[1]);
            mInnerPaint.setStrokeWidth(container.getResources().getDimensionPixelSize(
                    R.dimen.focus_outline_stroke_width));
            mInnerRadius = container.getResources().getDimensionPixelSize(
                    R.dimen.focus_inner_outline_radius);
        } else {
            mPaint.setStyle(Paint.Style.FILL);
            mRadius = container.getResources().getDimensionPixelSize(
                    R.dimen.grid_visualization_rounding_radius);
        }
        mMaxAlpha = Color.alpha(color);
        mMaxAlpha = Color.alpha(colors[0]);

        setAlpha(0);
        mShift = 0;
@@ -119,6 +127,7 @@ public abstract class ItemFocusIndicatorHelper<T> implements AnimatorUpdateListe
    protected void setAlpha(float alpha) {
        mAlpha = alpha;
        mPaint.setAlpha((int) (mAlpha * mMaxAlpha));
        mInnerPaint.setAlpha((int) (mAlpha * mMaxAlpha));
    }

    @Override
@@ -147,11 +156,18 @@ 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);
                int strokeWidth = (int) mPaint.getStrokeWidth();
                // Inset for inner outline. 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. Inset one more stroke width to leave space
                // for outer outline.
                newRect.inset((int) (strokeWidth * 1.5), (int) (strokeWidth * 1.5));
                c.drawRoundRect((float) newRect.left, (float) newRect.top,
                        (float) newRect.right, (float) newRect.bottom,
                        mInnerRadius, mInnerRadius, mInnerPaint);

                // Inset outward for drawing outer outline
                newRect.inset(-strokeWidth, -strokeWidth);
            }
            mDirtyRect.set(newRect);
            c.drawRoundRect((float) mDirtyRect.left, (float) mDirtyRect.top,
Loading