Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java |
| index 0ee47fa74f7a3f457b19a710a1bc9cecb712618a..f874e122a8510fa80d281cecf9cca93b1c68494c 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java |
| @@ -14,7 +14,6 @@ import android.graphics.Paint; |
| import android.graphics.Rect; |
| import android.os.SystemClock; |
| import android.text.Editable; |
| -import android.text.Layout; |
| import android.text.Selection; |
| import android.text.Spanned; |
| import android.text.TextUtils; |
| @@ -73,16 +72,8 @@ public class UrlBar extends VerticallyFixedEditText { |
| private boolean mFirstDrawComplete; |
| - /** |
| - * The text direction of the URL or query: LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, or |
| - * LAYOUT_DIRECTION_RTL. |
| - * */ |
| - private int mUrlDirection; |
| - |
| private UrlBarDelegate mUrlBarDelegate; |
| - private UrlDirectionListener mUrlDirectionListener; |
| - |
| private final AutocompleteSpan mAutocompleteSpan; |
| /** |
| @@ -135,20 +126,6 @@ public class UrlBar extends VerticallyFixedEditText { |
| private boolean mLastUrlEditWasDelete; |
| /** |
| - * Implement this to get updates when the direction of the text in the URL bar changes. |
| - * E.g. If the user is typing a URL, then erases it and starts typing a query in Arabic, |
| - * the direction will change from left-to-right to right-to-left. |
| - */ |
| - interface UrlDirectionListener { |
| - /** |
| - * Called whenever the layout direction of the UrlBar changes. |
| - * @param layoutDirection the new direction: android.view.View.LAYOUT_DIRECTION_LTR or |
| - * android.view.View.LAYOUT_DIRECTION_RTL |
| - */ |
| - public void onUrlDirectionChanged(int layoutDirection); |
| - } |
| - |
| - /** |
| * Delegate used to communicate with the content side and the parent layout. |
| */ |
| public interface UrlBarDelegate { |
| @@ -195,7 +172,13 @@ public class UrlBar extends VerticallyFixedEditText { |
| setUseDarkTextColors(true); |
| - mUrlDirection = LAYOUT_DIRECTION_LOCALE; |
| + // Force left-to-right rendering at the paragraph level. Right-to-left runs are still |
| + // rendered RTL, but will not flip the whole URL around. For example (if "ABC" is Hebrew), |
| + // this will render "ABC.com" as "CBA.com", rather than "com.CBA". This is consistent with |
| + // OmniboxViewViews on desktop. |
| + setTextDirection(TEXT_DIRECTION_LTR); |
|
Ted C
2016/05/18 17:01:01
Only available in API 17+
https://developer.andro
Matt Giuca
2016/06/09 08:39:12
Done.
|
| + setTextAlignment(TEXT_ALIGNMENT_VIEW_START); |
|
Ted C
2016/05/18 17:01:01
Same:
https://code.google.com/p/chromium/codesear
Matt Giuca
2016/06/09 08:39:12
Done.
|
| + |
| mAutocompleteSpan = new AutocompleteSpan(); |
| // The URL Bar is derived from an text edit class, and as such is focusable by |
| @@ -567,55 +550,6 @@ public class UrlBar extends VerticallyFixedEditText { |
| mOmniboxLivenessListener.onOmniboxInteractive(); |
| } |
| } |
| - |
| - // Notify listeners if the URL's direction has changed. |
| - updateUrlDirection(); |
| - } |
| - |
| - /** |
| - * If the direction of the URL has changed, update mUrlDirection and notify the |
| - * UrlDirectionListeners. |
| - */ |
| - private void updateUrlDirection() { |
| - Layout layout = getLayout(); |
| - if (layout == null) return; |
| - |
| - int urlDirection; |
| - if (length() == 0) { |
| - urlDirection = LAYOUT_DIRECTION_LOCALE; |
| - } else if (layout.getParagraphDirection(0) == Layout.DIR_LEFT_TO_RIGHT) { |
| - urlDirection = LAYOUT_DIRECTION_LTR; |
| - } else { |
| - urlDirection = LAYOUT_DIRECTION_RTL; |
| - } |
| - |
| - if (urlDirection != mUrlDirection) { |
| - mUrlDirection = urlDirection; |
| - if (mUrlDirectionListener != null) { |
| - mUrlDirectionListener.onUrlDirectionChanged(urlDirection); |
| - } |
| - } |
| - } |
| - |
| - /** |
| - * @return The text direction of the URL, e.g. LAYOUT_DIRECTION_LTR. |
| - */ |
| - public int getUrlDirection() { |
| - return mUrlDirection; |
| - } |
| - |
| - /** |
| - * Sets the listener for changes in the url bar's layout direction. Also calls |
| - * onUrlDirectionChanged() immediately on the listener. |
| - * |
| - * @param listener The UrlDirectionListener to receive callbacks when the url direction changes, |
| - * or null to unregister any previously registered listener. |
| - */ |
| - public void setUrlDirectionListener(UrlDirectionListener listener) { |
| - mUrlDirectionListener = listener; |
| - if (mUrlDirectionListener != null) { |
| - mUrlDirectionListener.onUrlDirectionChanged(mUrlDirection); |
| - } |
| } |
| /** |