Merge pull request #324 from mb-14/datefix

Expiry selection UI fix
This commit is contained in:
Dominik Schürmann 2014-03-05 21:36:47 +01:00
commit 5f3c9f3eb9
2 changed files with 25 additions and 2 deletions

View File

@ -115,8 +115,12 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
if (date == null) {
date = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
}
DatePickerDialog dialog = new DatePickerDialog(getContext(),
/*
* Using custom DatePickerDialog which overrides the setTitle because
* the DatePickerDialog title is buggy (unix warparound bug).
* See: https://code.google.com/p/android/issues/detail?id=49066
*/
DatePickerDialog dialog = new ExpiryDatePickerDialog(getContext(),
mExpiryDateSetListener, date.get(Calendar.YEAR), date.get(Calendar.MONTH),
date.get(Calendar.DAY_OF_MONTH));
mDatePickerResultCount = 0;
@ -131,6 +135,12 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
}
}
});
// setCalendarViewShown() is supported from API 11 onwards.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
// Hide calendarView in tablets because of the unix warparound bug.
dialog.getDatePicker().setCalendarViewShown(false);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
if ( dialog != null && mCreatedDate != null ) {
dialog.getDatePicker().setMinDate(mCreatedDate.getTime().getTime()+ DateUtils.DAY_IN_MILLIS);
@ -139,6 +149,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
dialog.getDatePicker().setMinDate(date.getTime().getTime()+ DateUtils.DAY_IN_MILLIS);
}
}
dialog.show();
}
});
@ -272,3 +283,14 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
}
}
class ExpiryDatePickerDialog extends DatePickerDialog {
public ExpiryDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
super(context, callBack, year, monthOfYear, dayOfMonth);
}
//Set permanent title.
public void setTitle(CharSequence title) {
super.setTitle(getContext().getString(R.string.expiry_date_dialog_title));
}
}

View File

@ -130,6 +130,7 @@
<string name="label_send_key">Upload key to selected keyserver after certification</string>
<string name="label_fingerprint">Fingerprint</string>
<string name="select_keys_button_default">Select</string>
<string name="expiry_date_dialog_title">Set expiry date</string>
<plurals name="select_keys_button">
<item quantity="one">%d selected</item>