Bug 1333089 - Force update up indicator drawable in onCreate even locale did not change. r=sebastian, a=lizzard
authormaliu <max@mxli.us>
Thu, 02 Feb 2017 11:38:47 +0800
changeset 375983 54bc0a9450897cd40565a38f7280df0e4f344641
parent 375982 7c487eb9d8bed85aeb0101eb378e278665e2962f
child 375984 644301c96f60cc9f7813afd53be1f349bab78242
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, lizzard
bugs1333089
milestone53.0a2
Bug 1333089 - Force update up indicator drawable in onCreate even locale did not change. r=sebastian, a=lizzard MozReview-Commit-ID: Ltuuq16u571
mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -235,16 +235,24 @@ public class GeckoPreferences
         final String newTitle = getString(title);
         if (newTitle != null) {
             Log.v(LOGTAG, "Setting action bar title to " + newTitle);
 
             setTitle(newTitle);
         }
     }
 
+    private void updateHomeAsUpIndicator() {
+        final ActionBar actionBar = getSupportActionBar();
+        if (actionBar == null) {
+            return;
+        }
+        actionBar.setHomeAsUpIndicator(android.support.v7.appcompat.R.drawable.abc_ic_ab_back_mtrl_am_alpha);
+    }
+
     /**
      * We only call this method for pre-HC versions of Android.
      */
     private void updateTitleForPrefsResource(int res) {
         // At present we only need to do this for non-leaf prefs views
         // and the locale switcher itself.
         int title = -1;
         if (res == R.xml.preferences) {
@@ -265,20 +273,18 @@ public class GeckoPreferences
 
     private void onLocaleChanged(Locale newLocale) {
         Log.d(LOGTAG, "onLocaleChanged: " + newLocale);
 
         BrowserLocaleManager.getInstance().updateConfiguration(getApplicationContext(), newLocale);
         //  If activity is not recreated, also update locale to current activity configuration
         BrowserLocaleManager.getInstance().updateConfiguration(GeckoPreferences.this, newLocale);
         ViewUtil.setLayoutDirection(getWindow().getDecorView(), newLocale);
-
         //  Force update navigate up icon by current layout direction
-        final ActionBar actionBar = getSupportActionBar();
-        actionBar.setHomeAsUpIndicator(android.support.v7.appcompat.R.drawable.abc_ic_ab_back_mtrl_am_alpha);
+        updateHomeAsUpIndicator();
 
         this.lastLocale = newLocale;
 
         if (isMultiPane()) {
             // This takes care of the left pane.
             invalidateHeaders();
 
             // Detach and reattach the current prefs pane so that it
@@ -328,16 +334,21 @@ public class GeckoPreferences
         intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
         startActivityForResultChoosingTransition(intent, REQUEST_CODE_PREF_SCREEN);
 
         setResult(RESULT_CODE_LOCALE_DID_CHANGE);
         finishChoosingTransition();
     }
 
     private void checkLocale() {
+        if (AppConstants.Versions.feature21Plus && AppConstants.Versions.preMarshmallow) {
+            //  Force update navigate up icon by current layout direction
+            updateHomeAsUpIndicator();
+        }
+
         final Locale currentLocale = Locale.getDefault();
         Log.v(LOGTAG, "Checking locale: " + currentLocale + " vs " + lastLocale);
         if (currentLocale.equals(lastLocale)) {
             return;
         }
 
         onLocaleChanged(currentLocale);
     }