Bug 1432854 - Fix Tab counter doesn't show native numbers for non-arabic numeral languages
MozReview-Commit-ID: 1sWCHya55GZ
--- 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;
@@ -161,19 +163,16 @@ public class TabCounter extends ThemedRe
void setCountWithAnimation(final int count) {
// Don't animate from initial state.
if (this.count == 0) {
setCount(count);
return;
}
- if (this.count == count) {
- return;
- }
// Don't animate if there are still over MAX_VISIBLE_TABS tabs open.
if (this.count > MAX_VISIBLE_TABS && count > MAX_VISIBLE_TABS) {
this.count = count;
return;
}
adjustTextSize(count);
@@ -188,17 +187,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,17 +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.onTabChanged(null, TabEvents.RESTORED, "");
if (mMenu != null) {
mMenu.clear();
onCreateOptionsMenu(mMenu);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {