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.widget.findinpage; | 5 package org.chromium.chrome.browser.widget.findinpage; |
6 | 6 |
7 import android.animation.Animator; | 7 import android.animation.Animator; |
8 import android.annotation.SuppressLint; | 8 import android.annotation.SuppressLint; |
9 import android.content.ClipData; | 9 import android.content.ClipData; |
10 import android.content.ClipboardManager; | 10 import android.content.ClipboardManager; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 TabWebContentsDelegateAndroid.FindMatchRectsListener { | 55 TabWebContentsDelegateAndroid.FindMatchRectsListener { |
56 private static final long ACCESSIBLE_ANNOUNCEMENT_DELAY_MILLIS = 500; | 56 private static final long ACCESSIBLE_ANNOUNCEMENT_DELAY_MILLIS = 500; |
57 | 57 |
58 // Toolbar UI | 58 // Toolbar UI |
59 private TextView mFindStatus; | 59 private TextView mFindStatus; |
60 protected FindQuery mFindQuery; | 60 protected FindQuery mFindQuery; |
61 protected TintedImageButton mCloseFindButton; | 61 protected TintedImageButton mCloseFindButton; |
62 protected TintedImageButton mFindPrevButton; | 62 protected TintedImageButton mFindPrevButton; |
63 protected TintedImageButton mFindNextButton; | 63 protected TintedImageButton mFindNextButton; |
64 | 64 |
65 private FindResultBar mResultBar = null; | 65 private FindResultBar mResultBar; |
66 | 66 |
67 private TabModelSelector mTabModelSelector; | 67 private TabModelSelector mTabModelSelector; |
68 private final TabModelSelectorObserver mTabModelSelectorObserver; | 68 private final TabModelSelectorObserver mTabModelSelectorObserver; |
69 private final TabModelObserver mTabModelObserver; | 69 private final TabModelObserver mTabModelObserver; |
70 private Tab mCurrentTab; | 70 private Tab mCurrentTab; |
71 private final TabObserver mTabObserver; | 71 private final TabObserver mTabObserver; |
72 private WindowAndroid mWindowAndroid; | 72 private WindowAndroid mWindowAndroid; |
73 private FindInPageBridge mFindInPageBridge; | 73 private FindInPageBridge mFindInPageBridge; |
74 private FindToolbarObserver mObserver; | 74 private FindToolbarObserver mObserver; |
75 | 75 |
76 /** Most recently entered search text (globally, in non-incognito tabs). */ | 76 /** Most recently entered search text (globally, in non-incognito tabs). */ |
77 private String mLastUserSearch = ""; | 77 private String mLastUserSearch = ""; |
78 | 78 |
79 /** Whether toolbar text is being set automatically (not typed by user). */ | 79 /** Whether toolbar text is being set automatically (not typed by user). */ |
80 private boolean mSettingFindTextProgrammatically = false; | 80 private boolean mSettingFindTextProgrammatically; |
81 | 81 |
82 /** Whether the search key should trigger a new search. */ | 82 /** Whether the search key should trigger a new search. */ |
83 private boolean mSearchKeyShouldTriggerSearch = false; | 83 private boolean mSearchKeyShouldTriggerSearch; |
84 | 84 |
85 private boolean mActive = false; | 85 private boolean mActive; |
86 | 86 |
87 private Handler mHandler = new Handler(); | 87 private Handler mHandler = new Handler(); |
88 private Runnable mAccessibleAnnouncementRunnable; | 88 private Runnable mAccessibleAnnouncementRunnable; |
89 private boolean mAccessibilityDidActivateResult; | 89 private boolean mAccessibilityDidActivateResult; |
90 | 90 |
91 /** Subclasses EditText in order to intercept BACK key presses. */ | 91 /** Subclasses EditText in order to intercept BACK key presses. */ |
92 @SuppressLint("Instantiatable") | 92 @SuppressLint("Instantiatable") |
93 static class FindQuery extends VerticallyFixedEditText implements OnKeyListe
ner { | 93 static class FindQuery extends VerticallyFixedEditText implements OnKeyListe
ner { |
94 private FindToolbar mFindToolbar; | 94 private FindToolbar mFindToolbar; |
95 | 95 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 final String findQuery = mFindQuery.getText().toString(); | 329 final String findQuery = mFindQuery.getText().toString(); |
330 if (findQuery.length() == 0) return; | 330 if (findQuery.length() == 0) return; |
331 | 331 |
332 UiUtils.hideKeyboard(mFindQuery); | 332 UiUtils.hideKeyboard(mFindQuery); |
333 mFindInPageBridge.startFinding(findQuery, forward, false); | 333 mFindInPageBridge.startFinding(findQuery, forward, false); |
334 mFindInPageBridge.activateFindInPageResultForAccessibility(); | 334 mFindInPageBridge.activateFindInPageResultForAccessibility(); |
335 mAccessibilityDidActivateResult = true; | 335 mAccessibilityDidActivateResult = true; |
336 } | 336 } |
337 | 337 |
338 private boolean mShowKeyboardOnceWindowIsFocused = false; | 338 private boolean mShowKeyboardOnceWindowIsFocused; |
339 | 339 |
340 @Override | 340 @Override |
341 public void onWindowFocusChanged(boolean hasFocus) { | 341 public void onWindowFocusChanged(boolean hasFocus) { |
342 super.onWindowFocusChanged(hasFocus); | 342 super.onWindowFocusChanged(hasFocus); |
343 | 343 |
344 if (mShowKeyboardOnceWindowIsFocused) { | 344 if (mShowKeyboardOnceWindowIsFocused) { |
345 mShowKeyboardOnceWindowIsFocused = false; | 345 mShowKeyboardOnceWindowIsFocused = false; |
346 // See showKeyboard() for explanation. | 346 // See showKeyboard() for explanation. |
347 // By this point we've already waited till the window regains focus | 347 // By this point we've already waited till the window regains focus |
348 // from the options menu, but we still need to use postDelayed with | 348 // from the options menu, but we still need to use postDelayed with |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 // practice that means the soft keyboard never shows up (whatever | 713 // practice that means the soft keyboard never shows up (whatever |
714 // flags you pass). So as a workaround we postpone asking for the | 714 // flags you pass). So as a workaround we postpone asking for the |
715 // keyboard to be shown until just after the window gets refocused. | 715 // keyboard to be shown until just after the window gets refocused. |
716 // See onWindowFocusChanged(boolean hasFocus). | 716 // See onWindowFocusChanged(boolean hasFocus). |
717 mShowKeyboardOnceWindowIsFocused = true; | 717 mShowKeyboardOnceWindowIsFocused = true; |
718 return; | 718 return; |
719 } | 719 } |
720 UiUtils.showKeyboard(mFindQuery); | 720 UiUtils.showKeyboard(mFindQuery); |
721 } | 721 } |
722 } | 722 } |
OLD | NEW |