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

Commit cfc0818b authored by Adam Powell's avatar Adam Powell Committed by android-build-merger
Browse files

Merge "Add contentInsetStartWithNavigation/EndWithActions" into nyc-dev

am: b3eca316

* commit 'b3eca316':
  Add contentInsetStartWithNavigation/EndWithActions

Change-Id: Icfcd1296131ed26c97d766ccad230a59900d4b97
parents 6c4b5c0a b3eca316
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -416,9 +416,11 @@ package android {
    field public static final int contentAuthority = 16843408; // 0x1010290
    field public static final int contentDescription = 16843379; // 0x1010273
    field public static final int contentInsetEnd = 16843860; // 0x1010454
    field public static final int contentInsetEndWithActions = 16844070; // 0x1010526
    field public static final int contentInsetLeft = 16843861; // 0x1010455
    field public static final int contentInsetRight = 16843862; // 0x1010456
    field public static final int contentInsetStart = 16843859; // 0x1010453
    field public static final int contentInsetStartWithNavigation = 16844069; // 0x1010525
    field public static final int contextClickable = 16844007; // 0x10104e7
    field public static final int contextPopupMenuStyle = 16844034; // 0x1010502
    field public static final int controlX1 = 16843772; // 0x10103fc
@@ -48290,9 +48292,15 @@ package android.widget {
    method public void collapseActionView();
    method public void dismissPopupMenus();
    method public int getContentInsetEnd();
    method public int getContentInsetEndWithActions();
    method public int getContentInsetLeft();
    method public int getContentInsetRight();
    method public int getContentInsetStart();
    method public int getContentInsetStartWithNavigation();
    method public int getCurrentContentInsetEnd();
    method public int getCurrentContentInsetLeft();
    method public int getCurrentContentInsetRight();
    method public int getCurrentContentInsetStart();
    method public android.graphics.drawable.Drawable getLogo();
    method public java.lang.CharSequence getLogoDescription();
    method public android.view.Menu getMenu();
@@ -48311,6 +48319,8 @@ package android.widget {
    method public void inflateMenu(int);
    method public boolean isOverflowMenuShowing();
    method protected void onLayout(boolean, int, int, int, int);
    method public void setContentInsetEndWithActions(int);
    method public void setContentInsetStartWithNavigation(int);
    method public void setContentInsetsAbsolute(int, int);
    method public void setContentInsetsRelative(int, int);
    method public void setLogo(int);
+10 −0
Original line number Diff line number Diff line
@@ -511,9 +511,11 @@ package android {
    field public static final int contentAuthority = 16843408; // 0x1010290
    field public static final int contentDescription = 16843379; // 0x1010273
    field public static final int contentInsetEnd = 16843860; // 0x1010454
    field public static final int contentInsetEndWithActions = 16844070; // 0x1010526
    field public static final int contentInsetLeft = 16843861; // 0x1010455
    field public static final int contentInsetRight = 16843862; // 0x1010456
    field public static final int contentInsetStart = 16843859; // 0x1010453
    field public static final int contentInsetStartWithNavigation = 16844069; // 0x1010525
    field public static final int contextClickable = 16844007; // 0x10104e7
    field public static final int contextPopupMenuStyle = 16844034; // 0x1010502
    field public static final int controlX1 = 16843772; // 0x10103fc
@@ -51354,9 +51356,15 @@ package android.widget {
    method public void collapseActionView();
    method public void dismissPopupMenus();
    method public int getContentInsetEnd();
    method public int getContentInsetEndWithActions();
    method public int getContentInsetLeft();
    method public int getContentInsetRight();
    method public int getContentInsetStart();
    method public int getContentInsetStartWithNavigation();
    method public int getCurrentContentInsetEnd();
    method public int getCurrentContentInsetLeft();
    method public int getCurrentContentInsetRight();
    method public int getCurrentContentInsetStart();
    method public android.graphics.drawable.Drawable getLogo();
    method public java.lang.CharSequence getLogoDescription();
    method public android.view.Menu getMenu();
@@ -51375,6 +51383,8 @@ package android.widget {
    method public void inflateMenu(int);
    method public boolean isOverflowMenuShowing();
    method protected void onLayout(boolean, int, int, int, int);
    method public void setContentInsetEndWithActions(int);
    method public void setContentInsetStartWithNavigation(int);
    method public void setContentInsetsAbsolute(int, int);
    method public void setContentInsetsRelative(int, int);
    method public void setLogo(int);
+10 −0
Original line number Diff line number Diff line
@@ -416,9 +416,11 @@ package android {
    field public static final int contentAuthority = 16843408; // 0x1010290
    field public static final int contentDescription = 16843379; // 0x1010273
    field public static final int contentInsetEnd = 16843860; // 0x1010454
    field public static final int contentInsetEndWithActions = 16844070; // 0x1010526
    field public static final int contentInsetLeft = 16843861; // 0x1010455
    field public static final int contentInsetRight = 16843862; // 0x1010456
    field public static final int contentInsetStart = 16843859; // 0x1010453
    field public static final int contentInsetStartWithNavigation = 16844069; // 0x1010525
    field public static final int contextClickable = 16844007; // 0x10104e7
    field public static final int contextPopupMenuStyle = 16844034; // 0x1010502
    field public static final int controlX1 = 16843772; // 0x10103fc
@@ -48364,9 +48366,15 @@ package android.widget {
    method public void collapseActionView();
    method public void dismissPopupMenus();
    method public int getContentInsetEnd();
    method public int getContentInsetEndWithActions();
    method public int getContentInsetLeft();
    method public int getContentInsetRight();
    method public int getContentInsetStart();
    method public int getContentInsetStartWithNavigation();
    method public int getCurrentContentInsetEnd();
    method public int getCurrentContentInsetLeft();
    method public int getCurrentContentInsetRight();
    method public int getCurrentContentInsetStart();
    method public android.graphics.drawable.Drawable getLogo();
    method public java.lang.CharSequence getLogoDescription();
    method public android.view.Menu getMenu();
@@ -48385,6 +48393,8 @@ package android.widget {
    method public void inflateMenu(int);
    method public boolean isOverflowMenuShowing();
    method protected void onLayout(boolean, int, int, int, int);
    method public void setContentInsetEndWithActions(int);
    method public void setContentInsetStartWithNavigation(int);
    method public void setContentInsetsAbsolute(int, int);
    method public void setContentInsetsRelative(int, int);
    method public void setLogo(int);
+179 −12
Original line number Diff line number Diff line
@@ -106,6 +106,8 @@ import java.util.List;
 * @attr ref android.R.styleable#Toolbar_contentInsetLeft
 * @attr ref android.R.styleable#Toolbar_contentInsetRight
 * @attr ref android.R.styleable#Toolbar_contentInsetStart
 * @attr ref android.R.styleable#Toolbar_contentInsetStartWithNavigation
 * @attr ref android.R.styleable#Toolbar_contentInsetEndWithActions
 * @attr ref android.R.styleable#Toolbar_gravity
 * @attr ref android.R.styleable#Toolbar_logo
 * @attr ref android.R.styleable#Toolbar_logoDescription
@@ -159,6 +161,8 @@ public class Toolbar extends ViewGroup {
    private int mTitleMarginBottom;

    private final RtlSpacingHelper mContentInsets = new RtlSpacingHelper();
    private int mContentInsetStartWithNavigation;
    private int mContentInsetEndWithActions;

    private int mGravity = Gravity.START | Gravity.CENTER_VERTICAL;

@@ -272,6 +276,11 @@ public class Toolbar extends ViewGroup {
            mContentInsets.setRelative(contentInsetStart, contentInsetEnd);
        }

        mContentInsetStartWithNavigation = a.getDimensionPixelOffset(
                R.styleable.Toolbar_contentInsetStartWithNavigation, RtlSpacingHelper.UNDEFINED);
        mContentInsetEndWithActions = a.getDimensionPixelOffset(
                R.styleable.Toolbar_contentInsetEndWithActions, RtlSpacingHelper.UNDEFINED);

        mCollapseIcon = a.getDrawable(R.styleable.Toolbar_collapseIcon);
        mCollapseDescription = a.getText(R.styleable.Toolbar_collapseContentDescription);

@@ -1055,7 +1064,7 @@ public class Toolbar extends ViewGroup {
    }

    /**
     * Set the content insets for this toolbar relative to layout direction.
     * Sets the content insets for this toolbar relative to layout direction.
     *
     * <p>The content inset affects the valid area for Toolbar content other than
     * the navigation button and menu. Insets define the minimum margin for these components
@@ -1069,13 +1078,15 @@ public class Toolbar extends ViewGroup {
     * @see #getContentInsetEnd()
     * @see #getContentInsetLeft()
     * @see #getContentInsetRight()
     * @attr ref android.R.styleable#Toolbar_contentInsetEnd
     * @attr ref android.R.styleable#Toolbar_contentInsetStart
     */
    public void setContentInsetsRelative(int contentInsetStart, int contentInsetEnd) {
        mContentInsets.setRelative(contentInsetStart, contentInsetEnd);
    }

    /**
     * Get the starting content inset for this toolbar.
     * Gets the starting content inset for this toolbar.
     *
     * <p>The content inset affects the valid area for Toolbar content other than
     * the navigation button and menu. Insets define the minimum margin for these components
@@ -1088,13 +1099,14 @@ public class Toolbar extends ViewGroup {
     * @see #getContentInsetEnd()
     * @see #getContentInsetLeft()
     * @see #getContentInsetRight()
     * @attr ref android.R.styleable#Toolbar_contentInsetStart
     */
    public int getContentInsetStart() {
        return mContentInsets.getStart();
    }

    /**
     * Get the ending content inset for this toolbar.
     * Gets the ending content inset for this toolbar.
     *
     * <p>The content inset affects the valid area for Toolbar content other than
     * the navigation button and menu. Insets define the minimum margin for these components
@@ -1107,13 +1119,14 @@ public class Toolbar extends ViewGroup {
     * @see #getContentInsetStart()
     * @see #getContentInsetLeft()
     * @see #getContentInsetRight()
     * @attr ref android.R.styleable#Toolbar_contentInsetEnd
     */
    public int getContentInsetEnd() {
        return mContentInsets.getEnd();
    }

    /**
     * Set the content insets for this toolbar.
     * Sets the content insets for this toolbar.
     *
     * <p>The content inset affects the valid area for Toolbar content other than
     * the navigation button and menu. Insets define the minimum margin for these components
@@ -1127,13 +1140,15 @@ public class Toolbar extends ViewGroup {
     * @see #getContentInsetEnd()
     * @see #getContentInsetLeft()
     * @see #getContentInsetRight()
     * @attr ref android.R.styleable#Toolbar_contentInsetLeft
     * @attr ref android.R.styleable#Toolbar_contentInsetRight
     */
    public void setContentInsetsAbsolute(int contentInsetLeft, int contentInsetRight) {
        mContentInsets.setAbsolute(contentInsetLeft, contentInsetRight);
    }

    /**
     * Get the left content inset for this toolbar.
     * Gets the left content inset for this toolbar.
     *
     * <p>The content inset affects the valid area for Toolbar content other than
     * the navigation button and menu. Insets define the minimum margin for these components
@@ -1146,13 +1161,14 @@ public class Toolbar extends ViewGroup {
     * @see #getContentInsetStart()
     * @see #getContentInsetEnd()
     * @see #getContentInsetRight()
     * @attr ref android.R.styleable#Toolbar_contentInsetLeft
     */
    public int getContentInsetLeft() {
        return mContentInsets.getLeft();
    }

    /**
     * Get the right content inset for this toolbar.
     * Gets the right content inset for this toolbar.
     *
     * <p>The content inset affects the valid area for Toolbar content other than
     * the navigation button and menu. Insets define the minimum margin for these components
@@ -1165,11 +1181,160 @@ public class Toolbar extends ViewGroup {
     * @see #getContentInsetStart()
     * @see #getContentInsetEnd()
     * @see #getContentInsetLeft()
     * @attr ref android.R.styleable#Toolbar_contentInsetRight
     */
    public int getContentInsetRight() {
        return mContentInsets.getRight();
    }

    /**
     * Gets the start content inset to use when a navigation button is present.
     *
     * <p>Different content insets are often called for when additional buttons are present
     * in the toolbar, as well as at different toolbar sizes. The larger value of
     * {@link #getContentInsetStart()} and this value will be used during layout.</p>
     *
     * @return the start content inset used when a navigation icon has been set in pixels
     *
     * @see #setContentInsetStartWithNavigation(int)
     * @attr ref android.R.styleable#Toolbar_contentInsetStartWithNavigation
     */
    public int getContentInsetStartWithNavigation() {
        return mContentInsetStartWithNavigation != RtlSpacingHelper.UNDEFINED
                ? mContentInsetStartWithNavigation
                : getContentInsetStart();
    }

    /**
     * Sets the start content inset to use when a navigation button is present.
     *
     * <p>Different content insets are often called for when additional buttons are present
     * in the toolbar, as well as at different toolbar sizes. The larger value of
     * {@link #getContentInsetStart()} and this value will be used during layout.</p>
     *
     * @param insetStartWithNavigation the inset to use when a navigation icon has been set
     *                                 in pixels
     *
     * @see #getContentInsetStartWithNavigation()
     * @attr ref android.R.styleable#Toolbar_contentInsetStartWithNavigation
     */
    public void setContentInsetStartWithNavigation(int insetStartWithNavigation) {
        if (insetStartWithNavigation < 0) {
            insetStartWithNavigation = RtlSpacingHelper.UNDEFINED;
        }
        if (insetStartWithNavigation != mContentInsetStartWithNavigation) {
            mContentInsetStartWithNavigation = insetStartWithNavigation;
            if (getNavigationIcon() != null) {
                requestLayout();
            }
        }
    }

    /**
     * Gets the end content inset to use when action buttons are present.
     *
     * <p>Different content insets are often called for when additional buttons are present
     * in the toolbar, as well as at different toolbar sizes. The larger value of
     * {@link #getContentInsetEnd()} and this value will be used during layout.</p>
     *
     * @return the end content inset used when a menu has been set in pixels
     *
     * @see #setContentInsetEndWithActions(int)
     * @attr ref android.R.styleable#Toolbar_contentInsetEndWithActions
     */
    public int getContentInsetEndWithActions() {
        return mContentInsetEndWithActions != RtlSpacingHelper.UNDEFINED
                ? mContentInsetEndWithActions
                : getContentInsetEnd();
    }

    /**
     * Sets the start content inset to use when action buttons are present.
     *
     * <p>Different content insets are often called for when additional buttons are present
     * in the toolbar, as well as at different toolbar sizes. The larger value of
     * {@link #getContentInsetEnd()} and this value will be used during layout.</p>
     *
     * @param insetEndWithActions the inset to use when a menu has been set in pixels
     *
     * @see #setContentInsetEndWithActions(int)
     * @attr ref android.R.styleable#Toolbar_contentInsetEndWithActions
     */
    public void setContentInsetEndWithActions(int insetEndWithActions) {
        if (insetEndWithActions < 0) {
            insetEndWithActions = RtlSpacingHelper.UNDEFINED;
        }
        if (insetEndWithActions != mContentInsetEndWithActions) {
            mContentInsetEndWithActions = insetEndWithActions;
            if (getNavigationIcon() != null) {
                requestLayout();
            }
        }
    }

    /**
     * Gets the content inset that will be used on the starting side of the bar in the current
     * toolbar configuration.
     *
     * @return the current content inset start in pixels
     *
     * @see #getContentInsetStartWithNavigation()
     */
    public int getCurrentContentInsetStart() {
        return getNavigationIcon() != null
                ? Math.max(getContentInsetStart(), Math.max(mContentInsetStartWithNavigation, 0))
                : getContentInsetStart();
    }

    /**
     * Gets the content inset that will be used on the ending side of the bar in the current
     * toolbar configuration.
     *
     * @return the current content inset end in pixels
     *
     * @see #getContentInsetEndWithActions()
     */
    public int getCurrentContentInsetEnd() {
        boolean hasActions = false;
        if (mMenuView != null) {
            final MenuBuilder mb = mMenuView.peekMenu();
            hasActions = mb != null && mb.hasVisibleItems();
        }
        return hasActions
                ? Math.max(getContentInsetEnd(), Math.max(mContentInsetEndWithActions, 0))
                : getContentInsetEnd();
    }

    /**
     * Gets the content inset that will be used on the left side of the bar in the current
     * toolbar configuration.
     *
     * @return the current content inset left in pixels
     *
     * @see #getContentInsetStartWithNavigation()
     * @see #getContentInsetEndWithActions()
     */
    public int getCurrentContentInsetLeft() {
        return isLayoutRtl()
                ? getCurrentContentInsetEnd()
                : getCurrentContentInsetStart();
    }

    /**
     * Gets the content inset that will be used on the right side of the bar in the current
     * toolbar configuration.
     *
     * @return the current content inset right in pixels
     *
     * @see #getContentInsetStartWithNavigation()
     * @see #getContentInsetEndWithActions()
     */
    public int getCurrentContentInsetRight() {
        return isLayoutRtl()
                ? getCurrentContentInsetStart()
                : getCurrentContentInsetEnd();
    }

    private void ensureNavButtonView() {
        if (mNavButtonView == null) {
            mNavButtonView = new ImageButton(getContext(), null, 0, mNavButtonStyle);
@@ -1406,7 +1571,7 @@ public class Toolbar extends ViewGroup {
            childState = combineMeasuredStates(childState, mCollapseButtonView.getMeasuredState());
        }

        final int contentInsetStart = getContentInsetStart();
        final int contentInsetStart = getCurrentContentInsetStart();
        width += Math.max(contentInsetStart, navWidth);
        collapsingMargins[marginStartIndex] = Math.max(0, contentInsetStart - navWidth);

@@ -1420,7 +1585,7 @@ public class Toolbar extends ViewGroup {
            childState = combineMeasuredStates(childState, mMenuView.getMeasuredState());
        }

        final int contentInsetEnd = getContentInsetEnd();
        final int contentInsetEnd = getCurrentContentInsetEnd();
        width += Math.max(contentInsetEnd, menuWidth);
        collapsingMargins[marginEndIndex] = Math.max(0, contentInsetEnd - menuWidth);

@@ -1543,10 +1708,12 @@ public class Toolbar extends ViewGroup {
            }
        }

        collapsingMargins[0] = Math.max(0, getContentInsetLeft() - left);
        collapsingMargins[1] = Math.max(0, getContentInsetRight() - (width - paddingRight - right));
        left = Math.max(left, getContentInsetLeft());
        right = Math.min(right, width - paddingRight - getContentInsetRight());
        final int contentInsetLeft = getCurrentContentInsetLeft();
        final int contentInsetRight = getCurrentContentInsetRight();
        collapsingMargins[0] = Math.max(0, contentInsetLeft - left);
        collapsingMargins[1] = Math.max(0, contentInsetRight - (width - paddingRight - right));
        left = Math.max(left, contentInsetLeft);
        right = Math.min(right, width - paddingRight - contentInsetRight);

        if (shouldLayout(mExpandedActionView)) {
            if (isRtl) {
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@
    <dimen name="action_bar_default_height_material">64dp</dimen>
    <!-- Default content inset of an action bar. -->
    <dimen name="action_bar_content_inset_material">24dp</dimen>
    <!-- Default content inset of an action bar with navigation present. -->
    <dimen name="action_bar_content_inset_with_nav">80dp</dimen>

    <!-- Default start padding of an action bar. -->
    <dimen name="action_bar_default_padding_start_material">8dp</dimen>
Loading