Bug 1432854 - Fix Tab counter doesn't show native numbers for non-arabic numeral languages
MozReview-Commit-ID: 3STmgEGAbJG
--- a/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/TabCounter.java
+++ b/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/TabCounter.java
@@ -14,16 +14,18 @@ import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import org.mozilla.gecko.R;
import org.mozilla.gecko.widget.themed.ThemedImageView;
import org.mozilla.gecko.widget.themed.ThemedRelativeLayout;
import org.mozilla.gecko.widget.themed.ThemedTextView;
+import java.text.NumberFormat;
+
public class TabCounter extends ThemedRelativeLayout {
private final ThemedImageView box;
private final ThemedImageView bar;
private final ThemedTextView text;
private final AnimatorSet animationSet;
private int count;
@@ -188,17 +190,17 @@ public class TabCounter extends ThemedRe
// Trigger animations.
animationSet.start();
}
private String formatForDisplay(int count) {
if (count > MAX_VISIBLE_TABS) {
return SO_MANY_TABS_OPEN;
}
- return String.valueOf(count);
+ return NumberFormat.getInstance().format(count);
}
private void adjustTextSize(int newCount) {
final float oldRatio = (this.count < MAX_VISIBLE_TABS && this.count >= 10) ? TWO_DIGITS_SIZE_RATIO : ONE_DIGIT_SIZE_RATIO;
final float newRatio = (newCount < MAX_VISIBLE_TABS && newCount >= 10) ? TWO_DIGITS_SIZE_RATIO : ONE_DIGIT_SIZE_RATIO;
if (this.count == 0 || newRatio != oldRatio) {
final int sizeInPixel = (int) (box.getWidth() * newRatio);
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -2910,16 +2910,17 @@ public class BrowserApp extends GeckoApp
}
@Override
public void onLocaleReady(final String locale) {
Log.d(LOGTAG, "onLocaleReady: " + locale);
super.onLocaleReady(locale);
HomePanelsManager.getInstance().onLocaleReady(locale);
+ mBrowserToolbar.onLocaleReady(locale);
if (mMenu != null) {
mMenu.clear();
onCreateOptionsMenu(mMenu);
}
}
@Override
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
@@ -536,16 +536,21 @@ public abstract class BrowserToolbar ext
switch (msg) {
case SELECTED:
case LOAD_ERROR:
case LOCATION_CHANGE:
isSwitchingTabs = false;
}
}
+ public void onLocaleReady(final String locale) {
+ final Tabs tabs = Tabs.getInstance();
+ tabsCounter.setCount(tabs.getDisplayCount());
+ }
+
/**
* Updates the progress bar percentage and hides/shows it depending on the loading state of the
* currently selected tab.
*/
private void updateProgressBarState() {
final Tab selectedTab = Tabs.getInstance().getSelectedTab();
// The selected tab may be null if GeckoApp (and thus the
// selected tab) are not yet initialized (bug 1090287).