Give expiry dates to PgpKeyOperation

This commit is contained in:
Dominik Schürmann
2014-01-29 03:51:36 +01:00
parent ecf6fc26c5
commit c70195e4e3
5 changed files with 43 additions and 17 deletions

View File

@@ -18,6 +18,8 @@
package org.sufficientlysecure.keychain.ui;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.Vector;
@@ -516,6 +518,8 @@ public class EditKeyActivity extends SherlockFragmentActivity {
PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys));
data.putIntegerArrayList(KeychainIntentService.SAVE_KEYRING_KEYS_USAGES,
getKeysUsages(mKeysView));
data.putSerializable(KeychainIntentService.SAVE_KEYRING_KEYS_EXPIRY_DATES,
getKeysExpiryDates(mKeysView));
data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId());
data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, masterCanSign);
@@ -642,7 +646,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
* @return
*/
private ArrayList<Integer> getKeysUsages(SectionView keysView) throws PgpGeneralException {
ArrayList<Integer> getKeysUsages = new ArrayList<Integer>();
ArrayList<Integer> keysUsages = new ArrayList<Integer>();
ViewGroup keyEditors = keysView.getEditors();
@@ -652,10 +656,27 @@ public class EditKeyActivity extends SherlockFragmentActivity {
for (int i = 0; i < keyEditors.getChildCount(); ++i) {
KeyEditor editor = (KeyEditor) keyEditors.getChildAt(i);
getKeysUsages.add(editor.getUsage());
keysUsages.add(editor.getUsage());
}
return getKeysUsages;
return keysUsages;
}
private ArrayList<GregorianCalendar> getKeysExpiryDates(SectionView keysView) throws PgpGeneralException {
ArrayList<GregorianCalendar> keysExpiryDates = new ArrayList<GregorianCalendar>();
ViewGroup keyEditors = keysView.getEditors();
if (keyEditors.getChildCount() == 0) {
throw new PgpGeneralException(getString(R.string.error_key_needs_master_key));
}
for (int i = 0; i < keyEditors.getChildCount(); ++i) {
KeyEditor editor = (KeyEditor) keyEditors.getChildAt(i);
keysExpiryDates.add(editor.getExpiryDate());
}
return keysExpiryDates;
}
private void updatePassPhraseButtonText() {

View File

@@ -368,7 +368,7 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements
public void onLoaderReset(Loader<Cursor> loader) {
switch (loader.getId()) {
case LOADER_ID_KEYRING:
// TODO?
// No resources need to be freed for this ID
break;
case LOADER_ID_USER_IDS:
mUserIdsAdapter.swapCursor(null);
@@ -383,7 +383,7 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements
private void uploadToKeyserver(Uri dataUri) {
Intent uploadIntent = new Intent(this, KeyServerUploadActivity.class);
uploadIntent.setData(mDataUri);
uploadIntent.setData(dataUri);
startActivityForResult(uploadIntent, Id.request.export_to_server);
}
@@ -410,7 +410,7 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements
private void signKey(Uri dataUri) {
Intent signIntent = new Intent(this, SignKeyActivity.class);
signIntent.setData(mDataUri);
signIntent.setData(dataUri);
startActivity(signIntent);
}

View File

@@ -62,9 +62,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
private int mDatePickerResultCount = 0;
private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
if (mDatePickerResultCount++ == 0) // Note: Ignore results after the first one - android
// sends multiples.
{
// Note: Ignore results after the first one - android sends multiples.
if (mDatePickerResultCount++ == 0) {
GregorianCalendar date = new GregorianCalendar(year, monthOfYear, dayOfMonth);
setExpiryDate(date);
}
@@ -122,10 +121,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
getContext().getString(R.string.btn_no_date),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (mDatePickerResultCount++ == 0) // Note: Ignore results after the
// first
// one - android sends multiples.
{
// Note: Ignore results after the first one - android sends multiples.
if (mDatePickerResultCount++ == 0) {
setExpiryDate(null);
}
}
@@ -208,8 +205,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
cal.setTime(PgpKeyHelper.getCreationDate(key));
mCreationDate.setText(DateFormat.getDateInstance().format(cal.getTime()));
cal = new GregorianCalendar();
Date date = PgpKeyHelper.getExpiryDate(key);
if (date == null) {
Date expiryDate = PgpKeyHelper.getExpiryDate(key);
if (expiryDate == null) {
setExpiryDate(null);
} else {
cal.setTime(PgpKeyHelper.getExpiryDate(key));