Skip to content

Commit cb46643

Browse files
committed
Fix bugs with popup menu in Recent Applications
Don't allow user to drag thumbnails when popup menu is showing Bug: 5144612 Dismiss popup menu when hitting home button Bug: 6163724 Change-Id: I4ae1fd118d1a26562832affcd75a8ab1cc53a665
1 parent fbdff47 commit cb46643

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
6868
static final boolean DEBUG = TabletStatusBar.DEBUG || PhoneStatusBar.DEBUG || false;
6969
private Context mContext;
7070
private BaseStatusBar mBar;
71+
private PopupMenu mPopup;
7172
private View mRecentsScrim;
7273
private View mRecentsNoApps;
7374
private ViewGroup mRecentsContainer;
@@ -313,6 +314,10 @@ public void show(boolean show, boolean animate,
313314
setFocusable(true);
314315
setFocusableInTouchMode(true);
315316
requestFocus();
317+
} else {
318+
if (mPopup != null) {
319+
mPopup.dismiss();
320+
}
316321
}
317322
}
318323

@@ -325,6 +330,7 @@ public void hide(boolean animate) {
325330
setVisibility(View.GONE);
326331
}
327332
if (mBar != null) {
333+
// This will indirectly cause show(false, ...) to get called
328334
mBar.animateCollapse();
329335
}
330336
}
@@ -729,10 +735,20 @@ private void startApplicationDetailsActivity(String packageName) {
729735
getContext().startActivity(intent);
730736
}
731737

738+
public boolean onInterceptTouchEvent(MotionEvent ev) {
739+
if (mPopup != null) {
740+
return true;
741+
} else {
742+
return super.onInterceptTouchEvent(ev);
743+
}
744+
}
745+
732746
public void handleLongPress(
733747
final View selectedView, final View anchorView, final View thumbnailView) {
734748
thumbnailView.setSelected(true);
735-
PopupMenu popup = new PopupMenu(mContext, anchorView == null ? selectedView : anchorView);
749+
final PopupMenu popup =
750+
new PopupMenu(mContext, anchorView == null ? selectedView : anchorView);
751+
mPopup = popup;
736752
popup.getMenuInflater().inflate(R.menu.recent_popup_menu, popup.getMenu());
737753
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
738754
public boolean onMenuItemClick(MenuItem item) {
@@ -756,6 +772,7 @@ public boolean onMenuItemClick(MenuItem item) {
756772
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
757773
public void onDismiss(PopupMenu menu) {
758774
thumbnailView.setSelected(false);
775+
mPopup = null;
759776
}
760777
});
761778
popup.show();

0 commit comments

Comments
 (0)