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

Commit 7525b6ee authored by kaiyiz's avatar kaiyiz
Browse files

Fix PopupWindow of overflow menu is not RTL(Right to Left) issue

Sometimes, PopupWindow doesn't update layout direction in time when the
layout direction of its anchor view changes.

Update the layout direction of PopupWindow when the layout direction of
its anchor view changes.

CRs-Fixed: 759907

Change-Id: I1141e83b7f4b0cda4e52082608d002500efe4088
parent 7b22df7e
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -1067,6 +1067,17 @@ public class PopupWindow {
        }
    }

    private boolean isNeedSetLayoutDirectionFromAnchor() {
        if (mPopupViewInitialLayoutDirectionInherited && mPopupView != null && mAnchor != null) {
            View anchor = mAnchor.get();
            if (anchor != null
                    && (mPopupView.getLayoutDirection() != anchor.getLayoutDirection())) {
                return true;
            }
        }
        return false;
    }

    /**
     * <p>Generate the layout parameters for the popup window.</p>
     *
@@ -1405,6 +1416,10 @@ public class PopupWindow {
            update = true;
        }

        if (isNeedSetLayoutDirectionFromAnchor()) {
            update = true;
        }

        if (update) {
            setLayoutDirectionFromAnchor();
            mWindowManager.updateViewLayout(mPopupView, p);
@@ -1506,6 +1521,10 @@ public class PopupWindow {
            update = true;
        }

        if (isNeedSetLayoutDirectionFromAnchor()) {
            update = true;
        }

        if (update) {
            setLayoutDirectionFromAnchor();
            mWindowManager.updateViewLayout(mPopupView, p);