Bug 1432854 - Fix Tab counter doesn't show native numbers for non-arabic numeral languages draft
authorSuhail Alkowaileet <xsoh.k7@gmail.com>
Wed, 07 Feb 2018 08:41:17 +0300
changeset 751939 4968a5eb77a9e6fdfaa29217c118f12f5b530a5a
parent 751476 f1a4b64f19b0e93c49492735db30a5023e624ae7
push id98094
push userbmo:xsoh.k7@gmail.com
push dateWed, 07 Feb 2018 05:46:10 +0000
bugs1432854
milestone60.0a1
Bug 1432854 - Fix Tab counter doesn't show native numbers for non-arabic numeral languages MozReview-Commit-ID: 1sWCHya55GZ
mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/TabCounter.java
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
--- 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) {