diff options
author | Amith Yamasani <yamasani@google.com> | 2010-03-12 06:47:00 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-03-12 06:47:00 -0800 |
commit | e1748c67143f3bd2187cdafa8788790c8e33dbe5 (patch) | |
tree | 43c6c2368856305a7c246262d1fba8f0ac0f8ab1 /core | |
parent | a028a4b5e89bc4648b44c4f3ccbceb5a0ce13409 (diff) | |
parent | d25eb35b6b80b6f8065ab39b1cf1abb1fd801234 (diff) | |
download | frameworks_base-e1748c67143f3bd2187cdafa8788790c8e33dbe5.zip frameworks_base-e1748c67143f3bd2187cdafa8788790c8e33dbe5.tar.gz frameworks_base-e1748c67143f3bd2187cdafa8788790c8e33dbe5.tar.bz2 |
Merge "Fix for 2175289 : Can't get keyboard in search dialog after switching to landscape"
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/SearchDialog.java | 46 | ||||
-rw-r--r-- | core/java/android/widget/AutoCompleteTextView.java | 18 |
2 files changed, 43 insertions, 21 deletions
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index bf9b021..ebc64d7 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -19,23 +19,25 @@ package android.app; import static android.app.SuggestionsAdapter.getColumnString; +import java.util.WeakHashMap; +import java.util.concurrent.atomic.AtomicLong; + import android.content.ActivityNotFoundException; +import android.content.BroadcastReceiver; import android.content.ComponentName; -import android.content.ContentResolver; -import android.content.ContentValues; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; import android.os.SystemClock; import android.provider.Browser; import android.speech.RecognizerIntent; @@ -43,11 +45,8 @@ import android.text.Editable; import android.text.InputType; import android.text.TextUtils; import android.text.TextWatcher; -import android.util.AndroidRuntimeException; import android.util.AttributeSet; import android.util.Log; -import android.util.Patterns; -import android.view.ContextThemeWrapper; import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; @@ -69,10 +68,6 @@ import android.widget.TextView; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemSelectedListener; -import java.util.ArrayList; -import java.util.WeakHashMap; -import java.util.concurrent.atomic.AtomicLong; - /** * Search dialog. This is controlled by the * SearchManager and runs in the current foreground process. @@ -154,6 +149,16 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mSearchManager = searchManager; + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); + context.registerReceiver(new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) { + onConfigurationChanged(); + } + } + }, filter); } /** @@ -394,10 +399,18 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS updateSearchAppIcon(); updateSearchBadge(); updateQueryHint(); + if (isLandscapeMode(getContext())) { + mSearchAutoComplete.ensureImeVisible(true); + } mSearchAutoComplete.showDropDownAfterLayout(); - } + } } - + + static boolean isLandscapeMode(Context context) { + return context.getResources().getConfiguration().orientation + == Configuration.ORIENTATION_LANDSCAPE; + } + /** * Update the UI according to the info in the current value of {@link #mSearchable}. */ @@ -983,7 +996,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mSearchAutoComplete.setSelection(selPoint); mSearchAutoComplete.setListSelection(0); mSearchAutoComplete.clearListSelection(); - mSearchAutoComplete.ensureImeVisible(); + mSearchAutoComplete.ensureImeVisible(true); return true; } @@ -1362,6 +1375,11 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS InputMethodManager inputManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(this, 0); + // If in landscape mode, then make sure that + // the ime is in front of the dropdown. + if (isLandscapeMode(getContext())) { + ensureImeVisible(true); + } } } diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index ed63787..65f7cdb 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -17,9 +17,11 @@ package android.widget; import android.content.Context; +import android.content.res.Configuration; import android.content.res.TypedArray; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable.Orientation; import android.text.Editable; import android.text.Selection; import android.text.TextUtils; @@ -210,10 +212,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe * Private hook into the on click event, dispatched from {@link PassThroughClickListener} */ private void onClickImpl() { - // If the dropdown is showing, bring it back in front of the soft - // keyboard when the user touches the text field. - if (mPopup.isShowing() && isInputMethodNotNeeded()) { - ensureImeVisible(); + // If the dropdown is showing, bring the keyboard to the front + // when the user touches the text field. + if (mPopup.isShowing()) { + ensureImeVisible(true); } } @@ -1114,11 +1116,13 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe /** * Ensures that the drop down is not obscuring the IME. - * + * @param visible whether the ime should be in front. If false, the ime is pushed to + * the background. * @hide internal used only here and SearchDialog */ - public void ensureImeVisible() { - mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); + public void ensureImeVisible(boolean visible) { + mPopup.setInputMethodMode(visible + ? PopupWindow.INPUT_METHOD_NEEDED : PopupWindow.INPUT_METHOD_NOT_NEEDED); showDropDown(); } |