mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-24 01:32:16 -05:00
Merge pull request #502 from thi/conform-to-style-guide
Conform to style guide, #466
This commit is contained in:
commit
64358bb3f8
@ -17,16 +17,17 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain;
|
package org.sufficientlysecure.keychain;
|
||||||
|
|
||||||
import java.io.File;
|
import android.app.Application;
|
||||||
import java.security.Provider;
|
import android.os.Environment;
|
||||||
import java.security.Security;
|
|
||||||
|
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.PRNGFixes;
|
import org.sufficientlysecure.keychain.util.PRNGFixes;
|
||||||
|
|
||||||
import android.app.Application;
|
import java.io.File;
|
||||||
import android.os.Environment;
|
import java.security.Provider;
|
||||||
|
import java.security.Security;
|
||||||
|
|
||||||
public class KeychainApplication extends Application {
|
public class KeychainApplication extends Application {
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.compatibility;
|
package org.sufficientlysecure.keychain.compatibility;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class ClipboardReflection {
|
public class ClipboardReflection {
|
||||||
|
|
||||||
private static final String clipboardLabel = "Keychain";
|
private static final String clipboardLabel = "Keychain";
|
||||||
|
@ -30,18 +30,12 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.Id;
|
import org.sufficientlysecure.keychain.Id;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.security.Provider;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class ExportHelper {
|
public class ExportHelper {
|
||||||
protected FileDialogFragment mFileDialog;
|
protected FileDialogFragment mFileDialog;
|
||||||
protected String mExportFilename;
|
protected String mExportFilename;
|
||||||
@ -81,7 +75,7 @@ public class ExportHelper {
|
|||||||
int type = keyType;
|
int type = keyType;
|
||||||
mExportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME);
|
mExportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME);
|
||||||
|
|
||||||
if( data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED) ) {
|
if (data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED)) {
|
||||||
type = Id.type.public_secret_key;
|
type = Id.type.public_secret_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import java.util.Vector;
|
|||||||
* Singleton Implementation of a Preference Helper
|
* Singleton Implementation of a Preference Helper
|
||||||
*/
|
*/
|
||||||
public class Preferences {
|
public class Preferences {
|
||||||
private static Preferences mPreferences;
|
private static Preferences sPreferences;
|
||||||
private SharedPreferences mSharedPreferences;
|
private SharedPreferences mSharedPreferences;
|
||||||
|
|
||||||
public static synchronized Preferences getPreferences(Context context) {
|
public static synchronized Preferences getPreferences(Context context) {
|
||||||
@ -38,10 +38,10 @@ public class Preferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized Preferences getPreferences(Context context, boolean forceNew) {
|
public static synchronized Preferences getPreferences(Context context, boolean forceNew) {
|
||||||
if (mPreferences == null || forceNew) {
|
if (sPreferences == null || forceNew) {
|
||||||
mPreferences = new Preferences(context);
|
sPreferences = new Preferences(context);
|
||||||
}
|
}
|
||||||
return mPreferences;
|
return sPreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preferences(Context context) {
|
private Preferences(Context context) {
|
||||||
|
@ -65,14 +65,16 @@ public class PgpConversionHelper {
|
|||||||
try {
|
try {
|
||||||
while ((obj = factory.nextObject()) != null) {
|
while ((obj = factory.nextObject()) != null) {
|
||||||
PGPSecretKey secKey = null;
|
PGPSecretKey secKey = null;
|
||||||
if(obj instanceof PGPSecretKey) {
|
if (obj instanceof PGPSecretKey) {
|
||||||
if ((secKey = (PGPSecretKey)obj ) == null) {
|
secKey = (PGPSecretKey) obj;
|
||||||
|
if (secKey == null) {
|
||||||
Log.e(Constants.TAG, "No keys given!");
|
Log.e(Constants.TAG, "No keys given!");
|
||||||
}
|
}
|
||||||
keys.add(secKey);
|
keys.add(secKey);
|
||||||
} else if(obj instanceof PGPSecretKeyRing) { //master keys are sent as keyrings
|
} else if (obj instanceof PGPSecretKeyRing) { //master keys are sent as keyrings
|
||||||
PGPSecretKeyRing keyRing = null;
|
PGPSecretKeyRing keyRing = null;
|
||||||
if ((keyRing = (PGPSecretKeyRing)obj) == null) {
|
keyRing = (PGPSecretKeyRing) obj;
|
||||||
|
if (keyRing == null) {
|
||||||
Log.e(Constants.TAG, "No keys given!");
|
Log.e(Constants.TAG, "No keys given!");
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -684,7 +684,8 @@ public class PgpDecryptVerify {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean verifyPrimaryKeyBinding(PGPSignatureSubpacketVector pkts,
|
private static boolean verifyPrimaryKeyBinding(PGPSignatureSubpacketVector pkts,
|
||||||
PGPPublicKey masterPublicKey, PGPPublicKey signingPublicKey) {
|
PGPPublicKey masterPublicKey,
|
||||||
|
PGPPublicKey signingPublicKey) {
|
||||||
boolean validPrimaryKeyBinding = false;
|
boolean validPrimaryKeyBinding = false;
|
||||||
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
|
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
|
||||||
new JcaPGPContentVerifierBuilderProvider()
|
new JcaPGPContentVerifierBuilderProvider()
|
||||||
|
@ -51,9 +51,9 @@ public class PgpHelper {
|
|||||||
".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*", Pattern.DOTALL);
|
".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*", Pattern.DOTALL);
|
||||||
|
|
||||||
public static final Pattern PGP_CLEARTEXT_SIGNATURE = Pattern
|
public static final Pattern PGP_CLEARTEXT_SIGNATURE = Pattern
|
||||||
.compile(
|
.compile(".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----" +
|
||||||
".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*",
|
"BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*",
|
||||||
Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
|
|
||||||
public static final Pattern PGP_PUBLIC_KEY = Pattern.compile(
|
public static final Pattern PGP_PUBLIC_KEY = Pattern.compile(
|
||||||
".*?(-----BEGIN PGP PUBLIC KEY BLOCK-----.*?-----END PGP PUBLIC KEY BLOCK-----).*",
|
".*?(-----BEGIN PGP PUBLIC KEY BLOCK-----.*?-----END PGP PUBLIC KEY BLOCK-----).*",
|
||||||
|
@ -168,7 +168,8 @@ public class PgpImportExport {
|
|||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bundle exportKeyRings(ArrayList<Long> publicKeyRingMasterIds, ArrayList<Long> secretKeyRingMasterIds,
|
public Bundle exportKeyRings(ArrayList<Long> publicKeyRingMasterIds,
|
||||||
|
ArrayList<Long> secretKeyRingMasterIds,
|
||||||
OutputStream outStream) throws PgpGeneralException,
|
OutputStream outStream) throws PgpGeneralException,
|
||||||
PGPException, IOException {
|
PGPException, IOException {
|
||||||
Bundle returnData = new Bundle();
|
Bundle returnData = new Bundle();
|
||||||
|
@ -300,8 +300,7 @@ public class PgpKeyHelper {
|
|||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getKeyUsage(PGPSecretKey key)
|
public static int getKeyUsage(PGPSecretKey key) {
|
||||||
{
|
|
||||||
return getKeyUsage(key.getPublicKey());
|
return getKeyUsage(key.getPublicKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,13 +309,19 @@ public class PgpKeyHelper {
|
|||||||
int usage = 0;
|
int usage = 0;
|
||||||
if (key.getVersion() >= 4) {
|
if (key.getVersion() >= 4) {
|
||||||
for (PGPSignature sig : new IterableIterator<PGPSignature>(key.getSignatures())) {
|
for (PGPSignature sig : new IterableIterator<PGPSignature>(key.getSignatures())) {
|
||||||
if (key.isMasterKey() && sig.getKeyID() != key.getKeyID()) continue;
|
if (key.isMasterKey() && sig.getKeyID() != key.getKeyID()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets();
|
PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets();
|
||||||
if (hashed != null) usage |= hashed.getKeyFlags();
|
if (hashed != null) {
|
||||||
|
usage |= hashed.getKeyFlags();
|
||||||
|
}
|
||||||
|
|
||||||
PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets();
|
PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets();
|
||||||
if (unhashed != null) usage |= unhashed.getKeyFlags();
|
if (unhashed != null) {
|
||||||
|
usage |= unhashed.getKeyFlags();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return usage;
|
return usage;
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.pgp;
|
package org.sufficientlysecure.keychain.pgp;
|
||||||
|
|
||||||
|
import android.util.Pair;
|
||||||
|
|
||||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||||
import org.spongycastle.bcpg.SymmetricKeyAlgorithmTags;
|
import org.spongycastle.bcpg.SymmetricKeyAlgorithmTags;
|
||||||
@ -45,6 +47,7 @@ import org.spongycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBu
|
|||||||
import org.spongycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
|
import org.spongycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
|
||||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.Id;
|
import org.sufficientlysecure.keychain.Id;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@ -193,8 +196,8 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PGPSecretKeyRing changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassPhrase,
|
public PGPSecretKeyRing changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassPhrase,
|
||||||
String newPassPhrase) throws IOException, PGPException,
|
String newPassPhrase)
|
||||||
NoSuchProviderException {
|
throws IOException, PGPException, NoSuchProviderException {
|
||||||
|
|
||||||
updateProgress(R.string.progress_building_key, 0, 100);
|
updateProgress(R.string.progress_building_key, 0, 100);
|
||||||
if (oldPassPhrase == null) {
|
if (oldPassPhrase == null) {
|
||||||
@ -216,7 +219,7 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<PGPSecretKeyRing,PGPPublicKeyRing> buildNewSecretKey(
|
private Pair<PGPSecretKeyRing, PGPPublicKeyRing> buildNewSecretKey(
|
||||||
ArrayList<String> userIds, ArrayList<PGPSecretKey> keys,
|
ArrayList<String> userIds, ArrayList<PGPSecretKey> keys,
|
||||||
ArrayList<GregorianCalendar> keysExpiryDates,
|
ArrayList<GregorianCalendar> keysExpiryDates,
|
||||||
ArrayList<Integer> keysUsages,
|
ArrayList<Integer> keysUsages,
|
||||||
@ -267,13 +270,16 @@ public class PgpKeyOperation {
|
|||||||
GregorianCalendar expiryDate = keysExpiryDates.get(0);
|
GregorianCalendar expiryDate = keysExpiryDates.get(0);
|
||||||
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
||||||
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
||||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
|
long numDays = (expiryDate.getTimeInMillis() / 86400000) -
|
||||||
if (numDays <= 0)
|
(creationDate.getTimeInMillis() / 86400000);
|
||||||
|
if (numDays <= 0) {
|
||||||
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
||||||
|
}
|
||||||
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
||||||
} else {
|
} else {
|
||||||
hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
|
hashedPacketsGen.setKeyExpirationTime(false, 0);
|
||||||
//this happens anyway
|
// do this explicitly, although since we're rebuilding,
|
||||||
|
// this happens anyway
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProgress(R.string.progress_building_master_key, 30, 100);
|
updateProgress(R.string.progress_building_master_key, 30, 100);
|
||||||
@ -339,15 +345,16 @@ public class PgpKeyOperation {
|
|||||||
GregorianCalendar expiryDate = keysExpiryDates.get(i);
|
GregorianCalendar expiryDate = keysExpiryDates.get(i);
|
||||||
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
||||||
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
||||||
long numDays =
|
long numDays = (expiryDate.getTimeInMillis() / 86400000) -
|
||||||
(expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
|
(creationDate.getTimeInMillis() / 86400000);
|
||||||
if (numDays <= 0) {
|
if (numDays <= 0) {
|
||||||
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
||||||
}
|
}
|
||||||
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
||||||
} else {
|
} else {
|
||||||
hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
|
hashedPacketsGen.setKeyExpirationTime(false, 0);
|
||||||
//this happens anyway
|
// do this explicitly, although since we're rebuilding,
|
||||||
|
// this happens anyway
|
||||||
}
|
}
|
||||||
|
|
||||||
keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate());
|
keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate());
|
||||||
@ -356,11 +363,11 @@ public class PgpKeyOperation {
|
|||||||
PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing();
|
PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing();
|
||||||
PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing();
|
PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing();
|
||||||
|
|
||||||
return new Pair<PGPSecretKeyRing,PGPPublicKeyRing>(secretKeyRing, publicKeyRing);
|
return new Pair<PGPSecretKeyRing, PGPPublicKeyRing>(secretKeyRing, publicKeyRing);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<PGPSecretKeyRing,PGPPublicKeyRing> buildSecretKey (PGPSecretKeyRing mKR,
|
public Pair<PGPSecretKeyRing, PGPPublicKeyRing> buildSecretKey(PGPSecretKeyRing mKR,
|
||||||
PGPPublicKeyRing pKR,
|
PGPPublicKeyRing pKR,
|
||||||
SaveKeyringParcel saveParcel)
|
SaveKeyringParcel saveParcel)
|
||||||
throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException {
|
throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException {
|
||||||
@ -444,22 +451,28 @@ public class PgpKeyOperation {
|
|||||||
GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(0);
|
GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(0);
|
||||||
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
||||||
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
||||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
|
long numDays = (expiryDate.getTimeInMillis() / 86400000) -
|
||||||
if (numDays <= 0)
|
(creationDate.getTimeInMillis() / 86400000);
|
||||||
|
if (numDays <= 0) {
|
||||||
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
||||||
|
}
|
||||||
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
||||||
} else {
|
} else {
|
||||||
hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
|
hashedPacketsGen.setKeyExpirationTime(false, 0);
|
||||||
//this happens anyway
|
// do this explicitly, although since we're rebuilding,
|
||||||
|
// this happens anyway
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveParcel.primaryIDChanged || !saveParcel.originalIDs.get(0).equals(saveParcel.userIDs.get(0))) {
|
if (saveParcel.primaryIDChanged ||
|
||||||
|
!saveParcel.originalIDs.get(0).equals(saveParcel.userIDs.get(0))) {
|
||||||
anyIDChanged = true;
|
anyIDChanged = true;
|
||||||
ArrayList<Pair<String, PGPSignature>> sigList = new ArrayList<Pair<String, PGPSignature>>();
|
ArrayList<Pair<String, PGPSignature>> sigList = new ArrayList<Pair<String, PGPSignature>>();
|
||||||
for (String userId : saveParcel.userIDs) {
|
for (String userId : saveParcel.userIDs) {
|
||||||
String origID = saveParcel.originalIDs.get(userIDIndex);
|
String origID = saveParcel.originalIDs.get(userIDIndex);
|
||||||
if ((origID.equals(userId) && !saveParcel.newIDs[userIDIndex]) && !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) {
|
if (origID.equals(userId) && !saveParcel.newIDs[userIDIndex] &&
|
||||||
Iterator<PGPSignature> origSigs = masterPublicKey.getSignaturesForID(origID); //TODO: make sure this iterator only has signatures we are interested in
|
!userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) {
|
||||||
|
Iterator<PGPSignature> origSigs = masterPublicKey.getSignaturesForID(origID);
|
||||||
|
// TODO: make sure this iterator only has signatures we are interested in
|
||||||
while (origSigs.hasNext()) {
|
while (origSigs.hasNext()) {
|
||||||
PGPSignature origSig = origSigs.next();
|
PGPSignature origSig = origSigs.next();
|
||||||
sigList.add(new Pair<String, PGPSignature>(origID, origSig));
|
sigList.add(new Pair<String, PGPSignature>(origID, origSig));
|
||||||
@ -484,7 +497,8 @@ public class PgpKeyOperation {
|
|||||||
userIDIndex++;
|
userIDIndex++;
|
||||||
}
|
}
|
||||||
for (Pair<String, PGPSignature> toAdd : sigList) {
|
for (Pair<String, PGPSignature> toAdd : sigList) {
|
||||||
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second);
|
masterPublicKey =
|
||||||
|
PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String userId : saveParcel.userIDs) {
|
for (String userId : saveParcel.userIDs) {
|
||||||
@ -505,7 +519,8 @@ public class PgpKeyOperation {
|
|||||||
if (!saveParcel.newIDs[userIDIndex]) {
|
if (!saveParcel.newIDs[userIDIndex]) {
|
||||||
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID);
|
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID);
|
||||||
}
|
}
|
||||||
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification);
|
masterPublicKey =
|
||||||
|
PGPPublicKey.addCertification(masterPublicKey, userId, certification);
|
||||||
}
|
}
|
||||||
userIDIndex++;
|
userIDIndex++;
|
||||||
}
|
}
|
||||||
@ -517,7 +532,8 @@ public class PgpKeyOperation {
|
|||||||
for (String userId : saveParcel.userIDs) {
|
for (String userId : saveParcel.userIDs) {
|
||||||
String origID = saveParcel.originalIDs.get(userIDIndex);
|
String origID = saveParcel.originalIDs.get(userIDIndex);
|
||||||
if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) {
|
if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) {
|
||||||
Iterator<PGPSignature> sigs = masterPublicKey.getSignaturesForID(userId); //TODO: make sure this iterator only has signatures we are interested in
|
Iterator<PGPSignature> sigs = masterPublicKey.getSignaturesForID(userId);
|
||||||
|
// TODO: make sure this iterator only has signatures we are interested in
|
||||||
while (sigs.hasNext()) {
|
while (sigs.hasNext()) {
|
||||||
PGPSignature sig = sigs.next();
|
PGPSignature sig = sigs.next();
|
||||||
sigList.add(new Pair<String, PGPSignature>(userId, sig));
|
sigList.add(new Pair<String, PGPSignature>(userId, sig));
|
||||||
@ -602,23 +618,27 @@ public class PgpKeyOperation {
|
|||||||
GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||||
creationDate.setTime(subPublicKey.getCreationTime());
|
creationDate.setTime(subPublicKey.getCreationTime());
|
||||||
GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(i);
|
GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(i);
|
||||||
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
// note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
||||||
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
// here we purposefully ignore partial days in each date - long type has
|
||||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
|
// no fractional part!
|
||||||
if (numDays <= 0)
|
long numDays = (expiryDate.getTimeInMillis() / 86400000) -
|
||||||
|
(creationDate.getTimeInMillis() / 86400000);
|
||||||
|
if (numDays <= 0) {
|
||||||
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
||||||
|
}
|
||||||
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
||||||
} else {
|
} else {
|
||||||
hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
|
hashedPacketsGen.setKeyExpirationTime(false, 0);
|
||||||
//this happens anyway
|
// do this explicitly, although since we're rebuilding,
|
||||||
|
// this happens anyway
|
||||||
}
|
}
|
||||||
|
|
||||||
keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate());
|
keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate());
|
||||||
//certifications will be discarded if the key is changed, because I think, for a start,
|
// certifications will be discarded if the key is changed, because I think, for a start,
|
||||||
//they will be invalid. Binding certs are regenerated anyway, and other certs which
|
// they will be invalid. Binding certs are regenerated anyway, and other certs which
|
||||||
//need to be kept are on IDs and attributes
|
// need to be kept are on IDs and attributes
|
||||||
//TODO: don't let revoked keys be edited, other than removed - changing one would result in the
|
// TODO: don't let revoked keys be edited, other than removed - changing one would
|
||||||
//revocation being wrong?
|
// result in the revocation being wrong?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,8 +677,10 @@ public class PgpKeyOperation {
|
|||||||
Log.d(Constants.TAG, " ------- in private key -------");
|
Log.d(Constants.TAG, " ------- in private key -------");
|
||||||
|
|
||||||
for(String uid : new IterableIterator<String>(secretKeyRing.getPublicKey().getUserIDs())) {
|
for(String uid : new IterableIterator<String>(secretKeyRing.getPublicKey().getUserIDs())) {
|
||||||
for(PGPSignature sig : new IterableIterator<PGPSignature>(secretKeyRing.getPublicKey().getSignaturesForID(uid))) {
|
for(PGPSignature sig : new IterableIterator<PGPSignature>(
|
||||||
Log.d(Constants.TAG, "sig: " + PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid);
|
secretKeyRing.getPublicKey().getSignaturesForID(uid))) {
|
||||||
|
Log.d(Constants.TAG, "sig: " +
|
||||||
|
PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -666,14 +688,16 @@ public class PgpKeyOperation {
|
|||||||
Log.d(Constants.TAG, " ------- in public key -------");
|
Log.d(Constants.TAG, " ------- in public key -------");
|
||||||
|
|
||||||
for(String uid : new IterableIterator<String>(publicKeyRing.getPublicKey().getUserIDs())) {
|
for(String uid : new IterableIterator<String>(publicKeyRing.getPublicKey().getUserIDs())) {
|
||||||
for(PGPSignature sig : new IterableIterator<PGPSignature>(publicKeyRing.getPublicKey().getSignaturesForID(uid))) {
|
for(PGPSignature sig : new IterableIterator<PGPSignature>(
|
||||||
Log.d(Constants.TAG, "sig: " + PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid);
|
publicKeyRing.getPublicKey().getSignaturesForID(uid))) {
|
||||||
|
Log.d(Constants.TAG, "sig: " +
|
||||||
|
PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return new Pair<PGPSecretKeyRing,PGPPublicKeyRing>(mKR, pKR);
|
return new Pair<PGPSecretKeyRing, PGPPublicKeyRing>(mKR, pKR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,9 +710,10 @@ public class PgpKeyOperation {
|
|||||||
* @param passphrase Passphrase of the secret key
|
* @param passphrase Passphrase of the secret key
|
||||||
* @return A keyring with added certifications
|
* @return A keyring with added certifications
|
||||||
*/
|
*/
|
||||||
public PGPPublicKey certifyKey(PGPSecretKey certificationKey, PGPPublicKey publicKey, List<String> userIds, String passphrase)
|
public PGPPublicKey certifyKey(PGPSecretKey certificationKey, PGPPublicKey publicKey,
|
||||||
|
List<String> userIds, String passphrase)
|
||||||
throws PgpGeneralMsgIdException, NoSuchAlgorithmException, NoSuchProviderException,
|
throws PgpGeneralMsgIdException, NoSuchAlgorithmException, NoSuchProviderException,
|
||||||
PGPException, SignatureException {
|
PGPException, SignatureException {
|
||||||
|
|
||||||
// create a signatureGenerator from the supplied masterKeyId and passphrase
|
// create a signatureGenerator from the supplied masterKeyId and passphrase
|
||||||
PGPSignatureGenerator signatureGenerator; {
|
PGPSignatureGenerator signatureGenerator; {
|
||||||
@ -720,7 +745,7 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fetch public key ring, add the certification and return it
|
// fetch public key ring, add the certification and return it
|
||||||
for(String userId : new IterableIterator<String>(userIds.iterator())) {
|
for (String userId : new IterableIterator<String>(userIds.iterator())) {
|
||||||
PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey);
|
PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey);
|
||||||
publicKey = PGPPublicKey.addCertification(publicKey, userId, sig);
|
publicKey = PGPPublicKey.addCertification(publicKey, userId, sig);
|
||||||
}
|
}
|
||||||
|
@ -83,9 +83,10 @@ public class PgpToX509 {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @author Bruno Harbulot
|
* @author Bruno Harbulot
|
||||||
*/
|
*/
|
||||||
public static X509Certificate createSelfSignedCert(PublicKey pubKey, PrivateKey privKey,
|
public static X509Certificate createSelfSignedCert(
|
||||||
X509Name subject, Date startDate, Date endDate, String subjAltNameURI)
|
PublicKey pubKey, PrivateKey privKey, X509Name subject, Date startDate, Date endDate,
|
||||||
throws InvalidKeyException, IllegalStateException, NoSuchAlgorithmException,
|
String subjAltNameURI)
|
||||||
|
throws InvalidKeyException, IllegalStateException, NoSuchAlgorithmException,
|
||||||
SignatureException, CertificateException, NoSuchProviderException {
|
SignatureException, CertificateException, NoSuchProviderException {
|
||||||
|
|
||||||
X509V3CertificateGenerator certGenerator = new X509V3CertificateGenerator();
|
X509V3CertificateGenerator certGenerator = new X509V3CertificateGenerator();
|
||||||
@ -182,10 +183,10 @@ public class PgpToX509 {
|
|||||||
/**
|
/**
|
||||||
* Creates a self-signed certificate from a PGP Secret Key.
|
* Creates a self-signed certificate from a PGP Secret Key.
|
||||||
*
|
*
|
||||||
* @param pgpSecKey PGP Secret Key (from which one can extract the public and private keys and other
|
* @param pgpSecKey PGP Secret Key (from which one can extract the public and private
|
||||||
* attributes).
|
* keys and other attributes).
|
||||||
* @param pgpPrivKey PGP Private Key corresponding to the Secret Key (password callbacks should be done
|
* @param pgpPrivKey PGP Private Key corresponding to the Secret Key (password callbacks
|
||||||
* before calling this method)
|
* should be done before calling this method)
|
||||||
* @param subjAltNameURI optional URI to embed in the subject alternative-name
|
* @param subjAltNameURI optional URI to embed in the subject alternative-name
|
||||||
* @return self-signed certificate
|
* @return self-signed certificate
|
||||||
* @throws PGPException
|
* @throws PGPException
|
||||||
@ -196,9 +197,9 @@ public class PgpToX509 {
|
|||||||
* @throws CertificateException
|
* @throws CertificateException
|
||||||
* @author Bruno Harbulot
|
* @author Bruno Harbulot
|
||||||
*/
|
*/
|
||||||
public static X509Certificate createSelfSignedCert(PGPSecretKey pgpSecKey,
|
public static X509Certificate createSelfSignedCert(
|
||||||
PGPPrivateKey pgpPrivKey, String subjAltNameURI) throws PGPException,
|
PGPSecretKey pgpSecKey, PGPPrivateKey pgpPrivKey, String subjAltNameURI)
|
||||||
NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException,
|
throws PGPException, NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException,
|
||||||
SignatureException, CertificateException {
|
SignatureException, CertificateException {
|
||||||
// get public key from secret key
|
// get public key from secret key
|
||||||
PGPPublicKey pgpPubKey = pgpSecKey.getPublicKey();
|
PGPPublicKey pgpPubKey = pgpSecKey.getPublicKey();
|
||||||
|
@ -22,14 +22,14 @@ import android.content.Context;
|
|||||||
public class PgpGeneralMsgIdException extends Exception {
|
public class PgpGeneralMsgIdException extends Exception {
|
||||||
static final long serialVersionUID = 0xf812773343L;
|
static final long serialVersionUID = 0xf812773343L;
|
||||||
|
|
||||||
private final int msgId;
|
private final int mMessageId;
|
||||||
|
|
||||||
public PgpGeneralMsgIdException(int msgId) {
|
public PgpGeneralMsgIdException(int messageId) {
|
||||||
super("msg[" + msgId + "]");
|
super("msg[" + messageId + "]");
|
||||||
this.msgId = msgId;
|
mMessageId = messageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PgpGeneralException getContextualized(Context context) {
|
public PgpGeneralException getContextualized(Context context) {
|
||||||
return new PgpGeneralException(context.getString(msgId), this);
|
return new PgpGeneralException(context.getString(mMessageId), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,12 +283,14 @@ public class KeychainContract {
|
|||||||
/**
|
/**
|
||||||
* Use if multiple items get returned
|
* Use if multiple items get returned
|
||||||
*/
|
*/
|
||||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api_app.accounts";
|
public static final String CONTENT_TYPE =
|
||||||
|
"vnd.android.cursor.dir/vnd.thialfihar.apg.api_app.accounts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use if a single item is returned
|
* Use if a single item is returned
|
||||||
*/
|
*/
|
||||||
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api_app.account";
|
public static final String CONTENT_ITEM_TYPE =
|
||||||
|
"vnd.android.cursor.item/vnd.thialfihar.apg.api_app.account";
|
||||||
|
|
||||||
public static Uri buildBaseUri(String packageName) {
|
public static Uri buildBaseUri(String packageName) {
|
||||||
return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS)
|
return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS)
|
||||||
|
@ -23,8 +23,8 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns;
|
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAccountsColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAccountsColumns;
|
||||||
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns;
|
||||||
|
@ -296,8 +296,8 @@ public class ProviderHelper {
|
|||||||
/**
|
/**
|
||||||
* Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing
|
* Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing
|
||||||
*/
|
*/
|
||||||
private static ContentProviderOperation buildPublicKeyOperations(Context context,
|
private static ContentProviderOperation buildPublicKeyOperations(
|
||||||
long keyRingRowId, PGPPublicKey key, int rank) throws IOException {
|
Context context, long keyRingRowId, PGPPublicKey key, int rank) throws IOException {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(Keys.KEY_ID, key.getKeyID());
|
values.put(Keys.KEY_ID, key.getKeyID());
|
||||||
values.put(Keys.IS_MASTER_KEY, key.isMasterKey());
|
values.put(Keys.IS_MASTER_KEY, key.isMasterKey());
|
||||||
@ -324,8 +324,8 @@ public class ProviderHelper {
|
|||||||
/**
|
/**
|
||||||
* Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing
|
* Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing
|
||||||
*/
|
*/
|
||||||
private static ContentProviderOperation buildPublicUserIdOperations(Context context,
|
private static ContentProviderOperation buildPublicUserIdOperations(
|
||||||
long keyRingRowId, String userId, int rank) {
|
Context context, long keyRingRowId, String userId, int rank) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId);
|
values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId);
|
||||||
values.put(UserIds.USER_ID, userId);
|
values.put(UserIds.USER_ID, userId);
|
||||||
@ -339,8 +339,8 @@ public class ProviderHelper {
|
|||||||
/**
|
/**
|
||||||
* Build ContentProviderOperation to add PGPSecretKey to database corresponding to a keyRing
|
* Build ContentProviderOperation to add PGPSecretKey to database corresponding to a keyRing
|
||||||
*/
|
*/
|
||||||
private static ContentProviderOperation buildSecretKeyOperations(Context context,
|
private static ContentProviderOperation buildSecretKeyOperations(
|
||||||
long keyRingRowId, PGPSecretKey key, int rank) throws IOException {
|
Context context, long keyRingRowId, PGPSecretKey key, int rank) throws IOException {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
|
|
||||||
boolean hasPrivate = true;
|
boolean hasPrivate = true;
|
||||||
@ -376,8 +376,8 @@ public class ProviderHelper {
|
|||||||
/**
|
/**
|
||||||
* Build ContentProviderOperation to add SecretUserIds to database corresponding to a keyRing
|
* Build ContentProviderOperation to add SecretUserIds to database corresponding to a keyRing
|
||||||
*/
|
*/
|
||||||
private static ContentProviderOperation buildSecretUserIdOperations(Context context,
|
private static ContentProviderOperation buildSecretUserIdOperations(
|
||||||
long keyRingRowId, String userId, int rank) {
|
Context context, long keyRingRowId, String userId, int rank) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId);
|
values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId);
|
||||||
values.put(UserIds.USER_ID, userId);
|
values.put(UserIds.USER_ID, userId);
|
||||||
@ -508,13 +508,14 @@ public class ProviderHelper {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public static boolean getMasterKeyCanCertify(Context context, Uri queryUri) {
|
public static boolean getMasterKeyCanCertify(Context context, Uri queryUri) {
|
||||||
String[] projection = new String[]{
|
String[] projection = new String[] {
|
||||||
KeyRings.MASTER_KEY_ID,
|
KeyRings.MASTER_KEY_ID,
|
||||||
"(SELECT COUNT(sign_keys." + Keys._ID + ") FROM " + Tables.KEYS
|
"(SELECT COUNT(sign_keys." + Keys._ID + ") FROM " + Tables.KEYS
|
||||||
+ " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = "
|
+ " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = "
|
||||||
+ KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID
|
+ KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID
|
||||||
+ " AND sign_keys." + Keys.CAN_CERTIFY + " = '1' AND " + Keys.IS_MASTER_KEY
|
+ " AND sign_keys." + Keys.CAN_CERTIFY + " = '1' AND " + Keys.IS_MASTER_KEY
|
||||||
+ " = 1) AS sign",};
|
+ " = 1) AS sign",
|
||||||
|
};
|
||||||
|
|
||||||
ContentResolver cr = context.getContentResolver();
|
ContentResolver cr = context.getContentResolver();
|
||||||
Cursor cursor = cr.query(queryUri, projection, null, null, null);
|
Cursor cursor = cr.query(queryUri, projection, null, null, null);
|
||||||
|
@ -17,10 +17,6 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.remote;
|
package org.sufficientlysecure.keychain.remote;
|
||||||
|
|
||||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
|
||||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
|
||||||
import org.sufficientlysecure.keychain.Id;
|
|
||||||
|
|
||||||
public class AppSettings {
|
public class AppSettings {
|
||||||
private String mPackageName;
|
private String mPackageName;
|
||||||
private byte[] mPackageSignature;
|
private byte[] mPackageSignature;
|
||||||
|
@ -188,7 +188,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Intent encryptAndSignImpl(Intent data, ParcelFileDescriptor input,
|
private Intent encryptAndSignImpl(Intent data, ParcelFileDescriptor input,
|
||||||
ParcelFileDescriptor output, AccountSettings accSettings, boolean sign) {
|
ParcelFileDescriptor output, AccountSettings accSettings,
|
||||||
|
boolean sign) {
|
||||||
try {
|
try {
|
||||||
boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||||
|
|
||||||
@ -292,7 +293,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os);
|
PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os);
|
||||||
builder.allowSymmetricDecryption(false) // no support for symmetric encryption
|
builder.allowSymmetricDecryption(false) // no support for symmetric encryption
|
||||||
.allowedKeyIds(allowedKeyIds) // allow only private keys associated with accounts of this app
|
.allowedKeyIds(allowedKeyIds) // allow only private keys associated with
|
||||||
|
// accounts of this app
|
||||||
.passphrase(passphrase);
|
.passphrase(passphrase);
|
||||||
|
|
||||||
// TODO: currently does not support binary signed-only content
|
// TODO: currently does not support binary signed-only content
|
||||||
@ -300,9 +302,11 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
||||||
// get PendingIntent for passphrase input, add it to given params and return to client
|
// get PendingIntent for passphrase input, add it to given params and return to client
|
||||||
Intent passphraseBundle = getPassphraseBundleIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded());
|
Intent passphraseBundle =
|
||||||
|
getPassphraseBundleIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded());
|
||||||
return passphraseBundle;
|
return passphraseBundle;
|
||||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED ==
|
||||||
|
decryptVerifyResult.getStatus()) {
|
||||||
throw new PgpGeneralException("Decryption of symmetric content not supported by API!");
|
throw new PgpGeneralException("Decryption of symmetric content not supported by API!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +459,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
} else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) {
|
} else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) {
|
||||||
String currentPkg = getCurrentCallingPackage();
|
String currentPkg = getCurrentCallingPackage();
|
||||||
Set<Long> allowedKeyIds =
|
Set<Long> allowedKeyIds =
|
||||||
ProviderHelper.getAllKeyIdsForApp(mContext, KeychainContract.ApiAccounts.buildBaseUri(currentPkg));
|
ProviderHelper.getAllKeyIdsForApp(mContext,
|
||||||
|
KeychainContract.ApiAccounts.buildBaseUri(currentPkg));
|
||||||
return decryptAndVerifyImpl(data, input, output, allowedKeyIds);
|
return decryptAndVerifyImpl(data, input, output, allowedKeyIds);
|
||||||
} else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) {
|
} else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) {
|
||||||
return getKeyImpl(data);
|
return getKeyImpl(data);
|
||||||
|
@ -243,7 +243,8 @@ public abstract class RemoteService extends Service {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw new WrongPackageSignatureException(
|
throw new WrongPackageSignatureException(
|
||||||
"PACKAGE NOT ALLOWED! Signature wrong! (Signature not equals signature from database)");
|
"PACKAGE NOT ALLOWED! Signature wrong! (Signature not " +
|
||||||
|
"equals signature from database)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,8 @@ public class AccountSettingsFragment extends Fragment implements
|
|||||||
this.mAccSettings = accountSettings;
|
this.mAccSettings = accountSettings;
|
||||||
|
|
||||||
mAccNameView.setText(accountSettings.getAccountName());
|
mAccNameView.setText(accountSettings.getAccountName());
|
||||||
Uri keyUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(accountSettings.getKeyId()));
|
Uri keyUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(
|
||||||
|
String.valueOf(accountSettings.getKeyId()));
|
||||||
mSelectKeyFragment.selectKey(keyUri);
|
mSelectKeyFragment.selectKey(keyUri);
|
||||||
mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(accountSettings
|
mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(accountSettings
|
||||||
.getEncryptionAlgorithm()));
|
.getEncryptionAlgorithm()));
|
||||||
|
@ -32,12 +32,10 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.Id;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.ui.widget.FixedListView;
|
import org.sufficientlysecure.keychain.ui.widget.FixedListView;
|
||||||
|
@ -37,11 +37,9 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
|
||||||
|
|
||||||
public class AppsListFragment extends ListFragment implements
|
public class AppsListFragment extends ListFragment implements
|
||||||
LoaderManager.LoaderCallbacks<Cursor> {
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
@ -95,7 +95,7 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
|||||||
if (ACTION_REGISTER.equals(action)) {
|
if (ACTION_REGISTER.equals(action)) {
|
||||||
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
||||||
final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE);
|
final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE);
|
||||||
Log.d(Constants.TAG, "ACTION_REGISTER packageName: "+packageName);
|
Log.d(Constants.TAG, "ACTION_REGISTER packageName: " + packageName);
|
||||||
|
|
||||||
// Inflate a "Done"/"Cancel" custom action bar view
|
// Inflate a "Done"/"Cancel" custom action bar view
|
||||||
ActionBarHelper.setTwoButtonView(getSupportActionBar(),
|
ActionBarHelper.setTwoButtonView(getSupportActionBar(),
|
||||||
|
@ -36,8 +36,6 @@ import org.sufficientlysecure.keychain.helper.Preferences;
|
|||||||
import org.sufficientlysecure.keychain.pgp.*;
|
import org.sufficientlysecure.keychain.pgp.*;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream;
|
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
||||||
import org.sufficientlysecure.keychain.util.*;
|
import org.sufficientlysecure.keychain.util.*;
|
||||||
@ -487,10 +485,13 @@ public class KeychainIntentService extends IntentService
|
|||||||
ProviderHelper.saveKeyRing(this, keyRing);
|
ProviderHelper.saveKeyRing(this, keyRing);
|
||||||
setProgress(R.string.progress_done, 100, 100);
|
setProgress(R.string.progress_done, 100, 100);
|
||||||
} else {
|
} else {
|
||||||
PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 90, 100));
|
PgpKeyOperation keyOperations =
|
||||||
PGPSecretKeyRing privkey = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId);
|
new PgpKeyOperation(new ProgressScaler(this, 0, 90, 100));
|
||||||
PGPPublicKeyRing pubkey = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, masterKeyId);
|
PGPSecretKeyRing privkey =
|
||||||
PgpKeyOperation.Pair<PGPSecretKeyRing,PGPPublicKeyRing> pair =
|
ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId);
|
||||||
|
PGPPublicKeyRing pubkey =
|
||||||
|
ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, masterKeyId);
|
||||||
|
PgpKeyOperation.Pair<PGPSecretKeyRing, PGPPublicKeyRing> pair =
|
||||||
keyOperations.buildSecretKey(privkey, pubkey, saveParams);
|
keyOperations.buildSecretKey(privkey, pubkey, saveParams);
|
||||||
setProgress(R.string.progress_saving_key_ring, 90, 100);
|
setProgress(R.string.progress_saving_key_ring, 90, 100);
|
||||||
ProviderHelper.saveKeyRing(this, pair.first);
|
ProviderHelper.saveKeyRing(this, pair.first);
|
||||||
@ -747,11 +748,14 @@ public class KeychainIntentService extends IntentService
|
|||||||
|
|
||||||
// verify downloaded key by comparing fingerprints
|
// verify downloaded key by comparing fingerprints
|
||||||
if (entry.getFingerPrintHex() != null) {
|
if (entry.getFingerPrintHex() != null) {
|
||||||
String downloadedKeyFp = PgpKeyHelper.convertFingerprintToHex(downloadedKey.getPublicKey().getFingerprint());
|
String downloadedKeyFp = PgpKeyHelper.convertFingerprintToHex(
|
||||||
|
downloadedKey.getPublicKey().getFingerprint());
|
||||||
if (downloadedKeyFp.equals(entry.getFingerPrintHex())) {
|
if (downloadedKeyFp.equals(entry.getFingerPrintHex())) {
|
||||||
Log.d(Constants.TAG, "fingerprint of downloaded key is the same as the requested fingerprint!");
|
Log.d(Constants.TAG, "fingerprint of downloaded key is the same as " +
|
||||||
|
"the requested fingerprint!");
|
||||||
} else {
|
} else {
|
||||||
throw new PgpGeneralException("fingerprint of downloaded key is NOT the same as the requested fingerprint!");
|
throw new PgpGeneralException("fingerprint of downloaded key is " +
|
||||||
|
"NOT the same as the requested fingerprint!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,7 +824,7 @@ public class KeychainIntentService extends IntentService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// contextualize the exception, if necessary
|
// contextualize the exception, if necessary
|
||||||
if(e instanceof PgpGeneralMsgIdException) {
|
if (e instanceof PgpGeneralMsgIdException) {
|
||||||
e = ((PgpGeneralMsgIdException) e).getContextualized(this);
|
e = ((PgpGeneralMsgIdException) e).getContextualized(this);
|
||||||
}
|
}
|
||||||
Log.e(Constants.TAG, "ApgService Exception: ", e);
|
Log.e(Constants.TAG, "ApgService Exception: ", e);
|
||||||
|
@ -25,14 +25,16 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.util.Log;
|
|
||||||
import android.support.v4.util.LongSparseArray;
|
import android.support.v4.util.LongSparseArray;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.spongycastle.openpgp.PGPException;
|
import org.spongycastle.openpgp.PGPException;
|
||||||
import org.spongycastle.openpgp.PGPPrivateKey;
|
import org.spongycastle.openpgp.PGPPrivateKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor;
|
import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor;
|
||||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.Id;
|
import org.sufficientlysecure.keychain.Id;
|
||||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||||
|
@ -46,20 +46,20 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
|
|
||||||
public SaveKeyringParcel() {}
|
public SaveKeyringParcel() {}
|
||||||
|
|
||||||
private SaveKeyringParcel(Parcel source)
|
private SaveKeyringParcel(Parcel source) {
|
||||||
{
|
userIDs = (ArrayList<String>) source.readSerializable();
|
||||||
userIDs = (ArrayList<String>)source.readSerializable();
|
originalIDs = (ArrayList<String>) source.readSerializable();
|
||||||
originalIDs = (ArrayList<String>)source.readSerializable();
|
deletedIDs = (ArrayList<String>) source.readSerializable();
|
||||||
deletedIDs = (ArrayList<String>)source.readSerializable();
|
|
||||||
newIDs = source.createBooleanArray();
|
newIDs = source.createBooleanArray();
|
||||||
primaryIDChanged = source.readByte() != 0;
|
primaryIDChanged = source.readByte() != 0;
|
||||||
moddedKeys = source.createBooleanArray();
|
moddedKeys = source.createBooleanArray();
|
||||||
byte[] tmp = source.createByteArray();
|
byte[] tmp = source.createByteArray();
|
||||||
if (tmp == null)
|
if (tmp == null) {
|
||||||
deletedKeys = null;
|
deletedKeys = null;
|
||||||
else
|
} else {
|
||||||
deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(tmp);
|
deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(tmp);
|
||||||
keysExpiryDates = (ArrayList<GregorianCalendar>)source.readSerializable();
|
}
|
||||||
|
keysExpiryDates = (ArrayList<GregorianCalendar>) source.readSerializable();
|
||||||
keysUsages = source.readArrayList(Integer.class.getClassLoader());
|
keysUsages = source.readArrayList(Integer.class.getClassLoader());
|
||||||
newPassPhrase = source.readString();
|
newPassPhrase = source.readString();
|
||||||
oldPassPhrase = source.readString();
|
oldPassPhrase = source.readString();
|
||||||
@ -69,8 +69,7 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel destination, int flags)
|
public void writeToParcel(Parcel destination, int flags) {
|
||||||
{
|
|
||||||
destination.writeSerializable(userIDs); //might not be the best method to store.
|
destination.writeSerializable(userIDs); //might not be the best method to store.
|
||||||
destination.writeSerializable(originalIDs);
|
destination.writeSerializable(originalIDs);
|
||||||
destination.writeSerializable(deletedIDs);
|
destination.writeSerializable(deletedIDs);
|
||||||
@ -78,8 +77,9 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
destination.writeByte((byte) (primaryIDChanged ? 1 : 0));
|
destination.writeByte((byte) (primaryIDChanged ? 1 : 0));
|
||||||
destination.writeBooleanArray(moddedKeys);
|
destination.writeBooleanArray(moddedKeys);
|
||||||
byte[] tmp = null;
|
byte[] tmp = null;
|
||||||
if (deletedKeys.size() != 0)
|
if (deletedKeys.size() != 0) {
|
||||||
tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys);
|
tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys);
|
||||||
|
}
|
||||||
destination.writeByteArray(tmp);
|
destination.writeByteArray(tmp);
|
||||||
destination.writeSerializable(keysExpiryDates);
|
destination.writeSerializable(keysExpiryDates);
|
||||||
destination.writeList(keysUsages);
|
destination.writeList(keysUsages);
|
||||||
@ -101,8 +101,7 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents()
|
public int describeContents() {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ import com.beardedhen.androidbootstrap.BootstrapButton;
|
|||||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
|
||||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
@ -213,7 +212,8 @@ public class CertifyKeyActivity extends ActionBarActivity implements
|
|||||||
fingerprintBlob = ProviderHelper.getFingerprint(this, mDataUri);
|
fingerprintBlob = ProviderHelper.getFingerprint(this, mDataUri);
|
||||||
}
|
}
|
||||||
String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob);
|
String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob);
|
||||||
((TextView) findViewById(R.id.fingerprint)).setText(PgpKeyHelper.colorizeFingerprint(fingerprint));
|
((TextView) findViewById(R.id.fingerprint))
|
||||||
|
.setText(PgpKeyHelper.colorizeFingerprint(fingerprint));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LOADER_ID_USER_IDS:
|
case LOADER_ID_USER_IDS:
|
||||||
@ -307,7 +307,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements
|
|||||||
|
|
||||||
// Bail out if there is not at least one user id selected
|
// Bail out if there is not at least one user id selected
|
||||||
ArrayList<String> userIds = mUserIdsAdapter.getSelectedUserIds();
|
ArrayList<String> userIds = mUserIdsAdapter.getSelectedUserIds();
|
||||||
if(userIds.isEmpty()) {
|
if (userIds.isEmpty()) {
|
||||||
Toast.makeText(CertifyKeyActivity.this, "No User IDs to sign selected!",
|
Toast.makeText(CertifyKeyActivity.this, "No User IDs to sign selected!",
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
|
@ -77,8 +77,10 @@ public class DecryptActivity extends DrawerActivity {
|
|||||||
// Handle intent actions, maybe changes the bundles
|
// Handle intent actions, maybe changes the bundles
|
||||||
handleActions(getIntent());
|
handleActions(getIntent());
|
||||||
|
|
||||||
mTabsAdapter.addTab(DecryptMessageFragment.class, mMessageFragmentBundle, getString(R.string.label_message));
|
mTabsAdapter.addTab(DecryptMessageFragment.class,
|
||||||
mTabsAdapter.addTab(DecryptFileFragment.class, mFileFragmentBundle, getString(R.string.label_file));
|
mMessageFragmentBundle, getString(R.string.label_message));
|
||||||
|
mTabsAdapter.addTab(DecryptFileFragment.class,
|
||||||
|
mFileFragmentBundle, getString(R.string.label_file));
|
||||||
mViewPager.setCurrentItem(mSwitchToTab);
|
mViewPager.setCurrentItem(mSwitchToTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +166,8 @@ public class DecryptActivity extends DrawerActivity {
|
|||||||
mSwitchToTab = PAGER_TAB_FILE;
|
mSwitchToTab = PAGER_TAB_FILE;
|
||||||
} else {
|
} else {
|
||||||
Log.e(Constants.TAG,
|
Log.e(Constants.TAG,
|
||||||
"Direct binary data without actual file in filesystem is not supported. Please use the Remote Service API!");
|
"Direct binary data without actual file in filesystem is not supported. " +
|
||||||
|
"Please use the Remote Service API!");
|
||||||
Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
|
Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
|
||||||
.show();
|
.show();
|
||||||
// end activity
|
// end activity
|
||||||
|
@ -200,7 +200,8 @@ public class DecryptFileFragment extends DecryptFragment {
|
|||||||
|
|
||||||
if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
||||||
showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded());
|
showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded());
|
||||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED ==
|
||||||
|
decryptVerifyResult.getStatus()) {
|
||||||
showPassphraseDialog(Id.key.symmetric);
|
showPassphraseDialog(Id.key.symmetric);
|
||||||
} else {
|
} else {
|
||||||
AppMsg.makeText(getActivity(), R.string.decryption_successful,
|
AppMsg.makeText(getActivity(), R.string.decryption_successful,
|
||||||
|
@ -154,7 +154,8 @@ public class DecryptMessageFragment extends DecryptFragment {
|
|||||||
|
|
||||||
if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
||||||
showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded());
|
showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded());
|
||||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED ==
|
||||||
|
decryptVerifyResult.getStatus()) {
|
||||||
showPassphraseDialog(Id.key.symmetric);
|
showPassphraseDialog(Id.key.symmetric);
|
||||||
} else {
|
} else {
|
||||||
AppMsg.makeText(getActivity(), R.string.decryption_successful,
|
AppMsg.makeText(getActivity(), R.string.decryption_successful,
|
||||||
|
@ -58,7 +58,7 @@ public class DrawerActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
// if the left margin of the loaded layout is close to the
|
// if the left margin of the loaded layout is close to the
|
||||||
// one used in tablets then set drawer as open and locked
|
// one used in tablets then set drawer as open and locked
|
||||||
if( Math.abs(leftMarginLoaded - leftMarginInTablets) < errorInMarginAllowed) {
|
if (Math.abs(leftMarginLoaded - leftMarginInTablets) < errorInMarginAllowed) {
|
||||||
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerList);
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerList);
|
||||||
mDrawerLayout.setScrimColor(Color.TRANSPARENT);
|
mDrawerLayout.setScrimColor(Color.TRANSPARENT);
|
||||||
mIsDrawerLocked = true;
|
mIsDrawerLocked = true;
|
||||||
@ -82,7 +82,7 @@ public class DrawerActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
// enable ActionBar app icon to behave as action to toggle nav drawer
|
// enable ActionBar app icon to behave as action to toggle nav drawer
|
||||||
// if the drawer is not locked
|
// if the drawer is not locked
|
||||||
if ( !mIsDrawerLocked ) {
|
if (!mIsDrawerLocked) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setHomeButtonEnabled(true);
|
getSupportActionBar().setHomeButtonEnabled(true);
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ public class DrawerActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( !mIsDrawerLocked ) {
|
if (!mIsDrawerLocked) {
|
||||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||||
} else {
|
} else {
|
||||||
// If the drawer is locked open make it un-focusable
|
// If the drawer is locked open make it un-focusable
|
||||||
@ -218,9 +218,9 @@ public class DrawerActivity extends ActionBarActivity {
|
|||||||
// setTitle(mDrawerTitles[position]);
|
// setTitle(mDrawerTitles[position]);
|
||||||
// If drawer isn't locked just close the drawer and
|
// If drawer isn't locked just close the drawer and
|
||||||
// it will move to the selected item by itself (via drawer toggle listener)
|
// it will move to the selected item by itself (via drawer toggle listener)
|
||||||
if ( !mIsDrawerLocked ) {
|
if (!mIsDrawerLocked) {
|
||||||
mDrawerLayout.closeDrawer(mDrawerList);
|
mDrawerLayout.closeDrawer(mDrawerList);
|
||||||
// else move to the selected item yourself
|
// else move to the selected item yourself
|
||||||
} else {
|
} else {
|
||||||
callIntentForDrawerItem(mSelectedItem);
|
callIntentForDrawerItem(mSelectedItem);
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import com.devspark.appmsg.AppMsg;
|
|||||||
|
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.Id;
|
import org.sufficientlysecure.keychain.Id;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@ -124,7 +125,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
|||||||
|
|
||||||
public void somethingChanged() {
|
public void somethingChanged() {
|
||||||
ActivityCompat.invalidateOptionsMenu(this);
|
ActivityCompat.invalidateOptionsMenu(this);
|
||||||
//Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving) + "(" + Boolean.toString(mUserIdsView.needsSaving()) + ", " + Boolean.toString(mKeysView.needsSaving()) + ")", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDeleted(Editor e, boolean wasNewItem) {
|
public void onDeleted(Editor e, boolean wasNewItem) {
|
||||||
@ -328,7 +328,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
cancelClicked(); //TODO: why isn't this triggered on my tablet - one of many ui problems I've had with this device. A code compatibility issue or a Samsung fail?
|
cancelClicked();
|
||||||
|
// TODO: why isn't this triggered on my tablet - one of many ui problems
|
||||||
|
// I've had with this device. A code compatibility issue or a Samsung fail?
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_key_edit_cancel:
|
case R.id.menu_key_edit_cancel:
|
||||||
cancelClicked();
|
cancelClicked();
|
||||||
@ -338,9 +340,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
|||||||
Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri);
|
long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri);
|
||||||
long[] ids = new long[]{masterKeyId};
|
long[] ids = new long[] {masterKeyId};
|
||||||
mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC,
|
mExportHelper.showExportKeysDialog(
|
||||||
null);
|
ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -389,8 +391,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
|||||||
if (!isSet) {
|
if (!isSet) {
|
||||||
isSet = true;
|
isSet = true;
|
||||||
String[] parts = PgpKeyHelper.splitUserId(userId);
|
String[] parts = PgpKeyHelper.splitUserId(userId);
|
||||||
if (parts[0] != null)
|
if (parts[0] != null) {
|
||||||
setTitle(parts[0]);
|
setTitle(parts[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mUserIds.add(userId);
|
mUserIds.add(userId);
|
||||||
}
|
}
|
||||||
@ -545,10 +548,11 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
String passphrase;
|
String passphrase;
|
||||||
if (mIsPassPhraseSet)
|
if (mIsPassPhraseSet) {
|
||||||
passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
|
passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
|
||||||
else
|
} else {
|
||||||
passphrase = "";
|
passphrase = "";
|
||||||
|
}
|
||||||
if (passphrase == null) {
|
if (passphrase == null) {
|
||||||
showPassphraseDialog(masterKeyId);
|
showPassphraseDialog(masterKeyId);
|
||||||
} else {
|
} else {
|
||||||
|
@ -155,12 +155,16 @@ public class EncryptActivity extends DrawerActivity implements
|
|||||||
// Handle intent actions
|
// Handle intent actions
|
||||||
handleActions(getIntent());
|
handleActions(getIntent());
|
||||||
|
|
||||||
mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class, mAsymmetricFragmentBundle, getString(R.string.label_asymmetric));
|
mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class,
|
||||||
mTabsAdapterMode.addTab(EncryptSymmetricFragment.class, mSymmetricFragmentBundle, getString(R.string.label_symmetric));
|
mAsymmetricFragmentBundle, getString(R.string.label_asymmetric));
|
||||||
|
mTabsAdapterMode.addTab(EncryptSymmetricFragment.class,
|
||||||
|
mSymmetricFragmentBundle, getString(R.string.label_symmetric));
|
||||||
mViewPagerMode.setCurrentItem(mSwitchToMode);
|
mViewPagerMode.setCurrentItem(mSwitchToMode);
|
||||||
|
|
||||||
mTabsAdapterContent.addTab(EncryptMessageFragment.class, mMessageFragmentBundle, getString(R.string.label_message));
|
mTabsAdapterContent.addTab(EncryptMessageFragment.class,
|
||||||
mTabsAdapterContent.addTab(EncryptFileFragment.class, mFileFragmentBundle, getString(R.string.label_file));
|
mMessageFragmentBundle, getString(R.string.label_message));
|
||||||
|
mTabsAdapterContent.addTab(EncryptFileFragment.class,
|
||||||
|
mFileFragmentBundle, getString(R.string.label_file));
|
||||||
mViewPagerContent.setCurrentItem(mSwitchToContent);
|
mViewPagerContent.setCurrentItem(mSwitchToContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,8 +216,10 @@ public class EncryptActivity extends DrawerActivity implements
|
|||||||
long[] encryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
|
long[] encryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
|
||||||
|
|
||||||
// preselect keys given by intent
|
// preselect keys given by intent
|
||||||
mAsymmetricFragmentBundle.putLongArray(EncryptAsymmetricFragment.ARG_ENCRYPTION_KEY_IDS, encryptionKeyIds);
|
mAsymmetricFragmentBundle.putLongArray(EncryptAsymmetricFragment.ARG_ENCRYPTION_KEY_IDS,
|
||||||
mAsymmetricFragmentBundle.putLong(EncryptAsymmetricFragment.ARG_SIGNATURE_KEY_ID, signatureKeyId);
|
encryptionKeyIds);
|
||||||
|
mAsymmetricFragmentBundle.putLong(EncryptAsymmetricFragment.ARG_SIGNATURE_KEY_ID,
|
||||||
|
signatureKeyId);
|
||||||
mSwitchToMode = PAGER_MODE_ASYMMETRIC;
|
mSwitchToMode = PAGER_MODE_ASYMMETRIC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,7 +240,8 @@ public class EncryptActivity extends DrawerActivity implements
|
|||||||
mSwitchToContent = PAGER_CONTENT_FILE;
|
mSwitchToContent = PAGER_CONTENT_FILE;
|
||||||
} else {
|
} else {
|
||||||
Log.e(Constants.TAG,
|
Log.e(Constants.TAG,
|
||||||
"Direct binary data without actual file in filesystem is not supported by Intents. Please use the Remote Service API!");
|
"Direct binary data without actual file in filesystem is not supported " +
|
||||||
|
"by Intents. Please use the Remote Service API!");
|
||||||
Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
|
Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
|
||||||
.show();
|
.show();
|
||||||
// end activity
|
// end activity
|
||||||
|
@ -264,8 +264,8 @@ public class EncryptAsymmetricFragment extends Fragment {
|
|||||||
|
|
||||||
case RESULT_CODE_SECRET_KEYS: {
|
case RESULT_CODE_SECRET_KEYS: {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
Uri uri_master_key = data.getData();
|
Uri uriMasterKey = data.getData();
|
||||||
setSignatureKeyId(Long.valueOf(uri_master_key.getLastPathSegment()));
|
setSignatureKeyId(Long.valueOf(uriMasterKey.getLastPathSegment()));
|
||||||
} else {
|
} else {
|
||||||
setSignatureKeyId(Id.key.none);
|
setSignatureKeyId(Id.key.none);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public class EncryptFileFragment extends Fragment {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mFileCompression = (Spinner) view.findViewById(R.id.fileCompression);
|
mFileCompression = (Spinner) view.findViewById(R.id.fileCompression);
|
||||||
Choice[] choices = new Choice[]{
|
Choice[] choices = new Choice[] {
|
||||||
new Choice(Id.choice.compression.none, getString(R.string.choice_none) + " ("
|
new Choice(Id.choice.compression.none, getString(R.string.choice_none) + " ("
|
||||||
+ getString(R.string.compression_fast) + ")"),
|
+ getString(R.string.compression_fast) + ")"),
|
||||||
new Choice(Id.choice.compression.zip, "ZIP ("
|
new Choice(Id.choice.compression.zip, "ZIP ("
|
||||||
@ -120,7 +120,8 @@ public class EncryptFileFragment extends Fragment {
|
|||||||
new Choice(Id.choice.compression.zlib, "ZLIB ("
|
new Choice(Id.choice.compression.zlib, "ZLIB ("
|
||||||
+ getString(R.string.compression_fast) + ")"),
|
+ getString(R.string.compression_fast) + ")"),
|
||||||
new Choice(Id.choice.compression.bzip2, "BZIP2 ("
|
new Choice(Id.choice.compression.bzip2, "BZIP2 ("
|
||||||
+ getString(R.string.compression_very_slow) + ")"),};
|
+ getString(R.string.compression_very_slow) + ")"),
|
||||||
|
};
|
||||||
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getActivity(),
|
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getActivity(),
|
||||||
android.R.layout.simple_spinner_item, choices);
|
android.R.layout.simple_spinner_item, choices);
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
@ -252,8 +253,9 @@ public class EncryptFileFragment extends Fragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEncryptInterface.getSignatureKey() != 0
|
if (mEncryptInterface.getSignatureKey() != 0 &&
|
||||||
&& PassphraseCacheService.getCachedPassphrase(getActivity(), mEncryptInterface.getSignatureKey()) == null) {
|
PassphraseCacheService.getCachedPassphrase(getActivity(),
|
||||||
|
mEncryptInterface.getSignatureKey()) == null) {
|
||||||
showPassphraseDialog();
|
showPassphraseDialog();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -282,8 +284,10 @@ public class EncryptFileFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
|
data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
|
||||||
} else {
|
} else {
|
||||||
data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
|
data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID,
|
||||||
data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys());
|
mEncryptInterface.getSignatureKey());
|
||||||
|
data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS,
|
||||||
|
mEncryptInterface.getEncryptionKeys());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
|
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
|
||||||
|
@ -150,8 +150,9 @@ public class EncryptMessageFragment extends Fragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEncryptInterface.getSignatureKey() != 0
|
if (mEncryptInterface.getSignatureKey() != 0 &&
|
||||||
&& PassphraseCacheService.getCachedPassphrase(getActivity(), mEncryptInterface.getSignatureKey()) == null) {
|
PassphraseCacheService.getCachedPassphrase(getActivity(),
|
||||||
|
mEncryptInterface.getSignatureKey()) == null) {
|
||||||
showPassphraseDialog(toClipboard);
|
showPassphraseDialog(toClipboard);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -182,8 +183,10 @@ public class EncryptMessageFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
|
data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
|
||||||
} else {
|
} else {
|
||||||
data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
|
data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID,
|
||||||
data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys());
|
mEncryptInterface.getSignatureKey());
|
||||||
|
data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS,
|
||||||
|
mEncryptInterface.getEncryptionKeys());
|
||||||
|
|
||||||
boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null
|
boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null
|
||||||
|| mEncryptInterface.getEncryptionKeys().length == 0);
|
|| mEncryptInterface.getEncryptionKeys().length == 0);
|
||||||
|
@ -168,7 +168,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(Constants.TAG,
|
Log.e(Constants.TAG,
|
||||||
"IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or 'fingerprint' extra!");
|
"IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " +
|
||||||
|
"'fingerprint' extra!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +234,7 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
|||||||
* onNavigationItemSelected() should check whether the Fragment is already in existence
|
* onNavigationItemSelected() should check whether the Fragment is already in existence
|
||||||
* inside your Activity."
|
* inside your Activity."
|
||||||
* <p/>
|
* <p/>
|
||||||
* from http://stackoverflow.com/questions/10983396/fragment-oncreateview-and-onactivitycreated-called-twice/14295474#14295474
|
* from http://bit.ly/1dBYThO
|
||||||
* <p/>
|
* <p/>
|
||||||
* In our case, if we start ImportKeysActivity with parameters to directly search using a fingerprint,
|
* In our case, if we start ImportKeysActivity with parameters to directly search using a fingerprint,
|
||||||
* the fragment would be loaded twice resulting in the query being empty after the second load.
|
* the fragment would be loaded twice resulting in the query being empty after the second load.
|
||||||
@ -337,7 +338,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
|||||||
// } else {
|
// } else {
|
||||||
// status.putString(
|
// status.putString(
|
||||||
// EXTRA_ERROR,
|
// EXTRA_ERROR,
|
||||||
// "Scanned fingerprint does NOT match the fingerprint of the received key. You shouldnt trust this key.");
|
// "Scanned fingerprint does NOT match the fingerprint of the received key. " +
|
||||||
|
// "You shouldnt trust this key.");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// } catch (QueryException e) {
|
// } catch (QueryException e) {
|
||||||
|
@ -65,7 +65,7 @@ public class ImportKeysClipboardFragment extends Fragment {
|
|||||||
String sendText = "";
|
String sendText = "";
|
||||||
if (clipboardText != null) {
|
if (clipboardText != null) {
|
||||||
sendText = clipboardText.toString();
|
sendText = clipboardText.toString();
|
||||||
if(sendText.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
|
if (sendText.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
|
||||||
mImportActivity.loadFromFingerprintUri(null, Uri.parse(sendText));
|
mImportActivity.loadFromFingerprintUri(null, Uri.parse(sendText));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
import com.google.zxing.integration.android.IntentResult;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -28,8 +30,9 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
import com.google.zxing.integration.android.IntentResult;
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.util.IntentIntegratorSupportV4;
|
import org.sufficientlysecure.keychain.util.IntentIntegratorSupportV4;
|
||||||
|
@ -66,11 +66,13 @@ public class KeyListActivity extends DrawerActivity {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_key_list_export_public:
|
case R.id.menu_key_list_export_public:
|
||||||
mExportHelper.showExportKeysDialog(null, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null);
|
mExportHelper.showExportKeysDialog(null,
|
||||||
|
Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_key_list_secret_export:
|
case R.id.menu_key_list_secret_export:
|
||||||
mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null);
|
mExportHelper.showExportKeysDialog(null, Id.type.secret_key,
|
||||||
|
Constants.Path.APP_DIR_FILE_SEC, null);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
@ -185,17 +185,20 @@ public class KeyListFragment extends Fragment
|
|||||||
}
|
}
|
||||||
case R.id.menu_key_list_multi_export: {
|
case R.id.menu_key_list_multi_export: {
|
||||||
ids = mStickyList.getWrappedList().getCheckedItemIds();
|
ids = mStickyList.getWrappedList().getCheckedItemIds();
|
||||||
long[] masterKeyIds = new long[2*ids.length];
|
long[] masterKeyIds = new long[2 * ids.length];
|
||||||
ArrayList<Long> allPubRowIds =
|
ArrayList<Long> allPubRowIds =
|
||||||
ProviderHelper.getPublicKeyRingsRowIds(getActivity());
|
ProviderHelper.getPublicKeyRingsRowIds(getActivity());
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
if (allPubRowIds.contains(ids[i])) {
|
if (allPubRowIds.contains(ids[i])) {
|
||||||
masterKeyIds[i] = ProviderHelper.getPublicMasterKeyId(getActivity(), ids[i]);
|
masterKeyIds[i] =
|
||||||
|
ProviderHelper.getPublicMasterKeyId(getActivity(), ids[i]);
|
||||||
} else {
|
} else {
|
||||||
masterKeyIds[i] = ProviderHelper.getSecretMasterKeyId(getActivity(), ids[i]);
|
masterKeyIds[i] =
|
||||||
|
ProviderHelper.getSecretMasterKeyId(getActivity(), ids[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity());
|
ExportHelper mExportHelper =
|
||||||
|
new ExportHelper((ActionBarActivity) getActivity());
|
||||||
mExportHelper
|
mExportHelper
|
||||||
.showExportKeysDialog(masterKeyIds, Id.type.public_key,
|
.showExportKeysDialog(masterKeyIds, Id.type.public_key,
|
||||||
Constants.Path.APP_DIR_FILE_PUB,
|
Constants.Path.APP_DIR_FILE_PUB,
|
||||||
|
@ -38,11 +38,11 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
|
public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
|
||||||
|
|
||||||
private PreferenceScreen mKeyServerPreference = null;
|
private PreferenceScreen mKeyServerPreference = null;
|
||||||
private static Preferences mPreferences;
|
private static Preferences sPreferences;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mPreferences = Preferences.getPreferences(this);
|
sPreferences = Preferences.getPreferences(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// final ActionBar actionBar = getSupportActionBar();
|
// final ActionBar actionBar = getSupportActionBar();
|
||||||
@ -59,7 +59,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
(IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL));
|
(IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL));
|
||||||
|
|
||||||
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
|
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
|
||||||
String servers[] = mPreferences.getKeyServers();
|
String servers[] = sPreferences.getKeyServers();
|
||||||
mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_key_servers,
|
mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_key_servers,
|
||||||
servers.length, servers.length));
|
servers.length, servers.length));
|
||||||
mKeyServerPreference
|
mKeyServerPreference
|
||||||
@ -68,7 +68,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
Intent intent = new Intent(PreferencesActivity.this,
|
Intent intent = new Intent(PreferencesActivity.this,
|
||||||
PreferencesKeyServerActivity.class);
|
PreferencesKeyServerActivity.class);
|
||||||
intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS,
|
intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS,
|
||||||
mPreferences.getKeyServers());
|
sPreferences.getKeyServers());
|
||||||
startActivityForResult(intent, Id.request.key_server_preference);
|
startActivityForResult(intent, Id.request.key_server_preference);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
String servers[] = data
|
String servers[] = data
|
||||||
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
||||||
mPreferences.setKeyServers(servers);
|
sPreferences.setKeyServers(servers);
|
||||||
mKeyServerPreference.setSummary(getResources().getQuantityString(
|
mKeyServerPreference.setSummary(getResources().getQuantityString(
|
||||||
R.plurals.n_key_servers, servers.length, servers.length));
|
R.plurals.n_key_servers, servers.length, servers.length));
|
||||||
break;
|
break;
|
||||||
@ -163,7 +163,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
(IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL));
|
(IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL));
|
||||||
|
|
||||||
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
|
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
|
||||||
String servers[] = mPreferences.getKeyServers();
|
String servers[] = sPreferences.getKeyServers();
|
||||||
mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_key_servers,
|
mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_key_servers,
|
||||||
servers.length, servers.length));
|
servers.length, servers.length));
|
||||||
mKeyServerPreference
|
mKeyServerPreference
|
||||||
@ -172,7 +172,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
Intent intent = new Intent(getActivity(),
|
Intent intent = new Intent(getActivity(),
|
||||||
PreferencesKeyServerActivity.class);
|
PreferencesKeyServerActivity.class);
|
||||||
intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS,
|
intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS,
|
||||||
mPreferences.getKeyServers());
|
sPreferences.getKeyServers());
|
||||||
startActivityForResult(intent, Id.request.key_server_preference);
|
startActivityForResult(intent, Id.request.key_server_preference);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
String servers[] = data
|
String servers[] = data
|
||||||
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
||||||
mPreferences.setKeyServers(servers);
|
sPreferences.setKeyServers(servers);
|
||||||
mKeyServerPreference.setSummary(getResources().getQuantityString(
|
mKeyServerPreference.setSummary(getResources().getQuantityString(
|
||||||
R.plurals.n_key_servers, servers.length, servers.length));
|
R.plurals.n_key_servers, servers.length, servers.length));
|
||||||
break;
|
break;
|
||||||
@ -256,14 +256,14 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void initializePassPassPhraceCacheTtl(final IntegerListPreference mPassphraseCacheTtl) {
|
private static void initializePassPassPhraceCacheTtl(final IntegerListPreference mPassphraseCacheTtl) {
|
||||||
mPassphraseCacheTtl.setValue("" + mPreferences.getPassPhraseCacheTtl());
|
mPassphraseCacheTtl.setValue("" + sPreferences.getPassPhraseCacheTtl());
|
||||||
mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry());
|
mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry());
|
||||||
mPassphraseCacheTtl
|
mPassphraseCacheTtl
|
||||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
mPassphraseCacheTtl.setValue(newValue.toString());
|
mPassphraseCacheTtl.setValue(newValue.toString());
|
||||||
mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry());
|
mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry());
|
||||||
mPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString()));
|
sPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -282,14 +282,14 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
mEncryptionAlgorithm.setEntries(entries);
|
mEncryptionAlgorithm.setEntries(entries);
|
||||||
mEncryptionAlgorithm.setEntryValues(values);
|
mEncryptionAlgorithm.setEntryValues(values);
|
||||||
mEncryptionAlgorithm.setValue("" + mPreferences.getDefaultEncryptionAlgorithm());
|
mEncryptionAlgorithm.setValue("" + sPreferences.getDefaultEncryptionAlgorithm());
|
||||||
mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry());
|
mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry());
|
||||||
mEncryptionAlgorithm
|
mEncryptionAlgorithm
|
||||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
mEncryptionAlgorithm.setValue(newValue.toString());
|
mEncryptionAlgorithm.setValue(newValue.toString());
|
||||||
mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry());
|
mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry());
|
||||||
mPreferences.setDefaultEncryptionAlgorithm(Integer.parseInt(newValue
|
sPreferences.setDefaultEncryptionAlgorithm(Integer.parseInt(newValue
|
||||||
.toString()));
|
.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -309,13 +309,13 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
mHashAlgorithm.setEntries(entries);
|
mHashAlgorithm.setEntries(entries);
|
||||||
mHashAlgorithm.setEntryValues(values);
|
mHashAlgorithm.setEntryValues(values);
|
||||||
mHashAlgorithm.setValue("" + mPreferences.getDefaultHashAlgorithm());
|
mHashAlgorithm.setValue("" + sPreferences.getDefaultHashAlgorithm());
|
||||||
mHashAlgorithm.setSummary(mHashAlgorithm.getEntry());
|
mHashAlgorithm.setSummary(mHashAlgorithm.getEntry());
|
||||||
mHashAlgorithm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
mHashAlgorithm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
mHashAlgorithm.setValue(newValue.toString());
|
mHashAlgorithm.setValue(newValue.toString());
|
||||||
mHashAlgorithm.setSummary(mHashAlgorithm.getEntry());
|
mHashAlgorithm.setSummary(mHashAlgorithm.getEntry());
|
||||||
mPreferences.setDefaultHashAlgorithm(Integer.parseInt(newValue.toString()));
|
sPreferences.setDefaultHashAlgorithm(Integer.parseInt(newValue.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -326,14 +326,14 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
int[] valueIds, String[] entries, String[] values) {
|
int[] valueIds, String[] entries, String[] values) {
|
||||||
mMessageCompression.setEntries(entries);
|
mMessageCompression.setEntries(entries);
|
||||||
mMessageCompression.setEntryValues(values);
|
mMessageCompression.setEntryValues(values);
|
||||||
mMessageCompression.setValue("" + mPreferences.getDefaultMessageCompression());
|
mMessageCompression.setValue("" + sPreferences.getDefaultMessageCompression());
|
||||||
mMessageCompression.setSummary(mMessageCompression.getEntry());
|
mMessageCompression.setSummary(mMessageCompression.getEntry());
|
||||||
mMessageCompression
|
mMessageCompression
|
||||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
mMessageCompression.setValue(newValue.toString());
|
mMessageCompression.setValue(newValue.toString());
|
||||||
mMessageCompression.setSummary(mMessageCompression.getEntry());
|
mMessageCompression.setSummary(mMessageCompression.getEntry());
|
||||||
mPreferences.setDefaultMessageCompression(Integer.parseInt(newValue
|
sPreferences.setDefaultMessageCompression(Integer.parseInt(newValue
|
||||||
.toString()));
|
.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -344,36 +344,36 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
(final IntegerListPreference mFileCompression, String[] entries, String[] values) {
|
(final IntegerListPreference mFileCompression, String[] entries, String[] values) {
|
||||||
mFileCompression.setEntries(entries);
|
mFileCompression.setEntries(entries);
|
||||||
mFileCompression.setEntryValues(values);
|
mFileCompression.setEntryValues(values);
|
||||||
mFileCompression.setValue("" + mPreferences.getDefaultFileCompression());
|
mFileCompression.setValue("" + sPreferences.getDefaultFileCompression());
|
||||||
mFileCompression.setSummary(mFileCompression.getEntry());
|
mFileCompression.setSummary(mFileCompression.getEntry());
|
||||||
mFileCompression.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
mFileCompression.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
mFileCompression.setValue(newValue.toString());
|
mFileCompression.setValue(newValue.toString());
|
||||||
mFileCompression.setSummary(mFileCompression.getEntry());
|
mFileCompression.setSummary(mFileCompression.getEntry());
|
||||||
mPreferences.setDefaultFileCompression(Integer.parseInt(newValue.toString()));
|
sPreferences.setDefaultFileCompression(Integer.parseInt(newValue.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeAsciiArmour(final CheckBoxPreference mAsciiArmour) {
|
private static void initializeAsciiArmour(final CheckBoxPreference mAsciiArmour) {
|
||||||
mAsciiArmour.setChecked(mPreferences.getDefaultAsciiArmour());
|
mAsciiArmour.setChecked(sPreferences.getDefaultAsciiArmour());
|
||||||
mAsciiArmour.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
mAsciiArmour.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
mAsciiArmour.setChecked((Boolean) newValue);
|
mAsciiArmour.setChecked((Boolean) newValue);
|
||||||
mPreferences.setDefaultAsciiArmour((Boolean) newValue);
|
sPreferences.setDefaultAsciiArmour((Boolean) newValue);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeForceV3Signatures(final CheckBoxPreference mForceV3Signatures) {
|
private static void initializeForceV3Signatures(final CheckBoxPreference mForceV3Signatures) {
|
||||||
mForceV3Signatures.setChecked(mPreferences.getForceV3Signatures());
|
mForceV3Signatures.setChecked(sPreferences.getForceV3Signatures());
|
||||||
mForceV3Signatures
|
mForceV3Signatures
|
||||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
mForceV3Signatures.setChecked((Boolean) newValue);
|
mForceV3Signatures.setChecked((Boolean) newValue);
|
||||||
mPreferences.setForceV3Signatures((Boolean) newValue);
|
sPreferences.setForceV3Signatures((Boolean) newValue);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -141,7 +141,8 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
|||||||
+ Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN
|
+ Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN
|
||||||
+ " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND "
|
+ " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND "
|
||||||
+ "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY
|
+ "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY
|
||||||
+ " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID,};
|
+ " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID,
|
||||||
|
};
|
||||||
|
|
||||||
String orderBy = UserIds.USER_ID + " ASC";
|
String orderBy = UserIds.USER_ID + " ASC";
|
||||||
|
|
||||||
|
@ -53,12 +53,12 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan
|
|||||||
|
|
||||||
private SelectSecretKeyCallback mCallback;
|
private SelectSecretKeyCallback mCallback;
|
||||||
|
|
||||||
final String[] PROJECTION = new String[]{
|
private static final String[] PROJECTION = new String[] {
|
||||||
KeychainContract.UserIds.USER_ID,
|
KeychainContract.UserIds.USER_ID,
|
||||||
KeychainContract.KeyRings.MASTER_KEY_ID
|
KeychainContract.KeyRings.MASTER_KEY_ID,
|
||||||
};
|
};
|
||||||
final int INDEX_USER_ID = 0;
|
private static final int INDEX_USER_ID = 0;
|
||||||
final int INDEX_MASTER_KEY_ID = 1;
|
private static final int INDEX_MASTER_KEY_ID = 1;
|
||||||
|
|
||||||
public interface SelectSecretKeyCallback {
|
public interface SelectSecretKeyCallback {
|
||||||
void onKeySelected(long secretKeyId);
|
void onKeySelected(long secretKeyId);
|
||||||
|
@ -38,7 +38,6 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.TabsAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.TabsAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment;
|
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.ShareQrCodeDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.ShareQrCodeDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@ -125,8 +124,9 @@ public class ViewKeyActivity extends ActionBarActivity {
|
|||||||
return true;
|
return true;
|
||||||
case R.id.menu_key_view_export_file:
|
case R.id.menu_key_view_export_file:
|
||||||
long masterKeyId =
|
long masterKeyId =
|
||||||
ProviderHelper.getPublicMasterKeyId(this, Long.valueOf(mDataUri.getLastPathSegment()));
|
ProviderHelper.getPublicMasterKeyId(this,
|
||||||
long[] ids = new long[]{masterKeyId};
|
Long.valueOf(mDataUri.getLastPathSegment()));
|
||||||
|
long[] ids = new long[] {masterKeyId};
|
||||||
mExportHelper.showExportKeysDialog(ids, Id.type.public_key,
|
mExportHelper.showExportKeysDialog(ids, Id.type.public_key,
|
||||||
Constants.Path.APP_DIR_FILE_PUB, null);
|
Constants.Path.APP_DIR_FILE_PUB, null);
|
||||||
return true;
|
return true;
|
||||||
|
@ -37,7 +37,6 @@ import com.beardedhen.androidbootstrap.BootstrapButton;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
@ -32,7 +32,6 @@ import android.widget.LinearLayout.LayoutParams;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -45,12 +44,12 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
protected List<ImportKeysListEntry> mData;
|
protected List<ImportKeysListEntry> mData;
|
||||||
|
|
||||||
static class ViewHolder {
|
static class ViewHolder {
|
||||||
private TextView mainUserId;
|
public TextView mainUserId;
|
||||||
private TextView mainUserIdRest;
|
public TextView mainUserIdRest;
|
||||||
private TextView keyId;
|
public TextView keyId;
|
||||||
private TextView fingerprint;
|
public TextView fingerprint;
|
||||||
private TextView algorithm;
|
public TextView algorithm;
|
||||||
private TextView status;
|
public TextView status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImportKeysAdapter(Activity activity) {
|
public ImportKeysAdapter(Activity activity) {
|
||||||
|
@ -249,7 +249,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
/**
|
/**
|
||||||
* Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
|
* Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
|
||||||
*/
|
*/
|
||||||
private final static SparseArray<String> ALGORITHM_IDS = new SparseArray<String>() {{
|
private static final SparseArray<String> ALGORITHM_IDS = new SparseArray<String>() {{
|
||||||
put(-1, "unknown"); // TODO: with resources
|
put(-1, "unknown"); // TODO: with resources
|
||||||
put(0, "unencrypted");
|
put(0, "unencrypted");
|
||||||
put(PGPPublicKey.RSA_GENERAL, "RSA");
|
put(PGPPublicKey.RSA_GENERAL, "RSA");
|
||||||
@ -267,6 +267,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
* Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
|
* Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
|
||||||
*/
|
*/
|
||||||
public static String getAlgorithmFromId(int algorithmId) {
|
public static String getAlgorithmFromId(int algorithmId) {
|
||||||
return (ALGORITHM_IDS.get(algorithmId) != null ? ALGORITHM_IDS.get(algorithmId) : ALGORITHM_IDS.get(-1));
|
return (ALGORITHM_IDS.get(algorithmId) != null ?
|
||||||
|
ALGORITHM_IDS.get(algorithmId) :
|
||||||
|
ALGORITHM_IDS.get(-1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,6 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentPagerAdapter;
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -34,9 +30,9 @@ public class PagerTabStripAdapter extends FragmentPagerAdapter {
|
|||||||
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
||||||
|
|
||||||
static final class TabInfo {
|
static final class TabInfo {
|
||||||
private final Class<?> clss;
|
public final Class<?> clss;
|
||||||
private final Bundle args;
|
public final Bundle args;
|
||||||
private final String title;
|
public final String title;
|
||||||
|
|
||||||
TabInfo(Class<?> clss, Bundle args, String title) {
|
TabInfo(Class<?> clss, Bundle args, String title) {
|
||||||
this.clss = clss;
|
this.clss = clss;
|
||||||
|
@ -36,8 +36,8 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
|
|||||||
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
||||||
|
|
||||||
static final class TabInfo {
|
static final class TabInfo {
|
||||||
private final Class<?> clss;
|
public final Class<?> clss;
|
||||||
private final Bundle args;
|
public final Bundle args;
|
||||||
|
|
||||||
TabInfo(Class<?> clss, Bundle args) {
|
TabInfo(Class<?> clss, Bundle args) {
|
||||||
this.clss = clss;
|
this.clss = clss;
|
||||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.support.v4.widget.CursorAdapter;
|
import android.support.v4.widget.CursorAdapter;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -149,8 +148,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
|
|||||||
DateFormat.getDateFormat(context).format(expiryDate) + ")");
|
DateFormat.getDateFormat(context).format(expiryDate) + ")");
|
||||||
|
|
||||||
keyExpiry.setVisibility(View.VISIBLE);
|
keyExpiry.setVisibility(View.VISIBLE);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
keyExpiry.setVisibility(View.GONE);
|
keyExpiry.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
// if key is expired or revoked, strike through text
|
// if key is expired or revoked, strike through text
|
||||||
|
@ -37,7 +37,7 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
|
|||||||
|
|
||||||
private int mIndexUserId, mIndexRank;
|
private int mIndexUserId, mIndexRank;
|
||||||
|
|
||||||
final private ArrayList<Boolean> mCheckStates;
|
private final ArrayList<Boolean> mCheckStates;
|
||||||
|
|
||||||
public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) {
|
public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) {
|
||||||
super(context, c, flags);
|
super(context, c, flags);
|
||||||
@ -55,14 +55,15 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public Cursor swapCursor(Cursor newCursor) {
|
public Cursor swapCursor(Cursor newCursor) {
|
||||||
initIndex(newCursor);
|
initIndex(newCursor);
|
||||||
if(mCheckStates != null) {
|
if (mCheckStates != null) {
|
||||||
mCheckStates.clear();
|
mCheckStates.clear();
|
||||||
if(newCursor != null) {
|
if (newCursor != null) {
|
||||||
int count = newCursor.getCount();
|
int count = newCursor.getCount();
|
||||||
mCheckStates.ensureCapacity(count);
|
mCheckStates.ensureCapacity(count);
|
||||||
// initialize to true (use case knowledge: we usually want to sign all uids)
|
// initialize to true (use case knowledge: we usually want to sign all uids)
|
||||||
for(int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++) {
|
||||||
mCheckStates.add(true);
|
mCheckStates.add(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +101,9 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
|
|||||||
vAddress.setText(userId[1]);
|
vAddress.setText(userId[1]);
|
||||||
|
|
||||||
// don't care further if checkboxes aren't shown
|
// don't care further if checkboxes aren't shown
|
||||||
if(mCheckStates == null)
|
if (mCheckStates == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final CheckBox vCheckBox = (CheckBox) view.findViewById(R.id.checkBox);
|
final CheckBox vCheckBox = (CheckBox) view.findViewById(R.id.checkBox);
|
||||||
final int position = cursor.getPosition();
|
final int position = cursor.getPosition();
|
||||||
@ -124,8 +126,8 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
|
|||||||
|
|
||||||
public ArrayList<String> getSelectedUserIds() {
|
public ArrayList<String> getSelectedUserIds() {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
for(int i = 0; i < mCheckStates.size(); i++) {
|
for (int i = 0; i < mCheckStates.size(); i++) {
|
||||||
if(mCheckStates.get(i)) {
|
if (mCheckStates.get(i)) {
|
||||||
mCursor.moveToPosition(i);
|
mCursor.moveToPosition(i);
|
||||||
result.add(mCursor.getString(mIndexUserId));
|
result.add(mCursor.getString(mIndexUserId));
|
||||||
}
|
}
|
||||||
|
@ -138,9 +138,10 @@ public class CreateKeyDialogFragment extends DialogFragment {
|
|||||||
final AdapterView.OnItemSelectedListener weakRsaListener = new AdapterView.OnItemSelectedListener() {
|
final AdapterView.OnItemSelectedListener weakRsaListener = new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
final Choice selectedAlgorithm = (Choice)algorithm.getSelectedItem();
|
final Choice selectedAlgorithm = (Choice) algorithm.getSelectedItem();
|
||||||
final int selectedKeySize = Integer.parseInt((String)keySize.getSelectedItem());
|
final int selectedKeySize = Integer.parseInt((String) keySize.getSelectedItem());
|
||||||
final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa && selectedKeySize <= 1024);
|
final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa &&
|
||||||
|
selectedKeySize <= 1024);
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!isWeakRsa);
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!isWeakRsa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
public static final int MESSAGE_OKAY = 1;
|
public static final int MESSAGE_OKAY = 1;
|
||||||
public static final int MESSAGE_ERROR = 0;
|
public static final int MESSAGE_ERROR = 0;
|
||||||
|
|
||||||
private boolean isSingleSelection = false;
|
private boolean mIsSingleSelection = false;
|
||||||
|
|
||||||
private TextView mainMessage;
|
private TextView mMainMessage;
|
||||||
private CheckBox checkDeleteSecret;
|
private CheckBox mCheckDeleteSecret;
|
||||||
private LinearLayout deleteSecretKeyView;
|
private LinearLayout mDeleteSecretKeyView;
|
||||||
private View inflateView;
|
private View mInflateView;
|
||||||
|
|
||||||
private Messenger mMessenger;
|
private Messenger mMessenger;
|
||||||
|
|
||||||
@ -90,12 +90,12 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
//Setup custom View to display in AlertDialog
|
//Setup custom View to display in AlertDialog
|
||||||
LayoutInflater inflater = activity.getLayoutInflater();
|
LayoutInflater inflater = activity.getLayoutInflater();
|
||||||
inflateView = inflater.inflate(R.layout.view_key_delete_fragment, null);
|
mInflateView = inflater.inflate(R.layout.view_key_delete_fragment, null);
|
||||||
builder.setView(inflateView);
|
builder.setView(mInflateView);
|
||||||
|
|
||||||
deleteSecretKeyView = (LinearLayout) inflateView.findViewById(R.id.deleteSecretKeyView);
|
mDeleteSecretKeyView = (LinearLayout) mInflateView.findViewById(R.id.deleteSecretKeyView);
|
||||||
mainMessage = (TextView) inflateView.findViewById(R.id.mainMessage);
|
mMainMessage = (TextView) mInflateView.findViewById(R.id.mainMessage);
|
||||||
checkDeleteSecret = (CheckBox) inflateView.findViewById(R.id.checkDeleteSecret);
|
mCheckDeleteSecret = (CheckBox) mInflateView.findViewById(R.id.checkDeleteSecret);
|
||||||
|
|
||||||
builder.setTitle(R.string.warning);
|
builder.setTitle(R.string.warning);
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
if (keyRingRowIds.length == 1) {
|
if (keyRingRowIds.length == 1) {
|
||||||
Uri dataUri;
|
Uri dataUri;
|
||||||
ArrayList<Long> publicKeyRings; //Any one will do
|
ArrayList<Long> publicKeyRings; //Any one will do
|
||||||
isSingleSelection = true;
|
mIsSingleSelection = true;
|
||||||
|
|
||||||
long selectedRow = keyRingRowIds[0];
|
long selectedRow = keyRingRowIds[0];
|
||||||
long keyType;
|
long keyType;
|
||||||
@ -119,16 +119,16 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String userId = ProviderHelper.getUserId(activity, dataUri);
|
String userId = ProviderHelper.getUserId(activity, dataUri);
|
||||||
//Hide the Checkbox and TextView since this is a single selection,user will be notified thru message
|
// Hide the Checkbox and TextView since this is a single selection,
|
||||||
deleteSecretKeyView.setVisibility(View.GONE);
|
// user will be notified thru message
|
||||||
//Set message depending on which key it is.
|
mDeleteSecretKeyView.setVisibility(View.GONE);
|
||||||
mainMessage.setText(getString(keyType == Id.type.secret_key ? R.string.secret_key_deletion_confirmation
|
// Set message depending on which key it is.
|
||||||
: R.string.public_key_deletetion_confirmation, userId));
|
mMainMessage.setText(getString(keyType == Id.type.secret_key ?
|
||||||
|
R.string.secret_key_deletion_confirmation :
|
||||||
|
R.string.public_key_deletetion_confirmation, userId));
|
||||||
} else {
|
} else {
|
||||||
deleteSecretKeyView.setVisibility(View.VISIBLE);
|
mDeleteSecretKeyView.setVisibility(View.VISIBLE);
|
||||||
mainMessage.setText(R.string.key_deletion_confirmation_multi);
|
mMainMessage.setText(R.string.key_deletion_confirmation_multi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -148,8 +148,9 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
String selectionIDs = "";
|
String selectionIDs = "";
|
||||||
for (int i = 0; i < keyRingRowIds.length; i++) {
|
for (int i = 0; i < keyRingRowIds.length; i++) {
|
||||||
selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'";
|
selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'";
|
||||||
if (i + 1 < keyRingRowIds.length)
|
if (i + 1 < keyRingRowIds.length) {
|
||||||
selectionIDs += ",";
|
selectionIDs += ",";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
selection += selectionIDs + ")";
|
selection += selectionIDs + ")";
|
||||||
|
|
||||||
@ -166,30 +167,33 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
masterKeyId = cursor.getLong(0);
|
masterKeyId = cursor.getLong(0);
|
||||||
keyType = cursor.getLong(1);
|
keyType = cursor.getLong(1);
|
||||||
|
|
||||||
Log.d(Constants.TAG, "masterKeyId: " + masterKeyId
|
Log.d(Constants.TAG, "masterKeyId: " + masterKeyId +
|
||||||
+ ", keyType:" + (keyType == KeychainContract.KeyTypes.PUBLIC ? "Public" : "Private"));
|
", keyType:" +
|
||||||
|
(keyType == KeychainContract.KeyTypes.PUBLIC ?
|
||||||
|
"Public" : "Private"));
|
||||||
|
|
||||||
if (keyType == KeychainContract.KeyTypes.SECRET) {
|
if (keyType == KeychainContract.KeyTypes.SECRET) {
|
||||||
if (checkDeleteSecret.isChecked() || isSingleSelection) {
|
if (mCheckDeleteSecret.isChecked() || mIsSingleSelection) {
|
||||||
ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), true);
|
ProviderHelper.deleteUnifiedKeyRing(activity,
|
||||||
|
String.valueOf(masterKeyId), true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), false);
|
ProviderHelper.deleteUnifiedKeyRing(activity,
|
||||||
|
String.valueOf(masterKeyId), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if the selected rows have actually been deleted
|
//Check if the selected rows have actually been deleted
|
||||||
cursor = activity.getContentResolver().query(queryUri, projection, selection, null, null);
|
cursor = activity.getContentResolver().query(
|
||||||
if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) {
|
queryUri, projection, selection, null, null);
|
||||||
|
if (cursor == null || cursor.getCount() == 0 ||
|
||||||
|
!mCheckDeleteSecret.isChecked()) {
|
||||||
isSuccessfullyDeleted = true;
|
isSuccessfullyDeleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dismiss();
|
dismiss();
|
||||||
@ -200,9 +204,7 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
sendMessageToHandler(MESSAGE_ERROR, null);
|
sendMessageToHandler(MESSAGE_ERROR, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -232,5 +234,4 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
Log.w(Constants.TAG, "Messenger is null!", e);
|
Log.w(Constants.TAG, "Messenger is null!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -111,7 +111,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment {
|
|||||||
content = keyringArmored.get(0);
|
content = keyringArmored.get(0);
|
||||||
|
|
||||||
// OnClickListener are set in onResume to prevent automatic dismissing of Dialogs
|
// OnClickListener are set in onResume to prevent automatic dismissing of Dialogs
|
||||||
// http://stackoverflow.com/questions/2620444/how-to-prevent-a-dialog-from-closing-when-a-button-is-clicked
|
// http://bit.ly/O5vfaR
|
||||||
alert.setPositiveButton(R.string.btn_next, null);
|
alert.setPositiveButton(R.string.btn_next, null);
|
||||||
alert.setNegativeButton(android.R.string.cancel, null);
|
alert.setNegativeButton(android.R.string.cancel, null);
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
* @param attrs
|
* @param attrs
|
||||||
*/
|
*/
|
||||||
private void processAttributes(Context context, AttributeSet attrs) {
|
private void processAttributes(Context context, AttributeSet attrs) {
|
||||||
if(attrs != null) {
|
if (attrs != null) {
|
||||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||||
R.styleable.FoldableLinearLayout, 0, 0);
|
R.styleable.FoldableLinearLayout, 0, 0);
|
||||||
mFoldedIconName = a.getString(R.styleable.FoldableLinearLayout_foldedIcon);
|
mFoldedIconName = a.getString(R.styleable.FoldableLinearLayout_foldedIcon);
|
||||||
@ -102,7 +102,7 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
// if the migration has already happened
|
// if the migration has already happened
|
||||||
// there is no need to move any children
|
// there is no need to move any children
|
||||||
if(!mHasMigrated) {
|
if (!mHasMigrated) {
|
||||||
migrateChildrenToContainer();
|
migrateChildrenToContainer();
|
||||||
mHasMigrated = true;
|
mHasMigrated = true;
|
||||||
}
|
}
|
||||||
@ -120,10 +120,10 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
int childNum = getChildCount();
|
int childNum = getChildCount();
|
||||||
View[] children = new View[childNum];
|
View[] children = new View[childNum];
|
||||||
|
|
||||||
for(int i = 0; i < childNum; i++) {
|
for (int i = 0; i < childNum; i++) {
|
||||||
children[i] = getChildAt(i);
|
children[i] = getChildAt(i);
|
||||||
}
|
}
|
||||||
if(children[0].getId() == R.id.foldableControl) {
|
if (children[0].getId() == R.id.foldableControl) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,14 +131,14 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
detachAllViewsFromParent();
|
detachAllViewsFromParent();
|
||||||
|
|
||||||
// Inflate the inner foldable_linearlayout.xml
|
// Inflate the inner foldable_linearlayout.xml
|
||||||
LayoutInflater inflator = (LayoutInflater)getContext().getSystemService(
|
LayoutInflater inflator = (LayoutInflater) getContext().getSystemService(
|
||||||
Context.LAYOUT_INFLATER_SERVICE);
|
Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
mFoldableLayout = inflator.inflate(R.layout.foldable_linearlayout, this, true);
|
mFoldableLayout = inflator.inflate(R.layout.foldable_linearlayout, this, true);
|
||||||
mFoldableContainer = (LinearLayout) mFoldableLayout.findViewById(R.id.foldableContainer);
|
mFoldableContainer = (LinearLayout) mFoldableLayout.findViewById(R.id.foldableContainer);
|
||||||
|
|
||||||
// Push previously collected children into foldableContainer.
|
// Push previously collected children into foldableContainer.
|
||||||
for(int i = 0; i < childNum; i++) {
|
for (int i = 0; i < childNum; i++) {
|
||||||
addView(children[i]);
|
addView(children[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addView(View child) {
|
public void addView(View child) {
|
||||||
if(mFoldableContainer != null) {
|
if (mFoldableContainer != null) {
|
||||||
mFoldableContainer.addView(child);
|
mFoldableContainer.addView(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,20 +16,6 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui.widget;
|
package org.sufficientlysecure.keychain.ui.widget;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
|
||||||
import org.spongycastle.openpgp.PGPKeyFlags;
|
|
||||||
import org.spongycastle.openpgp.PGPPublicKey;
|
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
|
||||||
import org.sufficientlysecure.keychain.util.Choice;
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@ -47,16 +33,23 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TableLayout;
|
import android.widget.TableLayout;
|
||||||
import android.widget.TableRow;
|
import android.widget.TableRow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
|
|
||||||
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.openpgp.PGPPublicKey;
|
import org.spongycastle.openpgp.PGPPublicKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.sufficientlysecure.keychain.Id;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.util.Choice;
|
import org.sufficientlysecure.keychain.util.Choice;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.*;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
||||||
private PGPSecretKey mKey;
|
private PGPSecretKey mKey;
|
||||||
@ -101,11 +94,13 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
GregorianCalendar date = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
GregorianCalendar date = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||||
date.set(year, monthOfYear, dayOfMonth);
|
date.set(year, monthOfYear, dayOfMonth);
|
||||||
if (mOriginalExpiryDate != null) {
|
if (mOriginalExpiryDate != null) {
|
||||||
long numDays = (date.getTimeInMillis() / 86400000) - (mOriginalExpiryDate.getTimeInMillis() / 86400000);
|
long numDays = (date.getTimeInMillis() / 86400000) -
|
||||||
if (numDays == 0)
|
(mOriginalExpiryDate.getTimeInMillis() / 86400000);
|
||||||
|
if (numDays == 0) {
|
||||||
setExpiryDate(mOriginalExpiryDate);
|
setExpiryDate(mOriginalExpiryDate);
|
||||||
else
|
} else {
|
||||||
setExpiryDate(date);
|
setExpiryDate(date);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setExpiryDate(date);
|
setExpiryDate(date);
|
||||||
}
|
}
|
||||||
@ -228,23 +223,23 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
boolean isDSAKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.DSA);
|
boolean isDSAKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.DSA);
|
||||||
if (isElGamalKey) {
|
if (isElGamalKey) {
|
||||||
mChkSign.setVisibility(View.INVISIBLE);
|
mChkSign.setVisibility(View.INVISIBLE);
|
||||||
TableLayout table = (TableLayout)findViewById(R.id.table_keylayout);
|
TableLayout table = (TableLayout) findViewById(R.id.table_keylayout);
|
||||||
TableRow row = (TableRow)findViewById(R.id.row_sign);
|
TableRow row = (TableRow) findViewById(R.id.row_sign);
|
||||||
table.removeView(row);
|
table.removeView(row);
|
||||||
}
|
}
|
||||||
if (isDSAKey) {
|
if (isDSAKey) {
|
||||||
mChkEncrypt.setVisibility(View.INVISIBLE);
|
mChkEncrypt.setVisibility(View.INVISIBLE);
|
||||||
TableLayout table = (TableLayout)findViewById(R.id.table_keylayout);
|
TableLayout table = (TableLayout) findViewById(R.id.table_keylayout);
|
||||||
TableRow row = (TableRow)findViewById(R.id.row_encrypt);
|
TableRow row = (TableRow) findViewById(R.id.row_encrypt);
|
||||||
table.removeView(row);
|
table.removeView(row);
|
||||||
}
|
}
|
||||||
if (!mIsMasterKey) {
|
if (!mIsMasterKey) {
|
||||||
mChkCertify.setVisibility(View.INVISIBLE);
|
mChkCertify.setVisibility(View.INVISIBLE);
|
||||||
TableLayout table = (TableLayout)findViewById(R.id.table_keylayout);
|
TableLayout table = (TableLayout) findViewById(R.id.table_keylayout);
|
||||||
TableRow row = (TableRow)findViewById(R.id.row_certify);
|
TableRow row = (TableRow) findViewById(R.id.row_certify);
|
||||||
table.removeView(row);
|
table.removeView(row);
|
||||||
} else {
|
} else {
|
||||||
TextView mLabelUsage2= (TextView) findViewById(R.id.label_usage2);
|
TextView mLabelUsage2 = (TextView) findViewById(R.id.label_usage2);
|
||||||
mLabelUsage2.setVisibility(View.INVISIBLE);
|
mLabelUsage2.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,8 +255,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
} else {
|
} else {
|
||||||
mUsage = PgpKeyHelper.getKeyUsage(key);
|
mUsage = PgpKeyHelper.getKeyUsage(key);
|
||||||
mOriginalUsage = mUsage;
|
mOriginalUsage = mUsage;
|
||||||
if (key.isMasterKey())
|
if (key.isMasterKey()) {
|
||||||
mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key));
|
mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key));
|
||||||
|
}
|
||||||
mChkSign.setChecked(PgpKeyHelper.isSigningKey(key));
|
mChkSign.setChecked(PgpKeyHelper.isSigningKey(key));
|
||||||
mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key));
|
mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key));
|
||||||
mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key));
|
mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key));
|
||||||
@ -323,19 +319,24 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getUsage() {
|
public int getUsage() {
|
||||||
mUsage = (mUsage & ~KeyFlags.CERTIFY_OTHER) | (mChkCertify.isChecked() ? KeyFlags.CERTIFY_OTHER : 0);
|
mUsage = (mUsage & ~KeyFlags.CERTIFY_OTHER) |
|
||||||
mUsage = (mUsage & ~KeyFlags.SIGN_DATA) | (mChkSign.isChecked() ? KeyFlags.SIGN_DATA : 0);
|
(mChkCertify.isChecked() ? KeyFlags.CERTIFY_OTHER : 0);
|
||||||
mUsage = (mUsage & ~KeyFlags.ENCRYPT_COMMS) | (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_COMMS : 0);
|
mUsage = (mUsage & ~KeyFlags.SIGN_DATA) |
|
||||||
mUsage = (mUsage & ~KeyFlags.ENCRYPT_STORAGE) | (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_STORAGE : 0);
|
(mChkSign.isChecked() ? KeyFlags.SIGN_DATA : 0);
|
||||||
mUsage = (mUsage & ~KeyFlags.AUTHENTICATION) | (mChkAuthenticate.isChecked() ? KeyFlags.AUTHENTICATION : 0);
|
mUsage = (mUsage & ~KeyFlags.ENCRYPT_COMMS) |
|
||||||
|
(mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_COMMS : 0);
|
||||||
|
mUsage = (mUsage & ~KeyFlags.ENCRYPT_STORAGE) |
|
||||||
|
(mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_STORAGE : 0);
|
||||||
|
mUsage = (mUsage & ~KeyFlags.AUTHENTICATION) |
|
||||||
|
(mChkAuthenticate.isChecked() ? KeyFlags.AUTHENTICATION : 0);
|
||||||
|
|
||||||
return mUsage;
|
return mUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsSaving()
|
public boolean needsSaving() {
|
||||||
{
|
if (mIsNewKey) {
|
||||||
if (mIsNewKey)
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
boolean retval = (getUsage() != mOriginalUsage);
|
boolean retval = (getUsage() != mOriginalUsage);
|
||||||
|
|
||||||
@ -345,21 +346,21 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
if (mOEDNull != mEDNull) {
|
if (mOEDNull != mEDNull) {
|
||||||
dateChanged = true;
|
dateChanged = true;
|
||||||
} else {
|
} else {
|
||||||
if(mOEDNull) //both null, no change
|
if (mOEDNull) {
|
||||||
|
//both null, no change
|
||||||
dateChanged = false;
|
dateChanged = false;
|
||||||
else
|
} else {
|
||||||
dateChanged = ((mExpiryDate.compareTo(mOriginalExpiryDate)) != 0);
|
dateChanged = ((mExpiryDate.compareTo(mOriginalExpiryDate)) != 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
retval |= dateChanged;
|
retval |= dateChanged;
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsNewKey()
|
public boolean getIsNewKey() {
|
||||||
{
|
|
||||||
return mIsNewKey;
|
return mIsNewKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExpiryDatePickerDialog extends DatePickerDialog {
|
class ExpiryDatePickerDialog extends DatePickerDialog {
|
||||||
|
@ -16,23 +16,6 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui.widget;
|
package org.sufficientlysecure.keychain.ui.widget;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.spongycastle.openpgp.PGPKeyFlags;
|
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
|
||||||
import org.sufficientlysecure.keychain.Id;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
|
||||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
|
|
||||||
import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener;
|
|
||||||
import org.sufficientlysecure.keychain.util.Choice;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@ -49,7 +32,10 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
|
|
||||||
|
import org.spongycastle.openpgp.PGPKeyFlags;
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Id;
|
import org.sufficientlysecure.keychain.Id;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
|
||||||
@ -61,7 +47,9 @@ import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
|
|||||||
import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener;
|
import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener;
|
||||||
import org.sufficientlysecure.keychain.util.Choice;
|
import org.sufficientlysecure.keychain.util.Choice;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
public class SectionView extends LinearLayout implements OnClickListener, EditorListener, Editor {
|
public class SectionView extends LinearLayout implements OnClickListener, EditorListener, Editor {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
@ -73,7 +61,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
|
|
||||||
private Choice mNewKeyAlgorithmChoice;
|
private Choice mNewKeyAlgorithmChoice;
|
||||||
private int mNewKeySize;
|
private int mNewKeySize;
|
||||||
private boolean oldItemDeleted = false;
|
private boolean mOldItemDeleted = false;
|
||||||
private ArrayList<String> mDeletedIDs = new ArrayList<String>();
|
private ArrayList<String> mDeletedIDs = new ArrayList<String>();
|
||||||
private ArrayList<PGPSecretKey> mDeletedKeys = new ArrayList<PGPSecretKey>();
|
private ArrayList<PGPSecretKey> mDeletedKeys = new ArrayList<PGPSecretKey>();
|
||||||
private boolean mCanEdit = true;
|
private boolean mCanEdit = true;
|
||||||
@ -150,13 +138,13 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void onDeleted(Editor editor, boolean wasNewItem) {
|
public void onDeleted(Editor editor, boolean wasNewItem) {
|
||||||
oldItemDeleted |= !wasNewItem;
|
mOldItemDeleted |= !wasNewItem;
|
||||||
if (oldItemDeleted) {
|
if (mOldItemDeleted) {
|
||||||
if (mType == Id.type.user_id)
|
if (mType == Id.type.user_id) {
|
||||||
mDeletedIDs.add(((UserIdEditor)editor).getOriginalID());
|
mDeletedIDs.add(((UserIdEditor) editor).getOriginalID());
|
||||||
else if (mType == Id.type.key)
|
} else if (mType == Id.type.key) {
|
||||||
mDeletedKeys.add(((KeyEditor)editor).getValue());
|
mDeletedKeys.add(((KeyEditor) editor).getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.updateEditorsVisible();
|
this.updateEditorsVisible();
|
||||||
if (mEditorListener != null) {
|
if (mEditorListener != null) {
|
||||||
@ -176,55 +164,55 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
mEditors.setVisibility(hasChildren ? View.VISIBLE : View.GONE);
|
mEditors.setVisibility(hasChildren ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsSaving()
|
public boolean needsSaving() {
|
||||||
{
|
|
||||||
//check each view for needs saving, take account of deleted items
|
//check each view for needs saving, take account of deleted items
|
||||||
boolean ret = oldItemDeleted;
|
boolean ret = mOldItemDeleted;
|
||||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
Editor editor = (Editor) mEditors.getChildAt(i);
|
Editor editor = (Editor) mEditors.getChildAt(i);
|
||||||
ret |= editor.needsSaving();
|
ret |= editor.needsSaving();
|
||||||
if (mType == Id.type.user_id)
|
if (mType == Id.type.user_id) {
|
||||||
ret |= ((UserIdEditor)editor).primarySwapped();
|
ret |= ((UserIdEditor) editor).primarySwapped();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean primaryChanged()
|
public boolean primaryChanged() {
|
||||||
{
|
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
Editor editor = (Editor) mEditors.getChildAt(i);
|
Editor editor = (Editor) mEditors.getChildAt(i);
|
||||||
if (mType == Id.type.user_id)
|
if (mType == Id.type.user_id) {
|
||||||
ret |= ((UserIdEditor)editor).primarySwapped();
|
ret |= ((UserIdEditor) editor).primarySwapped();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOriginalPrimaryID()
|
public String getOriginalPrimaryID() {
|
||||||
{ //NB: this will have to change when we change how Primary IDs are chosen, and so we need to be
|
//NB: this will have to change when we change how Primary IDs are chosen, and so we need to be
|
||||||
// careful about where Master key capabilities are stored... multiple primaries and
|
// careful about where Master key capabilities are stored... multiple primaries and
|
||||||
// revoked ones make this harder than the simple case we are continuing to assume here
|
// revoked ones make this harder than the simple case we are continuing to assume here
|
||||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
Editor editor = (Editor) mEditors.getChildAt(i);
|
Editor editor = (Editor) mEditors.getChildAt(i);
|
||||||
if (mType == Id.type.user_id) {
|
if (mType == Id.type.user_id) {
|
||||||
if(((UserIdEditor)editor).getIsOriginallyMainUserID()) {
|
if (((UserIdEditor) editor).getIsOriginallyMainUserID()) {
|
||||||
return ((UserIdEditor)editor).getOriginalID();
|
return ((UserIdEditor) editor).getOriginalID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getOriginalIDs()
|
public ArrayList<String> getOriginalIDs() {
|
||||||
{
|
|
||||||
ArrayList<String> orig = new ArrayList<String>();
|
ArrayList<String> orig = new ArrayList<String>();
|
||||||
if (mType == Id.type.user_id) {
|
if (mType == Id.type.user_id) {
|
||||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i);
|
UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i);
|
||||||
if (editor.isMainUserId())
|
if (editor.isMainUserId()) {
|
||||||
orig.add(0, editor.getOriginalID());
|
orig.add(0, editor.getOriginalID());
|
||||||
else
|
} else {
|
||||||
orig.add(editor.getOriginalID());
|
orig.add(editor.getOriginalID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return orig;
|
return orig;
|
||||||
} else {
|
} else {
|
||||||
@ -232,18 +220,15 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getDeletedIDs()
|
public ArrayList<String> getDeletedIDs() {
|
||||||
{
|
|
||||||
return mDeletedIDs;
|
return mDeletedIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<PGPSecretKey> getDeletedKeys()
|
public ArrayList<PGPSecretKey> getDeletedKeys() {
|
||||||
{
|
|
||||||
return mDeletedKeys;
|
return mDeletedKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Boolean> getNeedsSavingArray()
|
public List<Boolean> getNeedsSavingArray() {
|
||||||
{
|
|
||||||
ArrayList<Boolean> mList = new ArrayList<Boolean>();
|
ArrayList<Boolean> mList = new ArrayList<Boolean>();
|
||||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
Editor editor = (Editor) mEditors.getChildAt(i);
|
Editor editor = (Editor) mEditors.getChildAt(i);
|
||||||
@ -252,21 +237,20 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
return mList;
|
return mList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Boolean> getNewIDFlags()
|
public List<Boolean> getNewIDFlags() {
|
||||||
{
|
|
||||||
ArrayList<Boolean> mList = new ArrayList<Boolean>();
|
ArrayList<Boolean> mList = new ArrayList<Boolean>();
|
||||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i);
|
UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i);
|
||||||
if (editor.isMainUserId())
|
if (editor.isMainUserId()) {
|
||||||
mList.add(0, editor.getIsNewID());
|
mList.add(0, editor.getIsNewID());
|
||||||
else
|
} else {
|
||||||
mList.add(editor.getIsNewID());
|
mList.add(editor.getIsNewID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return mList;
|
return mList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Boolean> getNewKeysArray()
|
public List<Boolean> getNewKeysArray() {
|
||||||
{
|
|
||||||
ArrayList<Boolean> mList = new ArrayList<Boolean>();
|
ArrayList<Boolean> mList = new ArrayList<Boolean>();
|
||||||
if (mType == Id.type.key) {
|
if (mType == Id.type.key) {
|
||||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
@ -432,8 +416,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
mEditors, false);
|
mEditors, false);
|
||||||
view.setEditorListener(SectionView.this);
|
view.setEditorListener(SectionView.this);
|
||||||
int usage = 0;
|
int usage = 0;
|
||||||
if (mEditors.getChildCount() == 0)
|
if (mEditors.getChildCount() == 0) {
|
||||||
usage = PGPKeyFlags.CAN_CERTIFY;
|
usage = PGPKeyFlags.CAN_CERTIFY;
|
||||||
|
}
|
||||||
view.setValue(newKey, newKey.isMasterKey(), usage, true);
|
view.setValue(newKey, newKey.isMasterKey(), usage, true);
|
||||||
mEditors.addView(view);
|
mEditors.addView(view);
|
||||||
SectionView.this.updateEditorsVisible();
|
SectionView.this.updateEditorsVisible();
|
||||||
|
@ -16,11 +16,6 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui.widget;
|
package org.sufficientlysecure.keychain.ui.widget;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
@ -31,8 +26,12 @@ import android.view.View.OnClickListener;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
import org.sufficientlysecure.keychain.helper.ContactHelper;
|
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.helper.ContactHelper;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
public class UserIdEditor extends LinearLayout implements Editor, OnClickListener {
|
public class UserIdEditor extends LinearLayout implements Editor, OnClickListener {
|
||||||
private EditorListener mEditorListener = null;
|
private EditorListener mEditorListener = null;
|
||||||
@ -85,8 +84,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s)
|
public void afterTextChanged(Editable s) {
|
||||||
{
|
|
||||||
if (mEditorListener != null) {
|
if (mEditorListener != null) {
|
||||||
mEditorListener.onEdited();
|
mEditorListener.onEdited();
|
||||||
}
|
}
|
||||||
@ -240,25 +238,22 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
|
|||||||
@Override
|
@Override
|
||||||
public boolean needsSaving() {
|
public boolean needsSaving() {
|
||||||
boolean retval = false; //(mOriginallyMainUserID != isMainUserId());
|
boolean retval = false; //(mOriginallyMainUserID != isMainUserId());
|
||||||
retval |= !(mOriginalName.equals( ("" + mName.getText()).trim() ) );
|
retval |= !(mOriginalName.equals(("" + mName.getText()).trim()));
|
||||||
retval |= !(mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) );
|
retval |= !(mOriginalEmail.equals(("" + mEmail.getText()).trim()));
|
||||||
retval |= !(mOriginalComment.equals( ("" + mComment.getText()).trim() ) );
|
retval |= !(mOriginalComment.equals(("" + mComment.getText()).trim()));
|
||||||
retval |= mIsNewId;
|
retval |= mIsNewId;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsOriginallyMainUserID()
|
public boolean getIsOriginallyMainUserID() {
|
||||||
{
|
|
||||||
return mOriginallyMainUserID;
|
return mOriginallyMainUserID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean primarySwapped()
|
public boolean primarySwapped() {
|
||||||
{
|
|
||||||
return (mOriginallyMainUserID != isMainUserId());
|
return (mOriginallyMainUserID != isMainUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOriginalID()
|
public String getOriginalID() {
|
||||||
{
|
|
||||||
return mOriginalID;
|
return mOriginalID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ import org.apache.http.message.BasicNameValuePair;
|
|||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -43,8 +42,6 @@ import java.util.*;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry.getAlgorithmFromId;
|
|
||||||
|
|
||||||
public class HkpKeyServer extends KeyServer {
|
public class HkpKeyServer extends KeyServer {
|
||||||
private static class HttpError extends Exception {
|
private static class HttpError extends Exception {
|
||||||
private static final long serialVersionUID = 1718783705229428893L;
|
private static final long serialVersionUID = 1718783705229428893L;
|
||||||
@ -72,20 +69,22 @@ public class HkpKeyServer extends KeyServer {
|
|||||||
/**
|
/**
|
||||||
* pub:%keyid%:%algo%:%keylen%:%creationdate%:%expirationdate%:%flags%
|
* pub:%keyid%:%algo%:%keylen%:%creationdate%:%expirationdate%:%flags%
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>%<b>keyid</b>% = this is either the fingerprint or the key ID of the key. Either the 16-digit or 8-digit
|
* <li>%<b>keyid</b>% = this is either the fingerprint or the key ID of the key.
|
||||||
* key IDs are acceptable, but obviously the fingerprint is best.</li>
|
* Either the 16-digit or 8-digit key IDs are acceptable, but obviously the fingerprint is best.
|
||||||
|
* </li>
|
||||||
* <li>%<b>algo</b>% = the algorithm number, (i.e. 1==RSA, 17==DSA, etc).
|
* <li>%<b>algo</b>% = the algorithm number, (i.e. 1==RSA, 17==DSA, etc).
|
||||||
* See <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a></li>
|
* See <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a></li>
|
||||||
* <li>%<b>keylen</b>% = the key length (i.e. 1024, 2048, 4096, etc.)</li>
|
* <li>%<b>keylen</b>% = the key length (i.e. 1024, 2048, 4096, etc.)</li>
|
||||||
* <li>%<b>creationdate</b>% = creation date of the key in standard
|
* <li>%<b>creationdate</b>% = creation date of the key in standard
|
||||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of seconds since
|
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of
|
||||||
* 1/1/1970 UTC time)</li>
|
* seconds since 1/1/1970 UTC time)</li>
|
||||||
* <li>%<b>expirationdate</b>% = expiration date of the key in standard
|
* <li>%<b>expirationdate</b>% = expiration date of the key in standard
|
||||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of seconds since
|
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of
|
||||||
* 1/1/1970 UTC time)</li>
|
* seconds since 1/1/1970 UTC time)</li>
|
||||||
* <li>%<b>flags</b>% = letter codes to indicate details of the key, if any. Flags may be in any order. The
|
* <li>%<b>flags</b>% = letter codes to indicate details of the key, if any. Flags may be in any
|
||||||
* meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so
|
* order. The meaning of "disabled" is implementation-specific. Note that individual flags may
|
||||||
* the absence of a given flag does not necessarily mean the absence of the detail.
|
* be unimplemented, so the absence of a given flag does not necessarily mean the absence of the
|
||||||
|
* detail.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>r == revoked</li>
|
* <li>r == revoked</li>
|
||||||
* <li>d == disabled</li>
|
* <li>d == disabled</li>
|
||||||
@ -94,7 +93,8 @@ public class HkpKeyServer extends KeyServer {
|
|||||||
* </li>
|
* </li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @see <a href="http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00#section-5.2">5.2. Machine Readable Indexes</a>
|
* @see <a href="http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00#section-5.2">
|
||||||
|
* 5.2. Machine Readable Indexes</a>
|
||||||
* in Internet-Draft OpenPGP HTTP Keyserver Protocol Document
|
* in Internet-Draft OpenPGP HTTP Keyserver Protocol Document
|
||||||
*/
|
*/
|
||||||
public static final Pattern PUB_KEY_LINE = Pattern
|
public static final Pattern PUB_KEY_LINE = Pattern
|
||||||
@ -105,17 +105,19 @@ public class HkpKeyServer extends KeyServer {
|
|||||||
/**
|
/**
|
||||||
* uid:%escaped uid string%:%creationdate%:%expirationdate%:%flags%
|
* uid:%escaped uid string%:%creationdate%:%expirationdate%:%flags%
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>%<b>escaped uid string</b>% = the user ID string, with HTTP %-escaping for anything that isn't 7-bit
|
* <li>%<b>escaped uid string</b>% = the user ID string, with HTTP %-escaping for anything that
|
||||||
* safe as well as for the ":" character. Any other characters may be escaped, as desired.</li>
|
* isn't 7-bit safe as well as for the ":" character. Any other characters may be escaped, as
|
||||||
|
* desired.</li>
|
||||||
* <li>%<b>creationdate</b>% = creation date of the key in standard
|
* <li>%<b>creationdate</b>% = creation date of the key in standard
|
||||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of seconds since
|
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of
|
||||||
* 1/1/1970 UTC time)</li>
|
* seconds since 1/1/1970 UTC time)</li>
|
||||||
* <li>%<b>expirationdate</b>% = expiration date of the key in standard
|
* <li>%<b>expirationdate</b>% = expiration date of the key in standard
|
||||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of seconds since
|
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of
|
||||||
* 1/1/1970 UTC time)</li>
|
* seconds since 1/1/1970 UTC time)</li>
|
||||||
* <li>%<b>flags</b>% = letter codes to indicate details of the key, if any. Flags may be in any order. The
|
* <li>%<b>flags</b>% = letter codes to indicate details of the key, if any. Flags may be in any
|
||||||
* meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so
|
* order. The meaning of "disabled" is implementation-specific. Note that individual flags may
|
||||||
* the absence of a given flag does not necessarily mean the absence of the detail.
|
* be unimplemented, so the absence of a given flag does not necessarily mean the absence of
|
||||||
|
* the detail.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>r == revoked</li>
|
* <li>r == revoked</li>
|
||||||
* <li>d == disabled</li>
|
* <li>d == disabled</li>
|
||||||
@ -244,11 +246,10 @@ public class HkpKeyServer extends KeyServer {
|
|||||||
entry.setBitStrength(Integer.parseInt(matcher.group(3)));
|
entry.setBitStrength(Integer.parseInt(matcher.group(3)));
|
||||||
|
|
||||||
final int algorithmId = Integer.decode(matcher.group(2));
|
final int algorithmId = Integer.decode(matcher.group(2));
|
||||||
entry.setAlgorithm(getAlgorithmFromId(algorithmId));
|
entry.setAlgorithm(ImportKeysListEntry.getAlgorithmFromId(algorithmId));
|
||||||
|
|
||||||
// group 1 contains the full fingerprint (v4) or the long key id if available
|
// group 1 contains the full fingerprint (v4) or the long key id if available
|
||||||
// see https://bitbucket.org/skskeyserver/sks-keyserver/pull-request/12/fixes-for-machine-readable-indexes/diff
|
// see http://bit.ly/1d4bxbk and http://bit.ly/1gD1wwr
|
||||||
// and https://github.com/openpgp-keychain/openpgp-keychain/issues/259#issuecomment-38168176
|
|
||||||
String fingerprintOrKeyId = matcher.group(1);
|
String fingerprintOrKeyId = matcher.group(1);
|
||||||
if (fingerprintOrKeyId.length() > 16) {
|
if (fingerprintOrKeyId.length() > 16) {
|
||||||
entry.setFingerPrintHex(fingerprintOrKeyId.toLowerCase(Locale.US));
|
entry.setFingerPrintHex(fingerprintOrKeyId.toLowerCase(Locale.US));
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (C) 2010-2014 Thialfihar <thi@thialfihar.org>
|
||||||
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
|
import com.google.zxing.integration.android.IntentIntegrator;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import com.google.zxing.integration.android.IntentIntegrator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IntentIntegrator for the V4 Android compatibility package.
|
* IntentIntegrator for the V4 Android compatibility package.
|
||||||
|
@ -24,7 +24,7 @@ public class IterableIterator<T> implements Iterable<T> {
|
|||||||
|
|
||||||
public IterableIterator(Iterator<T> iter, boolean failsafe) {
|
public IterableIterator(Iterator<T> iter, boolean failsafe) {
|
||||||
mIter = iter;
|
mIter = iter;
|
||||||
if(failsafe && mIter == null) {
|
if (failsafe && mIter == null) {
|
||||||
// is there a better way?
|
// is there a better way?
|
||||||
mIter = new ArrayList<T>().iterator();
|
mIter = new ArrayList<T>().iterator();
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* This program is distributed in the hope that it will be useful,
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* See the License for the specific language governing permissions and
|
* GNU General Public License for more details.
|
||||||
* limitations under the License.
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
public interface KeychainServiceListener {
|
public interface KeychainServiceListener {
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (C) 2010-2014 Thialfihar <thi@thialfihar.org>
|
||||||
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
|
@ -36,7 +36,7 @@ public class ProgressScaler implements ProgressDialogUpdater {
|
|||||||
* Set progressDialogUpdater of ProgressDialog by sending message to handler on UI thread
|
* Set progressDialogUpdater of ProgressDialog by sending message to handler on UI thread
|
||||||
*/
|
*/
|
||||||
public void setProgress(String message, int progress, int max) {
|
public void setProgress(String message, int progress, int max) {
|
||||||
mWrapped.setProgress(message, mFrom+ progress*(mTo-mFrom)/max, mMax);
|
mWrapped.setProgress(message, mFrom + progress * (mTo - mFrom) / max, mMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(int resourceId, int progress, int max) {
|
public void setProgress(int resourceId, int progress, int max) {
|
||||||
|
@ -18,14 +18,16 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.EncodeHintType;
|
import com.google.zxing.EncodeHintType;
|
||||||
import com.google.zxing.WriterException;
|
import com.google.zxing.WriterException;
|
||||||
import com.google.zxing.common.BitMatrix;
|
import com.google.zxing.common.BitMatrix;
|
||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Color;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
@ -9,9 +9,9 @@ page at http://checkstyle.sourceforge.net/config.html -->
|
|||||||
|
|
||||||
<module name="OpenPgpChecker">
|
<module name="OpenPgpChecker">
|
||||||
|
|
||||||
<!--<module name="SuppressionFilter">
|
<module name="SuppressionFilter">
|
||||||
<property name="file" value="tools/suppressions.xml"/>
|
<property name="file" value="tools/suppressions.xml"/>
|
||||||
</module>-->
|
</module>
|
||||||
|
|
||||||
<module name="RegexpSingleline">
|
<module name="RegexpSingleline">
|
||||||
<!-- Requires a copyright notice in each file.
|
<!-- Requires a copyright notice in each file.
|
||||||
|
12
tools/suppressions.xml
Normal file
12
tools/suppressions.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<!DOCTYPE suppressions PUBLIC
|
||||||
|
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
|
||||||
|
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
|
||||||
|
|
||||||
|
<suppressions>
|
||||||
|
<suppress files="(Constants|Id|R|PgpConversionHelper)\.java" checks=".*NameCheck"/>
|
||||||
|
<suppress files="Apg.java" checks="LineLength"/>
|
||||||
|
<suppress files="FileDialog.java" checks="StaticVariableNameCheck"/>
|
||||||
|
<suppress files="PRNGFixes.java" checks=".*"/>
|
||||||
|
</suppressions>
|
Loading…
Reference in New Issue
Block a user