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

Commit f7c69b78 authored by Mady Mellor's avatar Mady Mellor
Browse files

Fix the pointer position when displayed in RTL

When displaying in RTL, the pointer translates from the opposite
side of the screen than the code assumes. This CL changes the math
for the pointer position when displaying in RTL.

Test: manual - test landscape / portrait on tablet / phone in LTR
               and RTL: have a couple of bubbles, expand the stack
               and select each bubble ensuring that the pointer is
               centered on the selection.
Bug: 230579507
Bug: 233950592
Change-Id: I71a6f64a43c1b7bb5e0a30773d4cc5ae55c63b6a
parent 1247cb1f
Loading
Loading
Loading
Loading
+17 −4
Original line number Original line Diff line number Diff line
@@ -908,6 +908,8 @@ public class BubbleExpandedView extends LinearLayout {
     * @param animate whether the pointer should animate to this position.
     * @param animate whether the pointer should animate to this position.
     */
     */
    public void setPointerPosition(float bubblePosition, boolean onLeft, boolean animate) {
    public void setPointerPosition(float bubblePosition, boolean onLeft, boolean animate) {
        final boolean isRtl = mContext.getResources().getConfiguration().getLayoutDirection()
                == LAYOUT_DIRECTION_RTL;
        // Pointer gets drawn in the padding
        // Pointer gets drawn in the padding
        final boolean showVertically = mPositioner.showBubblesVertically();
        final boolean showVertically = mPositioner.showBubblesVertically();
        final float paddingLeft = (showVertically && onLeft)
        final float paddingLeft = (showVertically && onLeft)
@@ -932,12 +934,23 @@ public class BubbleExpandedView extends LinearLayout {
            updatePointerView();
            updatePointerView();
            if (showVertically) {
            if (showVertically) {
                mPointerPos.y = bubbleCenter - (mPointerWidth / 2f);
                mPointerPos.y = bubbleCenter - (mPointerWidth / 2f);
                if (!isRtl) {
                    mPointerPos.x = onLeft
                    mPointerPos.x = onLeft
                            ? -mPointerHeight + mPointerOverlap
                            ? -mPointerHeight + mPointerOverlap
                            : getWidth() - mPaddingRight - mPointerOverlap;
                            : getWidth() - mPaddingRight - mPointerOverlap;
                } else {
                    mPointerPos.x = onLeft
                            ? -(getWidth() - mPaddingLeft - mPointerOverlap)
                            : mPointerHeight - mPointerOverlap;
                }
            } else {
            } else {
                mPointerPos.y = mPointerOverlap;
                mPointerPos.y = mPointerOverlap;
                if (!isRtl) {
                    mPointerPos.x = bubbleCenter - (mPointerWidth / 2f);
                    mPointerPos.x = bubbleCenter - (mPointerWidth / 2f);
                } else {
                    mPointerPos.x = -(getWidth() - mPaddingLeft - bubbleCenter)
                            + (mPointerWidth / 2f);
                }
            }
            }
            if (animate) {
            if (animate) {
                mPointerView.animate().translationX(mPointerPos.x).translationY(
                mPointerView.animate().translationX(mPointerPos.x).translationY(