summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-07-09 18:02:59 -0700
committerAdam Powell <adamp@google.com>2010-07-13 18:14:11 -0700
commit4267534d1c42af847ed0cefd1c88c99f66b36571 (patch)
tree86a49159ad830984d25b8f8184a692e09238c1b0 /policy
parent6ac7674e143f9716312f048da3f25ca83b646315 (diff)
downloadframeworks_base-4267534d1c42af847ed0cefd1c88c99f66b36571.zip
frameworks_base-4267534d1c42af847ed0cefd1c88c99f66b36571.tar.gz
frameworks_base-4267534d1c42af847ed0cefd1c88c99f66b36571.tar.bz2
Action Bar now supports submenus as popups.
Change-Id: I1691c16081b3474ed6d6e406f91f5f74a2dc8fcb
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 5c56d3c..879679f 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -27,6 +27,7 @@ import com.android.internal.view.RootViewSurfaceTaker;
import com.android.internal.view.menu.ContextMenuBuilder;
import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.view.menu.MenuDialogHelper;
+import com.android.internal.view.menu.MenuPopupHelper;
import com.android.internal.view.menu.MenuView;
import com.android.internal.view.menu.SubMenuBuilder;
import com.android.internal.widget.ActionBarView;
@@ -77,9 +78,12 @@ import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.ListPopupWindow;
import android.widget.ProgressBar;
import android.widget.TextView;
+import java.lang.ref.WeakReference;
+
/**
* Android-specific Window.
* <p>
@@ -96,7 +100,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
* Simple callback used by the context menu and its submenus. The options
* menu submenus do not use this (their behavior is more complex).
*/
- ContextMenuCallback mContextMenuCallback = new ContextMenuCallback(FEATURE_CONTEXT_MENU);
+ DialogMenuCallback mContextMenuCallback = new DialogMenuCallback(FEATURE_CONTEXT_MENU);
// This is the top-level view of the window, containing the window decor.
private DecorView mDecor;
@@ -808,8 +812,20 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
return true;
}
- // The window manager will give us a valid window token
- new MenuDialogHelper(subMenu).show(null);
+ final Menu parentMenu = subMenu.getRootMenu();
+ final PanelFeatureState panel = findMenuPanel(parentMenu);
+
+ /*
+ * Use the panel open state to determine whether this is coming from an open panel
+ * or an action button. If it's an open panel we want to use MenuDialogHelper.
+ * If it's closed we want to grab the relevant view and create a popup anchored to it.
+ */
+ if (panel.isOpen) {
+ // The window manager will give us a valid window token
+ new MenuDialogHelper(subMenu).show(null);
+ } else {
+ new MenuPopupHelper(getContext(), subMenu).show();
+ }
return true;
}
@@ -2797,11 +2813,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
* <li> Calls back to the callback's onMenuItemSelected when an item is
* selected.
*/
- private final class ContextMenuCallback implements MenuBuilder.Callback {
+ private final class DialogMenuCallback implements MenuBuilder.Callback {
private int mFeatureId;
private MenuDialogHelper mSubMenuHelper;
- public ContextMenuCallback(int featureId) {
+ public DialogMenuCallback(int featureId) {
mFeatureId = featureId;
}