Chromium Code Reviews| Index: chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionPopup.java |
| diff --git a/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionPopup.java b/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionPopup.java |
| index 883918adac4389ee24c20c8c79c44d17f027598c..986c7e14e8cb70646dd9d5c0b141283aa94f12f1 100644 |
| --- a/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionPopup.java |
| +++ b/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionPopup.java |
| @@ -5,6 +5,7 @@ |
| package org.chromium.chrome.shell.omnibox; |
| import android.content.Context; |
| +import android.graphics.Rect; |
| import android.os.Handler; |
| import android.text.Editable; |
| import android.text.TextUtils; |
| @@ -20,6 +21,7 @@ import android.widget.TextView; |
| import org.chromium.chrome.browser.omnibox.AutocompleteController; |
| import org.chromium.chrome.browser.omnibox.AutocompleteController.OnSuggestionsReceivedListener; |
| import org.chromium.chrome.browser.omnibox.OmniboxSuggestion; |
| +import org.chromium.chrome.shell.ChromeShellActivity; |
| import org.chromium.chrome.shell.ChromeShellToolbar; |
| import org.chromium.chrome.shell.R; |
| @@ -57,6 +59,7 @@ public class SuggestionPopup implements OnSuggestionsReceivedListener, TextWatch |
| int oldLeft, int oldTop, int oldRight, int oldBottom) { |
| if (mSuggestionsPopup == null || !mSuggestionsPopup.isShowing()) return; |
| mSuggestionsPopup.setWidth(mUrlField.getWidth()); |
| + mSuggestionsPopup.setHeight(getSuggestionPopupHeight()); |
| mSuggestionsPopup.show(); |
| } |
| }; |
| @@ -98,6 +101,22 @@ public class SuggestionPopup implements OnSuggestionsReceivedListener, TextWatch |
| if (mRequestSuggestions != null) mRequestSuggestions = null; |
| } |
| + private int getSuggestionPopupHeight() { |
| + Rect appRect = new Rect(); |
| + ((ChromeShellActivity)mContext).getWindow().getDecorView(). |
| + getWindowVisibleDisplayFrame(appRect); |
| + int dropDownItemHeight = mContext.getResources(). |
| + getDimensionPixelSize(R.dimen.dropdown_item_height); |
| + int height = dropDownItemHeight; |
|
Bernhard Bauer
2014/09/01 13:45:10
This value isn't used (and the variable only insid
ankit
2014/09/02 04:20:11
Done.
|
| + if (mSuggestionsPopup != null && mSuggestionsPopup.getListView() != null) { |
| + height = mSuggestionsPopup.getListView().getCount() * dropDownItemHeight; |
|
Bernhard Bauer
2014/09/01 13:45:10
Instead of asking the view for its number of items
ankit
2014/09/02 04:20:11
Stored value in a local variable and using it inst
|
| + if (appRect.height() > height) |
|
Bernhard Bauer
2014/09/01 13:45:10
I don't quite understand this. If the height of th
ankit
2014/09/02 04:20:11
Done.
|
| + return height; |
| + } |
| + //maintaining margin height of dropdDownItemHeight |
|
Bernhard Bauer
2014/09/01 13:45:10
Add a space after //, capitalize the first charact
ankit
2014/09/02 04:20:11
Done.
|
| + return appRect.height() - dropDownItemHeight; |
| + } |
| + |
| // OnSuggestionsReceivedListener implementation |
| @Override |
| @@ -116,9 +135,11 @@ public class SuggestionPopup implements OnSuggestionsReceivedListener, TextWatch |
| } |
| }); |
| } |
| + mSuggestionsPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED); |
| mSuggestionsPopup.setWidth(mUrlField.getWidth()); |
| mSuggestionArrayAdapter = |
| new SuggestionArrayAdapter(mContext, R.layout.dropdown_item, suggestions); |
| + mSuggestionsPopup.setHeight(getSuggestionPopupHeight()); |
| mSuggestionsPopup.setAdapter(mSuggestionArrayAdapter); |
| mSuggestionsPopup.setAnchorView(mUrlField); |
| mSuggestionsPopup.setOnItemClickListener(new OnItemClickListener() { |