diff options
author | Michael Kolb <kolby@google.com> | 2011-07-18 14:50:21 -0700 |
---|---|---|
committer | Michael Kolb <kolby@google.com> | 2011-07-18 14:58:37 -0700 |
commit | 8441d4bdc99f8e4a84d8292c7c2a6cdf4e562fff (patch) | |
tree | e66c8610e1a5248f3a7281d416db45a35fc41dca /src/com | |
parent | adb0e605def2c4011735cacd46835ca1e38e2eb3 (diff) | |
download | packages_apps_Browser-8441d4bdc99f8e4a84d8292c7c2a6cdf4e562fff.zip packages_apps_Browser-8441d4bdc99f8e4a84d8292c7c2a6cdf4e562fff.tar.gz packages_apps_Browser-8441d4bdc99f8e4a84d8292c7c2a6cdf4e562fff.tar.bz2 |
show menu on phone with menu key
Bug: 5017628
show the menu anchored to the tab switcher button
Change-Id: I99baa1978d4c0a99b0fe17fee198ddd5b7db1b76
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/browser/NavigationBarPhone.java | 30 | ||||
-rw-r--r-- | src/com/android/browser/PhoneUi.java | 6 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/com/android/browser/NavigationBarPhone.java b/src/com/android/browser/NavigationBarPhone.java index 684f986..2da0424 100644 --- a/src/com/android/browser/NavigationBarPhone.java +++ b/src/com/android/browser/NavigationBarPhone.java @@ -45,7 +45,7 @@ public class NavigationBarPhone extends NavigationBarBase implements private View mTitleContainer; private View mMore; private Drawable mTextfieldBgDrawable; - private boolean mMenuShowing; + private PopupMenu mPopupMenu; private boolean mNeedsMenu; public NavigationBarPhone(Context context) { @@ -163,18 +163,28 @@ public class NavigationBarPhone extends NavigationBarBase implements } public boolean isMenuShowing() { - return mMenuShowing; + return (mPopupMenu != null); + } + + void showMenu() { + // called from menu key, use tab switcher as anchor + showMenu(mTabSwitcher); } void showMenu(View anchor) { - mMenuShowing = true; - PopupMenu popup = new PopupMenu(mContext, anchor); - Menu menu = popup.getMenu(); - popup.getMenuInflater().inflate(R.menu.browser, menu); + mPopupMenu = new PopupMenu(mContext, anchor); + Menu menu = mPopupMenu.getMenu(); + mPopupMenu.getMenuInflater().inflate(R.menu.browser, menu); mUiController.updateMenuState(mBaseUi.getActiveTab(), menu); - popup.setOnMenuItemClickListener(this); - popup.setOnDismissListener(this); - popup.show(); + mPopupMenu.setOnMenuItemClickListener(this); + mPopupMenu.setOnDismissListener(this); + mPopupMenu.show(); + } + + void dismissMenu() { + if (mPopupMenu != null) { + mPopupMenu.dismiss(); + } } @Override @@ -193,7 +203,7 @@ public class NavigationBarPhone extends NavigationBarBase implements } private void onMenuHidden() { - mMenuShowing = false; + mPopupMenu = null; mBaseUi.showTitleBarForDuration(); } diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java index 6c484db..99320b7 100644 --- a/src/com/android/browser/PhoneUi.java +++ b/src/com/android/browser/PhoneUi.java @@ -79,10 +79,10 @@ public class PhoneUi extends BaseUi { @Override public boolean onMenuKey() { - if (mNavScreen == null) { - showNavScreen(); + if (mNavigationBar.isMenuShowing()) { + mNavigationBar.dismissMenu(); } else { - mNavScreen.close(); + mNavigationBar.showMenu(); } return true; } |