| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.omnibox; | 5 package org.chromium.chrome.browser.omnibox; |
| 6 | 6 |
| 7 import android.content.ClipData; | 7 import android.content.ClipData; |
| 8 import android.content.ClipboardManager; | 8 import android.content.ClipboardManager; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 mFocused = focused; | 430 mFocused = focused; |
| 431 if (!focused) mAutocompleteSpan.clearSpan(); | 431 if (!focused) mAutocompleteSpan.clearSpan(); |
| 432 super.onFocusChanged(focused, direction, previouslyFocusedRect); | 432 super.onFocusChanged(focused, direction, previouslyFocusedRect); |
| 433 | 433 |
| 434 if (focused && mFirstFocusTimeMs == 0) { | 434 if (focused && mFirstFocusTimeMs == 0) { |
| 435 mFirstFocusTimeMs = SystemClock.elapsedRealtime(); | 435 mFirstFocusTimeMs = SystemClock.elapsedRealtime(); |
| 436 if (mOmniboxLivenessListener != null) mOmniboxLivenessListener.onOmn
iboxFocused(); | 436 if (mOmniboxLivenessListener != null) mOmniboxLivenessListener.onOmn
iboxFocused(); |
| 437 } | 437 } |
| 438 | 438 |
| 439 if (focused) StartupMetrics.getInstance().recordFocusedOmnibox(); | 439 if (focused) StartupMetrics.getInstance().recordFocusedOmnibox(); |
| 440 |
| 441 // When unfocused, force left-to-right rendering at the paragraph level
(which is desired |
| 442 // for URLs). Right-to-left runs are still rendered RTL, but will not fl
ip the whole URL |
| 443 // around. This is consistent with OmniboxViewViews on desktop. When foc
used, render text |
| 444 // normally (to allow users to make non-URL searches and to avoid showin
g Android's split |
| 445 // insertion point when an RTL user enters RTL text). |
| 446 if (focused) { |
| 447 ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_INHERIT)
; |
| 448 } else { |
| 449 ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_LTR); |
| 450 } |
| 451 // Always align to the same as the paragraph direction (LTR = left, RTL
= right). |
| 452 ApiCompatibilityUtils.setTextAlignment(this, TEXT_ALIGNMENT_TEXT_START); |
| 440 } | 453 } |
| 441 | 454 |
| 442 /** | 455 /** |
| 443 * @return The elapsed realtime timestamp in ms of the first time the url ba
r was focused, | 456 * @return The elapsed realtime timestamp in ms of the first time the url ba
r was focused, |
| 444 * 0 if never. | 457 * 0 if never. |
| 445 */ | 458 */ |
| 446 public long getFirstFocusTime() { | 459 public long getFirstFocusTime() { |
| 447 return mFirstFocusTimeMs; | 460 return mFirstFocusTimeMs; |
| 448 } | 461 } |
| 449 | 462 |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 return (int) paint.measureText(ELLIPSIS); | 1181 return (int) paint.measureText(ELLIPSIS); |
| 1169 } | 1182 } |
| 1170 | 1183 |
| 1171 @Override | 1184 @Override |
| 1172 public void draw(Canvas canvas, CharSequence text, int start, int end, | 1185 public void draw(Canvas canvas, CharSequence text, int start, int end, |
| 1173 float x, int top, int y, int bottom, Paint paint) { | 1186 float x, int top, int y, int bottom, Paint paint) { |
| 1174 canvas.drawText(ELLIPSIS, x, y, paint); | 1187 canvas.drawText(ELLIPSIS, x, y, paint); |
| 1175 } | 1188 } |
| 1176 } | 1189 } |
| 1177 } | 1190 } |
| OLD | NEW |