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
This commit is contained in:
Adam Powell
2010-08-09 15:27:54 -07:00
parent feb1a4e5e0
commit dec9dfd0f9
3 changed files with 57 additions and 22 deletions

View File

@@ -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}
@@ -177,6 +179,15 @@ public class Dialog implements DialogInterface, Window.Callback,
return mContext;
}
/**
* 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;