mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 834471 - Part 2: Fix some FindBugs warnings about DateTimePicker. r=wesj
This commit is contained in:
parent
d7c5c23c6e
commit
773010998a
@ -123,7 +123,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
|
|||||||
} else if (mType.equals("date")) {
|
} else if (mType.equals("date")) {
|
||||||
try {
|
try {
|
||||||
DateTimePicker input = new DateTimePicker(GeckoApp.mAppContext, "yyyy-MM-dd", mValue,
|
DateTimePicker input = new DateTimePicker(GeckoApp.mAppContext, "yyyy-MM-dd", mValue,
|
||||||
DateTimePicker.pickersState.DATE);
|
DateTimePicker.PickersState.DATE);
|
||||||
input.toggleCalendar(true);
|
input.toggleCalendar(true);
|
||||||
mView = (View)input;
|
mView = (View)input;
|
||||||
} catch (UnsupportedOperationException ex) {
|
} catch (UnsupportedOperationException ex) {
|
||||||
@ -145,7 +145,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
|
|||||||
}
|
}
|
||||||
} else if (mType.equals("week")) {
|
} else if (mType.equals("week")) {
|
||||||
DateTimePicker input = new DateTimePicker(GeckoApp.mAppContext, "yyyy-'W'ww", mValue,
|
DateTimePicker input = new DateTimePicker(GeckoApp.mAppContext, "yyyy-'W'ww", mValue,
|
||||||
DateTimePicker.pickersState.WEEK);
|
DateTimePicker.PickersState.WEEK);
|
||||||
mView = (View)input;
|
mView = (View)input;
|
||||||
} else if (mType.equals("time")) {
|
} else if (mType.equals("time")) {
|
||||||
TimePicker input = new TimePicker(GeckoApp.mAppContext);
|
TimePicker input = new TimePicker(GeckoApp.mAppContext);
|
||||||
@ -162,12 +162,12 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
|
|||||||
mView = (View)input;
|
mView = (View)input;
|
||||||
} else if (mType.equals("datetime-local") || mType.equals("datetime")) {
|
} else if (mType.equals("datetime-local") || mType.equals("datetime")) {
|
||||||
DateTimePicker input = new DateTimePicker(GeckoApp.mAppContext, "yyyy-MM-dd kk:mm", mValue,
|
DateTimePicker input = new DateTimePicker(GeckoApp.mAppContext, "yyyy-MM-dd kk:mm", mValue,
|
||||||
DateTimePicker.pickersState.DATETIME);
|
DateTimePicker.PickersState.DATETIME);
|
||||||
input.toggleCalendar(true);
|
input.toggleCalendar(true);
|
||||||
mView = (View)input;
|
mView = (View)input;
|
||||||
} else if (mType.equals("month")) {
|
} else if (mType.equals("month")) {
|
||||||
DateTimePicker input = new DateTimePicker(GeckoApp.mAppContext, "yyyy-MM", mValue,
|
DateTimePicker input = new DateTimePicker(GeckoApp.mAppContext, "yyyy-MM", mValue,
|
||||||
DateTimePicker.pickersState.MONTH);
|
DateTimePicker.PickersState.MONTH);
|
||||||
mView = (View)input;
|
mView = (View)input;
|
||||||
} else if (mType.equals("textbox") || mType.equals("password")) {
|
} else if (mType.equals("textbox") || mType.equals("password")) {
|
||||||
EditText input = new EditText(GeckoApp.mAppContext);
|
EditText input = new EditText(GeckoApp.mAppContext);
|
||||||
|
@ -90,9 +90,9 @@ public class DateTimePicker extends FrameLayout {
|
|||||||
private Calendar mMinDate;
|
private Calendar mMinDate;
|
||||||
private Calendar mMaxDate;
|
private Calendar mMaxDate;
|
||||||
private Calendar mCurrentDate;
|
private Calendar mCurrentDate;
|
||||||
private pickersState mState;
|
private PickersState mState;
|
||||||
|
|
||||||
public static enum pickersState { DATE, MONTH, WEEK, TIME, DATETIME };
|
public static enum PickersState { DATE, MONTH, WEEK, TIME, DATETIME };
|
||||||
|
|
||||||
public class OnValueChangeListener implements NumberPicker.OnValueChangeListener {
|
public class OnValueChangeListener implements NumberPicker.OnValueChangeListener {
|
||||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||||
@ -109,7 +109,7 @@ public class DateTimePicker extends FrameLayout {
|
|||||||
setTempDate(Calendar.DAY_OF_MONTH, old, newVal, 1, maxDayOfMonth);
|
setTempDate(Calendar.DAY_OF_MONTH, old, newVal, 1, maxDayOfMonth);
|
||||||
} else if (picker == mMonthSpinner && mMonthEnabled) {
|
} else if (picker == mMonthSpinner && mMonthEnabled) {
|
||||||
int old = mTempDate.get(Calendar.MONTH);
|
int old = mTempDate.get(Calendar.MONTH);
|
||||||
setTempDate(Calendar.MONTH, old, newVal, 0, 11);
|
setTempDate(Calendar.MONTH, old, newVal, Calendar.JANUARY, Calendar.DECEMBER);
|
||||||
} else if (picker == mWeekSpinner) {
|
} else if (picker == mWeekSpinner) {
|
||||||
int old = mTempDate.get(Calendar.WEEK_OF_YEAR);
|
int old = mTempDate.get(Calendar.WEEK_OF_YEAR);
|
||||||
int maxWeekOfYear = mTempDate.getActualMaximum(Calendar.WEEK_OF_YEAR);
|
int maxWeekOfYear = mTempDate.getActualMaximum(Calendar.WEEK_OF_YEAR);
|
||||||
@ -213,32 +213,32 @@ public class DateTimePicker extends FrameLayout {
|
|||||||
private void displayPickers() {
|
private void displayPickers() {
|
||||||
setWeekShown(false);
|
setWeekShown(false);
|
||||||
set12HourShown(mIs12HourMode);
|
set12HourShown(mIs12HourMode);
|
||||||
if (mState == pickersState.DATETIME) {
|
if (mState == PickersState.DATETIME) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setHourShown(false);
|
setHourShown(false);
|
||||||
setMinuteShown(false);
|
setMinuteShown(false);
|
||||||
if (mState == pickersState.WEEK) {
|
if (mState == PickersState.WEEK) {
|
||||||
setDayShown(false);
|
setDayShown(false);
|
||||||
setMonthShown(false);
|
setMonthShown(false);
|
||||||
setWeekShown(true);
|
setWeekShown(true);
|
||||||
} else if (mState == pickersState.MONTH) {
|
} else if (mState == PickersState.MONTH) {
|
||||||
setDayShown(false);
|
setDayShown(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTimePicker(Context context) {
|
public DateTimePicker(Context context) {
|
||||||
this(context, "", "", pickersState.DATE);
|
this(context, "", "", PickersState.DATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTimePicker(Context context, String dateFormat, String dateTimeValue, pickersState state) {
|
public DateTimePicker(Context context, String dateFormat, String dateTimeValue, PickersState state) {
|
||||||
super(context);
|
super(context);
|
||||||
if (Build.VERSION.SDK_INT < 11) {
|
if (Build.VERSION.SDK_INT < 11) {
|
||||||
throw new UnsupportedOperationException("Custom DateTimePicker is only available for SDK > 10");
|
throw new UnsupportedOperationException("Custom DateTimePicker is only available for SDK > 10");
|
||||||
}
|
}
|
||||||
setCurrentLocale(Locale.getDefault());
|
setCurrentLocale(Locale.getDefault());
|
||||||
mMinDate.set(DEFAULT_START_YEAR,1,1);
|
mMinDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1);
|
||||||
mMaxDate.set(DEFAULT_END_YEAR,12,31);
|
mMaxDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31);
|
||||||
mState = state;
|
mState = state;
|
||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
inflater.inflate(R.layout.datetime_picker, this, true);
|
inflater.inflate(R.layout.datetime_picker, this, true);
|
||||||
@ -261,7 +261,7 @@ public class DateTimePicker extends FrameLayout {
|
|||||||
|
|
||||||
// If we're displaying a date, the screen is wide enought (and if we're using a sdk where the calendar view exists)
|
// If we're displaying a date, the screen is wide enought (and if we're using a sdk where the calendar view exists)
|
||||||
// then display a calendar.
|
// then display a calendar.
|
||||||
if ((mState == pickersState.DATE || mState == pickersState.DATETIME) &&
|
if ((mState == PickersState.DATE || mState == PickersState.DATETIME) &&
|
||||||
Build.VERSION.SDK_INT > 10 && mScreenWidth >= SCREEN_SIZE_THRESHOLD) {
|
Build.VERSION.SDK_INT > 10 && mScreenWidth >= SCREEN_SIZE_THRESHOLD) {
|
||||||
if (DEBUG) Log.d(LOGTAG,"SDK > 10 and screen wide enough, displaying calendar");
|
if (DEBUG) Log.d(LOGTAG,"SDK > 10 and screen wide enough, displaying calendar");
|
||||||
mCalendar = new CalendarView(context);
|
mCalendar = new CalendarView(context);
|
||||||
@ -288,7 +288,7 @@ public class DateTimePicker extends FrameLayout {
|
|||||||
// If the screen is more wide than high, we are displaying daye and time spinners,
|
// If the screen is more wide than high, we are displaying daye and time spinners,
|
||||||
// and if there is no calendar displayed,
|
// and if there is no calendar displayed,
|
||||||
// we should display the fields in one row.
|
// we should display the fields in one row.
|
||||||
if (mScreenWidth > mScreenHeight && mState == pickersState.DATETIME) {
|
if (mScreenWidth > mScreenHeight && mState == PickersState.DATETIME) {
|
||||||
mSpinners.setOrientation(LinearLayout.HORIZONTAL);
|
mSpinners.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
}
|
}
|
||||||
mCalendar = null;
|
mCalendar = null;
|
||||||
@ -453,8 +453,8 @@ public class DateTimePicker extends FrameLayout {
|
|||||||
mMonthSpinner.setMinValue(mCurrentDate.getActualMinimum(Calendar.MONTH));
|
mMonthSpinner.setMinValue(mCurrentDate.getActualMinimum(Calendar.MONTH));
|
||||||
mMonthSpinner.setMaxValue(mCurrentDate.get(Calendar.MONTH));
|
mMonthSpinner.setMaxValue(mCurrentDate.get(Calendar.MONTH));
|
||||||
} else {
|
} else {
|
||||||
mMonthSpinner.setMinValue(0);
|
mMonthSpinner.setMinValue(Calendar.JANUARY);
|
||||||
mMonthSpinner.setMaxValue(11);
|
mMonthSpinner.setMaxValue(Calendar.DECEMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] displayedValues = Arrays.copyOfRange(mShortMonths,
|
String[] displayedValues = Arrays.copyOfRange(mShortMonths,
|
||||||
@ -494,7 +494,7 @@ public class DateTimePicker extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void toggleCalendar(boolean shown) {
|
public void toggleCalendar(boolean shown) {
|
||||||
if ((mState != pickersState.DATE && mState != pickersState.DATETIME) ||
|
if ((mState != PickersState.DATE && mState != PickersState.DATETIME) ||
|
||||||
Build.VERSION.SDK_INT < 11 || mScreenWidth < SCREEN_SIZE_THRESHOLD) {
|
Build.VERSION.SDK_INT < 11 || mScreenWidth < SCREEN_SIZE_THRESHOLD) {
|
||||||
if (DEBUG) Log.d(LOGTAG,"Cannot display calendar on this device, in this state" +
|
if (DEBUG) Log.d(LOGTAG,"Cannot display calendar on this device, in this state" +
|
||||||
": screen width :"+mScreenWidth);
|
": screen width :"+mScreenWidth);
|
||||||
|
Loading…
Reference in New Issue
Block a user