diff options
| author | Adam Powell <adamp@google.com> | 2010-08-09 15:27:54 -0700 |
|---|---|---|
| committer | Adam Powell <adamp@google.com> | 2010-08-09 22:18:24 -0700 |
| commit | dec9dfd0f9f9ae23e4f126d765178fbd26a9eadb (patch) | |
| tree | 3bf55050649259ea260928965f92817a1ad7865f /core/java/android/app/Dialog.java | |
| parent | feb1a4e5e090eecbae2e5454b738870440349488 (diff) | |
Support ActionBar in Dialogs
Dialogs planning on using an ActionBar must have an appropriate
theme. (Later on this will likely be default.)
Change-Id: I7fbf5f76eed3d10765fddeaf211e4decb4e89f87
Diffstat (limited to 'core/java/android/app/Dialog.java')
| -rw-r--r-- | core/java/android/app/Dialog.java | 24 |
1 files changed, 21 insertions, 3 deletions
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; |
