Put PgpMain methods in separate opbject classes, handle passphrase dialog in EditKey not in SecretKeyList

This commit is contained in:
Dominik Schürmann
2013-09-15 16:42:08 +02:00
parent 121f8aaca0
commit 5aebd115d4
33 changed files with 2774 additions and 2603 deletions

View File

@@ -32,7 +32,7 @@ import org.spongycastle.openpgp.PGPObjectFactory;
import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.spongycastle.openpgp.PGPUtil;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.PgpHelper;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.util.InputData;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.PositionAwareInputStream;
@@ -142,13 +142,13 @@ public class ImportKeysListLoader extends AsyncTaskLoader<List<Map<String, Strin
}
private void addToData(PGPKeyRing keyring) {
String userId = PgpHelper.getMainUserId(keyring.getPublicKey());
String userId = PgpKeyHelper.getMainUserId(keyring.getPublicKey());
if (keyring instanceof PGPSecretKeyRing) {
userId = mContext.getString(R.string.secretKeyring) + " " + userId;
}
String fingerprint = PgpHelper.convertFingerprintToHex(keyring.getPublicKey()
String fingerprint = PgpKeyHelper.convertFingerprintToHex(keyring.getPublicKey()
.getFingerprint());
Map<String, String> attrs = new HashMap<String, String>();

View File

@@ -19,7 +19,7 @@ package org.sufficientlysecure.keychain.ui.widget;
import org.spongycastle.openpgp.PGPPublicKey;
import org.spongycastle.openpgp.PGPSecretKey;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.pgp.PgpHelper;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.util.Choice;
import org.sufficientlysecure.keychain.R;
@@ -151,9 +151,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
mDeleteButton.setVisibility(View.INVISIBLE);
}
mAlgorithm.setText(PgpHelper.getAlgorithmInfo(key));
String keyId1Str = PgpHelper.getSmallFingerPrint(key.getKeyID());
String keyId2Str = PgpHelper.getSmallFingerPrint(key.getKeyID() >> 32);
mAlgorithm.setText(PgpKeyHelper.getAlgorithmInfo(key));
String keyId1Str = PgpKeyHelper.getSmallFingerPrint(key.getKeyID());
String keyId2Str = PgpKeyHelper.getSmallFingerPrint(key.getKeyID() >> 32);
mKeyId.setText(keyId1Str + " " + keyId2Str);
Vector<Choice> choices = new Vector<Choice>();
@@ -179,8 +179,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
// Set value in choice dropdown to key
int selectId = 0;
if (PgpHelper.isEncryptionKey(key)) {
if (PgpHelper.isSigningKey(key)) {
if (PgpKeyHelper.isEncryptionKey(key)) {
if (PgpKeyHelper.isSigningKey(key)) {
selectId = Id.choice.usage.sign_and_encrypt;
} else {
selectId = Id.choice.usage.encrypt_only;
@@ -203,14 +203,14 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
}
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(PgpHelper.getCreationDate(key));
cal.setTime(PgpKeyHelper.getCreationDate(key));
mCreationDate.setText(DateFormat.getDateInstance().format(cal.getTime()));
cal = new GregorianCalendar();
Date date = PgpHelper.getExpiryDate(key);
Date date = PgpKeyHelper.getExpiryDate(key);
if (date == null) {
setExpiryDate(null);
} else {
cal.setTime(PgpHelper.getExpiryDate(key));
cal.setTime(PgpKeyHelper.getExpiryDate(key));
setExpiryDate(cal);
}

View File

@@ -19,7 +19,7 @@ package org.sufficientlysecure.keychain.ui.widget;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.pgp.PgpHelper;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
import org.sufficientlysecure.keychain.util.Log;
@@ -117,7 +117,7 @@ public class KeyListAdapter extends CursorTreeAdapter {
keyLayout.setVisibility(View.GONE);
userIdLayout.setVisibility(View.VISIBLE);
String fingerprint = PgpHelper.getFingerPrint(context,
String fingerprint = PgpKeyHelper.getFingerPrint(context,
cursor.getLong(cursor.getColumnIndex(Keys.KEY_ID)));
fingerprint = fingerprint.replace(" ", "\n");
@@ -132,9 +132,9 @@ public class KeyListAdapter extends CursorTreeAdapter {
keyLayout.setVisibility(View.VISIBLE);
userIdLayout.setVisibility(View.GONE);
String keyIdStr = PgpHelper.getSmallFingerPrint(cursor.getLong(cursor
String keyIdStr = PgpKeyHelper.getSmallFingerPrint(cursor.getLong(cursor
.getColumnIndex(Keys.KEY_ID)));
String algorithmStr = PgpHelper.getAlgorithmInfo(
String algorithmStr = PgpKeyHelper.getAlgorithmInfo(
cursor.getInt(cursor.getColumnIndex(Keys.ALGORITHM)),
cursor.getInt(cursor.getColumnIndex(Keys.KEY_SIZE)));

View File

@@ -19,7 +19,7 @@ package org.sufficientlysecure.keychain.ui.widget;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.pgp.PgpHelper;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
import org.sufficientlysecure.keychain.R;
@@ -87,7 +87,7 @@ public class SelectKeyCursorAdapter extends CursorAdapter {
}
long masterKeyId = cursor.getLong(cursor.getColumnIndex(KeyRings.MASTER_KEY_ID));
keyId.setText(PgpHelper.getSmallFingerPrint(masterKeyId));
keyId.setText(PgpKeyHelper.getSmallFingerPrint(masterKeyId));
if (mainUserIdRest.getText().length() == 0) {
mainUserIdRest.setVisibility(View.GONE);