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

Commit 1b17d6be authored by Schneider Victor-tulias's avatar Schneider Victor-tulias
Browse files

Make the workspace popup menu items statically ordered.

Test: manual

Fixes: 160190991.

Reordering the workspace's popup menu items breaks muscle memory of getting to the wallpaper and home settings. Added ArrowPopup#show and refactored ArrowPopup#reorderAndShow to allow more flexbility.

Change-Id: I3fa327d08488a52312c86769bb9a065ccacb17aa
parent 91ef6856
Loading
Loading
Loading
Loading
+38 −20
Original line number Diff line number Diff line
@@ -151,13 +151,34 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac
     * @param viewsToFlip number of views from the top to to flip in case of reverse order
     */
    protected void reorderAndShow(int viewsToFlip) {
        setupForDisplay();
        boolean reverseOrder = mIsAboveIcon;
        if (reverseOrder) {
            reverseOrder(viewsToFlip);
        }
        onInflationComplete(reverseOrder);
        addArrow();
        animateOpen();
    }

    /**
     * Shows the popup at the desired location.
     */
    protected void show() {
        setupForDisplay();
        onInflationComplete(false);
        addArrow();
        animateOpen();
    }

    private void setupForDisplay() {
        setVisibility(View.INVISIBLE);
        mIsOpen = true;
        getPopupContainer().addView(this);
        orientAboutObject();
    }

        boolean reverseOrder = mIsAboveIcon;
        if (reverseOrder) {
    private void reverseOrder(int viewsToFlip) {
        int count = getChildCount();
        ArrayList<View> allViews = new ArrayList<>(count);
        for (int i = 0; i < count; i++) {
@@ -174,9 +195,8 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac

        orientAboutObject();
    }
        onInflationComplete(reverseOrder);

        // Add the arrow.
    private void addArrow() {
        final Resources res = getResources();
        final int arrowCenterOffset = res.getDimensionPixelSize(isAlignedWithStart()
                ? R.dimen.popup_arrow_horizontal_center_start
@@ -214,8 +234,6 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac

        mArrow.setPivotX(arrowLp.width / 2);
        mArrow.setPivotY(mIsAboveIcon ? arrowLp.height : 0);

        animateOpen();
    }

    protected boolean isAlignedWithStart() {
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public class OptionsPopupView extends ArrowPopup
            view.setOnLongClickListener(popup);
            popup.mItemMap.put(view, item);
        }
        popup.reorderAndShow(popup.getChildCount());
        popup.show();
    }

    @VisibleForTesting