| 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..fe1be4c7f3550aa16480591960379a3189473b1e 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;
|
|
|
| @@ -40,6 +42,7 @@ public class SuggestionPopup implements OnSuggestionsReceivedListener, TextWatch
|
| private Runnable mRequestSuggestions;
|
| private ListPopupWindow mSuggestionsPopup;
|
| private SuggestionArrayAdapter mSuggestionArrayAdapter;
|
| + private int mSuggestionsPopupItemsCount;
|
|
|
| /**
|
| * Initializes a suggestion popup that will track urlField value and display suggestions based
|
| @@ -57,6 +60,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,13 +102,29 @@ public class SuggestionPopup implements OnSuggestionsReceivedListener, TextWatch
|
| if (mRequestSuggestions != null) mRequestSuggestions = null;
|
| }
|
|
|
| - // OnSuggestionsReceivedListener implementation
|
| + private int getSuggestionPopupHeight() {
|
| + Rect appRect = new Rect();
|
| + ((ChromeShellActivity)mContext).getWindow().getDecorView().
|
| + getWindowVisibleDisplayFrame(appRect);
|
| + int dropDownItemHeight = mContext.getResources().
|
| + getDimensionPixelSize(R.dimen.dropdown_item_height);
|
| + // Applying margin height equal to |dropDownItemHeight| if constrained by app rect.
|
| + int popupHeight = appRect.height() - dropDownItemHeight;
|
| + if (mSuggestionsPopup != null) {
|
| + int height = mSuggestionsPopupItemsCount * dropDownItemHeight;
|
| + if (height < popupHeight)
|
| + popupHeight = height;
|
| + }
|
| + return popupHeight;
|
| + }
|
|
|
| + // OnSuggestionsReceivedListener implementation
|
| @Override
|
| public void onSuggestionsReceived(List<OmniboxSuggestion> suggestions,
|
| String inlineAutocompleteText) {
|
| if (!mUrlField.isFocused() || suggestions.isEmpty())
|
| return;
|
| + mSuggestionsPopupItemsCount = suggestions.size();
|
| if (mSuggestionsPopup == null) {
|
| mSuggestionsPopup = new ListPopupWindow(
|
| mContext, null, android.R.attr.autoCompleteTextViewStyle);
|
| @@ -116,9 +136,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() {
|
|
|