Moved context modes into view, renamed to action modes
ContextualMode renamed to ActionMode. Adds a reference to the action
bar and reduces confusion around things named "Context".
Change-Id: Ia5098b1d0799a0ece0810c34e6696eda039fb005
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 431f66d..61fd5f3 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -16,8 +16,8 @@
package android.app;
-import java.util.ArrayList;
-import java.util.HashMap;
+import com.android.internal.app.ActionBarImpl;
+import com.android.internal.policy.PolicyManager;
import android.content.ComponentCallbacks;
import android.content.ComponentName;
@@ -52,7 +52,9 @@
import android.util.EventLog;
import android.util.Log;
import android.util.SparseArray;
+import android.view.ActionMode;
import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
import android.view.ContextThemeWrapper;
import android.view.InflateException;
import android.view.KeyEvent;
@@ -62,21 +64,18 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
+import android.view.View.OnCreateContextMenuListener;
import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
import android.view.ViewManager;
import android.view.Window;
import android.view.WindowManager;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.View.OnCreateContextMenuListener;
-import android.view.ViewGroup.LayoutParams;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AdapterView;
import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-import com.android.internal.app.ActionBarImpl;
-import com.android.internal.policy.PolicyManager;
-import com.android.internal.widget.ActionBarView;
+import java.util.ArrayList;
+import java.util.HashMap;
/**
* An activity is a single, focused thing that the user can do. Almost all
@@ -4073,6 +4072,25 @@
}
}
+ /**
+ * Start a context mode.
+ *
+ * @param callback Callback that will manage lifecycle events for this context mode
+ * @return The ContextMode that was started, or null if it was canceled
+ *
+ * @see ActionMode
+ */
+ public ActionMode startContextMode(ActionMode.Callback callback) {
+ return mWindow.getDecorView().startActionMode(callback);
+ }
+
+ public ActionMode onStartActionMode(ActionMode.Callback callback) {
+ if (mActionBar != null) {
+ return mActionBar.startContextMode(callback);
+ }
+ return null;
+ }
+
// ------------------ Internal API ------------------
final void setParent(Activity parent) {
@@ -4286,19 +4304,4 @@
}
}
}
-
- @Override
- public ContextualMode startContextualMode(ContextualMode.Callback callback) {
- if (mActionBar == null) {
- return null;
- }
- return mActionBar.startContextualMode(callback);
- }
-
- @Override
- public void finishContextualMode() {
- if (mActionBar != null) {
- mActionBar.finishContextualMode();
- }
- }
}