Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1039)

Unified Diff: chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionPopup.java

Issue 517403003: Making suggestion popup scrollable in landscape mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected comment line position. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698