diff options
Diffstat (limited to 'src/com/android/launcher3/ExtendedEditText.java')
-rw-r--r-- | src/com/android/launcher3/ExtendedEditText.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java index 596aa8f7b..403c8b8ba 100644 --- a/src/com/android/launcher3/ExtendedEditText.java +++ b/src/com/android/launcher3/ExtendedEditText.java @@ -16,12 +16,16 @@ package com.android.launcher3; import android.content.Context; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.DragEvent; import android.view.KeyEvent; +import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; +import com.android.launcher3.util.UiThreadHelper; + /** * The edit text that reports back when the back key has been pressed. @@ -102,8 +106,7 @@ public class ExtendedEditText extends EditText { } public void dispatchBackKey() { - ((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE)) - .hideSoftInputFromWindow(getWindowToken(), 0); + UiThreadHelper.hideKeyboardAsync(getContext(), getWindowToken()); if (mBackKeyListener != null) { mBackKeyListener.onBackKey(); } @@ -121,4 +124,17 @@ public class ExtendedEditText extends EditText { public boolean isSuggestionsEnabled() { return !mForceDisableSuggestions && super.isSuggestionsEnabled(); } + + public void reset() { + if (!TextUtils.isEmpty(getText())) { + setText(""); + } + if (isFocused()) { + View nextFocus = focusSearch(View.FOCUS_DOWN); + if (nextFocus != null) { + nextFocus.requestFocus(); + } + } + UiThreadHelper.hideKeyboardAsync(getContext(), getWindowToken()); + } } |