| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.searchwidget; | 5 package org.chromium.chrome.browser.searchwidget; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.os.Handler; | 8 import android.os.Handler; |
| 9 import android.util.AttributeSet; | 9 import android.util.AttributeSet; |
| 10 import android.view.View; | 10 import android.view.View; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 @Override | 69 @Override |
| 70 public void onNativeLibraryReady() { | 70 public void onNativeLibraryReady() { |
| 71 super.onNativeLibraryReady(); | 71 super.onNativeLibraryReady(); |
| 72 setAutocompleteProfile(Profile.getLastUsedProfile().getOriginalProfile()
); | 72 setAutocompleteProfile(Profile.getLastUsedProfile().getOriginalProfile()
); |
| 73 setShowCachedZeroSuggestResults(true); | 73 setShowCachedZeroSuggestResults(true); |
| 74 } | 74 } |
| 75 | 75 |
| 76 /** Called when the SearchActivity has finished initialization. */ | 76 /** Called when the SearchActivity has finished initialization. */ |
| 77 void onDeferredStartup(boolean isVoiceSearchIntent) { | 77 void onDeferredStartup(boolean isVoiceSearchIntent) { |
| 78 SearchWidgetProvider.updateCachedVoiceSearchAvailability(isVoiceSearchEn
abled()); |
| 78 if (isVoiceSearchIntent && mUrlBar.isFocused()) onUrlFocusChange(true); | 79 if (isVoiceSearchIntent && mUrlBar.isFocused()) onUrlFocusChange(true); |
| 79 } | 80 } |
| 80 | 81 |
| 81 /** Begins a new query. */ | 82 /** Begins a new query. */ |
| 82 void beginQuery(boolean isVoiceSearchIntent) { | 83 void beginQuery(boolean isVoiceSearchIntent) { |
| 83 if (isVoiceSearchIntent) { | 84 if (isVoiceSearchEnabled() && isVoiceSearchIntent) { |
| 84 startVoiceRecognition(); | 85 startVoiceRecognition(); |
| 85 } else { | 86 } else { |
| 86 focusTextBox(); | 87 focusTextBox(); |
| 87 } | 88 } |
| 88 } | 89 } |
| 89 | 90 |
| 90 private void focusTextBox() { | 91 private void focusTextBox() { |
| 91 if (mNativeInitialized) onUrlFocusChange(true); | 92 if (mNativeInitialized) onUrlFocusChange(true); |
| 92 | 93 |
| 93 mUrlBar.setIgnoreTextChangesForAutocomplete(true); | 94 mUrlBar.setIgnoreTextChangesForAutocomplete(true); |
| 94 mUrlBar.setUrl("", null); | 95 mUrlBar.setUrl("", null); |
| 95 mUrlBar.setIgnoreTextChangesForAutocomplete(false); | 96 mUrlBar.setIgnoreTextChangesForAutocomplete(false); |
| 96 | 97 |
| 97 mUrlBar.setCursorVisible(true); | 98 mUrlBar.setCursorVisible(true); |
| 98 mUrlBar.setSelection(0, mUrlBar.getText().length()); | 99 mUrlBar.setSelection(0, mUrlBar.getText().length()); |
| 99 new Handler().post(new Runnable() { | 100 new Handler().post(new Runnable() { |
| 100 @Override | 101 @Override |
| 101 public void run() { | 102 public void run() { |
| 102 UiUtils.showKeyboard(mUrlBar); | 103 UiUtils.showKeyboard(mUrlBar); |
| 103 } | 104 } |
| 104 }); | 105 }); |
| 105 } | 106 } |
| 106 } | 107 } |
| OLD | NEW |