mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-16 13:55:03 -05:00
Merge pull request #328 from bhargavgolla/patch-1
Issue #234 : Adding a min date not to go below creation date
This commit is contained in:
commit
9646a3d471
@ -34,6 +34,7 @@ import android.app.DatePickerDialog;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.text.format.DateUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@ -58,6 +59,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
Spinner mUsage;
|
Spinner mUsage;
|
||||||
TextView mCreationDate;
|
TextView mCreationDate;
|
||||||
BootstrapButton mExpiryDateButton;
|
BootstrapButton mExpiryDateButton;
|
||||||
|
GregorianCalendar mCreatedDate;
|
||||||
GregorianCalendar mExpiryDate;
|
GregorianCalendar mExpiryDate;
|
||||||
|
|
||||||
private int mDatePickerResultCount = 0;
|
private int mDatePickerResultCount = 0;
|
||||||
@ -129,6 +131,14 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
//When created date isn't available
|
||||||
|
dialog.getDatePicker().setMinDate(date.getTime().getTime()+ DateUtils.DAY_IN_MILLIS);
|
||||||
|
}
|
||||||
|
}
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -205,7 +215,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
|
|
||||||
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||||
cal.setTime(PgpKeyHelper.getCreationDate(key));
|
cal.setTime(PgpKeyHelper.getCreationDate(key));
|
||||||
mCreationDate.setText(DateFormat.getDateInstance().format(cal.getTime()));
|
setCreatedDate(cal);
|
||||||
cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||||
Date expiryDate = PgpKeyHelper.getExpiryDate(key);
|
Date expiryDate = PgpKeyHelper.getExpiryDate(key);
|
||||||
if (expiryDate == null) {
|
if (expiryDate == null) {
|
||||||
@ -235,6 +245,15 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
mEditorListener = listener;
|
mEditorListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setCreatedDate(GregorianCalendar date) {
|
||||||
|
mCreatedDate = date;
|
||||||
|
if (date == null) {
|
||||||
|
mCreationDate.setText(getContext().getString(R.string.none));
|
||||||
|
} else {
|
||||||
|
mCreationDate.setText(DateFormat.getDateInstance().format(date.getTime()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setExpiryDate(GregorianCalendar date) {
|
private void setExpiryDate(GregorianCalendar date) {
|
||||||
mExpiryDate = date;
|
mExpiryDate = date;
|
||||||
if (date == null) {
|
if (date == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user