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

Commit 310849ab authored by Adam Powell's avatar Adam Powell
Browse files

Bug 4563099 - Action bar tabs - place second row tabs on top in the

absence of home/up

Change-Id: I9d656962161f0cb26cecbc85991b347d2e951c76
parent 31bc2f92
Loading
Loading
Loading
Loading
+26 −5
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.widget;

import android.app.ActionBar;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
@@ -32,6 +33,7 @@ import android.widget.FrameLayout;
public class ActionBarContainer extends FrameLayout {
    private boolean mIsTransitioning;
    private View mTabContainer;
    private ActionBarView mActionBarView;

    public ActionBarContainer(Context context) {
        this(context, null);
@@ -46,6 +48,12 @@ public class ActionBarContainer extends FrameLayout {
        a.recycle();
    }

    @Override
    public void onFinishInflate() {
        super.onFinishInflate();
        mActionBarView = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
    }

    /**
     * Set the action bar into a "transitioning" state. While transitioning
     * the bar will block focus and touch from all of its descendants. This
@@ -101,9 +109,8 @@ public class ActionBarContainer extends FrameLayout {
        final int count = getChildCount();
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child == mTabContainer) {
                continue;
            }

            if (child == mTabContainer) continue;

            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            nonTabHeight = Math.max(nonTabHeight,
@@ -125,8 +132,22 @@ public class ActionBarContainer extends FrameLayout {
        super.onLayout(changed, l, t, r, b);
        if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
            final int containerHeight = getMeasuredHeight();
            mTabContainer.layout(l, containerHeight - mTabContainer.getMeasuredHeight(),
                    r, containerHeight);
            final int tabHeight = mTabContainer.getMeasuredHeight();

            if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) {
                // Not showing home, put tabs on top.
                final int count = getChildCount();
                for (int i = 0; i < count; i++){
                    final View child = getChildAt(i);

                    if (child == mTabContainer) continue;

                    child.offsetTopAndBottom(tabHeight);
                }
                mTabContainer.layout(l, 0, r, tabHeight);
            } else {
                mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
            }
        }
    }
}