Merge "Fix bug 5341139 - bottom bar stays if app wants to handle orientation change"
This commit is contained in:
@@ -35,6 +35,8 @@ public abstract class AbsActionBarView extends ViewGroup {
|
||||
protected ActionMenuView mMenuView;
|
||||
protected ActionMenuPresenter mActionMenuPresenter;
|
||||
protected ActionBarContainer mSplitView;
|
||||
protected boolean mSplitActionBar;
|
||||
protected boolean mSplitWhenNarrow;
|
||||
protected int mContentHeight;
|
||||
|
||||
protected Animator mVisibilityAnim;
|
||||
@@ -66,11 +68,31 @@ public abstract class AbsActionBarView extends ViewGroup {
|
||||
com.android.internal.R.attr.actionBarStyle, 0);
|
||||
setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
|
||||
a.recycle();
|
||||
if (mSplitWhenNarrow) {
|
||||
setSplitActionBar(getContext().getResources().getBoolean(
|
||||
com.android.internal.R.bool.split_action_bar_is_narrow));
|
||||
}
|
||||
if (mActionMenuPresenter != null) {
|
||||
mActionMenuPresenter.onConfigurationChanged(newConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the bar should be split right now, no questions asked.
|
||||
* @param split true if the bar should split
|
||||
*/
|
||||
public void setSplitActionBar(boolean split) {
|
||||
mSplitActionBar = split;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the bar should split if we enter a narrow screen configuration.
|
||||
* @param splitWhenNarrow true if the bar should check to split after a config change
|
||||
*/
|
||||
public void setSplitWhenNarrow(boolean splitWhenNarrow) {
|
||||
mSplitWhenNarrow = splitWhenNarrow;
|
||||
}
|
||||
|
||||
public void setContentHeight(int height) {
|
||||
mContentHeight = height;
|
||||
requestLayout();
|
||||
|
||||
@@ -93,6 +93,39 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitActionBar(boolean split) {
|
||||
if (mSplitActionBar != split) {
|
||||
if (mActionMenuPresenter != null) {
|
||||
// Mode is already active; move everything over and adjust the menu itself.
|
||||
final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
|
||||
LayoutParams.MATCH_PARENT);
|
||||
if (!split) {
|
||||
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
|
||||
mMenuView.setBackgroundDrawable(null);
|
||||
final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
|
||||
if (oldParent != null) oldParent.removeView(mMenuView);
|
||||
addView(mMenuView, layoutParams);
|
||||
} else {
|
||||
// Allow full screen width in split mode.
|
||||
mActionMenuPresenter.setWidthLimit(
|
||||
getContext().getResources().getDisplayMetrics().widthPixels, true);
|
||||
// No limit to the item count; use whatever will fit.
|
||||
mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
|
||||
// Span the whole width
|
||||
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = mContentHeight;
|
||||
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
|
||||
mMenuView.setBackgroundDrawable(mSplitBackground);
|
||||
final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
|
||||
if (oldParent != null) oldParent.removeView(mMenuView);
|
||||
mSplitView.addView(mMenuView, layoutParams);
|
||||
}
|
||||
}
|
||||
super.setSplitActionBar(split);
|
||||
}
|
||||
}
|
||||
|
||||
public void setContentHeight(int height) {
|
||||
mContentHeight = height;
|
||||
}
|
||||
@@ -179,7 +212,7 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
|
||||
|
||||
final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
|
||||
LayoutParams.MATCH_PARENT);
|
||||
if (mSplitView == null) {
|
||||
if (!mSplitActionBar) {
|
||||
menu.addMenuPresenter(mActionMenuPresenter);
|
||||
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
|
||||
mMenuView.setBackgroundDrawable(null);
|
||||
|
||||
@@ -113,7 +113,6 @@ public class ActionBarView extends AbsActionBarView {
|
||||
private int mProgressStyle;
|
||||
private int mIndeterminateProgressStyle;
|
||||
|
||||
private boolean mSplitActionBar;
|
||||
private boolean mUserTitle;
|
||||
private boolean mIncludeTabs;
|
||||
private boolean mIsCollapsable;
|
||||
@@ -301,6 +300,7 @@ public class ActionBarView extends AbsActionBarView {
|
||||
addView(mIndeterminateProgressView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitActionBar(boolean splitActionBar) {
|
||||
if (mSplitActionBar != splitActionBar) {
|
||||
if (mMenuView != null) {
|
||||
@@ -316,7 +316,10 @@ public class ActionBarView extends AbsActionBarView {
|
||||
addView(mMenuView);
|
||||
}
|
||||
}
|
||||
mSplitActionBar = splitActionBar;
|
||||
if (mSplitView != null) {
|
||||
mSplitView.setVisibility(splitActionBar ? VISIBLE : GONE);
|
||||
}
|
||||
super.setSplitActionBar(splitActionBar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2762,28 +2762,30 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
}
|
||||
|
||||
boolean splitActionBar = false;
|
||||
if ((mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0) {
|
||||
final boolean splitWhenNarrow =
|
||||
(mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0;
|
||||
if (splitWhenNarrow) {
|
||||
splitActionBar = getContext().getResources().getBoolean(
|
||||
com.android.internal.R.bool.split_action_bar_is_narrow);
|
||||
} else {
|
||||
splitActionBar = getWindowStyle().getBoolean(
|
||||
com.android.internal.R.styleable.Window_windowSplitActionBar, false);
|
||||
}
|
||||
if (splitActionBar) {
|
||||
final ActionBarContainer splitView = (ActionBarContainer) findViewById(
|
||||
com.android.internal.R.id.split_action_bar);
|
||||
if (splitView != null) {
|
||||
splitView.setVisibility(View.VISIBLE);
|
||||
mActionBar.setSplitActionBar(splitActionBar);
|
||||
mActionBar.setSplitView(splitView);
|
||||
final ActionBarContainer splitView = (ActionBarContainer) findViewById(
|
||||
com.android.internal.R.id.split_action_bar);
|
||||
if (splitView != null) {
|
||||
mActionBar.setSplitView(splitView);
|
||||
mActionBar.setSplitActionBar(splitActionBar);
|
||||
mActionBar.setSplitWhenNarrow(splitWhenNarrow);
|
||||
|
||||
final ActionBarContextView cab = (ActionBarContextView) findViewById(
|
||||
com.android.internal.R.id.action_context_bar);
|
||||
cab.setSplitView(splitView);
|
||||
} else {
|
||||
Log.e(TAG, "Requested split action bar with " +
|
||||
"incompatible window decor! Ignoring request.");
|
||||
}
|
||||
final ActionBarContextView cab = (ActionBarContextView) findViewById(
|
||||
com.android.internal.R.id.action_context_bar);
|
||||
cab.setSplitView(splitView);
|
||||
cab.setSplitActionBar(splitActionBar);
|
||||
cab.setSplitWhenNarrow(splitWhenNarrow);
|
||||
} else if (splitActionBar) {
|
||||
Log.e(TAG, "Requested split action bar with " +
|
||||
"incompatible window decor! Ignoring request.");
|
||||
}
|
||||
|
||||
// Post the panel invalidate for later; avoid application onCreateOptionsMenu
|
||||
|
||||
Reference in New Issue
Block a user