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
This commit is contained in:
Schneider Victor-tulias 2020-09-25 12:32:08 -07:00
parent 91ef6856d7
commit 1b17d6be20
2 changed files with 39 additions and 21 deletions

View File

@ -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 * @param viewsToFlip number of views from the top to to flip in case of reverse order
*/ */
protected void reorderAndShow(int viewsToFlip) { 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); setVisibility(View.INVISIBLE);
mIsOpen = true; mIsOpen = true;
getPopupContainer().addView(this); getPopupContainer().addView(this);
orientAboutObject(); orientAboutObject();
}
boolean reverseOrder = mIsAboveIcon; private void reverseOrder(int viewsToFlip) {
if (reverseOrder) {
int count = getChildCount(); int count = getChildCount();
ArrayList<View> allViews = new ArrayList<>(count); ArrayList<View> allViews = new ArrayList<>(count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@ -174,9 +195,8 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac
orientAboutObject(); orientAboutObject();
} }
onInflationComplete(reverseOrder);
// Add the arrow. private void addArrow() {
final Resources res = getResources(); final Resources res = getResources();
final int arrowCenterOffset = res.getDimensionPixelSize(isAlignedWithStart() final int arrowCenterOffset = res.getDimensionPixelSize(isAlignedWithStart()
? R.dimen.popup_arrow_horizontal_center_start ? 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.setPivotX(arrowLp.width / 2);
mArrow.setPivotY(mIsAboveIcon ? arrowLp.height : 0); mArrow.setPivotY(mIsAboveIcon ? arrowLp.height : 0);
animateOpen();
} }
protected boolean isAlignedWithStart() { protected boolean isAlignedWithStart() {

View File

@ -133,7 +133,7 @@ public class OptionsPopupView extends ArrowPopup
view.setOnLongClickListener(popup); view.setOnLongClickListener(popup);
popup.mItemMap.put(view, item); popup.mItemMap.put(view, item);
} }
popup.reorderAndShow(popup.getChildCount()); popup.show();
} }
@VisibleForTesting @VisibleForTesting