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

Commit f567ee8f authored by Hyunyoung Song's avatar Hyunyoung Song Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'am-47bc3657-4ec5-48ea-a081-c94faa8bfc8c' into ub-launcher3-dorval-polish2

* changes:
  PopupContainerWithArrow should align correctly in RTL mode Test: see attached screenshot in the bug am: 435a35de
  PopupContainerWithArrow should align correctly in RTL mode Test: see attached screenshot in the bug
parents 4dd5a5d1 febdbfca
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -399,6 +399,24 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
        openAnim.start();
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
        DragLayer dragLayer = mLauncher.getDragLayer();
        if (getTranslationX() + l < 0 ||
                getTranslationX() + l + getMeasuredWidth() > dragLayer.getWidth()) {
            // If we are still off screen, center horizontally too.
            mGravity |= Gravity.CENTER_HORIZONTAL;
        }

        if (Gravity.isHorizontal(mGravity)) {
            setX(dragLayer.getWidth() / 2 - getMeasuredWidth() / 2);
        }
        if (Gravity.isVertical(mGravity)) {
            setY(dragLayer.getHeight() / 2 - getMeasuredHeight() / 2);
        }
    }

    /**
     * Returns the point at which the center of the arrow merges with the first popup item.
     */
@@ -517,22 +535,9 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
            mIsAboveIcon = true;
        }

        if (x < dragLayer.getLeft() || x + width > dragLayer.getRight()) {
            // If we are still off screen, center horizontally too.
            mGravity |= Gravity.CENTER_HORIZONTAL;
        }

        if (Gravity.isHorizontal(mGravity)) {
            setX(dragLayer.getWidth() / 2 - getMeasuredWidth() / 2);
        } else {
        setX(x);
        }
        if (Gravity.isVertical(mGravity)) {
            setY(dragLayer.getHeight() / 2 - getMeasuredHeight() / 2);
        } else {
        setY(y);
    }
    }

    private boolean isAlignedWithStart() {
        return mIsLeftAligned && !mIsRtl || !mIsLeftAligned && mIsRtl;