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:
parent
91ef6856d7
commit
1b17d6be20
|
@ -151,32 +151,52 @@ 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) {
|
||||
int count = getChildCount();
|
||||
ArrayList<View> allViews = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (i == viewsToFlip) {
|
||||
Collections.reverse(allViews);
|
||||
}
|
||||
allViews.add(getChildAt(i));
|
||||
private void reverseOrder(int viewsToFlip) {
|
||||
int count = getChildCount();
|
||||
ArrayList<View> allViews = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (i == viewsToFlip) {
|
||||
Collections.reverse(allViews);
|
||||
}
|
||||
Collections.reverse(allViews);
|
||||
removeAllViews();
|
||||
for (int i = 0; i < count; i++) {
|
||||
addView(allViews.get(i));
|
||||
}
|
||||
|
||||
orientAboutObject();
|
||||
allViews.add(getChildAt(i));
|
||||
}
|
||||
Collections.reverse(allViews);
|
||||
removeAllViews();
|
||||
for (int i = 0; i < count; i++) {
|
||||
addView(allViews.get(i));
|
||||
}
|
||||
onInflationComplete(reverseOrder);
|
||||
|
||||
// Add the arrow.
|
||||
orientAboutObject();
|
||||
}
|
||||
|
||||
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() {
|
||||
|
|
|
@ -133,7 +133,7 @@ public class OptionsPopupView extends ArrowPopup
|
|||
view.setOnLongClickListener(popup);
|
||||
popup.mItemMap.put(view, item);
|
||||
}
|
||||
popup.reorderAndShow(popup.getChildCount());
|
||||
popup.show();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
|
Loading…
Reference in New Issue