Merge "Handle action mode changes properly for actionbar tabs" into lmp-dev
diff --git a/core/java/com/android/internal/app/WindowDecorActionBar.java b/core/java/com/android/internal/app/WindowDecorActionBar.java
index a8f7bb3..2377c22 100644
--- a/core/java/com/android/internal/app/WindowDecorActionBar.java
+++ b/core/java/com/android/internal/app/WindowDecorActionBar.java
@@ -866,14 +866,7 @@
mDecorToolbar.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE);
mContextView.animateToVisibility(toActionMode ? View.VISIBLE : View.GONE);
- if (mTabScrollView != null && !mDecorToolbar.hasEmbeddedTabs() &&
- isCollapsed(mDecorToolbar.getViewGroup())) {
- mTabScrollView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE);
- }
- }
-
- private boolean isCollapsed(View view) {
- return view == null || view.getVisibility() == View.GONE || view.getMeasuredHeight() == 0;
+ // mTabScrollView's visibility is not affected by action mode.
}
public Context getThemedContext() {
diff --git a/core/java/com/android/internal/widget/ActionBarContainer.java b/core/java/com/android/internal/widget/ActionBarContainer.java
index d24f32f..847a47d 100644
--- a/core/java/com/android/internal/widget/ActionBarContainer.java
+++ b/core/java/com/android/internal/widget/ActionBarContainer.java
@@ -260,6 +260,11 @@
return view == null || view.getVisibility() == GONE || view.getMeasuredHeight() == 0;
}
+ private int getMeasuredHeightWithMargins(View view) {
+ final LayoutParams lp = (LayoutParams) view.getLayoutParams();
+ return view.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
+ }
+
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mActionBarView == null &&
@@ -271,26 +276,23 @@
if (mActionBarView == null) return;
- int nonTabMaxHeight = 0;
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- if (child == mTabContainer) {
- continue;
- }
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- nonTabMaxHeight = Math.max(nonTabMaxHeight, isCollapsed(child) ? 0 :
- child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
- }
-
if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
- final int mode = MeasureSpec.getMode(heightMeasureSpec);
- if (mode == MeasureSpec.AT_MOST) {
- final int maxHeight = MeasureSpec.getSize(heightMeasureSpec);
- setMeasuredDimension(getMeasuredWidth(),
- Math.min(nonTabMaxHeight + mTabContainer.getMeasuredHeight(),
- maxHeight));
+ int nonTabMaxHeight = 0;
+ final int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ if (child == mTabContainer) {
+ continue;
+ }
+ nonTabMaxHeight = Math.max(nonTabMaxHeight, isCollapsed(child) ? 0 :
+ getMeasuredHeightWithMargins(child));
}
+ final int mode = MeasureSpec.getMode(heightMeasureSpec);
+ final int maxHeight = mode == MeasureSpec.AT_MOST ?
+ MeasureSpec.getSize(heightMeasureSpec) : Integer.MAX_VALUE;
+ setMeasuredDimension(getMeasuredWidth(),
+ Math.min(nonTabMaxHeight + getMeasuredHeightWithMargins(mTabContainer),
+ maxHeight));
}
}
@@ -303,8 +305,10 @@
if (tabContainer != null && tabContainer.getVisibility() != GONE) {
final int containerHeight = getMeasuredHeight();
+ final LayoutParams lp = (LayoutParams) tabContainer.getLayoutParams();
final int tabHeight = tabContainer.getMeasuredHeight();
- tabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
+ tabContainer.layout(l, containerHeight - tabHeight - lp.bottomMargin, r,
+ containerHeight - lp.bottomMargin);
}
boolean needsInvalidate = false;
diff --git a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java
index 63a4843..478c8f2 100644
--- a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java
+++ b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java
@@ -578,7 +578,7 @@
@Override
public void animateToVisibility(int visibility) {
if (visibility == View.GONE) {
- mToolbar.animate().translationY(mToolbar.getHeight()).alpha(0)
+ mToolbar.animate().alpha(0)
.setListener(new AnimatorListenerAdapter() {
private boolean mCanceled = false;
@Override
@@ -594,7 +594,7 @@
}
});
} else if (visibility == View.VISIBLE) {
- mToolbar.animate().translationY(0).alpha(1)
+ mToolbar.animate().alpha(1)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {