Commit cbc0eaa7 authored by Troy Hildebrandt's avatar Troy Hildebrandt Committed by Commit Bot

Avoid forcing LTR on the URL bar if displaying a query.

We currently force the text in the URL bar to display LTR if the URL bar
is unfocused. This CL avoids that if we're displaying query terms
instead.

Bug: 776988
Change-Id: I563b903c24435adcfca9dad7efcaec3dd64770fa
Reviewed-on: https://chromium-review.googlesource.com/935474Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Troy Hildebrandt <thildebr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539283}
parent 20d36369
......@@ -2085,6 +2085,11 @@ public class LocationBarLayout extends FrameLayout
focusCurrentTab();
}
@Override
public boolean shouldForceLTR() {
return !mToolbarDataProvider.isDisplayingQueryTerms();
}
/**
* @return Returns the original url of the page.
*/
......
......@@ -171,6 +171,11 @@ public class UrlBar extends AutocompleteEditText {
* Called to notify that back key has been pressed while the URL bar has focus.
*/
void backKeyPressed();
/**
* @return Whether or not we should force LTR text on the URL bar when unfocused.
*/
boolean shouldForceLTR();
}
public UrlBar(Context context, AttributeSet attrs) {
......@@ -346,7 +351,7 @@ public class UrlBar extends AutocompleteEditText {
// normally (to allow users to make non-URL searches and to avoid showing Android's split
// insertion point when an RTL user enters RTL text). Also render text normally when the
// text field is empty (because then it displays an instruction that is not a URL).
if (mFocused || length() == 0) {
if (mFocused || length() == 0 || !mUrlBarDelegate.shouldForceLTR()) {
ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_INHERIT);
} else {
ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_LTR);
......
......@@ -701,6 +701,11 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
assert false : "The URL bar should never take focus in CCTs.";
}
@Override
public boolean shouldForceLTR() {
return true;
}
@Override
public void setUrlBarFocus(boolean shouldBeFocused) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment