Add Fragment option menu APIs.
Also fix up how transactions are handled so that a series of transactions
can correctly be created and committed.
Change-Id: I948ba47d49e9b2246a1958bd9eac9dd36dc5a855
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index d64f2c5..98505c5 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -77,9 +77,6 @@
import com.android.internal.app.SplitActionBar;
import com.android.internal.policy.PolicyManager;
-import java.util.ArrayList;
-import java.util.HashMap;
-
/**
* An activity is a single, focused thing that the user can do. Almost all
* activities interact with the user, so the Activity class takes care of
@@ -2242,7 +2239,9 @@
*/
public boolean onCreatePanelMenu(int featureId, Menu menu) {
if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onCreateOptionsMenu(menu);
+ boolean show = onCreateOptionsMenu(menu);
+ show |= mFragments.dispatchCreateOptionsMenu(menu, getMenuInflater());
+ return show;
}
return false;
}
@@ -2259,6 +2258,7 @@
public boolean onPreparePanel(int featureId, View view, Menu menu) {
if (featureId == Window.FEATURE_OPTIONS_PANEL && menu != null) {
boolean goforit = onPrepareOptionsMenu(menu);
+ goforit |= mFragments.dispatchPrepareOptionsMenu(menu);
return goforit && menu.hasVisibleItems();
}
return true;
@@ -2289,7 +2289,10 @@
// doesn't call through to superclass's implmeentation of each
// of these methods below
EventLog.writeEvent(50000, 0, item.getTitleCondensed());
- return onOptionsItemSelected(item);
+ if (onOptionsItemSelected(item)) {
+ return true;
+ }
+ return mFragments.dispatchOptionsItemSelected(item);
case Window.FEATURE_CONTEXT_MENU:
EventLog.writeEvent(50000, 1, item.getTitleCondensed());
@@ -2312,6 +2315,7 @@
public void onPanelClosed(int featureId, Menu menu) {
switch (featureId) {
case Window.FEATURE_OPTIONS_PANEL:
+ mFragments.dispatchOptionsMenuClosed(menu);
onOptionsMenuClosed(menu);
break;
@@ -2322,6 +2326,15 @@
}
/**
+ * Declare that the options menu has changed, so should be recreated.
+ * The {@link #onCreateOptionsMenu(Menu)} method will be called the next
+ * time it needs to be displayed.
+ */
+ public void invalidateOptionsMenu() {
+ mWindow.invalidatePanelMenu(Window.FEATURE_OPTIONS_PANEL);
+ }
+
+ /**
* Initialize the contents of the Activity's standard options menu. You
* should place your menu items in to <var>menu</var>.
*
@@ -3887,6 +3900,7 @@
fragment.mFromLayout = true;
fragment.mFragmentId = id;
fragment.mTag = tag;
+ fragment.mImmediateActivity = this;
mFragments.addFragment(fragment, true);
}
// If this fragment is newly instantiated (either right now, or