Skip to content

Commit

Permalink
deprecate badgeColor, use badgeBackgroundColor
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Jul 18, 2023
1 parent a1b9170 commit e06e816
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
TiC.PROPERTY_ACTIVE_TINT_COLOR,
TiC.PROPERTY_ACTIVE_TITLE_COLOR,
TiC.PROPERTY_BADGE,
TiC.PROPERTY_BADGE_COLOR,
TiC.PROPERTY_BADGE_COLOR, // DEPRECATED: Superseded by PROPERTY_BADGE_BACKGROUND_COLOR.
TiC.PROPERTY_BADGE_BACKGROUND_COLOR,
TiC.PROPERTY_BADGE_TEXT_COLOR,
TiC.PROPERTY_ICON,
TiC.PROPERTY_TINT_COLOR,
Expand Down Expand Up @@ -246,7 +247,8 @@ public void onPropertyChanged(String name, Object value)
tabGroupView.updateTabIcon(this.tabGroupProxy.getTabIndex(this));
} else if (name.equals(TiC.PROPERTY_BADGE)) {
tabGroupView.updateBadge(this.tabGroupProxy.getTabIndex(this));
} else if (name.equals(TiC.PROPERTY_BADGE_COLOR) || name.equals(TiC.PROPERTY_BADGE_TEXT_COLOR)) {
} else if (name.equals(TiC.PROPERTY_BADGE_COLOR) || name.equals(TiC.PROPERTY_BADGE_BACKGROUND_COLOR)
|| name.equals(TiC.PROPERTY_BADGE_TEXT_COLOR)) {
tabGroupView.updateBadgeColor(this.tabGroupProxy.getTabIndex(this));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,18 @@ public void updateBadgeColor(int index)

// TODO: reset to default value when property is null
if (tabProxy.hasPropertyAndNotNull(TiC.PROPERTY_BADGE_COLOR)) {
Log.w(TAG, "badgeColor is deprecated. Use badgeBackgroundColor instead.");
int menuItemId = this.mBottomNavigationView.getMenu().getItem(index).getItemId();
BadgeDrawable badgeDrawable = this.mBottomNavigationView.getOrCreateBadge(menuItemId);
badgeDrawable.setBackgroundColor(
TiConvert.toColor(tabProxy.getProperty(TiC.PROPERTY_BADGE_COLOR), tabProxy.getActivity()));
}
if (tabProxy.hasPropertyAndNotNull(TiC.PROPERTY_BADGE_BACKGROUND_COLOR)) {
int menuItemId = this.mBottomNavigationView.getMenu().getItem(index).getItemId();
BadgeDrawable badgeDrawable = this.mBottomNavigationView.getOrCreateBadge(menuItemId);
badgeDrawable.setBackgroundColor(
TiConvert.toColor(tabProxy.getProperty(TiC.PROPERTY_BADGE_BACKGROUND_COLOR), tabProxy.getActivity()));
}
if (tabProxy.hasPropertyAndNotNull(TiC.PROPERTY_BADGE_TEXT_COLOR)) {
int menuItemId = this.mBottomNavigationView.getMenu().getItem(index).getItemId();
BadgeDrawable badgeDrawable = this.mBottomNavigationView.getOrCreateBadge(menuItemId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,16 @@ public void updateBadgeColor(int index)

// TODO: reset to default value when property is null
if (tabProxy.hasPropertyAndNotNull(TiC.PROPERTY_BADGE_COLOR)) {
Log.w(TAG, "badgeColor is deprecated. Use badgeBackgroundColor instead.");
BadgeDrawable badgeDrawable = this.mTabLayout.getTabAt(index).getOrCreateBadge();
badgeDrawable.setBackgroundColor(
TiConvert.toColor(tabProxy.getProperty(TiC.PROPERTY_BADGE_COLOR), tabProxy.getActivity()));
}
if (tabProxy.hasPropertyAndNotNull(TiC.PROPERTY_BADGE_BACKGROUND_COLOR)) {
BadgeDrawable badgeDrawable = this.mTabLayout.getTabAt(index).getOrCreateBadge();
badgeDrawable.setBackgroundColor(
TiConvert.toColor(tabProxy.getProperty(TiC.PROPERTY_BADGE_BACKGROUND_COLOR), tabProxy.getActivity()));
}
if (tabProxy.hasPropertyAndNotNull(TiC.PROPERTY_BADGE_TEXT_COLOR)) {
BadgeDrawable badgeDrawable = this.mTabLayout.getTabAt(index).getOrCreateBadge();
badgeDrawable.setBadgeTextColor(
Expand Down
3 changes: 2 additions & 1 deletion android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ public class TiC
public static final String PROPERTY_BACKGROUND_SELECTED_COLOR = "backgroundSelectedColor";
public static final String PROPERTY_BACKGROUND_SELECTED_IMAGE = "backgroundSelectedImage";
public static final String PROPERTY_BADGE = "badge";
public static final String PROPERTY_BADGE_COLOR = "badgeColor";
public static final String PROPERTY_BADGE_COLOR = "badgeColor"; // DEPRECATED: Superseded by PROPERTY_BADGE_BACKGROUND_COLOR.
public static final String PROPERTY_BADGE_BACKGROUND_COLOR = "badgeBackgroundColor";
public static final String PROPERTY_BADGE_TEXT_COLOR = "badgeTextColor";
public static final String PROPERTY_TARGET_ITEM_INDEX = "targetItemIndex";
public static final String PROPERTY_TARGET_SECTION = "targetSection";
Expand Down
13 changes: 13 additions & 0 deletions apidoc/Titanium/UI/Tab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ properties:
since: {android: "9.3.0"}

- name: badgeColor
deprecated:
since: "12.2.0"
notes: Use [Titanium.UI.Tab.badgeBackgroundColor](Titanium.UI.Tab.badgeBackgroundColor) instead.
summary: |
If this item displays a badge, this color will be used for the badge's background.
If set to null, the default background color will be used instead.
Expand All @@ -205,6 +208,16 @@ properties:
platforms: [android, iphone, ipad, macos]
since: {android: "9.3.0", iphone: "6.1.0", ipad: "6.1.0", macos: "9.2.0"}

- name: badgeBackgroundColor
summary: |
If this item displays a badge, this color will be used for the badge's background.
If set to null, the default background color will be used instead.
description: |
For information about color values, see the "Colors" section of <Titanium.UI>.
type: [String, Titanium.UI.Color]
platforms: [android, iphone, ipad, macos]
since: {android: "12.2.0"}

- name: badgeTextColor
summary: |
Set the text color of the badge.
Expand Down

0 comments on commit e06e816

Please sign in to comment.