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

Commit 3f7f7ac3 authored by Adam Powell's avatar Adam Powell
Browse files

Add dividers to action bar navigation. Lighter dividers for holo themes.

Change-Id: I879dbd815a891fe5db20678b674a9cee63a5e1ae
parent 6bc926bb
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -5476,6 +5476,17 @@
 visibility="public"
>
</field>
<field name="itemPadding"
 type="int"
 transient="false"
 volatile="false"
 value="16843582"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="itemTextAppearance"
 type="int"
 transient="false"
+2 −2
Original line number Diff line number Diff line
@@ -155,8 +155,8 @@ public class LinearLayout extends ViewGroup {
    public LinearLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        TypedArray a = 
            context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.LinearLayout);
        TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.LinearLayout, defStyle, 0);

        int index = a.getInt(com.android.internal.R.styleable.LinearLayout_orientation, -1);
        if (index >= 0) {
+41 −16
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ public class ActionBarView extends ViewGroup {
    private TextView mTitleView;
    private TextView mSubtitleView;
    private Spinner mSpinner;
    private LinearLayout mListNavLayout;
    private HorizontalScrollView mTabScrollView;
    private LinearLayout mTabLayout;
    private View mCustomNavView;
@@ -97,6 +98,7 @@ public class ActionBarView extends ViewGroup {
    private ProgressBar mIndeterminateProgressView;

    private int mProgressBarPadding;
    private int mItemPadding;
    
    private int mTitleStyleRes;
    private int mSubtitleStyleRes;
@@ -193,6 +195,7 @@ public class ActionBarView extends ViewGroup {
                R.styleable.ActionBar_indeterminateProgressStyle, 0);

        mProgressBarPadding = a.getDimensionPixelOffset(R.styleable.ActionBar_progressBarPadding, 0);
        mItemPadding = a.getDimensionPixelOffset(R.styleable.ActionBar_itemPadding, 0);

        setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, DISPLAY_DEFAULT));

@@ -419,7 +422,7 @@ public class ActionBarView extends ViewGroup {
            switch (oldMode) {
            case ActionBar.NAVIGATION_MODE_LIST:
                if (mSpinner != null) {
                    removeView(mSpinner);
                    removeView(mListNavLayout);
                }
                break;
            case ActionBar.NAVIGATION_MODE_TABS:
@@ -430,11 +433,21 @@ public class ActionBarView extends ViewGroup {
            
            switch (mode) {
            case ActionBar.NAVIGATION_MODE_LIST:
                if (mSpinner == null) {
                    mSpinner = new Spinner(mContext, null,
                            com.android.internal.R.attr.actionDropDownStyle);
                    mListNavLayout = new LinearLayout(mContext, null,
                            com.android.internal.R.attr.actionBarTabBarStyle);
                    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                    params.gravity = Gravity.CENTER;
                    mListNavLayout.addView(mSpinner, params);
                }
                if (mSpinner.getAdapter() != mSpinnerAdapter) {
                    mSpinner.setAdapter(mSpinnerAdapter);
                }
                mSpinner.setOnItemSelectedListener(mNavItemSelectedListener);
                addView(mSpinner);
                addView(mListNavLayout);
                break;
            case ActionBar.NAVIGATION_MODE_TABS:
                ensureTabsExist();
@@ -631,24 +644,32 @@ public class ActionBarView extends ViewGroup {
            rightOfCenter -= mMenuView.getMeasuredWidth();
        }

        if (mTitleLayout != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
        boolean showTitle = mTitleLayout != null &&
                (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
        if (showTitle) {
            availableWidth = measureChildView(mTitleLayout, availableWidth, childSpecHeight, 0);
            leftOfCenter -= mTitleLayout.getMeasuredWidth();
        }

        switch (mNavigationMode) {
        case ActionBar.NAVIGATION_MODE_LIST:
            if (mSpinner != null) {
                mSpinner.measure(
            if (mListNavLayout != null) {
                final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding;
                availableWidth -= itemPaddingSize;
                leftOfCenter -= itemPaddingSize;
                mListNavLayout.measure(
                        MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
                        MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
                final int spinnerWidth = mSpinner.getMeasuredWidth();
                availableWidth -= spinnerWidth;
                leftOfCenter -= spinnerWidth;
                        MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
                final int listNavWidth = mListNavLayout.getMeasuredWidth();
                availableWidth -= listNavWidth;
                leftOfCenter -= listNavWidth;
            }
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabScrollView != null) {
                final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding;
                availableWidth -= itemPaddingSize;
                leftOfCenter -= itemPaddingSize;
                mTabScrollView.measure(
                        MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
                        MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
@@ -755,7 +776,9 @@ public class ActionBarView extends ViewGroup {
            x += positionChild(mHomeLayout, x, y, contentHeight);
        }
        
        if (mTitleLayout != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
        final boolean showTitle = mTitleLayout != null &&
                (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
        if (showTitle) {
            x += positionChild(mTitleLayout, x, y, contentHeight);
        }

@@ -763,13 +786,15 @@ public class ActionBarView extends ViewGroup {
        case ActionBar.NAVIGATION_MODE_STANDARD:
            break;
        case ActionBar.NAVIGATION_MODE_LIST:
            if (mSpinner != null) {
                x += positionChild(mSpinner, x, y, contentHeight);
            if (mListNavLayout != null) {
                if (showTitle) x += mItemPadding;
                x += positionChild(mListNavLayout, x, y, contentHeight) + mItemPadding;
            }
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabScrollView != null) {
                x += positionChild(mTabScrollView, x, y, contentHeight);
                if (showTitle) x += mItemPadding;
                x += positionChild(mTabScrollView, x, y, contentHeight) + mItemPadding;
            }
            break;
        }
+3 −0
Original line number Diff line number Diff line
@@ -4542,6 +4542,9 @@
        <attr name="indeterminateProgressStyle" format="reference" />
        <!-- Specifies the horizontal padding on either end for an embedded progress bar. -->
        <attr name="progressBarPadding" format="dimension" />
        <!-- Specifies padding that should be applied to the left and right sides of
             system-provided items in the bar. -->
        <attr name="itemPadding" format="dimension" />
    </declare-styleable>

    <declare-styleable name="ActionMode">
+1 −0
Original line number Diff line number Diff line
@@ -1396,6 +1396,7 @@
  <public type="attr" name="dividerPadding" />
  <public type="attr" name="borderlessButtonStyle" />
  <public type="attr" name="dividerHorizontal" />
  <public type="attr" name="itemPadding" />

  <public type="anim" name="animator_fade_in" />
  <public type="anim" name="animator_fade_out" />
Loading