diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/widget/SearchView.java | 32 | ||||
| -rw-r--r-- | core/java/com/android/internal/view/menu/MenuBuilder.java | 1 |
2 files changed, 23 insertions, 10 deletions
diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index 91b19ed19658..8b4d3a9a40d1 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -118,6 +118,21 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { private SearchableInfo mSearchable; private Bundle mAppSearchData; + /* + * SearchView can be set expanded before the IME is ready to be shown during + * initial UI setup. The show operation is asynchronous to account for this. + */ + private Runnable mShowImeRunnable = new Runnable() { + public void run() { + InputMethodManager imm = (InputMethodManager) + getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + + if (imm != null) { + imm.showSoftInputUnchecked(0, null); + } + } + }; + // For voice searching private final Intent mVoiceWebSearchIntent; private final Intent mVoiceAppSearchIntent; @@ -650,16 +665,15 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { mSubmitArea.getBackground().setState(focused ? FOCUSED_STATE_SET : EMPTY_STATE_SET); } - private void setImeVisibility(boolean visible) { - InputMethodManager imm = (InputMethodManager) - getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + private void setImeVisibility(final boolean visible) { + if (visible) { + post(mShowImeRunnable); + } else { + removeCallbacks(mShowImeRunnable); + InputMethodManager imm = (InputMethodManager) + getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - // We made sure the IME was displayed, so also make sure it is closed - // when we go away. - if (imm != null) { - if (visible) { - imm.showSoftInputUnchecked(0, null); - } else { + if (imm != null) { imm.hideSoftInputFromWindow(getWindowToken(), 0); } } diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java index 19cbe25af54d..7839a0847619 100644 --- a/core/java/com/android/internal/view/menu/MenuBuilder.java +++ b/core/java/com/android/internal/view/menu/MenuBuilder.java @@ -27,7 +27,6 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Parcelable; -import android.util.Log; import android.util.SparseArray; import android.view.ActionProvider; import android.view.ContextMenu.ContextMenuInfo; |
