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

Commit a28cd2ca authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Take RTL layouts into account for bounding rect alignment" into main

parents 6c934231 bc78448a
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -600,15 +600,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);
    }