summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.xml22
-rw-r--r--core/java/android/app/Dialog.java24
-rw-r--r--core/java/com/android/internal/app/ActionBarImpl.java33
3 files changed, 57 insertions, 22 deletions
diff --git a/api/current.xml b/api/current.xml
index b7eec9934cfe..a944213cc79d 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -26353,6 +26353,17 @@
<parameter name="id" type="int">
</parameter>
</method>
+<method name="getActionBar"
+ return="android.app.ActionBar"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getContext"
return="android.content.Context"
abstract="false"
@@ -213236,17 +213247,6 @@
visibility="public"
>
</method>
-<method name="getVisibleTitleHeight"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
<method name="getZoomControls"
return="android.view.View"
abstract="false"
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index a9420b4edeff..b4c138e1660e 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -16,6 +16,7 @@
package android.app;
+import com.android.internal.app.ActionBarImpl;
import com.android.internal.policy.PolicyManager;
import android.content.ComponentName;
@@ -27,9 +28,9 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.view.ActionMode;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
-import android.view.ActionMode;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -77,6 +78,7 @@ public class Dialog implements DialogInterface, Window.Callback,
final WindowManager mWindowManager;
Window mWindow;
View mDecor;
+ private ActionBarImpl mActionBar;
/**
* This field should be made private, so it is hidden from the SDK.
* {@hide}
@@ -178,6 +180,15 @@ public class Dialog implements DialogInterface, Window.Callback,
}
/**
+ * Retrieve the {@link ActionBar} attached to this dialog, if present.
+ *
+ * @return The ActionBar attached to the dialog or null if no ActionBar is present.
+ */
+ public ActionBar getActionBar() {
+ return mActionBar;
+ }
+
+ /**
* Sets the Activity that owns this dialog. An example use: This Dialog will
* use the suggested volume control stream of the Activity.
*
@@ -228,6 +239,11 @@ public class Dialog implements DialogInterface, Window.Callback,
onStart();
mDecor = mWindow.getDecorView();
+
+ if (mActionBar == null && mWindow.hasFeature(Window.FEATURE_ACTION_BAR)) {
+ mActionBar = new ActionBarImpl(this);
+ }
+
WindowManager.LayoutParams l = mWindow.getAttributes();
if ((l.softInputMode
& WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION) == 0) {
@@ -834,12 +850,14 @@ public class Dialog implements DialogInterface, Window.Callback,
}
public ActionMode onStartActionMode(ActionMode.Callback callback) {
- // TODO Support context modes in dialogs
+ if (mActionBar != null) {
+ return mActionBar.startActionMode(callback);
+ }
return null;
}
/**
- * @return The activity associated with this dialog, or null if there is no assocaited activity.
+ * @return The activity associated with this dialog, or null if there is no associated activity.
*/
private ComponentName getAssociatedActivity() {
Activity activity = mOwnerActivity;
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 281f32c83224..6b5240990e99 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -24,8 +24,10 @@ import com.android.internal.widget.ActionBarView;
import android.app.ActionBar;
import android.app.Activity;
+import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentTransaction;
+import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.view.ActionMode;
@@ -54,7 +56,9 @@ public class ActionBarImpl extends ActionBar {
private static final int TAB_SWITCH_SHOW_HIDE = 0;
private static final int TAB_SWITCH_ADD_REMOVE = 1;
+ private Context mContext;
private Activity mActivity;
+ private Dialog mDialog;
private ViewAnimator mAnimatorView;
private ActionBarView mActionView;
@@ -88,8 +92,17 @@ public class ActionBarImpl extends ActionBar {
};
public ActionBarImpl(Activity activity) {
- final View decor = activity.getWindow().getDecorView();
mActivity = activity;
+ init(activity.getWindow().getDecorView());
+ }
+
+ public ActionBarImpl(Dialog dialog) {
+ mDialog = dialog;
+ init(dialog.getWindow().getDecorView());
+ }
+
+ private void init(View decor) {
+ mContext = decor.getContext();
mActionView = (ActionBarView) decor.findViewById(com.android.internal.R.id.action_bar);
mUpperContextView = (ActionBarContextView) decor.findViewById(
com.android.internal.R.id.action_context_bar);
@@ -109,23 +122,23 @@ public class ActionBarImpl extends ActionBar {
@Override
public void setStandardNavigationMode(int titleResId, int subtitleResId) {
- setStandardNavigationMode(mActivity.getString(titleResId),
- mActivity.getString(subtitleResId));
+ setStandardNavigationMode(mContext.getString(titleResId),
+ mContext.getString(subtitleResId));
}
@Override
public void setStandardNavigationMode(int titleResId) {
- setStandardNavigationMode(mActivity.getString(titleResId));
+ setStandardNavigationMode(mContext.getString(titleResId));
}
@Override
public void setTitle(int resId) {
- setTitle(mActivity.getString(resId));
+ setTitle(mContext.getString(resId));
}
@Override
public void setSubtitle(int resId) {
- setSubtitle(mActivity.getString(resId));
+ setSubtitle(mContext.getString(resId));
}
public void setCustomNavigationMode(View view) {
@@ -345,6 +358,10 @@ public class ActionBarImpl extends ActionBar {
@Override
public void setTabNavigationMode() {
+ if (mActivity == null) {
+ throw new IllegalStateException(
+ "Tab navigation mode cannot be used outside of an Activity");
+ }
mActionView.setNavigationMode(NAVIGATION_MODE_TABS);
}
@@ -396,7 +413,7 @@ public class ActionBarImpl extends ActionBar {
@Override
public MenuInflater getMenuInflater() {
- return new MenuInflater(mActivity);
+ return new MenuInflater(mContext);
}
@Override
@@ -485,7 +502,7 @@ public class ActionBarImpl extends ActionBar {
return true;
}
- new MenuPopupHelper(mActivity, subMenu).show();
+ new MenuPopupHelper(mContext, subMenu).show();
return true;
}