mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-17 07:30:14 -05:00
Removing remaining uses of Id, closing one of the oldest bugs #9
This commit is contained in:
parent
59220fbe04
commit
b04e6816f4
@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.sufficientlysecure.keychain.remote.ui.AppsListActivity;
|
||||
import org.sufficientlysecure.keychain.ui.DecryptActivity;
|
||||
@ -80,4 +81,24 @@ public final class Constants {
|
||||
REGISTERED_APPS_LIST
|
||||
};
|
||||
}
|
||||
|
||||
public static final class choice {
|
||||
public static final class algorithm {
|
||||
public static final int dsa = 0x21070001;
|
||||
public static final int elgamal = 0x21070002;
|
||||
public static final int rsa = 0x21070003;
|
||||
}
|
||||
|
||||
public static final class compression {
|
||||
public static final int none = 0x21070001;
|
||||
public static final int zlib = CompressionAlgorithmTags.ZLIB;
|
||||
public static final int bzip2 = CompressionAlgorithmTags.BZIP2;
|
||||
public static final int zip = CompressionAlgorithmTags.ZIP;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class key {
|
||||
public static final int none = 0;
|
||||
public static final int symmetric = -1;
|
||||
}
|
||||
}
|
||||
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 Thialfihar <thi@thialfihar.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
* <p/>
|
||||
* - refactor ids, some are not needed and can be done with xml
|
||||
*/
|
||||
public final class Id {
|
||||
|
||||
|
||||
public static final class type {
|
||||
public static final int public_key = 0x21070001;
|
||||
public static final int secret_key = 0x21070002;
|
||||
public static final int user_id = 0x21070003;
|
||||
public static final int key = 0x21070004;
|
||||
}
|
||||
|
||||
public static final class choice {
|
||||
public static final class algorithm {
|
||||
public static final int dsa = 0x21070001;
|
||||
public static final int elgamal = 0x21070002;
|
||||
public static final int rsa = 0x21070003;
|
||||
}
|
||||
|
||||
public static final class compression {
|
||||
public static final int none = 0x21070001;
|
||||
public static final int zlib = CompressionAlgorithmTags.ZLIB;
|
||||
public static final int bzip2 = CompressionAlgorithmTags.BZIP2;
|
||||
public static final int zip = CompressionAlgorithmTags.ZIP;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class return_value {
|
||||
public static final int ok = 0;
|
||||
public static final int error = -1;
|
||||
public static final int no_master_key = -2;
|
||||
public static final int updated = 1;
|
||||
public static final int bad = -3;
|
||||
}
|
||||
|
||||
public static final class key {
|
||||
public static final int none = 0;
|
||||
public static final int symmetric = -1;
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,6 @@ import android.os.Messenger;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.widget.Toast;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
|
@ -23,7 +23,6 @@ import android.content.SharedPreferences;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
@ -99,7 +98,7 @@ public class Preferences {
|
||||
|
||||
public int getDefaultMessageCompression() {
|
||||
return mSharedPreferences.getInt(Constants.Pref.DEFAULT_MESSAGE_COMPRESSION,
|
||||
Id.choice.compression.zlib);
|
||||
Constants.choice.compression.zlib);
|
||||
}
|
||||
|
||||
public void setDefaultMessageCompression(int value) {
|
||||
@ -110,7 +109,7 @@ public class Preferences {
|
||||
|
||||
public int getDefaultFileCompression() {
|
||||
return mSharedPreferences.getInt(Constants.Pref.DEFAULT_FILE_COMPRESSION,
|
||||
Id.choice.compression.none);
|
||||
Constants.choice.compression.none);
|
||||
}
|
||||
|
||||
public void setDefaultFileCompression(int value) {
|
||||
|
@ -22,14 +22,7 @@ import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
import org.spongycastle.openpgp.PGPEncryptedDataList;
|
||||
import org.spongycastle.openpgp.PGPObjectFactory;
|
||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.spongycastle.openpgp.PGPUtil;
|
||||
import org.sufficientlysecure.keychain.BuildConfig;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.ProgressDialogUpdater;
|
||||
|
@ -31,7 +31,6 @@ import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
@ -59,6 +58,11 @@ public class PgpImportExport {
|
||||
|
||||
private ProviderHelper mProviderHelper;
|
||||
|
||||
public static final int RETURN_OK = 0;
|
||||
public static final int RETURN_ERROR = -1;
|
||||
public static final int RETURN_BAD = -2;
|
||||
public static final int RETURN_UPDATED = 1;
|
||||
|
||||
public PgpImportExport(Context context, ProgressDialogUpdater progress) {
|
||||
super();
|
||||
this.mContext = context;
|
||||
@ -112,8 +116,12 @@ public class PgpImportExport {
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
if (aos != null) { aos.close(); }
|
||||
if (bos != null) { bos.close(); }
|
||||
if (aos != null) {
|
||||
aos.close();
|
||||
}
|
||||
if (bos != null) {
|
||||
bos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
@ -142,17 +150,17 @@ public class PgpImportExport {
|
||||
|
||||
int status = storeKeyRingInCache(keyring);
|
||||
|
||||
if (status == Id.return_value.error) {
|
||||
if (status == RETURN_ERROR) {
|
||||
throw new PgpGeneralException(
|
||||
mContext.getString(R.string.error_saving_keys));
|
||||
}
|
||||
|
||||
// update the counts to display to the user at the end
|
||||
if (status == Id.return_value.updated) {
|
||||
if (status == RETURN_UPDATED) {
|
||||
++oldKeys;
|
||||
} else if (status == Id.return_value.ok) {
|
||||
} else if (status == RETURN_OK) {
|
||||
++newKeys;
|
||||
} else if (status == Id.return_value.bad) {
|
||||
} else if (status == RETURN_BAD) {
|
||||
++badKeys;
|
||||
}
|
||||
} else {
|
||||
@ -248,12 +256,9 @@ public class PgpImportExport {
|
||||
return returnData;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: implement Id.return_value.updated as status when key already existed
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public int storeKeyRingInCache(PGPKeyRing keyring) {
|
||||
int status = Integer.MIN_VALUE; // out of bounds value (Id.return_value.*)
|
||||
int status = RETURN_ERROR;
|
||||
try {
|
||||
if (keyring instanceof PGPSecretKeyRing) {
|
||||
PGPSecretKeyRing secretKeyRing = (PGPSecretKeyRing) keyring;
|
||||
@ -265,7 +270,7 @@ public class PgpImportExport {
|
||||
if (testSecretKey.isPrivateKeyEmpty()) {
|
||||
// this is bad, something is very wrong...
|
||||
save = false;
|
||||
status = Id.return_value.bad;
|
||||
status = RETURN_BAD;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -286,17 +291,15 @@ public class PgpImportExport {
|
||||
mProviderHelper.saveKeyRing(newPubRing);
|
||||
}
|
||||
mProviderHelper.saveKeyRing(secretKeyRing);
|
||||
// TODO: remove status returns, use exceptions!
|
||||
status = Id.return_value.ok;
|
||||
status = RETURN_OK;
|
||||
}
|
||||
} else if (keyring instanceof PGPPublicKeyRing) {
|
||||
PGPPublicKeyRing publicKeyRing = (PGPPublicKeyRing) keyring;
|
||||
mProviderHelper.saveKeyRing(publicKeyRing);
|
||||
// TODO: remove status returns, use exceptions!
|
||||
status = Id.return_value.ok;
|
||||
status = RETURN_OK;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
status = Id.return_value.error;
|
||||
status = RETURN_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -48,7 +48,6 @@ import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
@ -144,14 +143,14 @@ public class PgpKeyOperation {
|
||||
KeyPairGenerator keyGen;
|
||||
|
||||
switch (algorithmChoice) {
|
||||
case Id.choice.algorithm.dsa: {
|
||||
case Constants.choice.algorithm.dsa: {
|
||||
keyGen = KeyPairGenerator.getInstance("DSA", Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
||||
keyGen.initialize(keySize, new SecureRandom());
|
||||
algorithm = PGPPublicKey.DSA;
|
||||
break;
|
||||
}
|
||||
|
||||
case Id.choice.algorithm.elgamal: {
|
||||
case Constants.choice.algorithm.elgamal: {
|
||||
if (isMasterKey) {
|
||||
throw new PgpGeneralMsgIdException(R.string.error_master_key_must_not_be_el_gamal);
|
||||
}
|
||||
@ -166,7 +165,7 @@ public class PgpKeyOperation {
|
||||
break;
|
||||
}
|
||||
|
||||
case Id.choice.algorithm.rsa: {
|
||||
case Constants.choice.algorithm.rsa: {
|
||||
keyGen = KeyPairGenerator.getInstance("RSA", Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
||||
keyGen.initialize(keySize, new SecureRandom());
|
||||
|
||||
|
@ -41,7 +41,6 @@ import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||
import org.spongycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder;
|
||||
import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.util.InputData;
|
||||
@ -123,11 +122,11 @@ public class PgpSignEncrypt {
|
||||
// optional
|
||||
private ProgressDialogUpdater mProgress = null;
|
||||
private boolean mEnableAsciiArmorOutput = false;
|
||||
private int mCompressionId = Id.choice.compression.none;
|
||||
private int mCompressionId = Constants.choice.compression.none;
|
||||
private long[] mEncryptionMasterKeyIds = null;
|
||||
private String mSymmetricPassphrase = null;
|
||||
private int mSymmetricEncryptionAlgorithm = 0;
|
||||
private long mSignatureMasterKeyId = Id.key.none;
|
||||
private long mSignatureMasterKeyId = Constants.key.none;
|
||||
private int mSignatureHashAlgorithm = 0;
|
||||
private boolean mSignatureForceV3 = false;
|
||||
private String mSignaturePassphrase = null;
|
||||
@ -252,10 +251,10 @@ public class PgpSignEncrypt {
|
||||
throws IOException, PGPException, NoSuchProviderException,
|
||||
NoSuchAlgorithmException, SignatureException, KeyExtractionException, NoSigningKeyException, NoPassphraseException {
|
||||
|
||||
boolean enableSignature = mSignatureMasterKeyId != Id.key.none;
|
||||
boolean enableSignature = mSignatureMasterKeyId != Constants.key.none;
|
||||
boolean enableEncryption = ((mEncryptionMasterKeyIds != null && mEncryptionMasterKeyIds.length > 0)
|
||||
|| mSymmetricPassphrase != null);
|
||||
boolean enableCompression = (mCompressionId != Id.choice.compression.none);
|
||||
boolean enableCompression = (mCompressionId != Constants.choice.compression.none);
|
||||
|
||||
Log.d(Constants.TAG, "enableSignature:" + enableSignature
|
||||
+ "\nenableEncryption:" + enableEncryption
|
||||
|
@ -19,11 +19,11 @@ package org.sufficientlysecure.keychain.remote;
|
||||
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
public class AccountSettings {
|
||||
private String mAccountName;
|
||||
private long mKeyId = Id.key.none;
|
||||
private long mKeyId = Constants.key.none;
|
||||
private int mEncryptionAlgorithm;
|
||||
private int mHashAlgorithm;
|
||||
private int mCompression;
|
||||
@ -39,7 +39,7 @@ public class AccountSettings {
|
||||
// defaults:
|
||||
this.mEncryptionAlgorithm = PGPEncryptedData.AES_256;
|
||||
this.mHashAlgorithm = HashAlgorithmTags.SHA512;
|
||||
this.mCompression = Id.choice.compression.zlib;
|
||||
this.mCompression = Constants.choice.compression.zlib;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
|
@ -30,7 +30,6 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.spongycastle.util.Arrays;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||
@ -269,7 +268,7 @@ public class OpenPgpService extends RemoteService {
|
||||
.signaturePassphrase(passphrase);
|
||||
} else {
|
||||
// encrypt only
|
||||
builder.signatureMasterKeyId(Id.key.none);
|
||||
builder.signatureMasterKeyId(Constants.key.none);
|
||||
}
|
||||
// execute PGP operation!
|
||||
builder.build().execute();
|
||||
|
@ -27,7 +27,6 @@ import android.view.View;
|
||||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.sufficientlysecure.htmltextview.HtmlTextView;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
@ -142,7 +141,7 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
||||
// Save
|
||||
|
||||
// user needs to select a key!
|
||||
if (mAccSettingsFragment.getAccSettings().getKeyId() == Id.key.none) {
|
||||
if (mAccSettingsFragment.getAccSettings().getKeyId() == Constants.key.none) {
|
||||
mAccSettingsFragment.setErrorOnSelectKeyFragment(
|
||||
getString(R.string.api_register_error_select_key));
|
||||
} else {
|
||||
|
@ -36,7 +36,6 @@ import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.spongycastle.openpgp.PGPUtil;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.FileHelper;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
@ -588,21 +587,21 @@ public class KeychainIntentService extends IntentService
|
||||
keysTotal);
|
||||
PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 100, 100));
|
||||
|
||||
PGPSecretKey masterKey = keyOperations.createKey(Id.choice.algorithm.rsa,
|
||||
PGPSecretKey masterKey = keyOperations.createKey(Constants.choice.algorithm.rsa,
|
||||
4096, passphrase, true);
|
||||
newKeys.add(masterKey);
|
||||
keyUsageList.add(KeyFlags.CERTIFY_OTHER);
|
||||
keysCreated++;
|
||||
setProgress(keysCreated, keysTotal);
|
||||
|
||||
PGPSecretKey subKey = keyOperations.createKey(Id.choice.algorithm.rsa,
|
||||
PGPSecretKey subKey = keyOperations.createKey(Constants.choice.algorithm.rsa,
|
||||
4096, passphrase, false);
|
||||
newKeys.add(subKey);
|
||||
keyUsageList.add(KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE);
|
||||
keysCreated++;
|
||||
setProgress(keysCreated, keysTotal);
|
||||
|
||||
subKey = keyOperations.createKey(Id.choice.algorithm.rsa,
|
||||
subKey = keyOperations.createKey(Constants.choice.algorithm.rsa,
|
||||
4096, passphrase, false);
|
||||
newKeys.add(subKey);
|
||||
keyUsageList.add(KeyFlags.SIGN_DATA);
|
||||
@ -846,7 +845,7 @@ public class KeychainIntentService extends IntentService
|
||||
// store the signed key in our local cache
|
||||
PgpImportExport pgpImportExport = new PgpImportExport(this, null);
|
||||
int retval = pgpImportExport.storeKeyRingInCache(publicRing);
|
||||
if (retval != Id.return_value.ok && retval != Id.return_value.updated) {
|
||||
if (retval != PgpImportExport.RETURN_OK && retval != PgpImportExport.RETURN_UPDATED) {
|
||||
throw new PgpGeneralException("Failed to store signed key in local cache");
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,7 @@ import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor;
|
||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@ -170,7 +168,7 @@ public class PassphraseCacheService extends Service {
|
||||
|
||||
// try to get master key id which is used as an identifier for cached passphrases
|
||||
long masterKeyId = keyId;
|
||||
if (masterKeyId != Id.key.symmetric) {
|
||||
if (masterKeyId != Constants.key.symmetric) {
|
||||
try {
|
||||
masterKeyId = new ProviderHelper(this).getMasterKeyId(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(Long.toString(keyId)));
|
||||
|
@ -33,9 +33,7 @@ import android.widget.EditText;
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
import com.devspark.appmsg.AppMsg;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.FileHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult;
|
||||
@ -202,7 +200,7 @@ public class DecryptFileFragment extends DecryptFragment {
|
||||
showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded());
|
||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED ==
|
||||
decryptVerifyResult.getStatus()) {
|
||||
showPassphraseDialog(Id.key.symmetric);
|
||||
showPassphraseDialog(Constants.key.symmetric);
|
||||
} else {
|
||||
// display signature result in activity
|
||||
onResult(decryptVerifyResult);
|
||||
|
@ -31,9 +31,7 @@ import android.widget.EditText;
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
import com.devspark.appmsg.AppMsg;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult;
|
||||
@ -156,7 +154,7 @@ public class DecryptMessageFragment extends DecryptFragment {
|
||||
showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded());
|
||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED ==
|
||||
decryptVerifyResult.getStatus()) {
|
||||
showPassphraseDialog(Id.key.symmetric);
|
||||
showPassphraseDialog(Constants.key.symmetric);
|
||||
} else {
|
||||
byte[] decryptedMessage = returnData
|
||||
.getByteArray(KeychainIntentService.RESULT_DECRYPTED_BYTES);
|
||||
|
@ -44,11 +44,9 @@ import android.widget.Toast;
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
import com.devspark.appmsg.AppMsg;
|
||||
|
||||
import org.spongycastle.openpgp.PGPException;
|
||||
import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
||||
import org.sufficientlysecure.keychain.helper.ExportHelper;
|
||||
@ -73,7 +71,6 @@ import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
@ -391,13 +388,13 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
mChangePassphrase.setText(getString(R.string.btn_change_passphrase));
|
||||
}
|
||||
mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
||||
mUserIdsView.setType(Id.type.user_id);
|
||||
mUserIdsView.setType(SectionView.TYPE_USER_ID);
|
||||
mUserIdsView.setCanBeEdited(mMasterCanSign);
|
||||
mUserIdsView.setUserIds(mUserIds);
|
||||
mUserIdsView.setEditorListener(this);
|
||||
container.addView(mUserIdsView);
|
||||
mKeysView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
||||
mKeysView.setType(Id.type.key);
|
||||
mKeysView.setType(SectionView.TYPE_KEY);
|
||||
mKeysView.setCanBeEdited(mMasterCanSign);
|
||||
mKeysView.setKeys(mKeys, mKeysUsages, newKeys);
|
||||
mKeysView.setEditorListener(this);
|
||||
|
@ -26,7 +26,6 @@ import android.support.v4.view.ViewPager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
||||
import org.sufficientlysecure.keychain.helper.FileHelper;
|
||||
@ -74,7 +73,7 @@ public class EncryptActivity extends DrawerActivity implements
|
||||
|
||||
// model useb by message and file fragment
|
||||
private long mEncryptionKeyIds[] = null;
|
||||
private long mSigningKeyId = Id.key.none;
|
||||
private long mSigningKeyId = Constants.key.none;
|
||||
private String mPassphrase;
|
||||
private String mPassphraseAgain;
|
||||
|
||||
|
@ -33,7 +33,6 @@ import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
@ -60,7 +59,7 @@ public class EncryptAsymmetricFragment extends Fragment {
|
||||
private TextView mMainUserIdRest;
|
||||
|
||||
// model
|
||||
private long mSecretKeyId = Id.key.none;
|
||||
private long mSecretKeyId = Constants.key.none;
|
||||
private long mEncryptionKeyIds[] = null;
|
||||
|
||||
// Container Activity must implement this interface
|
||||
@ -116,7 +115,7 @@ public class EncryptAsymmetricFragment extends Fragment {
|
||||
if (checkBox.isChecked()) {
|
||||
selectSecretKey();
|
||||
} else {
|
||||
setSignatureKeyId(Id.key.none);
|
||||
setSignatureKeyId(Constants.key.none);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -196,7 +195,7 @@ public class EncryptAsymmetricFragment extends Fragment {
|
||||
mEncryptionKeyIds.length));
|
||||
}
|
||||
|
||||
if (mSecretKeyId == Id.key.none) {
|
||||
if (mSecretKeyId == Constants.key.none) {
|
||||
mSign.setChecked(false);
|
||||
mMainUserId.setText("");
|
||||
mMainUserIdRest.setText("");
|
||||
@ -263,7 +262,7 @@ public class EncryptAsymmetricFragment extends Fragment {
|
||||
Uri uriMasterKey = data.getData();
|
||||
setSignatureKeyId(Long.valueOf(uriMasterKey.getLastPathSegment()));
|
||||
} else {
|
||||
setSignatureKeyId(Id.key.none);
|
||||
setSignatureKeyId(Constants.key.none);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
import com.devspark.appmsg.AppMsg;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.FileHelper;
|
||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||
@ -112,13 +111,13 @@ public class EncryptFileFragment extends Fragment {
|
||||
|
||||
mFileCompression = (Spinner) view.findViewById(R.id.fileCompression);
|
||||
Choice[] choices = new Choice[]{
|
||||
new Choice(Id.choice.compression.none, getString(R.string.choice_none) + " ("
|
||||
new Choice(Constants.choice.compression.none, getString(R.string.choice_none) + " ("
|
||||
+ getString(R.string.compression_fast) + ")"),
|
||||
new Choice(Id.choice.compression.zip, "ZIP ("
|
||||
new Choice(Constants.choice.compression.zip, "ZIP ("
|
||||
+ getString(R.string.compression_fast) + ")"),
|
||||
new Choice(Id.choice.compression.zlib, "ZLIB ("
|
||||
new Choice(Constants.choice.compression.zlib, "ZLIB ("
|
||||
+ getString(R.string.compression_fast) + ")"),
|
||||
new Choice(Id.choice.compression.bzip2, "BZIP2 ("
|
||||
new Choice(Constants.choice.compression.bzip2, "BZIP2 ("
|
||||
+ getString(R.string.compression_very_slow) + ")"),
|
||||
};
|
||||
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getActivity(),
|
||||
|
@ -28,7 +28,6 @@ import android.view.ViewGroup;
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.FileHelper;
|
||||
|
||||
|
@ -55,7 +55,6 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.ExportHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
@ -238,7 +237,7 @@ public class KeyListFragment extends Fragment
|
||||
setListShown(false);
|
||||
|
||||
// Create an empty adapter we will use to display the loaded data.
|
||||
mAdapter = new KeyListAdapter(getActivity(), null, Id.type.public_key);
|
||||
mAdapter = new KeyListAdapter(getActivity(), null, 0);
|
||||
mStickyList.setAdapter(mAdapter);
|
||||
|
||||
// Prepare the loader. Either re-connect with an existing one,
|
||||
|
@ -31,7 +31,6 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||
import org.sufficientlysecure.keychain.ui.widget.IntegerListPreference;
|
||||
@ -89,8 +88,12 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
initializeEncryptionAlgorithm(
|
||||
(IntegerListPreference) findPreference(Constants.Pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
||||
|
||||
int[] valueIds = new int[]{Id.choice.compression.none, Id.choice.compression.zip,
|
||||
Id.choice.compression.zlib, Id.choice.compression.bzip2,};
|
||||
int[] valueIds = new int[]{
|
||||
Constants.choice.compression.none,
|
||||
Constants.choice.compression.zip,
|
||||
Constants.choice.compression.zlib,
|
||||
Constants.choice.compression.bzip2,
|
||||
};
|
||||
String[] entries = new String[]{
|
||||
getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")",
|
||||
"ZIP (" + getString(R.string.compression_fast) + ")",
|
||||
@ -226,13 +229,20 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
initializeEncryptionAlgorithm(
|
||||
(IntegerListPreference) findPreference(Constants.Pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
||||
|
||||
int[] valueIds = new int[]{Id.choice.compression.none, Id.choice.compression.zip,
|
||||
Id.choice.compression.zlib, Id.choice.compression.bzip2,};
|
||||
int[] valueIds = new int[]{
|
||||
Constants.choice.compression.none,
|
||||
Constants.choice.compression.zip,
|
||||
Constants.choice.compression.zlib,
|
||||
Constants.choice.compression.bzip2,
|
||||
};
|
||||
|
||||
String[] entries = new String[]{
|
||||
getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")",
|
||||
"ZIP (" + getString(R.string.compression_fast) + ")",
|
||||
"ZLIB (" + getString(R.string.compression_fast) + ")",
|
||||
"BZIP2 (" + getString(R.string.compression_very_slow) + ")",};
|
||||
"BZIP2 (" + getString(R.string.compression_very_slow) + ")",
|
||||
};
|
||||
|
||||
String[] values = new String[valueIds.length];
|
||||
for (int i = 0; i < values.length; ++i) {
|
||||
values[i] = "" + valueIds[i];
|
||||
|
@ -34,7 +34,8 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.util.Choice;
|
||||
|
||||
@ -91,14 +92,14 @@ public class CreateKeyDialogFragment extends DialogFragment {
|
||||
|
||||
mAlgorithmSpinner = (Spinner) view.findViewById(R.id.create_key_algorithm);
|
||||
ArrayList<Choice> choices = new ArrayList<Choice>();
|
||||
choices.add(new Choice(Id.choice.algorithm.dsa, getResources().getString(
|
||||
choices.add(new Choice(Constants.choice.algorithm.dsa, getResources().getString(
|
||||
R.string.dsa)));
|
||||
if (!wouldBeMasterKey) {
|
||||
choices.add(new Choice(Id.choice.algorithm.elgamal, getResources().getString(
|
||||
choices.add(new Choice(Constants.choice.algorithm.elgamal, getResources().getString(
|
||||
R.string.elgamal)));
|
||||
}
|
||||
|
||||
choices.add(new Choice(Id.choice.algorithm.rsa, getResources().getString(
|
||||
choices.add(new Choice(Constants.choice.algorithm.rsa, getResources().getString(
|
||||
R.string.rsa)));
|
||||
|
||||
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(context,
|
||||
@ -107,7 +108,7 @@ public class CreateKeyDialogFragment extends DialogFragment {
|
||||
mAlgorithmSpinner.setAdapter(adapter);
|
||||
// make RSA the default
|
||||
for (int i = 0; i < choices.size(); ++i) {
|
||||
if (choices.get(i).getId() == Id.choice.algorithm.rsa) {
|
||||
if (choices.get(i).getId() == Constants.choice.algorithm.rsa) {
|
||||
mAlgorithmSpinner.setSelection(i);
|
||||
break;
|
||||
}
|
||||
@ -224,12 +225,12 @@ public class CreateKeyDialogFragment extends DialogFragment {
|
||||
final int[] elGamalSupportedLengths = {1536, 2048, 3072, 4096, 8192};
|
||||
int properKeyLength = -1;
|
||||
switch (algorithmId) {
|
||||
case Id.choice.algorithm.rsa:
|
||||
case Constants.choice.algorithm.rsa:
|
||||
if (currentKeyLength > 1024 && currentKeyLength <= 8192) {
|
||||
properKeyLength = currentKeyLength + ((8 - (currentKeyLength % 8)) % 8);
|
||||
}
|
||||
break;
|
||||
case Id.choice.algorithm.elgamal:
|
||||
case Constants.choice.algorithm.elgamal:
|
||||
int[] elGammalKeyDiff = new int[elGamalSupportedLengths.length];
|
||||
for (int i = 0; i < elGamalSupportedLengths.length; i++) {
|
||||
elGammalKeyDiff[i] = Math.abs(elGamalSupportedLengths[i] - currentKeyLength);
|
||||
@ -244,7 +245,7 @@ public class CreateKeyDialogFragment extends DialogFragment {
|
||||
}
|
||||
properKeyLength = elGamalSupportedLengths[minimalIndex];
|
||||
break;
|
||||
case Id.choice.algorithm.dsa:
|
||||
case Constants.choice.algorithm.dsa:
|
||||
if (currentKeyLength >= 512 && currentKeyLength <= 1024) {
|
||||
properKeyLength = currentKeyLength + ((64 - (currentKeyLength % 64)) % 64);
|
||||
}
|
||||
@ -283,15 +284,15 @@ public class CreateKeyDialogFragment extends DialogFragment {
|
||||
final Object selectedItem = mKeySizeSpinner.getSelectedItem();
|
||||
keySizeAdapter.clear();
|
||||
switch (algorithmId) {
|
||||
case Id.choice.algorithm.rsa:
|
||||
case Constants.choice.algorithm.rsa:
|
||||
replaceArrayAdapterContent(keySizeAdapter, R.array.rsa_key_size_spinner_values);
|
||||
mCustomKeyInfoTextView.setText(getResources().getString(R.string.key_size_custom_info_rsa));
|
||||
break;
|
||||
case Id.choice.algorithm.elgamal:
|
||||
case Constants.choice.algorithm.elgamal:
|
||||
replaceArrayAdapterContent(keySizeAdapter, R.array.elgamal_key_size_spinner_values);
|
||||
mCustomKeyInfoTextView.setText(""); // ElGamal does not support custom key length
|
||||
break;
|
||||
case Id.choice.algorithm.dsa:
|
||||
case Constants.choice.algorithm.dsa:
|
||||
replaceArrayAdapterContent(keySizeAdapter, R.array.dsa_key_size_spinner_values);
|
||||
mCustomKeyInfoTextView.setText(getResources().getString(R.string.key_size_custom_info_dsa));
|
||||
break;
|
||||
|
@ -46,7 +46,6 @@ import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor;
|
||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
@ -99,7 +98,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
||||
public static PassphraseDialogFragment newInstance(Context context, Messenger messenger,
|
||||
long secretKeyId) throws PgpGeneralException {
|
||||
// check if secret key has a passphrase
|
||||
if (!(secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none)) {
|
||||
if (!(secretKeyId == Constants.key.symmetric || secretKeyId == Constants.key.none)) {
|
||||
if (!PassphraseCacheService.hasPassphrase(context, secretKeyId)) {
|
||||
throw new PgpGeneralException("No passphrase! No passphrase dialog needed!");
|
||||
}
|
||||
@ -135,7 +134,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
||||
|
||||
final PGPSecretKey secretKey;
|
||||
|
||||
if (secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none) {
|
||||
if (secretKeyId == Constants.key.symmetric || secretKeyId == Constants.key.none) {
|
||||
secretKey = null;
|
||||
alert.setMessage(R.string.passphrase_for_symmetric_encryption);
|
||||
} else {
|
||||
@ -225,7 +224,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
||||
}
|
||||
keyId = secretKey.getKeyID();
|
||||
} else {
|
||||
keyId = Id.key.symmetric;
|
||||
keyId = Constants.key.symmetric;
|
||||
}
|
||||
|
||||
// cache the new passphrase
|
||||
|
@ -38,7 +38,6 @@ import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
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;
|
||||
@ -72,6 +71,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
|
||||
private ProgressDialogFragment mGeneratingDialog;
|
||||
|
||||
public static final int TYPE_USER_ID = 1;
|
||||
public static final int TYPE_KEY = 2;
|
||||
|
||||
public void setEditorListener(EditorListener listener) {
|
||||
mEditorListener = listener;
|
||||
}
|
||||
@ -93,12 +95,12 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
public void setType(int type) {
|
||||
mType = type;
|
||||
switch (type) {
|
||||
case Id.type.user_id: {
|
||||
case TYPE_USER_ID: {
|
||||
mTitle.setText(R.string.section_user_ids);
|
||||
break;
|
||||
}
|
||||
|
||||
case Id.type.key: {
|
||||
case TYPE_KEY: {
|
||||
mTitle.setText(R.string.section_keys);
|
||||
break;
|
||||
}
|
||||
@ -142,9 +144,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
public void onDeleted(Editor editor, boolean wasNewItem) {
|
||||
mOldItemDeleted |= !wasNewItem;
|
||||
if (mOldItemDeleted) {
|
||||
if (mType == Id.type.user_id) {
|
||||
if (mType == TYPE_USER_ID) {
|
||||
mDeletedIDs.add(((UserIdEditor) editor).getOriginalID());
|
||||
} else if (mType == Id.type.key) {
|
||||
} else if (mType == TYPE_KEY) {
|
||||
mDeletedKeys.add(((KeyEditor) editor).getValue());
|
||||
}
|
||||
}
|
||||
@ -172,7 +174,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||
Editor editor = (Editor) mEditors.getChildAt(i);
|
||||
ret |= editor.needsSaving();
|
||||
if (mType == Id.type.user_id) {
|
||||
if (mType == TYPE_USER_ID) {
|
||||
ret |= ((UserIdEditor) editor).primarySwapped();
|
||||
}
|
||||
}
|
||||
@ -183,7 +185,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
boolean ret = false;
|
||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||
Editor editor = (Editor) mEditors.getChildAt(i);
|
||||
if (mType == Id.type.user_id) {
|
||||
if (mType == TYPE_USER_ID) {
|
||||
ret |= ((UserIdEditor) editor).primarySwapped();
|
||||
}
|
||||
}
|
||||
@ -196,7 +198,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
// revoked ones make this harder than the simple case we are continuing to assume here
|
||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||
Editor editor = (Editor) mEditors.getChildAt(i);
|
||||
if (mType == Id.type.user_id) {
|
||||
if (mType == TYPE_USER_ID) {
|
||||
if (((UserIdEditor) editor).getIsOriginallyMainUserID()) {
|
||||
return ((UserIdEditor) editor).getOriginalID();
|
||||
}
|
||||
@ -207,7 +209,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
|
||||
public ArrayList<String> getOriginalIDs() {
|
||||
ArrayList<String> orig = new ArrayList<String>();
|
||||
if (mType == Id.type.user_id) {
|
||||
if (mType == TYPE_USER_ID) {
|
||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||
UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i);
|
||||
if (editor.isMainUserId()) {
|
||||
@ -254,7 +256,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
|
||||
public List<Boolean> getNewKeysArray() {
|
||||
ArrayList<Boolean> mList = new ArrayList<Boolean>();
|
||||
if (mType == Id.type.key) {
|
||||
if (mType == TYPE_KEY) {
|
||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||
KeyEditor editor = (KeyEditor) mEditors.getChildAt(i);
|
||||
mList.add(editor.getIsNewKey());
|
||||
@ -269,7 +271,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
public void onClick(View v) {
|
||||
if (mCanBeEdited) {
|
||||
switch (mType) {
|
||||
case Id.type.user_id: {
|
||||
case TYPE_USER_ID: {
|
||||
UserIdEditor view = (UserIdEditor) mInflater.inflate(
|
||||
R.layout.edit_key_user_id_item, mEditors, false);
|
||||
view.setEditorListener(this);
|
||||
@ -281,7 +283,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
break;
|
||||
}
|
||||
|
||||
case Id.type.key: {
|
||||
case TYPE_KEY: {
|
||||
CreateKeyDialogFragment mCreateKeyDialogFragment =
|
||||
CreateKeyDialogFragment.newInstance(mEditors.getChildCount());
|
||||
mCreateKeyDialogFragment
|
||||
@ -307,7 +309,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
}
|
||||
|
||||
public void setUserIds(Vector<String> list) {
|
||||
if (mType != Id.type.user_id) {
|
||||
if (mType != TYPE_USER_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -325,7 +327,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
}
|
||||
|
||||
public void setKeys(Vector<PGPSecretKey> list, Vector<Integer> usages, boolean newKeys) {
|
||||
if (mType != Id.type.key) {
|
||||
if (mType != TYPE_KEY) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -56,13 +56,13 @@ public class AlgorithmNames {
|
||||
mHashNames.put(HashAlgorithmTags.SHA384, "SHA-384");
|
||||
mHashNames.put(HashAlgorithmTags.SHA512, "SHA-512");
|
||||
|
||||
mCompressionNames.put(Id.choice.compression.none, mActivity.getString(R.string.choice_none)
|
||||
mCompressionNames.put(Constants.choice.compression.none, mActivity.getString(R.string.choice_none)
|
||||
+ " (" + mActivity.getString(R.string.compression_fast) + ")");
|
||||
mCompressionNames.put(Id.choice.compression.zip,
|
||||
mCompressionNames.put(Constants.choice.compression.zip,
|
||||
"ZIP (" + mActivity.getString(R.string.compression_fast) + ")");
|
||||
mCompressionNames.put(Id.choice.compression.zlib,
|
||||
mCompressionNames.put(Constants.choice.compression.zlib,
|
||||
"ZLIB (" + mActivity.getString(R.string.compression_fast) + ")");
|
||||
mCompressionNames.put(Id.choice.compression.bzip2,
|
||||
mCompressionNames.put(Constants.choice.compression.bzip2,
|
||||
"BZIP2 (" + mActivity.getString(R.string.compression_very_slow) + ")");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user