summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Amith Yamasani <yamasani@google.com> 2010-03-10 21:09:28 -0800
committer Amith Yamasani <yamasani@google.com> 2010-03-11 16:05:17 -0800
commitd25eb35b6b80b6f8065ab39b1cf1abb1fd801234 (patch)
tree4fa5b47b841f3e0471678fd3e159d8aa364dba56
parent4ea0628a8418b033bd22c8f38c3c66960e43c359 (diff)
Fix for 2175289 : Can't get keyboard in search dialog after switching to landscape
The auto complete drop down was obscuring the keyboard. This fix checks if the screen is in landscape mode and forces the keyboard in front when necessary.
-rw-r--r--core/java/android/app/SearchDialog.java46
-rw-r--r--core/java/android/widget/AutoCompleteTextView.java18
2 files changed, 43 insertions, 21 deletions
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index bf9b021eaced..ebc64d79c20d 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 ed6378737606..65f7cdbee3ce 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();
}