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

Commit bc78448a authored by Jorge Gil's avatar Jorge Gil
Browse files

Take RTL layouts into account for bounding rect alignment

The bounding rects should take layout direction into consideration given
the App Header layout itself does, otherwise the rects won't match the
system elements in the header.

Fix: 375671209
Flag: EXEMPT bug fix
Test: Force RTL in dev settings, open Chrome with custom header in
freeform, check tabs align to the edges of the system elements

Change-Id: Ia12e431275bcf4182d9d11184e3fb19bfe159b68
parent 662f37ea
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -593,15 +593,27 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>

    private Rect calculateBoundingRectLocal(@NonNull OccludingCaptionElement element,
            int elementWidthPx, @NonNull Rect captionRect) {
        final boolean isRtl =
                mDecorWindowContext.getResources().getConfiguration().getLayoutDirection()
                        == View.LAYOUT_DIRECTION_RTL;
        switch (element.mAlignment) {
            case START -> {
                if (isRtl) {
                    return new Rect(captionRect.width() - elementWidthPx, 0,
                            captionRect.width(), captionRect.height());
                } else {
                    return new Rect(0, 0, elementWidthPx, captionRect.height());
                }
            }
            case END -> {
                if (isRtl) {
                    return new Rect(0, 0, elementWidthPx, captionRect.height());
                } else {
                    return new Rect(captionRect.width() - elementWidthPx, 0,
                            captionRect.width(), captionRect.height());
                }
            }
        }
        throw new IllegalArgumentException("Unexpected alignment " + element.mAlignment);
    }