Bug 1331995 - Reset text direction to locale in order to reveal text hint, r=sebastian
MozReview-Commit-ID: I1FIL7QDRSu
--- 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);
}