зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1014233 - Discard autocomplete result if we are not expecting a result. r=wesj
This commit is contained in:
Родитель
6ebb289168
Коммит
cd33c2cc58
|
@ -61,6 +61,8 @@ public class ToolbarEditText extends CustomEditText
|
||||||
private boolean mSettingAutoComplete;
|
private boolean mSettingAutoComplete;
|
||||||
// Spans used for marking the autocomplete text
|
// Spans used for marking the autocomplete text
|
||||||
private Object[] mAutoCompleteSpans;
|
private Object[] mAutoCompleteSpans;
|
||||||
|
// Do not process autocomplete result
|
||||||
|
private boolean mDiscardAutoCompleteResult;
|
||||||
|
|
||||||
public ToolbarEditText(Context context, AttributeSet attrs) {
|
public ToolbarEditText(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
@ -226,6 +228,12 @@ public class ToolbarEditText extends CustomEditText
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void onAutocomplete(final String result) {
|
public final void onAutocomplete(final String result) {
|
||||||
|
// If mDiscardAutoCompleteResult is true, we temporarily disabled
|
||||||
|
// autocomplete (due to backspacing, etc.) and we should bail early.
|
||||||
|
if (mDiscardAutoCompleteResult) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isEnabled() || result == null) {
|
if (!isEnabled() || result == null) {
|
||||||
mAutoCompleteResult = "";
|
mAutoCompleteResult = "";
|
||||||
return;
|
return;
|
||||||
|
@ -437,6 +445,10 @@ public class ToolbarEditText extends CustomEditText
|
||||||
|
|
||||||
mAutoCompletePrefixLength = textLength;
|
mAutoCompletePrefixLength = textLength;
|
||||||
|
|
||||||
|
// If we are not autocompleting, we set mDiscardAutoCompleteResult to true
|
||||||
|
// to discard any autocomplete results that are in-flight, and vice versa.
|
||||||
|
mDiscardAutoCompleteResult = !doAutocomplete;
|
||||||
|
|
||||||
if (doAutocomplete && mAutoCompleteResult.startsWith(text)) {
|
if (doAutocomplete && mAutoCompleteResult.startsWith(text)) {
|
||||||
// If this text already matches our autocomplete text, autocomplete likely
|
// If this text already matches our autocomplete text, autocomplete likely
|
||||||
// won't change. Just reuse the old autocomplete value.
|
// won't change. Just reuse the old autocomplete value.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче