Merge pull request #59 from bcbarnes-gmx/Issue41

Issues #41 and #43
This commit is contained in:
Dominik Schürmann 2013-07-22 08:43:05 -07:00
commit 51ff397ef2
3 changed files with 14 additions and 5 deletions

View File

@ -65,7 +65,7 @@
android:gravity="right" android:gravity="right"
android:numeric="integer" android:numeric="integer"
android:padding="4dp" android:padding="4dp"
android:text="1024" /> android:text="@string/default_key_bit_size" />
</TableRow> </TableRow>
</TableLayout> </TableLayout>

View File

@ -328,6 +328,7 @@
<string name="fast">fast</string> <string name="fast">fast</string>
<string name="slow">slow</string> <string name="slow">slow</string>
<string name="very_slow">very slow</string> <string name="very_slow">very slow</string>
<string name="default_key_bit_size">2048</string>
<!-- APG 2.0 --> <!-- APG 2.0 -->

View File

@ -59,11 +59,15 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
Button mExpiryDateButton; Button mExpiryDateButton;
GregorianCalendar mExpiryDate; GregorianCalendar mExpiryDate;
private int mDatePickerResultCount = 0;
private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() { private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
if(mDatePickerResultCount++ == 0) // Note: Ignore results after the first one - android sends multiples.
{
GregorianCalendar date = new GregorianCalendar(year, monthOfYear, dayOfMonth); GregorianCalendar date = new GregorianCalendar(year, monthOfYear, dayOfMonth);
setExpiryDate(date); setExpiryDate(date);
} }
}
}; };
public KeyEditor(Context context) { public KeyEditor(Context context) {
@ -111,12 +115,16 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
DatePickerDialog dialog = new DatePickerDialog(getContext(), DatePickerDialog dialog = new DatePickerDialog(getContext(),
mExpiryDateSetListener, date.get(Calendar.YEAR), date.get(Calendar.MONTH), mExpiryDateSetListener, date.get(Calendar.YEAR), date.get(Calendar.MONTH),
date.get(Calendar.DAY_OF_MONTH)); date.get(Calendar.DAY_OF_MONTH));
mDatePickerResultCount = 0;
dialog.setCancelable(true); dialog.setCancelable(true);
dialog.setButton(Dialog.BUTTON_NEGATIVE, getContext() dialog.setButton(Dialog.BUTTON_NEGATIVE, getContext()
.getString(R.string.btn_noDate), new DialogInterface.OnClickListener() { .getString(R.string.btn_noDate), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if(mDatePickerResultCount++ == 0) // Note: Ignore results after the first one - android sends multiples.
{
setExpiryDate(null); setExpiryDate(null);
} }
}
}); });
dialog.show(); dialog.show();
} }