Merge "Fix bug 5279075 - Handle action bar config changes when action mode is active"

This commit is contained in:
Adam Powell
2011-09-08 18:23:26 -07:00
committed by Android (Google) Code Review
3 changed files with 37 additions and 33 deletions

View File

@@ -15,6 +15,7 @@
*/
package com.android.internal.widget;
import com.android.internal.R;
import com.android.internal.view.menu.ActionMenuPresenter;
import com.android.internal.view.menu.ActionMenuView;
@@ -23,6 +24,8 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
@@ -32,6 +35,7 @@ public abstract class AbsActionBarView extends ViewGroup {
protected ActionMenuView mMenuView;
protected ActionMenuPresenter mActionMenuPresenter;
protected ActionBarContainer mSplitView;
protected int mContentHeight;
protected Animator mVisibilityAnim;
protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener();
@@ -52,6 +56,30 @@ public abstract class AbsActionBarView extends ViewGroup {
super(context, attrs, defStyle);
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Action bar can change size on configuration changes.
// Reread the desired height from the theme-specified style.
TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar,
com.android.internal.R.attr.actionBarStyle, 0);
setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
a.recycle();
if (mActionMenuPresenter != null) {
mActionMenuPresenter.onConfigurationChanged(newConfig);
}
}
public void setContentHeight(int height) {
mContentHeight = height;
requestLayout();
}
public int getContentHeight() {
return mContentHeight;
}
public void setSplitView(ActionBarContainer splitView) {
mSplitView = splitView;
}

View File

@@ -44,8 +44,6 @@ import android.widget.TextView;
public class ActionBarContextView extends AbsActionBarView implements AnimatorListener {
private static final String TAG = "ActionBarContextView";
private int mContentHeight;
private CharSequence mTitle;
private CharSequence mSubtitle;
@@ -94,15 +92,7 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
a.recycle();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (mActionMenuPresenter != null) {
mActionMenuPresenter.onConfigurationChanged(newConfig);
}
}
public void setHeight(int height) {
public void setContentHeight(int height) {
mContentHeight = height;
}

View File

@@ -84,8 +84,6 @@ public class ActionBarView extends AbsActionBarView {
private static final int DEFAULT_CUSTOM_GRAVITY = Gravity.LEFT | Gravity.CENTER_VERTICAL;
private int mContentHeight;
private int mNavigationMode;
private int mDisplayOptions = -1;
private CharSequence mTitle;
@@ -257,16 +255,6 @@ public class ActionBarView extends AbsActionBarView {
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Action bar can change size on configuration changes.
// Reread the desired height from the theme-specified style.
TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar,
com.android.internal.R.attr.actionBarStyle, 0);
setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
a.recycle();
if (mActionMenuPresenter != null) {
mActionMenuPresenter.onConfigurationChanged(newConfig);
}
mTitleView = null;
mSubtitleView = null;
mTitleUpView = null;
@@ -277,6 +265,13 @@ public class ActionBarView extends AbsActionBarView {
if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
initTitle();
}
if (mTabScrollView != null && mIncludeTabs) {
ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams();
lp.width = LayoutParams.WRAP_CONTENT;
lp.height = LayoutParams.MATCH_PARENT;
mTabScrollView.setAllowCollapse(true);
}
}
@Override
@@ -304,15 +299,6 @@ public class ActionBarView extends AbsActionBarView {
addView(mIndeterminateProgressView);
}
public void setContentHeight(int height) {
mContentHeight = height;
requestLayout();
}
public int getContentHeight() {
return mContentHeight;
}
public void setSplitActionBar(boolean splitActionBar) {
if (mSplitActionBar != splitActionBar) {
if (mMenuView != null) {
@@ -957,7 +943,7 @@ public class ActionBarView extends AbsActionBarView {
}
if (mContextView != null) {
mContextView.setHeight(getMeasuredHeight());
mContextView.setContentHeight(getMeasuredHeight());
}
if (mProgressView != null && mProgressView.getVisibility() != GONE) {