1
0
Fork 0

For #12976 - Show infinity symbol in the tab counter when the count is greater than 99

master
Shen 2020-08-12 18:11:12 -07:00 committed by Mugurell
parent 87349c17a1
commit 0356d86784
1 changed files with 13 additions and 1 deletions

View File

@ -39,9 +39,13 @@ import mozilla.components.browser.tabstray.TabViewHolder
import mozilla.components.support.ktx.android.util.dpToPx
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.toolbar.TabCounter.Companion.INFINITE_CHAR_PADDING_BOTTOM
import org.mozilla.fenix.components.toolbar.TabCounter.Companion.MAX_VISIBLE_TABS
import org.mozilla.fenix.components.toolbar.TabCounter.Companion.SO_MANY_TABS_OPEN
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.tabtray.SaveToCollectionsButtonAdapter.MultiselectModeChange
import java.text.NumberFormat
/**
* View that contains and configures the BrowserAwesomeBar
@ -372,7 +376,7 @@ class TabTrayView(
}
view.tab_tray_overflow.isVisible = !hasNoTabs
counter_text.text = "${browserState.normalTabs.size}"
counter_text.text = updateTabCounter(browserState.normalTabs.size)
updateTabCounterContentDescription(browserState.normalTabs.size)
adjustNewTabButtonsForNormalMode()
@ -457,6 +461,14 @@ class TabTrayView(
}
}
private fun updateTabCounter(count: Int): String {
if (count > MAX_VISIBLE_TABS) {
counter_text.setPadding(0, 0, 0, INFINITE_CHAR_PADDING_BOTTOM)
return SO_MANY_TABS_OPEN
}
return NumberFormat.getInstance().format(count.toLong())
}
fun setTopOffset(landscape: Boolean) {
val topOffset = if (landscape) {
0