From e04fbca0dcd8a9b268e5725f49525af87d1c18c2 Mon Sep 17 00:00:00 2001 From: maliu Date: Wed, 1 Mar 2017 14:04:52 +0800 Subject: [PATCH] Bug 1331995 - Reset text direction to locale in order to reveal text hint, r=sebastian MozReview-Commit-ID: I1FIL7QDRSu --HG-- extra : rebase_source : 7c11f50a6fe58f2752ef2409bcbf33bfdf8b3258 --- .../mozilla/gecko/toolbar/ToolbarDisplayLayout.java | 9 +++++++++ .../base/java/org/mozilla/gecko/util/ViewUtil.java | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java index 84b0051f87d5..831f5a6ce3fc 100644 --- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java +++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java @@ -26,6 +26,7 @@ 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; @@ -245,6 +246,14 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout { 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); } diff --git a/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java b/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java index 89864d2a743f..af9b9b228cf1 100644 --- a/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java +++ b/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java @@ -165,7 +165,18 @@ public class ViewUtil { } /** - * 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