Bug 1245692 - Force height for CalendarView on pre-lollipop r?sebastian
By default CalendarView doesn't receive sufficient height on pre-lollipop
devices, in fact the entire dialog won't even appear unless we manually
assign height. This is slightly hacky, but necessary to ensure correct
layouting. (We previously assigned both height and width to the CalendarView,
however that results in all kinds of odd behaviour - this change is necessary
only to have acceptable behaviour on older devices.)
MozReview-Commit-ID: H7wzHsrOJy4
--- a/mobile/android/base/java/org/mozilla/gecko/widget/DateTimePicker.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/DateTimePicker.java
@@ -16,16 +16,17 @@
package org.mozilla.gecko.widget;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Locale;
+import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.R;
import android.content.Context;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -334,16 +335,20 @@ public class DateTimePicker extends Fram
CalendarView view, int year, int month, int monthDay) {
mTempDate.set(year, month, monthDay);
setDate(mTempDate);
notifyDateChanged();
}
});
mPickers.addView(mCalendar);
+
+ if (Versions.preLollipop) {
+ mCalendar.getLayoutParams().height = 400;
+ }
} else {
// If the screen is more wide than high, we are displaying day and
// time spinners, and if there is no calendar displayed, we should
// display the fields in one row.
if (mScreenWidth > mScreenHeight && mState == PickersState.DATETIME) {
mPickers.setOrientation(LinearLayout.HORIZONTAL);
}
mCalendar = null;