summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget/AutoCompleteTextView.java
diff options
context:
space:
mode:
authorMike LeBeau <mlebeau@android.com>2009-05-07 19:04:39 -0700
committerMike LeBeau <mlebeau@android.com>2009-05-08 14:42:54 -0700
commit98acd54fa6657e8131b3a2a957de7882a2f511ab (patch)
tree2da851adf6af5c04a3aeef4b51b12a1d1cc7ace9 /core/java/android/widget/AutoCompleteTextView.java
parent55280a91884b9256e8db6af6a09f28b3feeaa9d8 (diff)
downloadframeworks_base-98acd54fa6657e8131b3a2a957de7882a2f511ab.zip
frameworks_base-98acd54fa6657e8131b3a2a957de7882a2f511ab.tar.gz
frameworks_base-98acd54fa6657e8131b3a2a957de7882a2f511ab.tar.bz2
Make the search dialog's autocomplete dropdown behave correctly
with respect to the soft keyboard. getMaxAvailableHeight in PopupWindow relies on View's getWindowVisibleDisplayFrame, which always takes into account the IME, whereas in this case, because we want the window to extend down to the bottom of the display when it is being interacted with by the user, I added a new boolean option 'ignoreBottomDecorations' to getMaxAvailableHeight. If true, the method returns the height which will extend the PopupWindow down to the bottom of the screen, rather than just down to the IME. Then in AutoCompleteTextView, I set this to true when the dropDownAlwaysVisible attribute is true and the PopupWindow's input method mode is INPUT_METHOD_NOT_NEEDED (which happens when the list is dragged or otherwise interacted with). Then, because the dropdown height is only calculated when we call showDropDown(), I had to replace a couple calls to mPopup.update(). There are still a few remaining bugs here I'm tracking Still to do: * Fix a strange re-placement of the window which happens intermittently. * Strange behavior when using the directional pad. * In a few cases, the list does not correctly size itself to the IME. This seems to be because the available height is calculated before the IME is yet on screen, and thus is calculated as the entire screen.
Diffstat (limited to 'core/java/android/widget/AutoCompleteTextView.java')
-rw-r--r--core/java/android/widget/AutoCompleteTextView.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index 9c10f0a..a1d16ea 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -208,7 +208,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
&& mPopup.isShowing()
&& mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED) {
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
- mPopup.update();
+ showDropDown();
}
}
@@ -1171,9 +1171,14 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
}
}
- // Max height available on the screen for a popup
- final int maxHeight =
- mPopup.getMaxAvailableHeight(getDropDownAnchorView(), mDropDownVerticalOffset);
+ // Max height available on the screen for a popup. If this AutoCompleteTextView has
+ // the dropDownAlwaysVisible attribute, and the input method is not currently required,
+ // we then we ask for the height ignoring any bottom decorations like the input method.
+ // Otherwise we respect the input method.
+ boolean ignoreBottomDecorations = mDropDownAlwaysVisible &&
+ mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED;
+ final int maxHeight = mPopup.getMaxAvailableHeight(
+ getDropDownAnchorView(), mDropDownVerticalOffset, ignoreBottomDecorations);
final int measuredHeight = mDropDownList.measureHeightOfChildren(MeasureSpec.UNSPECIFIED,
0, ListView.NO_POSITION, maxHeight - otherHeights, 2) + otherHeights;
@@ -1255,7 +1260,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
- mPopup.update();
+ showDropDown();
}
return false;
}