Bug 711198: Autocomplete popup should have a minimum width [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian 2011-12-19 13:19:05 -08:00
parent bb4d5c8d26
commit 347c5c4c3e

View File

@ -68,6 +68,8 @@ public class AutoCompletePopup extends ListView {
private static final String LOGTAG = "AutoCompletePopup";
private static int sMinWidth = 0;
public AutoCompletePopup(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
@ -132,7 +134,18 @@ public class AutoCompletePopup extends ListView {
// If the textbox is smaller than the screen-width,
// shrink the list's width
if ((left + width) < viewport.width)
listWidth = left + width;
listWidth = left < 0 ? left + width : width;
// Late initializing variable to allow DisplayMetrics not to be null and avoid NPE
if (sMinWidth == 0)
sMinWidth = 100 * GeckoAppShell.getDpi();
if (listWidth < sMinWidth) {
listWidth = sMinWidth;
if ((listLeft + listWidth) > viewport.width)
listLeft = (int)viewport.width - listWidth;
}
// If the list is extending outside of the viewport
// try moving above