Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the maximum character count for the order badge #13825

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
22.1
-----

- [*] The order count badge is now fully visible for counts higher than 99 [https://github.com/woocommerce/woocommerce-android/pull/13825]

22.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MainBottomNavigationView @JvmOverloads constructor(
ordersBadge = getOrCreateBadge(R.id.orders)
ordersBadge.isVisible = false
ordersBadge.backgroundColor = ContextCompat.getColor(context, R.color.color_primary)
ordersBadge.maxCharacterCount = 3 // this includes the plus sign
ordersBadge.maxCharacterCount = 4 // this includes the plus sign
Copy link
Contributor

@atorresveiga atorresveiga Mar 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detekt is complaining because this is a magic number. Consider using a constant

Patch:

Index: WooCommerce/src/main/kotlin/com/woocommerce/android/ui/main/MainBottomNavigationView.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/main/MainBottomNavigationView.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/main/MainBottomNavigationView.kt
--- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/main/MainBottomNavigationView.kt	(revision ef5228c65ce77c421ce87a32256de86660484d2d)
+++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/main/MainBottomNavigationView.kt	(date 1742665694598)
@@ -76,7 +76,7 @@
         ordersBadge = getOrCreateBadge(R.id.orders)
         ordersBadge.isVisible = false
         ordersBadge.backgroundColor = ContextCompat.getColor(context, R.color.color_primary)
-        ordersBadge.maxCharacterCount = 4 // this includes the plus sign
+        ordersBadge.maxCharacterCount = MAX_CHARACTERS_IN_BADGE // this includes the plus sign
 
         moreMenuBadge = getOrCreateBadge(R.id.moreMenu)
         moreMenuBadge.isVisible = false
@@ -156,4 +156,8 @@
 
     private fun NavDestination.matchDestination(@IdRes destId: Int): Boolean =
         hierarchy.any { it.id == destId }
+    
+    companion object {
+        const val MAX_CHARACTERS_IN_BADGE = 4
+    }
 }


moreMenuBadge = getOrCreateBadge(R.id.moreMenu)
moreMenuBadge.isVisible = false
Expand Down Expand Up @@ -133,10 +133,6 @@ class MainBottomNavigationView @JvmOverloads constructor(
}
}

fun clearOrderBadgeCount() {
ordersBadge.clearNumber()
}

override fun onNavigationItemSelected(item: MenuItem): Boolean {
navController?.let { navController ->
val navSuccess = NavigationUI.onNavDestinationSelected(item, navController)
Expand Down