Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd20f196 authored by Yigit Boyar's avatar Yigit Boyar Committed by Android (Google) Code Review
Browse files

Merge "Handle action mode changes properly for actionbar tabs" into lmp-dev

parents 80ea66b1 2bbad0cd
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -866,14 +866,7 @@ public class WindowDecorActionBar extends ActionBar implements

        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() {
+23 −19
Original line number Diff line number Diff line
@@ -260,6 +260,11 @@ public class ActionBarContainer extends FrameLayout {
        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,6 +276,7 @@ public class ActionBarContainer extends FrameLayout {

        if (mActionBarView == null) return;

        if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
            int nonTabMaxHeight = 0;
            final int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
@@ -278,21 +284,17 @@ public class ActionBarContainer extends FrameLayout {
                if (child == mTabContainer) {
                    continue;
                }
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                nonTabMaxHeight = Math.max(nonTabMaxHeight, isCollapsed(child) ? 0 :
                    child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
                        getMeasuredHeightWithMargins(child));
            }

        if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
            final int mode = MeasureSpec.getMode(heightMeasureSpec);
            if (mode == MeasureSpec.AT_MOST) {
                final int maxHeight = MeasureSpec.getSize(heightMeasureSpec);
            final int maxHeight = mode == MeasureSpec.AT_MOST ?
                    MeasureSpec.getSize(heightMeasureSpec) : Integer.MAX_VALUE;
            setMeasuredDimension(getMeasuredWidth(),
                        Math.min(nonTabMaxHeight + mTabContainer.getMeasuredHeight(),
                    Math.min(nonTabMaxHeight + getMeasuredHeightWithMargins(mTabContainer),
                            maxHeight));
        }
    }
    }

    @Override
    public void onLayout(boolean changed, int l, int t, int r, int b) {
@@ -303,8 +305,10 @@ public class ActionBarContainer extends FrameLayout {

        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;
+2 −2
Original line number Diff line number Diff line
@@ -578,7 +578,7 @@ public class ToolbarWidgetWrapper implements DecorToolbar {
    @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 @@ public class ToolbarWidgetWrapper implements DecorToolbar {
                        }
                    });
        } else if (visibility == View.VISIBLE) {
            mToolbar.animate().translationY(0).alpha(1)
            mToolbar.animate().alpha(1)
                    .setListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationStart(Animator animation) {