Skip to content

Commit 8917838

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug 5386180 - Wire up action bar home/up for dialogs"
2 parents edb8b62 + 915ce0d commit 8917838

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

core/java/com/android/internal/widget/ActionBarView.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ public class ActionBarView extends AbsActionBarView {
132132
private ExpandedActionViewMenuPresenter mExpandedMenuPresenter;
133133
View mExpandedActionView;
134134

135+
Window.Callback mWindowCallback;
136+
135137
private final AdapterView.OnItemSelectedListener mNavItemSelectedListener =
136138
new AdapterView.OnItemSelectedListener() {
137139
public void onItemSelected(AdapterView parent, View view, int position, long id) {
@@ -156,11 +158,7 @@ public void onClick(View v) {
156158

157159
private final OnClickListener mUpClickListener = new OnClickListener() {
158160
public void onClick(View v) {
159-
Context context = getContext();
160-
if (context instanceof Activity) {
161-
Activity activity = (Activity) context;
162-
activity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
163-
}
161+
mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
164162
}
165163
};
166164

@@ -275,6 +273,14 @@ protected void onConfigurationChanged(Configuration newConfig) {
275273
}
276274
}
277275

276+
/**
277+
* Set the window callback used to invoke menu items; used for dispatching home button presses.
278+
* @param cb Window callback to dispatch to
279+
*/
280+
public void setWindowCallback(Window.Callback cb) {
281+
mWindowCallback = cb;
282+
}
283+
278284
@Override
279285
public void onDetachedFromWindow() {
280286
super.onDetachedFromWindow();

policy/src/com/android/internal/policy/impl/PhoneWindow.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,7 @@ private void installDecor() {
27502750
} else {
27512751
mActionBar = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
27522752
if (mActionBar != null) {
2753+
mActionBar.setWindowCallback(getCallback());
27532754
if (mActionBar.getTitle() == null) {
27542755
mActionBar.setWindowTitle(mTitle);
27552756
}

0 commit comments

Comments
 (0)