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

Commit 098f5bd4 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Action bar tab layout tweaks."

parents 8239b95d d21aa12e
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -176,6 +176,8 @@ public class ActionBarImpl extends ActionBar {
            }
            mActionView.setEmbeddedTabView(mTabScrollView);
        }
        mActionView.setCollapsable(!mHasEmbeddedTabs &&
                getNavigationMode() == NAVIGATION_MODE_TABS);

        TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar);
        mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
@@ -307,7 +309,9 @@ public class ActionBarImpl extends ActionBar {
            selectTab(null);
        }
        mTabs.clear();
        if (mTabScrollView != null) {
            mTabScrollView.removeAllTabs();
        }
        mSavedTabPosition = INVALID_POSITION;
    }

@@ -887,6 +891,7 @@ public class ActionBarImpl extends ActionBar {
                }
                break;
        }
        mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs);
    }

    @Override
+15 −2
Original line number Diff line number Diff line
@@ -96,13 +96,26 @@ public class ActionBarContainer extends FrameLayout {
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        int nonTabHeight = 0;
        final int count = getChildCount();
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child == mTabContainer) {
                continue;
            }

            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            nonTabHeight = Math.max(nonTabHeight,
                    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 measuredHeight = getMeasuredHeight();
                final int maxHeight = MeasureSpec.getSize(heightMeasureSpec);
                setMeasuredDimension(getMeasuredWidth(),
                        Math.min(measuredHeight + mTabContainer.getMeasuredHeight(), maxHeight));
                        Math.min(nonTabHeight + mTabContainer.getMeasuredHeight(), maxHeight));
            }
        }
    }
+29 −2
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public class ActionBarView extends AbsActionBarView {
    private boolean mSplitActionBar;
    private boolean mUserTitle;
    private boolean mIncludeTabs;
    private boolean mIsCollapsable;

    private MenuBuilder mOptionsMenu;
    
@@ -629,8 +630,30 @@ public class ActionBarView extends AbsActionBarView {
        mContextView = view;
    }

    public void setCollapsable(boolean collapsable) {
        mIsCollapsable = collapsable;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        final int childCount = getChildCount();
        if (mIsCollapsable) {
            int visibleChildren = 0;
            for (int i = 0; i < childCount; i++) {
                final View child = getChildAt(i);
                if (child.getVisibility() != GONE &&
                        !(child == mMenuView && mMenuView.getChildCount() == 0)) {
                    visibleChildren++;
                }
            }

            if (visibleChildren == 0) {
                // No size for an empty action bar when collapsable.
                setMeasuredDimension(0, 0);
                return;
            }
        }

        int widthMode = MeasureSpec.getMode(widthMeasureSpec);
        if (widthMode != MeasureSpec.EXACTLY) {
            throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
@@ -761,8 +784,7 @@ public class ActionBarView extends AbsActionBarView {

        if (mContentHeight <= 0) {
            int measuredHeight = 0;
            final int count = getChildCount();
            for (int i = 0; i < count; i++) {
            for (int i = 0; i < childCount; i++) {
                View v = getChildAt(i);
                int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
                if (paddedViewHeight > measuredHeight) {
@@ -791,6 +813,11 @@ public class ActionBarView extends AbsActionBarView {
        final int y = getPaddingTop();
        final int contentHeight = b - t - getPaddingTop() - getPaddingBottom();

        if (contentHeight <= 0) {
            // Nothing to do if we can't see anything.
            return;
        }

        if (mHomeLayout.getVisibility() != GONE) {
            x += positionChild(mHomeLayout, x, y, contentHeight);
        }