From 1e78dd165a2d32d28e3a77c512b41102dedd5cc8 Mon Sep 17 00:00:00 2001 From: Dominik Date: Wed, 20 Jun 2012 20:06:17 +0300 Subject: [PATCH] backward compatible extras, restructuring --- .../android/apg/ApgApplication.java | 2 +- .../android/apg/deprecated/ApgService2.java | 2 +- .../AskForPassphrase.java | 11 +- .../android/apg/helper/PGPMain.java | 34 ++-- .../android/apg/helper/Preferences.java | 4 - .../android/apg/service/ApgService.java | 86 +++++------ .../CachedPassphrase.java} | 10 +- .../PassphraseCacheService.java | 2 +- .../android/apg/ui/BaseActivity.java | 146 +++++++++--------- .../android/apg/ui/DecryptActivity.java | 10 +- .../android/apg/ui/EditKeyActivity.java | 1 - .../apg/ui/KeyServerQueryActivity.java | 1 - .../android/apg/ui/MainActivity.java | 1 - .../android/apg/ui/PreferencesActivity.java | 3 +- .../apg/ui/PreferencesKeyServerActivity.java | 1 - .../android/apg/ui/PublicKeyListActivity.java | 1 - .../android/apg/ui/SecretKeyListActivity.java | 2 +- .../apg/ui/SelectPublicKeyListActivity.java | 1 - .../apg/ui/SelectSecretKeyListActivity.java | 1 - .../android/apg/ui/widget/KeyEditor.java | 1 - .../apg/integration/ApgIntentHelper.java | 8 - 21 files changed, 152 insertions(+), 176 deletions(-) rename org_apg/src/org/thialfihar/android/apg/{passphrase => deprecated}/AskForPassphrase.java (98%) rename org_apg/src/org/thialfihar/android/apg/{passphrase/CachedPassPhrase.java => service/CachedPassphrase.java} (85%) rename org_apg/src/org/thialfihar/android/apg/{passphrase => service}/PassphraseCacheService.java (98%) diff --git a/org_apg/src/org/thialfihar/android/apg/ApgApplication.java b/org_apg/src/org/thialfihar/android/apg/ApgApplication.java index 586685109..149a40b54 100644 --- a/org_apg/src/org/thialfihar/android/apg/ApgApplication.java +++ b/org_apg/src/org/thialfihar/android/apg/ApgApplication.java @@ -16,7 +16,7 @@ package org.thialfihar.android.apg; -import org.thialfihar.android.apg.passphrase.PassphraseCacheService; +import org.thialfihar.android.apg.service.PassphraseCacheService; import android.app.Application; diff --git a/org_apg/src/org/thialfihar/android/apg/deprecated/ApgService2.java b/org_apg/src/org/thialfihar/android/apg/deprecated/ApgService2.java index e8e0b0f23..73a587f07 100644 --- a/org_apg/src/org/thialfihar/android/apg/deprecated/ApgService2.java +++ b/org_apg/src/org/thialfihar/android/apg/deprecated/ApgService2.java @@ -34,10 +34,10 @@ import org.thialfihar.android.apg.R.string; import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.helper.Preferences; -import org.thialfihar.android.apg.passphrase.PassphraseCacheService; import org.thialfihar.android.apg.provider.KeyRings; import org.thialfihar.android.apg.provider.Keys; import org.thialfihar.android.apg.provider.UserIds; +import org.thialfihar.android.apg.service.PassphraseCacheService; import org.thialfihar.android.apg.util.InputData; import android.content.ContentResolver; diff --git a/org_apg/src/org/thialfihar/android/apg/passphrase/AskForPassphrase.java b/org_apg/src/org/thialfihar/android/apg/deprecated/AskForPassphrase.java similarity index 98% rename from org_apg/src/org/thialfihar/android/apg/passphrase/AskForPassphrase.java rename to org_apg/src/org/thialfihar/android/apg/deprecated/AskForPassphrase.java index b24c39a86..90cd39176 100644 --- a/org_apg/src/org/thialfihar/android/apg/passphrase/AskForPassphrase.java +++ b/org_apg/src/org/thialfihar/android/apg/deprecated/AskForPassphrase.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.thialfihar.android.apg.passphrase; +package org.thialfihar.android.apg.deprecated; import org.spongycastle.jce.provider.BouncyCastleProvider; import org.spongycastle.openpgp.PGPException; @@ -38,6 +38,13 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; +/** + * TODO: + * + * - Use new PassphraseDialogFragment! + * + * + */ public class AskForPassphrase { public static interface PassPhraseCallbackInterface { void passPhraseCallback(long keyId, String passPhrase); @@ -110,7 +117,7 @@ public class AskForPassphrase { } else { keyId = Id.key.symmetric; } - + // cache again PGPMain.setCachedPassPhrase(keyId, passPhrase); // return by callback diff --git a/org_apg/src/org/thialfihar/android/apg/helper/PGPMain.java b/org_apg/src/org/thialfihar/android/apg/helper/PGPMain.java index 7dde78342..4c87b2ca8 100644 --- a/org_apg/src/org/thialfihar/android/apg/helper/PGPMain.java +++ b/org_apg/src/org/thialfihar/android/apg/helper/PGPMain.java @@ -71,13 +71,13 @@ import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder; import org.spongycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder; import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyDataDecryptorFactoryBuilder; import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator; -import org.thialfihar.android.apg.passphrase.CachedPassPhrase; import org.thialfihar.android.apg.provider.DataProvider; import org.thialfihar.android.apg.provider.Database; import org.thialfihar.android.apg.provider.KeyRings; import org.thialfihar.android.apg.provider.Keys; import org.thialfihar.android.apg.provider.UserIds; import org.thialfihar.android.apg.service.ApgService; +import org.thialfihar.android.apg.service.CachedPassphrase; import org.thialfihar.android.apg.util.HkpKeyServer; import org.thialfihar.android.apg.util.InputData; import org.thialfihar.android.apg.util.PositionAwareInputStream; @@ -185,7 +185,7 @@ public class PGPMain { ".*?(-----BEGIN PGP PUBLIC KEY BLOCK-----.*?-----END PGP PUBLIC KEY BLOCK-----).*", Pattern.DOTALL); - private static HashMap mPassPhraseCache = new HashMap(); + private static HashMap mPassPhraseCache = new HashMap(); private static String mEditPassPhrase = null; private static Database mDatabase = null; @@ -225,7 +225,7 @@ public class PGPMain { } public static void setCachedPassPhrase(long keyId, String passPhrase) { - mPassPhraseCache.put(keyId, new CachedPassPhrase(new Date().getTime(), passPhrase)); + mPassPhraseCache.put(keyId, new CachedPassphrase(new Date().getTime(), passPhrase)); } public static String getCachedPassPhrase(long keyId) { @@ -241,7 +241,7 @@ public class PGPMain { } realId = masterKey.getKeyID(); } - CachedPassPhrase cpp = mPassPhraseCache.get(realId); + CachedPassphrase cpp = mPassPhraseCache.get(realId); if (cpp == null) { return null; } @@ -255,7 +255,7 @@ public class PGPMain { long realTtl = ttl * 1000; long now = new Date().getTime(); Vector oldKeys = new Vector(); - for (Map.Entry pair : mPassPhraseCache.entrySet()) { + for (Map.Entry pair : mPassPhraseCache.entrySet()) { long lived = now - pair.getValue().timestamp; if (lived >= realTtl) { oldKeys.add(pair.getKey()); @@ -1516,7 +1516,7 @@ public class PGPMain { if (dataChunk instanceof PGPOnePassSignatureList) { if (progress != null) progress.setProgress(R.string.progress_processingSignature, currentProgress, 100); - returnData.putBoolean(ApgService.EXTRA_SIGNATURE, true); + returnData.putBoolean(ApgService.RESULT_SIGNATURE, true); PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk; for (int i = 0; i < sigList.size(); ++i) { signature = sigList.get(i); @@ -1534,12 +1534,12 @@ public class PGPMain { if (sigKeyRing != null) { userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing)); } - returnData.putString(ApgService.EXTRA_SIGNATURE_USER_ID, userId); + returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId); break; } } - returnData.putLong(ApgService.EXTRA_SIGNATURE_KEY_ID, signatureKeyId); + returnData.putLong(ApgService.RESULT_SIGNATURE_KEY_ID, signatureKeyId); if (signature != null) { JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider = new JcaPGPContentVerifierBuilderProvider() @@ -1550,7 +1550,7 @@ public class PGPMain { // deprecated method: // signature.initVerify(signatureKey, new BouncyCastleProvider()); } else { - returnData.putBoolean(ApgService.EXTRA_SIGNATURE_UNKNOWN, true); + returnData.putBoolean(ApgService.RESULT_SIGNATURE_UNKNOWN, true); } dataChunk = plainFact.nextObject(); @@ -1587,7 +1587,7 @@ public class PGPMain { try { signature.update(buffer, 0, n); } catch (SignatureException e) { - returnData.putBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS, false); + returnData.putBoolean(ApgService.RESULT_SIGNATURE_SUCCESS, false); signature = null; } } @@ -1610,9 +1610,9 @@ public class PGPMain { PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject(); PGPSignature messageSignature = signatureList.get(signatureIndex); if (signature.verify(messageSignature)) { - returnData.putBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS, true); + returnData.putBoolean(ApgService.RESULT_SIGNATURE_SUCCESS, true); } else { - returnData.putBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS, false); + returnData.putBoolean(ApgService.RESULT_SIGNATURE_SUCCESS, false); } } } @@ -1667,7 +1667,7 @@ public class PGPMain { byte[] clearText = out.toByteArray(); outStream.write(clearText); - returnData.putBoolean(ApgService.EXTRA_SIGNATURE, true); + returnData.putBoolean(ApgService.RESULT_SIGNATURE, true); if (progress != null) progress.setProgress(R.string.progress_processingSignature, 60, 100); @@ -1709,15 +1709,15 @@ public class PGPMain { if (sigKeyRing != null) { userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing)); } - returnData.putString(ApgService.EXTRA_SIGNATURE_USER_ID, userId); + returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId); break; } } - returnData.putLong(ApgService.EXTRA_SIGNATURE_KEY_ID, signatureKeyId); + returnData.putLong(ApgService.RESULT_SIGNATURE_KEY_ID, signatureKeyId); if (signature == null) { - returnData.putBoolean(ApgService.EXTRA_SIGNATURE_UNKNOWN, true); + returnData.putBoolean(ApgService.RESULT_SIGNATURE_UNKNOWN, true); if (progress != null) progress.setProgress(R.string.progress_done, 100, 100); return returnData; @@ -1748,7 +1748,7 @@ public class PGPMain { } while (lookAhead != -1); } - returnData.putBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS, signature.verify()); + returnData.putBoolean(ApgService.RESULT_SIGNATURE_SUCCESS, signature.verify()); if (progress != null) progress.setProgress(R.string.progress_done, 100, 100); diff --git a/org_apg/src/org/thialfihar/android/apg/helper/Preferences.java b/org_apg/src/org/thialfihar/android/apg/helper/Preferences.java index f4e15e134..1d9124eac 100644 --- a/org_apg/src/org/thialfihar/android/apg/helper/Preferences.java +++ b/org_apg/src/org/thialfihar/android/apg/helper/Preferences.java @@ -21,10 +21,6 @@ import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.openpgp.PGPEncryptedData; import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Id; -import org.thialfihar.android.apg.Constants.defaults; -import org.thialfihar.android.apg.Constants.pref; -import org.thialfihar.android.apg.Id.choice; -import org.thialfihar.android.apg.Id.choice.compression; import android.content.Context; import android.content.SharedPreferences; diff --git a/org_apg/src/org/thialfihar/android/apg/service/ApgService.java b/org_apg/src/org/thialfihar/android/apg/service/ApgService.java index 152944fa8..f57d67c44 100644 --- a/org_apg/src/org/thialfihar/android/apg/service/ApgService.java +++ b/org_apg/src/org/thialfihar/android/apg/service/ApgService.java @@ -75,40 +75,40 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { // keys for data bundle // encrypt - public static final String SECRET_KEY_ID = "secret_key_id"; - public static final String USE_ASCII_AMOR = "use_ascii_amor"; - public static final String ENCRYPTION_KEYS_IDS = "encryption_keys_ids"; - public static final String SIGNATURE_KEY_ID = "signature_key_id"; - public static final String COMPRESSION_ID = "compression_id"; - public static final String GENERATE_SIGNATURE = "generate_signature"; - public static final String SIGN_ONLY = "sign_only"; - public static final String MESSAGE_BYTES = "message_bytes"; - public static final String INPUT_FILE = "input_file"; - public static final String OUTPUT_FILE = "output_file"; - public static final String PROVIDER_URI = "provider_uri"; + public static final String SECRET_KEY_ID = "secretKeyId"; + public static final String USE_ASCII_AMOR = "useAsciiAmor"; + public static final String ENCRYPTION_KEYS_IDS = "encryptionKeysIds"; + public static final String SIGNATURE_KEY_ID = "signatureKeyId"; + public static final String COMPRESSION_ID = "compressionId"; + public static final String GENERATE_SIGNATURE = "generateSignature"; + public static final String SIGN_ONLY = "signOnly"; + public static final String MESSAGE_BYTES = "messageBytes"; + public static final String INPUT_FILE = "inputFile"; + public static final String OUTPUT_FILE = "outputFile"; + public static final String PROVIDER_URI = "providerUri"; // decrypt - public static final String SIGNED_ONLY = "signed_only"; - public static final String RETURN_BYTES = "return_binary"; - public static final String CIPHERTEXT_BYTES = "ciphertext_bytes"; - public static final String ASSUME_SYMMETRIC = "assume_symmetric"; + public static final String SIGNED_ONLY = "signedOnly"; + public static final String RETURN_BYTES = "returnBinary"; + public static final String CIPHERTEXT_BYTES = "ciphertextBytes"; + public static final String ASSUME_SYMMETRIC = "assumeSymmetric"; // edit keys - public static final String NEW_PASSPHRASE = "new_passphrase"; - public static final String CURRENT_PASSPHRASE = "current_passphrase"; - public static final String USER_IDS = "user_ids"; + public static final String NEW_PASSPHRASE = "newPassphrase"; + public static final String CURRENT_PASSPHRASE = "currentPassphrase"; + public static final String USER_IDS = "userIds"; public static final String KEYS = "keys"; - public static final String KEYS_USAGES = "keys_usages"; - public static final String MASTER_KEY_ID = "master_key_id"; + public static final String KEYS_USAGES = "keysUsages"; + public static final String MASTER_KEY_ID = "masterKeyId"; // generate key public static final String ALGORITHM = "algorithm"; public static final String KEY_SIZE = "key_size"; public static final String SYMMETRIC_PASSPHRASE = "passphrase"; - public static final String MASTER_KEY = "master_key"; + public static final String MASTER_KEY = "masterKey"; // delete file securely - public static final String DELETE_FILE = "delete_file"; + public static final String DELETE_FILE = "deleteFile"; // possible EXTRA_ACTIONs public static final int ACTION_ENCRYPT_SIGN_BYTES = 10; @@ -127,24 +127,24 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { // possible data keys as result // keys - public static final String RESULT_NEW_KEY = "new_key"; - public static final String RESULT_NEW_KEY2 = "new_key2"; + public static final String RESULT_NEW_KEY = "newKey"; + public static final String RESULT_NEW_KEY2 = "newKey2"; // encrypt - public static final String RESULT_SIGNATURE_DATA = "signature_data"; - public static final String RESULT_SIGNATURE_TEXT = "signature_text"; - public static final String RESULT_ENCRYPTED_MESSAGE = "encrypted_message"; - public static final String RESULT_ENCRYPTED_DATA = "encrypted_data"; - public static final String RESULT_URI = "result_uri"; + public static final String RESULT_SIGNATURE_DATA = "signatureData"; + public static final String RESULT_SIGNATURE_TEXT = "signatureText"; + public static final String RESULT_ENCRYPTED_MESSAGE = "encryptedMessage"; + public static final String RESULT_ENCRYPTED_DATA = "encryptedData"; + public static final String RESULT_URI = "resultUri"; // decrypt - public static final String RESULT_DECRYPTED_MESSAGE = "decrypted_message"; - public static final String RESULT_DECRYPTED_DATA = "decrypted_data"; - public static final String EXTRA_SIGNATURE = "signature"; - public static final String EXTRA_SIGNATURE_KEY_ID = "signature_key_id"; - public static final String EXTRA_SIGNATURE_USER_ID = "signature_user_id"; - public static final String EXTRA_SIGNATURE_SUCCESS = "signature_success"; - public static final String EXTRA_SIGNATURE_UNKNOWN = "signature_unknown"; + public static final String RESULT_DECRYPTED_MESSAGE = "decryptedMessage"; + public static final String RESULT_DECRYPTED_DATA = "decryptedData"; + public static final String RESULT_SIGNATURE = "signature"; + public static final String RESULT_SIGNATURE_KEY_ID = "signatureKeyId"; + public static final String RESULT_SIGNATURE_USER_ID = "signatureUserId"; + public static final String RESULT_SIGNATURE_SUCCESS = "signatureSuccess"; + public static final String RESULT_SIGNATURE_UNKNOWN = "signatureUnknown"; Messenger mMessenger; @@ -197,8 +197,8 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { long masterKeyId = data.getLong(MASTER_KEY_ID); /* Operation */ - PGPMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId, - oldPassPhrase, newPassPhrase, this); + PGPMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId, oldPassPhrase, + newPassPhrase, this); PGPMain.setCachedPassPhrase(masterKeyId, newPassPhrase); /* Output */ @@ -416,7 +416,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { int compressionId = data.getInt(COMPRESSION_ID); boolean generateSignature = data.getBoolean(GENERATE_SIGNATURE); boolean signOnly = data.getBoolean(SIGN_ONLY); - + /* Operation */ // InputStream InputStream in = getContentResolver().openInputStream(providerUri); @@ -429,8 +429,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { while (true) { streamFilename = PGPMain.generateRandomString(32); if (streamFilename == null) { - throw new PGPMain.GeneralException( - "couldn't generate random file name"); + throw new PGPMain.GeneralException("couldn't generate random file name"); } openFileInput(streamFilename).close(); } @@ -585,7 +584,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { } outStream.close(); - + /* Output */ sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData); } catch (Exception e) { @@ -613,8 +612,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { while (true) { streamFilename = PGPMain.generateRandomString(32); if (streamFilename == null) { - throw new PGPMain.GeneralException( - "couldn't generate random file name"); + throw new PGPMain.GeneralException("couldn't generate random file name"); } openFileInput(streamFilename).close(); } diff --git a/org_apg/src/org/thialfihar/android/apg/passphrase/CachedPassPhrase.java b/org_apg/src/org/thialfihar/android/apg/service/CachedPassphrase.java similarity index 85% rename from org_apg/src/org/thialfihar/android/apg/passphrase/CachedPassPhrase.java rename to org_apg/src/org/thialfihar/android/apg/service/CachedPassphrase.java index 08696c6eb..0467bc2c5 100644 --- a/org_apg/src/org/thialfihar/android/apg/passphrase/CachedPassPhrase.java +++ b/org_apg/src/org/thialfihar/android/apg/service/CachedPassphrase.java @@ -12,13 +12,13 @@ * limitations under the License. */ -package org.thialfihar.android.apg.passphrase; +package org.thialfihar.android.apg.service; -public class CachedPassPhrase { +public class CachedPassphrase { public final long timestamp; public final String passPhrase; - public CachedPassPhrase(long timestamp, String passPhrase) { + public CachedPassphrase(long timestamp, String passPhrase) { super(); this.timestamp = timestamp; this.passPhrase = passPhrase; @@ -33,11 +33,11 @@ public class CachedPassPhrase { @Override public boolean equals(Object other) { - if (!(other instanceof CachedPassPhrase)) { + if (!(other instanceof CachedPassphrase)) { return false; } - CachedPassPhrase o = (CachedPassPhrase) other; + CachedPassphrase o = (CachedPassphrase) other; if (timestamp != o.timestamp) { return false; } diff --git a/org_apg/src/org/thialfihar/android/apg/passphrase/PassphraseCacheService.java b/org_apg/src/org/thialfihar/android/apg/service/PassphraseCacheService.java similarity index 98% rename from org_apg/src/org/thialfihar/android/apg/passphrase/PassphraseCacheService.java rename to org_apg/src/org/thialfihar/android/apg/service/PassphraseCacheService.java index c7758cb4f..4d004ebfd 100644 --- a/org_apg/src/org/thialfihar/android/apg/passphrase/PassphraseCacheService.java +++ b/org_apg/src/org/thialfihar/android/apg/service/PassphraseCacheService.java @@ -12,7 +12,7 @@ * limitations under the License. */ -package org.thialfihar.android.apg.passphrase; +package org.thialfihar.android.apg.service; import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.helper.Preferences; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/BaseActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/BaseActivity.java index 542f65d3c..f8df4b1f2 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/BaseActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/BaseActivity.java @@ -17,25 +17,20 @@ package org.thialfihar.android.apg.ui; import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.ProgressDialogUpdater; +import org.thialfihar.android.apg.deprecated.AskForPassphrase; import org.thialfihar.android.apg.deprecated.PausableThread; import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.helper.Preferences; -import org.thialfihar.android.apg.passphrase.AskForPassphrase; -import org.thialfihar.android.apg.passphrase.PassphraseCacheService; import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.view.MenuItem; -import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; @@ -45,9 +40,6 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.Message; -import android.support.v4.app.DialogFragment; -import android.support.v4.app.Fragment; -import android.widget.Toast; public class BaseActivity extends SherlockFragmentActivity implements Runnable, ProgressDialogUpdater, AskForPassphrase.PassPhraseCallbackInterface { @@ -89,14 +81,14 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable, } } -// startCacheService(this, mPreferences); + // startCacheService(this, mPreferences); } -// public static void startCacheService(Activity activity, Preferences preferences) { -// Intent intent = new Intent(activity, PassphraseCacheService.class); -// intent.putExtra(PassphraseCacheService.EXTRA_TTL, preferences.getPassPhraseCacheTtl()); -// activity.startService(intent); -// } + // public static void startCacheService(Activity activity, Preferences preferences) { + // Intent intent = new Intent(activity, PassphraseCacheService.class); + // intent.putExtra(PassphraseCacheService.EXTRA_TTL, preferences.getPassPhraseCacheTtl()); + // activity.startService(intent); + // } @Override public boolean onOptionsItemSelected(MenuItem item) { @@ -218,48 +210,48 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable, return alert.create(); } -// case Id.dialog.delete_file: { -// AlertDialog.Builder alert = new AlertDialog.Builder(this); -// -// alert.setIcon(android.R.drawable.ic_dialog_alert); -// alert.setTitle(R.string.warning); -// alert.setMessage(this.getString(R.string.fileDeleteConfirmation, getDeleteFile())); -// -// alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { -// public void onClick(DialogInterface dialog, int id) { -// removeDialog(Id.dialog.delete_file); -// final File file = new File(getDeleteFile()); -// showDialog(Id.dialog.deleting); -// mDeletingThread = new Thread(new Runnable() { -// public void run() { -// Bundle data = new Bundle(); -// data.putInt(Constants.extras.STATUS, Id.message.delete_done); -// try { -// Apg.deleteFileSecurely(BaseActivity.this, file, BaseActivity.this); -// } catch (FileNotFoundException e) { -// data.putString(Apg.EXTRA_ERROR, BaseActivity.this.getString( -// R.string.error_fileNotFound, file)); -// } catch (IOException e) { -// data.putString(Apg.EXTRA_ERROR, BaseActivity.this.getString( -// R.string.error_fileDeleteFailed, file)); -// } -// Message msg = new Message(); -// msg.setData(data); -// sendMessage(msg); -// } -// }); -// mDeletingThread.start(); -// } -// }); -// alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { -// public void onClick(DialogInterface dialog, int id) { -// removeDialog(Id.dialog.delete_file); -// } -// }); -// alert.setCancelable(true); -// -// return alert.create(); -// } + // case Id.dialog.delete_file: { + // AlertDialog.Builder alert = new AlertDialog.Builder(this); + // + // alert.setIcon(android.R.drawable.ic_dialog_alert); + // alert.setTitle(R.string.warning); + // alert.setMessage(this.getString(R.string.fileDeleteConfirmation, getDeleteFile())); + // + // alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + // public void onClick(DialogInterface dialog, int id) { + // removeDialog(Id.dialog.delete_file); + // final File file = new File(getDeleteFile()); + // showDialog(Id.dialog.deleting); + // mDeletingThread = new Thread(new Runnable() { + // public void run() { + // Bundle data = new Bundle(); + // data.putInt(Constants.extras.STATUS, Id.message.delete_done); + // try { + // Apg.deleteFileSecurely(BaseActivity.this, file, BaseActivity.this); + // } catch (FileNotFoundException e) { + // data.putString(Apg.EXTRA_ERROR, BaseActivity.this.getString( + // R.string.error_fileNotFound, file)); + // } catch (IOException e) { + // data.putString(Apg.EXTRA_ERROR, BaseActivity.this.getString( + // R.string.error_fileDeleteFailed, file)); + // } + // Message msg = new Message(); + // msg.setData(data); + // sendMessage(msg); + // } + // }); + // mDeletingThread.start(); + // } + // }); + // alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { + // public void onClick(DialogInterface dialog, int id) { + // removeDialog(Id.dialog.delete_file); + // } + // }); + // alert.setCancelable(true); + // + // return alert.create(); + // } default: { break; @@ -335,11 +327,11 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable, break; } -// case Id.message.delete_done: { -// mProgressDialog = null; -// deleteDoneCallback(msg); -// break; -// } + // case Id.message.delete_done: { + // mProgressDialog = null; + // deleteDoneCallback(msg); + // break; + // } case Id.message.import_done: // intentionally no break case Id.message.export_done: // intentionally no break @@ -360,21 +352,21 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable, } -// public void deleteDoneCallback(Message msg) { -// removeDialog(Id.dialog.deleting); -// mDeletingThread = null; -// -// Bundle data = msg.getData(); -// String error = data.getString(Apg.EXTRA_ERROR); -// String message; -// if (error != null) { -// message = getString(R.string.errorMessage, error); -// } else { -// message = getString(R.string.fileDeleteSuccessful); -// } -// -// Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); -// } + // public void deleteDoneCallback(Message msg) { + // removeDialog(Id.dialog.deleting); + // mDeletingThread = null; + // + // Bundle data = msg.getData(); + // String error = data.getString(Apg.EXTRA_ERROR); + // String message; + // if (error != null) { + // message = getString(R.string.errorMessage, error); + // } else { + // message = getString(R.string.fileDeleteSuccessful); + // } + // + // Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); + // } public void passPhraseCallback(long keyId, String passPhrase) { // TODO: Not needed anymore, now implemented in AskForSecretKeyPass diff --git a/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java index 8a87a77ab..b491ca4c2 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java @@ -770,9 +770,9 @@ public class DecryptActivity extends SherlockFragmentActivity { } } - if (data.getBoolean(ApgService.EXTRA_SIGNATURE)) { - String userId = data.getString(ApgService.EXTRA_SIGNATURE_USER_ID); - mSignatureKeyId = data.getLong(ApgService.EXTRA_SIGNATURE_KEY_ID); + if (data.getBoolean(ApgService.RESULT_SIGNATURE)) { + String userId = data.getString(ApgService.RESULT_SIGNATURE_USER_ID); + mSignatureKeyId = data.getLong(ApgService.RESULT_SIGNATURE_KEY_ID); mUserIdRest .setText("id: " + PGPHelper.getSmallFingerPrint(mSignatureKeyId)); if (userId == null) { @@ -785,9 +785,9 @@ public class DecryptActivity extends SherlockFragmentActivity { } mUserId.setText(userId); - if (data.getBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS)) { + if (data.getBoolean(ApgService.RESULT_SIGNATURE_SUCCESS)) { mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); - } else if (data.getBoolean(ApgService.EXTRA_SIGNATURE_UNKNOWN)) { + } else if (data.getBoolean(ApgService.RESULT_SIGNATURE_UNKNOWN)) { mSignatureStatusImage.setImageResource(R.drawable.overlay_error); Toast.makeText(DecryptActivity.this, R.string.unknownSignatureKeyTouchToLookUp, Toast.LENGTH_LONG) diff --git a/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java index 17ce7d5c9..b9270e22f 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java @@ -23,7 +23,6 @@ import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain; -import org.thialfihar.android.apg.helper.OtherHelper; import org.thialfihar.android.apg.helper.PGPConversionHelper; import org.thialfihar.android.apg.service.ApgHandler; import org.thialfihar.android.apg.service.ApgService; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/KeyServerQueryActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/KeyServerQueryActivity.java index 1cb7ecaca..ec140e8d2 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/KeyServerQueryActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/KeyServerQueryActivity.java @@ -21,7 +21,6 @@ import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.helper.PGPHelper; -import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.util.HkpKeyServer; import org.thialfihar.android.apg.util.KeyServer.InsufficientQuery; import org.thialfihar.android.apg.util.KeyServer.KeyInfo; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/MainActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/MainActivity.java index db30b0671..dafc2924b 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/MainActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/MainActivity.java @@ -22,7 +22,6 @@ import java.security.Security; import org.spongycastle.jce.provider.BouncyCastleProvider; import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.R; -import org.thialfihar.android.apg.helper.PGPMain; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockActivity; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/PreferencesActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/PreferencesActivity.java index 84beee428..81a0545d1 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/PreferencesActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/PreferencesActivity.java @@ -20,9 +20,8 @@ import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.openpgp.PGPEncryptedData; import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Id; -import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.helper.Preferences; -import org.thialfihar.android.apg.passphrase.PassphraseCacheService; +import org.thialfihar.android.apg.service.PassphraseCacheService; import org.thialfihar.android.apg.ui.widget.IntegerListPreference; import org.thialfihar.android.apg.R; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/PreferencesKeyServerActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/PreferencesKeyServerActivity.java index ee193cdd5..b54cbde71 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/PreferencesKeyServerActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/PreferencesKeyServerActivity.java @@ -20,7 +20,6 @@ import java.util.Vector; import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.R; -import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.ui.widget.Editor; import org.thialfihar.android.apg.ui.widget.KeyServerEditor; import org.thialfihar.android.apg.ui.widget.Editor.EditorListener; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/PublicKeyListActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/PublicKeyListActivity.java index 601f467aa..d5b05b64e 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/PublicKeyListActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/PublicKeyListActivity.java @@ -26,7 +26,6 @@ import org.thialfihar.android.apg.helper.PGPMain; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; -import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; import android.view.ContextMenu; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/SecretKeyListActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/SecretKeyListActivity.java index 60c6a6ef6..2d5108cad 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/SecretKeyListActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/SecretKeyListActivity.java @@ -19,9 +19,9 @@ package org.thialfihar.android.apg.ui; import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Id; +import org.thialfihar.android.apg.deprecated.AskForPassphrase; import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain; -import org.thialfihar.android.apg.passphrase.AskForPassphrase; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyListActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyListActivity.java index fb7e5a0dd..545db98f9 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyListActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyListActivity.java @@ -21,7 +21,6 @@ import java.util.Vector; import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.Id; -import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.ui.widget.SelectPublicKeyListAdapter; import com.actionbarsherlock.app.ActionBar; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyListActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyListActivity.java index 865fab789..b36278a74 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyListActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyListActivity.java @@ -19,7 +19,6 @@ package org.thialfihar.android.apg.ui; import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.Id; -import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.ui.widget.SelectSecretKeyListAdapter; import com.actionbarsherlock.app.ActionBar; diff --git a/org_apg/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java b/org_apg/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java index 6efe17c6d..87d715fd9 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java @@ -20,7 +20,6 @@ import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPSecretKey; import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.helper.PGPHelper; -import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.util.Choice; import org.thialfihar.android.apg.R; diff --git a/org_apg_integration_lib/src/org/thialfihar/android/apg/integration/ApgIntentHelper.java b/org_apg_integration_lib/src/org/thialfihar/android/apg/integration/ApgIntentHelper.java index ee8754e51..d38f1d3cc 100644 --- a/org_apg_integration_lib/src/org/thialfihar/android/apg/integration/ApgIntentHelper.java +++ b/org_apg_integration_lib/src/org/thialfihar/android/apg/integration/ApgIntentHelper.java @@ -193,13 +193,6 @@ public class ApgIntentHelper { break; } apgData.setEncryptedData(data.getStringExtra(Constants.EXTRA_ENCRYPTED_MESSAGE)); - // this was a stupid bug in an earlier version, just gonna leave this in for an APG - // version or two - if (apgData.getEncryptedData() == null) { - apgData.setEncryptedData(data.getStringExtra(Constants.EXTRA_DECRYPTED_MESSAGE)); - } - if (apgData.getEncryptedData() != null) { - } break; case Constants.DECRYPT_MESSAGE: @@ -215,7 +208,6 @@ public class ApgIntentHelper { false)); apgData.setDecryptedData(data.getStringExtra(Constants.EXTRA_DECRYPTED_MESSAGE)); - break; default: