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.animation.Animator; | 7 import android.animation.Animator; |
8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
11 import android.annotation.SuppressLint; | 11 import android.annotation.SuppressLint; |
12 import android.content.Context; | 12 import android.content.Context; |
13 import android.os.SystemClock; | 13 import android.os.SystemClock; |
14 import android.text.Layout; | 14 import android.text.Layout; |
15 import android.text.TextUtils; | 15 import android.text.TextUtils; |
16 import android.util.AttributeSet; | 16 import android.util.AttributeSet; |
17 import android.util.LayoutDirection; | 17 import android.util.LayoutDirection; |
18 import android.view.View; | 18 import android.view.View; |
19 import android.view.ViewGroup; | 19 import android.view.ViewGroup; |
20 import android.widget.TextView; | 20 import android.widget.TextView; |
21 | 21 |
22 import org.chromium.base.ApiCompatibilityUtils; | 22 import org.chromium.base.ApiCompatibilityUtils; |
| 23 import org.chromium.base.VisibleForTesting; |
23 import org.chromium.chrome.R; | 24 import org.chromium.chrome.R; |
24 import org.chromium.chrome.browser.util.MathUtils; | 25 import org.chromium.chrome.browser.util.MathUtils; |
25 import org.chromium.ui.interpolators.BakedBezierInterpolator; | 26 import org.chromium.ui.interpolators.BakedBezierInterpolator; |
26 | 27 |
27 /** | 28 /** |
28 * Widget that handles displaying the URL. Adds the capability to show the trai
ling portion | 29 * Widget that handles displaying the URL. Adds the capability to show the trai
ling portion |
29 * of the URL in a separate text widget for animations. | 30 * of the URL in a separate text widget for animations. |
30 */ | 31 */ |
31 public class UrlContainer extends ViewGroup { | 32 public class UrlContainer extends ViewGroup { |
32 private static final int MIN_TRAILING_TEXT_SHOW_DURATION_MS = 3000; | 33 private static final int MIN_TRAILING_TEXT_SHOW_DURATION_MS = 3000; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 166 |
166 if (trailingText == null) trailingText = ""; | 167 if (trailingText == null) trailingText = ""; |
167 if (!trailingText.equals(mTrailingTextView.getText())) { | 168 if (!trailingText.equals(mTrailingTextView.getText())) { |
168 mTrailingTextView.setText(trailingText); | 169 mTrailingTextView.setText(trailingText); |
169 changed |= true; | 170 changed |= true; |
170 } | 171 } |
171 return changed; | 172 return changed; |
172 } | 173 } |
173 | 174 |
174 /** | 175 /** |
| 176 * Return the complete text shown in the URL container. Even if the trailin
g text has faded |
| 177 * away, this will be included in the returned string. |
| 178 */ |
| 179 @VisibleForTesting |
| 180 public String getText() { |
| 181 return mUrlBarView.getText().toString() + mTrailingTextView.getText().to
String(); |
| 182 } |
| 183 |
| 184 /** |
175 * Specifies whether the trailing URL text should use dark text colors or li
ght colors. | 185 * Specifies whether the trailing URL text should use dark text colors or li
ght colors. |
176 * @param useDarkColors Whether the text colors should be dark (i.e. appropr
iate for use | 186 * @param useDarkColors Whether the text colors should be dark (i.e. appropr
iate for use |
177 * on a light background). | 187 * on a light background). |
178 */ | 188 */ |
179 public void setUseDarkTextColors(boolean useDarkColors) { | 189 public void setUseDarkTextColors(boolean useDarkColors) { |
180 mUseDarkColors = useDarkColors; | 190 mUseDarkColors = useDarkColors; |
181 mUrlBarView.setUseDarkTextColors(mUseDarkColors); | 191 mUrlBarView.setUseDarkTextColors(mUseDarkColors); |
182 | 192 |
183 int trailingTextColorId = R.color.url_emphasis_non_emphasized_text; | 193 int trailingTextColorId = R.color.url_emphasis_non_emphasized_text; |
184 if (!mUseDarkColors) { | 194 if (!mUseDarkColors) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } else { | 318 } else { |
309 if (mTrailingTextShownWhileFocused) { | 319 if (mTrailingTextShownWhileFocused) { |
310 setTrailingTextVisible(true); | 320 setTrailingTextVisible(true); |
311 if (mTrailingTextHiddenWhileFocused) { | 321 if (mTrailingTextHiddenWhileFocused) { |
312 setTrailingTextVisible(false); | 322 setTrailingTextVisible(false); |
313 } | 323 } |
314 } | 324 } |
315 } | 325 } |
316 } | 326 } |
317 } | 327 } |
OLD | NEW |