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 ActionMenuView mMenuView;
|
||||||
protected ActionMenuPresenter mActionMenuPresenter;
|
protected ActionMenuPresenter mActionMenuPresenter;
|
||||||
protected ActionBarContainer mSplitView;
|
protected ActionBarContainer mSplitView;
|
||||||
|
protected boolean mSplitActionBar;
|
||||||
|
protected boolean mSplitWhenNarrow;
|
||||||
protected int mContentHeight;
|
protected int mContentHeight;
|
||||||
|
|
||||||
protected Animator mVisibilityAnim;
|
protected Animator mVisibilityAnim;
|
||||||
@@ -66,11 +68,31 @@ public abstract class AbsActionBarView extends ViewGroup {
|
|||||||
com.android.internal.R.attr.actionBarStyle, 0);
|
com.android.internal.R.attr.actionBarStyle, 0);
|
||||||
setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
|
setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
if (mSplitWhenNarrow) {
|
||||||
|
setSplitActionBar(getContext().getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.split_action_bar_is_narrow));
|
||||||
|
}
|
||||||
if (mActionMenuPresenter != null) {
|
if (mActionMenuPresenter != null) {
|
||||||
mActionMenuPresenter.onConfigurationChanged(newConfig);
|
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) {
|
public void setContentHeight(int height) {
|
||||||
mContentHeight = height;
|
mContentHeight = height;
|
||||||
requestLayout();
|
requestLayout();
|
||||||
|
|||||||
@@ -93,6 +93,39 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
|
|||||||
a.recycle();
|
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) {
|
public void setContentHeight(int height) {
|
||||||
mContentHeight = height;
|
mContentHeight = height;
|
||||||
}
|
}
|
||||||
@@ -179,7 +212,7 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
|
|||||||
|
|
||||||
final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
|
final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
|
||||||
LayoutParams.MATCH_PARENT);
|
LayoutParams.MATCH_PARENT);
|
||||||
if (mSplitView == null) {
|
if (!mSplitActionBar) {
|
||||||
menu.addMenuPresenter(mActionMenuPresenter);
|
menu.addMenuPresenter(mActionMenuPresenter);
|
||||||
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
|
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
|
||||||
mMenuView.setBackgroundDrawable(null);
|
mMenuView.setBackgroundDrawable(null);
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
private int mProgressStyle;
|
private int mProgressStyle;
|
||||||
private int mIndeterminateProgressStyle;
|
private int mIndeterminateProgressStyle;
|
||||||
|
|
||||||
private boolean mSplitActionBar;
|
|
||||||
private boolean mUserTitle;
|
private boolean mUserTitle;
|
||||||
private boolean mIncludeTabs;
|
private boolean mIncludeTabs;
|
||||||
private boolean mIsCollapsable;
|
private boolean mIsCollapsable;
|
||||||
@@ -301,6 +300,7 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
addView(mIndeterminateProgressView);
|
addView(mIndeterminateProgressView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setSplitActionBar(boolean splitActionBar) {
|
public void setSplitActionBar(boolean splitActionBar) {
|
||||||
if (mSplitActionBar != splitActionBar) {
|
if (mSplitActionBar != splitActionBar) {
|
||||||
if (mMenuView != null) {
|
if (mMenuView != null) {
|
||||||
@@ -316,7 +316,10 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
addView(mMenuView);
|
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;
|
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(
|
splitActionBar = getContext().getResources().getBoolean(
|
||||||
com.android.internal.R.bool.split_action_bar_is_narrow);
|
com.android.internal.R.bool.split_action_bar_is_narrow);
|
||||||
} else {
|
} else {
|
||||||
splitActionBar = getWindowStyle().getBoolean(
|
splitActionBar = getWindowStyle().getBoolean(
|
||||||
com.android.internal.R.styleable.Window_windowSplitActionBar, false);
|
com.android.internal.R.styleable.Window_windowSplitActionBar, false);
|
||||||
}
|
}
|
||||||
if (splitActionBar) {
|
final ActionBarContainer splitView = (ActionBarContainer) findViewById(
|
||||||
final ActionBarContainer splitView = (ActionBarContainer) findViewById(
|
com.android.internal.R.id.split_action_bar);
|
||||||
com.android.internal.R.id.split_action_bar);
|
if (splitView != null) {
|
||||||
if (splitView != null) {
|
mActionBar.setSplitView(splitView);
|
||||||
splitView.setVisibility(View.VISIBLE);
|
mActionBar.setSplitActionBar(splitActionBar);
|
||||||
mActionBar.setSplitActionBar(splitActionBar);
|
mActionBar.setSplitWhenNarrow(splitWhenNarrow);
|
||||||
mActionBar.setSplitView(splitView);
|
|
||||||
|
|
||||||
final ActionBarContextView cab = (ActionBarContextView) findViewById(
|
final ActionBarContextView cab = (ActionBarContextView) findViewById(
|
||||||
com.android.internal.R.id.action_context_bar);
|
com.android.internal.R.id.action_context_bar);
|
||||||
cab.setSplitView(splitView);
|
cab.setSplitView(splitView);
|
||||||
} else {
|
cab.setSplitActionBar(splitActionBar);
|
||||||
Log.e(TAG, "Requested split action bar with " +
|
cab.setSplitWhenNarrow(splitWhenNarrow);
|
||||||
"incompatible window decor! Ignoring request.");
|
} 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
|
// Post the panel invalidate for later; avoid application onCreateOptionsMenu
|
||||||
|
|||||||
Reference in New Issue
Block a user