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

Commit e002c2fb authored by Adam Powell's avatar Adam Powell
Browse files

Implement action bar tab mode for Toolbar-based decor action bars

Coordinate between the stacked row, etc. Also fix a silly bug in
Toolbar child views with Gravity.BOTTOM.

Bug 15332084

Change-Id: Ie91b7d5255c63d9befcc65d7939c1523e018809f
parent 0b4da0c4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1339,7 +1339,8 @@ public class Toolbar extends ViewGroup {
                return getPaddingTop();

            case Gravity.BOTTOM:
                return getPaddingBottom() - child.getMeasuredHeight() - lp.bottomMargin;
                return getHeight() - getPaddingBottom() -
                        child.getMeasuredHeight() - lp.bottomMargin;

            default:
            case Gravity.CENTER_VERTICAL:
+3 −0
Original line number Diff line number Diff line
@@ -281,6 +281,9 @@ public class ToolbarActionBar extends ActionBar {

    @Override
    public void setNavigationMode(@NavigationMode int mode) {
        if (mode == ActionBar.NAVIGATION_MODE_TABS) {
            throw new IllegalArgumentException("Tabs not supported in this configuration");
        }
        mDecorToolbar.setNavigationMode(mode);
    }

+1 −4
Original line number Diff line number Diff line
@@ -349,10 +349,7 @@ public class ActionBarView extends AbsActionBarView implements DecorToolbar {
        return mIncludeTabs;
    }

    public void setEmbeddedTabView(View view) {
        setEmbeddedTabView((ScrollingTabContainerView) view);
    }

    @Override
    public void setEmbeddedTabView(ScrollingTabContainerView tabs) {
        if (mTabScrollView != null) {
            removeView(mTabScrollView);
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public interface DecorToolbar {

    int getDisplayOptions();
    void setDisplayOptions(int opts);
    void setEmbeddedTabView(View tabView);
    void setEmbeddedTabView(ScrollingTabContainerView tabView);
    boolean hasEmbeddedTabs();
    boolean isTitleTruncated();
    void setCollapsible(boolean collapsible);
+25 −2
Original line number Diff line number Diff line
@@ -397,8 +397,19 @@ public class ToolbarWidgetWrapper implements DecorToolbar {
    }

    @Override
    public void setEmbeddedTabView(View tabView) {
    public void setEmbeddedTabView(ScrollingTabContainerView tabView) {
        if (mTabView != null && mTabView.getParent() == mToolbar) {
            mToolbar.removeView(mTabView);
        }
        mTabView = tabView;
        if (tabView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
            mToolbar.addView(mTabView, 0);
            Toolbar.LayoutParams lp = (Toolbar.LayoutParams) mTabView.getLayoutParams();
            lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
            lp.gravity = Gravity.START | Gravity.BOTTOM;
            tabView.setAllowCollapse(true);
        }
    }

    @Override
@@ -436,6 +447,11 @@ public class ToolbarWidgetWrapper implements DecorToolbar {
                        mToolbar.removeView(mSpinner);
                    }
                    break;
                case ActionBar.NAVIGATION_MODE_TABS:
                    if (mTabView != null && mTabView.getParent() == mToolbar) {
                        mToolbar.removeView(mTabView);
                    }
                    break;
            }

            mNavigationMode = mode;
@@ -448,7 +464,14 @@ public class ToolbarWidgetWrapper implements DecorToolbar {
                    mToolbar.addView(mSpinner, 0);
                    break;
                case ActionBar.NAVIGATION_MODE_TABS:
                    throw new IllegalStateException("Tabs not supported in this configuration");
                    if (mTabView != null) {
                        mToolbar.addView(mTabView, 0);
                        Toolbar.LayoutParams lp = (Toolbar.LayoutParams) mTabView.getLayoutParams();
                        lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
                        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
                        lp.gravity = Gravity.START | Gravity.BOTTOM;
                    }
                    break;
                default:
                    throw new IllegalArgumentException("Invalid navigation mode " + mode);
            }