Bug 1331995 - Reset text direction to locale in order to reveal text hint, r=sebastian
authormaliu <max@mxli.us>
Wed, 01 Mar 2017 14:04:52 +0800
changeset 394357 c6a264b47ece8d056a3c709dcf9978059557ba2b
parent 394356 e440be3a764b24041af3d381042ba905fe849f09
child 394358 af67c447c17b86e3e6055a4fbda866f15a091961
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1331995
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1331995 - Reset text direction to locale in order to reveal text hint, r=sebastian MozReview-Commit-ID: I1FIL7QDRSu
mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
@@ -21,16 +21,17 @@ import org.mozilla.gecko.SiteIdentity.Tr
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.animation.PropertyAnimator;
 import org.mozilla.gecko.animation.ViewHelper;
 import org.mozilla.gecko.toolbar.BrowserToolbarTabletBase.ForwardButtonAnimation;
 import org.mozilla.gecko.Experiments;
 import org.mozilla.gecko.util.HardwareUtils;
 import org.mozilla.gecko.util.StringUtils;
+import org.mozilla.gecko.util.ViewUtil;
 import org.mozilla.gecko.widget.themed.ThemedLinearLayout;
 import org.mozilla.gecko.widget.themed.ThemedTextView;
 
 import android.content.Context;
 import android.os.SystemClock;
 import android.support.annotation.NonNull;
 import android.support.v4.view.ViewCompat;
 import android.text.Spannable;
@@ -240,16 +241,24 @@ public class ToolbarDisplayLayout extend
         if (flags.contains(UpdateFlags.PRIVATE_MODE)) {
             mTitle.setPrivateMode(tab.isPrivate());
         }
     }
 
     void setTitle(CharSequence title) {
         mTitle.setText(title);
 
+        if (TextUtils.isEmpty(title)) {
+            //  Reset TextDirection to Locale in order to reveal text hint in correct direction
+            ViewUtil.setTextDirection(mTitle, TEXT_DIRECTION_LOCALE);
+        } else {
+            //  Otherwise, fall back to default first strong strategy
+            ViewUtil.setTextDirection(mTitle, TEXT_DIRECTION_FIRST_STRONG);
+        }
+
         if (mTitleChangeListener != null) {
             mTitleChangeListener.onTitleChange(title);
         }
     }
 
     private void updateTitle(@NonNull Tab tab) {
         // Keep the title unchanged if there's no selected tab,
         // or if the tab is entering reader mode.
--- a/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java
+++ b/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java
@@ -160,17 +160,28 @@ public class ViewUtil {
             case ViewCompat.LAYOUT_DIRECTION_LTR:
             default:
                 ViewCompat.setLayoutDirection(view, ViewCompat.LAYOUT_DIRECTION_LTR);
                 break;
         }
     }
 
     /**
-     * RTL compatibility wrapper to force set TextDirection for JB mr1 and above
+     * RTL compatibility wrapper to set TextDirection
+     * @param textView
+     * @param textDirection
+     */
+    public static void setTextDirection(TextView textView, int textDirection) {
+        if(AppConstants.Versions.feature17Plus) {
+            textView.setTextDirection(textDirection);
+        }
+    }
+
+    /**
+     * RTL compatibility wrapper to force set TextDirection as RTL for JB mr1 and above
      *
      * @param textView
      * @param isRtl
      */
     public static void setTextDirectionRtlCompat(TextView textView, boolean isRtl) {
         if (AppConstants.Versions.feature17Plus) {
             setTextDirectionRtlCompat17(textView, isRtl);
         }