Add "enabled" suffix to itemHorizontalTranslation attribute name.

The suffix makes it clearer that the attribute is boolean.

This attribute was introduced in an alpha release, so it is fine to rename.

PiperOrigin-RevId: 193964290
This commit is contained in:
afohrman 2018-04-23 15:16:02 -04:00 committed by Daniel Nizri
parent 95ac4dacfe
commit 2f2ba0ce3d
4 changed files with 24 additions and 24 deletions

View File

@ -61,7 +61,7 @@ public class BottomNavigationMenuView extends ViewGroup implements MenuView {
private final OnClickListener onClickListener;
private final Pools.Pool<BottomNavigationItemView> itemPool = new Pools.SynchronizedPool<>(5);
private boolean itemHorizontalTranslation;
private boolean itemHorizontalTranslationEnabled;
@LabelVisibilityMode private int labelVisibilityMode;
private BottomNavigationItemView[] buttons;
@ -133,7 +133,7 @@ public class BottomNavigationMenuView extends ViewGroup implements MenuView {
final int heightSpec = MeasureSpec.makeMeasureSpec(itemHeight, MeasureSpec.EXACTLY);
if (isShifting(labelVisibilityMode, visibleCount) && itemHorizontalTranslation) {
if (isShifting(labelVisibilityMode, visibleCount) && itemHorizontalTranslationEnabled) {
final View activeChild = getChildAt(selectedItemPosition);
int activeItemWidth = activeItemMinWidth;
if (activeChild.getVisibility() != View.GONE) {
@ -406,11 +406,12 @@ public class BottomNavigationMenuView extends ViewGroup implements MenuView {
* Sets whether the menu items horizontally translate on selection when the combined item widths
* fill the screen.
*
* @param itemHorizontalTranslation whether the menu items horizontally translate on selection
* @see #getItemHorizontalTranslation()
* @param itemHorizontalTranslationEnabled whether the menu items horizontally translate on
* selection
* @see #isItemHorizontalTranslationEnabled()
*/
public void setItemHorizontalTranslation(boolean itemHorizontalTranslation) {
this.itemHorizontalTranslation = itemHorizontalTranslation;
public void setItemHorizontalTranslationEnabled(boolean itemHorizontalTranslationEnabled) {
this.itemHorizontalTranslationEnabled = itemHorizontalTranslationEnabled;
}
/**
@ -418,10 +419,10 @@ public class BottomNavigationMenuView extends ViewGroup implements MenuView {
* widths fill the screen.
*
* @return whether the menu items horizontally translate on selection
* @see #setItemHorizontalTranslation(boolean)
* @see #setItemHorizontalTranslationEnabled(boolean)
*/
public boolean getItemHorizontalTranslation() {
return itemHorizontalTranslation;
public boolean isItemHorizontalTranslationEnabled() {
return itemHorizontalTranslationEnabled;
}
public ColorStateList createDefaultColorStateList(int baseColorThemeAttr) {

View File

@ -175,8 +175,8 @@ public class BottomNavigationView extends FrameLayout {
a.getInteger(
R.styleable.BottomNavigationView_labelVisibilityMode,
LabelVisibilityMode.LABEL_VISIBILITY_AUTO));
setItemHorizontalTranslation(
a.getBoolean(R.styleable.BottomNavigationView_itemHorizontalTranslation, true));
setItemHorizontalTranslationEnabled(
a.getBoolean(R.styleable.BottomNavigationView_itemHorizontalTranslationEnabled, true));
int itemBackground = a.getResourceId(R.styleable.BottomNavigationView_itemBackground, 0);
menuView.setItemBackgroundRes(itemBackground);
@ -475,12 +475,12 @@ public class BottomNavigationView extends FrameLayout {
* Sets whether the menu items horizontally translate on selection when the combined item widths
* fill up the screen.
*
* @param itemHorizontalTranslation whether the items horizontally translate on selection
* @see #getItemHorizontalTranslation()
* @param itemHorizontalTranslationEnabled whether the items horizontally translate on selection
* @see #isItemHorizontalTranslationEnabled()
*/
public void setItemHorizontalTranslation(boolean itemHorizontalTranslation) {
if (menuView.getItemHorizontalTranslation() != itemHorizontalTranslation) {
menuView.setItemHorizontalTranslation(itemHorizontalTranslation);
public void setItemHorizontalTranslationEnabled(boolean itemHorizontalTranslationEnabled) {
if (menuView.isItemHorizontalTranslationEnabled() != itemHorizontalTranslationEnabled) {
menuView.setItemHorizontalTranslationEnabled(itemHorizontalTranslationEnabled);
presenter.updateMenuView(false);
}
}
@ -490,10 +490,10 @@ public class BottomNavigationView extends FrameLayout {
* screen.
*
* @return whether the menu items horizontally translate on selection
* @see #setItemHorizontalTranslation(boolean)
* @see #setItemHorizontalTranslationEnabled(boolean)
*/
public boolean getItemHorizontalTranslation() {
return menuView.getItemHorizontalTranslation();
public boolean isItemHorizontalTranslationEnabled() {
return menuView.isItemHorizontalTranslationEnabled();
}
/** Listener for handling selection events on bottom navigation items. */

View File

@ -58,9 +58,8 @@
precedence over android:textColor in itemTextAppearanceInactive or
itemTextAppearanceActive. Attribute type definition is in navigation package. -->
<attr name="itemTextColor"/>
<!-- Whether the items should translate horizontally when in "selected" label visibility
mode. -->
<attr name="itemHorizontalTranslation" format="boolean"/>
<!-- Whether the items translate horizontally when in "selected" label visibility mode. -->
<attr name="itemHorizontalTranslationEnabled" format="boolean"/>
<attr name="elevation"/>
</declare-styleable>

View File

@ -20,7 +20,7 @@
<item name="elevation">@dimen/design_bottom_navigation_elevation</item>
<item name="labelVisibilityMode">auto</item>
<item name="itemBackground">?attr/selectableItemBackgroundBorderless</item>
<item name="itemHorizontalTranslation">true</item>
<item name="itemHorizontalTranslationEnabled">true</item>
<item name="itemIconSize">@dimen/design_bottom_navigation_icon_size</item>
</style>
@ -29,7 +29,7 @@
colorPrimary for the icon and text colors. -->
<style name="Widget.MaterialComponents.BottomNavigationView" parent="Widget.Design.BottomNavigationView">
<item name="android:background">@android:color/white</item>
<item name="itemHorizontalTranslation">false</item>
<item name="itemHorizontalTranslationEnabled">false</item>
<item name="itemIconTint">@color/mtrl_bottom_nav_item_tint</item>
<item name="itemTextAppearanceInactive">
@style/TextAppearance.MaterialComponents.BottomNavigationView