aboutsummaryrefslogtreecommitdiffstats
path: root/org_apg/src/org/thialfihar/android/apg/ui
diff options
context:
space:
mode:
authorDominik <dominik@dominikschuermann.de>2012-11-14 16:02:11 +0100
committerDominik <dominik@dominikschuermann.de>2012-11-14 16:02:11 +0100
commitd61e00ae6c2bf071860195cbff48be81c59c47d9 (patch)
treed88105b90d612e6ad6590032c662e09e0c503175 /org_apg/src/org/thialfihar/android/apg/ui
parent8aac7ea7be1172f1dc0713fa5cf75fc95f082aa3 (diff)
downloadopen-keychain-d61e00ae6c2bf071860195cbff48be81c59c47d9.tar.gz
open-keychain-d61e00ae6c2bf071860195cbff48be81c59c47d9.tar.bz2
open-keychain-d61e00ae6c2bf071860195cbff48be81c59c47d9.zip
Fix decrypt by searching for secret key based on keyId not masterKeyId, new ApgService for RPC
Diffstat (limited to 'org_apg/src/org/thialfihar/android/apg/ui')
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java107
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java48
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java61
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/ImportFromQRCodeActivity.java28
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/KeyListActivity.java54
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java4
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/KeyServerQueryActivity.java28
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/KeyServerUploadActivity.java20
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/SignKeyActivity.java36
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteFileDialogFragment.java18
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteKeyDialogFragment.java4
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/dialog/PassphraseDialogFragment.java3
-rw-r--r--org_apg/src/org/thialfihar/android/apg/ui/widget/SectionView.java26
13 files changed, 213 insertions, 224 deletions
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 880349760..498dfd93b 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java
@@ -25,8 +25,8 @@ import org.thialfihar.android.apg.helper.OtherHelper;
import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.provider.ProviderHelper;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
-import org.thialfihar.android.apg.service.ApgService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
import org.thialfihar.android.apg.service.PassphraseCacheService;
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
import org.thialfihar.android.apg.ui.dialog.FileDialogFragment;
@@ -115,7 +115,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
private String mOutputFilename = null;
private Uri mContentUri = null;
- private byte[] mData = null;
+ private byte[] mDataBytes = null;
private boolean mReturnBinary = false;
private long mUnknownSignatureKeyId = 0;
@@ -126,14 +126,6 @@ public class DecryptActivity extends SherlockFragmentActivity {
private boolean mLookupUnknownKey = true;
- public void setSecretKeyId(long id) {
- mSecretKeyId = id;
- }
-
- public long getSecretKeyId() {
- return mSecretKeyId;
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
@@ -334,8 +326,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (mSignatureKeyId == 0) {
return;
}
- PGPPublicKeyRing key = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(DecryptActivity.this,
- mSignatureKeyId);
+ PGPPublicKeyRing key = ProviderHelper.getPGPPublicKeyRingByKeyId(
+ DecryptActivity.this, mSignatureKeyId);
if (key != null) {
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID);
@@ -367,7 +359,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (decryptImmediately
|| (mSource.getCurrentView().getId() == R.id.sourceMessage && (mMessage.getText()
- .length() > 0 || mData != null || mContentUri != null))) {
+ .length() > 0 || mDataBytes != null || mContentUri != null))) {
decryptClicked();
}
}
@@ -388,9 +380,9 @@ public class DecryptActivity extends SherlockFragmentActivity {
Log.d(Constants.TAG, "got extras");
}
- mData = extras.getByteArray(EXTRA_DATA);
+ mDataBytes = extras.getByteArray(EXTRA_DATA);
String textData = null;
- if (mData == null) {
+ if (mDataBytes == null) {
Log.d(Constants.TAG, "EXTRA_DATA was null");
textData = extras.getString(EXTRA_TEXT);
} else {
@@ -456,7 +448,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
mReturnBinary = extras.getBoolean(EXTRA_BINARY, false);
if (mContentUri == null) {
- mData = extras.getByteArray(EXTRA_DATA);
+ mDataBytes = extras.getByteArray(EXTRA_DATA);
String data = extras.getString(EXTRA_TEXT);
if (data != null) {
Matcher matcher = PGPMain.PGP_MESSAGE.matcher(data);
@@ -567,11 +559,9 @@ public class DecryptActivity extends SherlockFragmentActivity {
getDecryptionKeyFromInputStream();
- Log.d(Constants.TAG, "secretKeyId: " + getSecretKeyId());
-
// if we need a symmetric passphrase or a passphrase to use a secret key ask for it
- if (getSecretKeyId() == Id.key.symmetric
- || PassphraseCacheService.getCachedPassphrase(this, getSecretKeyId()) == null) {
+ if (mSecretKeyId == Id.key.symmetric
+ || PassphraseCacheService.getCachedPassphrase(this, mSecretKeyId) == null) {
showPassphraseDialog();
} else {
if (mDecryptTarget == Id.target.file) {
@@ -618,7 +608,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
}
/**
- * TODO: externalize this into ApgService???
+ * TODO: Rework function, remove global variables
*/
private void getDecryptionKeyFromInputStream() {
InputStream inStream = null;
@@ -646,23 +636,24 @@ public class DecryptActivity extends SherlockFragmentActivity {
Toast.LENGTH_SHORT).show();
}
} else {
- if (mData != null) {
- inStream = new ByteArrayInputStream(mData);
+ if (mDataBytes != null) {
+ inStream = new ByteArrayInputStream(mDataBytes);
} else {
inStream = new ByteArrayInputStream(mMessage.getText().toString().getBytes());
}
}
+ // get decryption key for this inStream
try {
try {
- setSecretKeyId(PGPMain.getDecryptionKeyId(this, inStream));
- if (getSecretKeyId() == Id.key.none) {
+ mSecretKeyId = PGPMain.getDecryptionKeyId(this, inStream);
+ if (mSecretKeyId == Id.key.none) {
throw new PGPMain.ApgGeneralException(
getString(R.string.error_noSecretKeyFound));
}
mAssumeSymmetricEncryption = false;
} catch (PGPMain.NoAsymmetricEncryptionException e) {
- setSecretKeyId(Id.key.symmetric);
+ mSecretKeyId = Id.key.symmetric;
if (!PGPMain.hasSymmetricEncryption(this, inStream)) {
throw new PGPMain.ApgGeneralException(
getString(R.string.error_noKnownEncryptionFound));
@@ -684,7 +675,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
intent.putExtra(EncryptActivity.EXTRA_TEXT, data);
intent.putExtra(EncryptActivity.EXTRA_SUBJECT, "Re: " + mSubject);
intent.putExtra(EncryptActivity.EXTRA_SEND_TO, mReplyTo);
- intent.putExtra(EncryptActivity.EXTRA_SIGNATURE_KEY_ID, getSecretKeyId());
+ intent.putExtra(EncryptActivity.EXTRA_SIGNATURE_KEY_ID, mSecretKeyId);
intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, new long[] { mSignatureKeyId });
startActivity(intent);
}
@@ -742,62 +733,62 @@ public class DecryptActivity extends SherlockFragmentActivity {
Log.d(Constants.TAG, "decryptStart");
// Send all information needed to service to decrypt in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
// fill values for this action
Bundle data = new Bundle();
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_DECRYPT_VERIFY);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_DECRYPT_VERIFY);
// choose action based on input: decrypt stream, file or bytes
if (mContentUri != null) {
- data.putInt(ApgService.TARGET, ApgService.TARGET_STREAM);
+ data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
- data.putParcelable(ApgService.PROVIDER_URI, mContentUri);
+ data.putParcelable(ApgIntentService.PROVIDER_URI, mContentUri);
} else if (mDecryptTarget == Id.target.file) {
- data.putInt(ApgService.TARGET, ApgService.TARGET_FILE);
+ data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_FILE);
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
+ mOutputFilename);
- data.putString(ApgService.INPUT_FILE, mInputFilename);
- data.putString(ApgService.OUTPUT_FILE, mOutputFilename);
+ data.putString(ApgIntentService.INPUT_FILE, mInputFilename);
+ data.putString(ApgIntentService.OUTPUT_FILE, mOutputFilename);
} else {
- data.putInt(ApgService.TARGET, ApgService.TARGET_BYTES);
+ data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
- if (mData != null) {
- data.putByteArray(ApgService.CIPHERTEXT_BYTES, mData);
+ if (mDataBytes != null) {
+ data.putByteArray(ApgIntentService.CIPHERTEXT_BYTES, mDataBytes);
} else {
String message = mMessage.getText().toString();
- data.putByteArray(ApgService.CIPHERTEXT_BYTES, message.getBytes());
+ data.putByteArray(ApgIntentService.CIPHERTEXT_BYTES, message.getBytes());
}
}
- data.putLong(ApgService.SECRET_KEY_ID, getSecretKeyId());
+ data.putLong(ApgIntentService.SECRET_KEY_ID, mSecretKeyId);
- data.putBoolean(ApgService.SIGNED_ONLY, mSignedOnly);
- data.putBoolean(ApgService.LOOKUP_UNKNOWN_KEY, mLookupUnknownKey);
- data.putBoolean(ApgService.RETURN_BYTES, mReturnBinary);
- data.putBoolean(ApgService.ASSUME_SYMMETRIC, mAssumeSymmetricEncryption);
+ data.putBoolean(ApgIntentService.SIGNED_ONLY, mSignedOnly);
+ data.putBoolean(ApgIntentService.LOOKUP_UNKNOWN_KEY, mLookupUnknownKey);
+ data.putBoolean(ApgIntentService.RETURN_BYTES, mReturnBinary);
+ data.putBoolean(ApgIntentService.ASSUME_SYMMETRIC, mAssumeSymmetricEncryption);
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after encrypting is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_decrypting,
- ProgressDialog.STYLE_HORIZONTAL) {
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this,
+ R.string.progress_decrypting, ProgressDialog.STYLE_HORIZONTAL) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
// get returned data bundle
Bundle returnData = message.getData();
// if key is unknown show lookup dialog
- if (returnData.getBoolean(ApgService.RESULT_SIGNATURE_LOOKUP_KEY)
+ if (returnData.getBoolean(ApgIntentService.RESULT_SIGNATURE_LOOKUP_KEY)
&& mLookupUnknownKey) {
mUnknownSignatureKeyId = returnData
- .getLong(ApgService.RESULT_SIGNATURE_KEY_ID);
+ .getLong(ApgIntentService.RESULT_SIGNATURE_KEY_ID);
lookupUnknownKey(mUnknownSignatureKeyId);
return;
}
@@ -822,7 +813,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
switch (mDecryptTarget) {
case Id.target.message:
String decryptedMessage = returnData
- .getString(ApgService.RESULT_DECRYPTED_MESSAGE);
+ .getString(ApgIntentService.RESULT_DECRYPTED_STRING);
mMessage.setText(decryptedMessage);
mMessage.setHorizontallyScrolling(false);
mReplyEnabled = false;
@@ -846,9 +837,11 @@ public class DecryptActivity extends SherlockFragmentActivity {
}
- if (returnData.getBoolean(ApgService.RESULT_SIGNATURE)) {
- String userId = returnData.getString(ApgService.RESULT_SIGNATURE_USER_ID);
- mSignatureKeyId = returnData.getLong(ApgService.RESULT_SIGNATURE_KEY_ID);
+ if (returnData.getBoolean(ApgIntentService.RESULT_SIGNATURE)) {
+ String userId = returnData
+ .getString(ApgIntentService.RESULT_SIGNATURE_USER_ID);
+ mSignatureKeyId = returnData
+ .getLong(ApgIntentService.RESULT_SIGNATURE_KEY_ID);
mUserIdRest
.setText("id: " + PGPHelper.getSmallFingerPrint(mSignatureKeyId));
if (userId == null) {
@@ -861,9 +854,9 @@ public class DecryptActivity extends SherlockFragmentActivity {
}
mUserId.setText(userId);
- if (returnData.getBoolean(ApgService.RESULT_SIGNATURE_SUCCESS)) {
+ if (returnData.getBoolean(ApgIntentService.RESULT_SIGNATURE_SUCCESS)) {
mSignatureStatusImage.setImageResource(R.drawable.overlay_ok);
- } else if (returnData.getBoolean(ApgService.RESULT_SIGNATURE_UNKNOWN)) {
+ } else if (returnData.getBoolean(ApgIntentService.RESULT_SIGNATURE_UNKNOWN)) {
mSignatureStatusImage.setImageResource(R.drawable.overlay_error);
Toast.makeText(DecryptActivity.this,
R.string.unknownSignatureKeyTouchToLookUp, Toast.LENGTH_LONG)
@@ -879,7 +872,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);
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 f781f1ac1..96bd0ea5e 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java
@@ -26,8 +26,8 @@ import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.PGPConversionHelper;
import org.thialfihar.android.apg.provider.ProviderHelper;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
-import org.thialfihar.android.apg.service.ApgService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
import org.thialfihar.android.apg.ui.dialog.SetPassphraseDialogFragment;
import org.thialfihar.android.apg.ui.widget.KeyEditor;
import org.thialfihar.android.apg.ui.widget.SectionView;
@@ -224,32 +224,32 @@ public class EditKeyActivity extends SherlockFragmentActivity {
mBuildLayout = false;
// Send all information needed to service generate keys in other thread
- Intent serviceIntent = new Intent(this, ApgService.class);
- serviceIntent.putExtra(ApgService.EXTRA_ACTION,
- ApgService.ACTION_GENERATE_DEFAULT_RSA_KEYS);
+ Intent serviceIntent = new Intent(this, ApgIntentService.class);
+ serviceIntent.putExtra(ApgIntentService.EXTRA_ACTION,
+ ApgIntentService.ACTION_GENERATE_DEFAULT_RSA_KEYS);
// fill values for this action
Bundle data = new Bundle();
- data.putString(ApgService.SYMMETRIC_PASSPHRASE, mCurrentPassPhrase);
+ data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, mCurrentPassPhrase);
- serviceIntent.putExtra(ApgService.EXTRA_DATA, data);
+ serviceIntent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after generating is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this,
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this,
R.string.progress_generating, ProgressDialog.STYLE_SPINNER) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
// get new key from data bundle returned from service
Bundle data = message.getData();
PGPSecretKeyRing masterKeyRing = (PGPSecretKeyRing) PGPConversionHelper
.BytesToPGPKeyRing(data
- .getByteArray(ApgService.RESULT_NEW_KEY));
+ .getByteArray(ApgIntentService.RESULT_NEW_KEY));
PGPSecretKeyRing subKeyRing = (PGPSecretKeyRing) PGPConversionHelper
.BytesToPGPKeyRing(data
- .getByteArray(ApgService.RESULT_NEW_KEY2));
+ .getByteArray(ApgIntentService.RESULT_NEW_KEY2));
// add master key
@SuppressWarnings("unchecked")
@@ -271,7 +271,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- serviceIntent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ serviceIntent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
saveHandler.showProgressDialog(this);
@@ -412,30 +412,30 @@ public class EditKeyActivity extends SherlockFragmentActivity {
}
// Send all information needed to service to edit key in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_SAVE_KEYRING);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_SAVE_KEYRING);
// fill values for this action
Bundle data = new Bundle();
- data.putString(ApgService.CURRENT_PASSPHRASE, mCurrentPassPhrase);
- data.putString(ApgService.NEW_PASSPHRASE, mNewPassPhrase);
- data.putStringArrayList(ApgService.USER_IDS, getUserIds(mUserIdsView));
+ data.putString(ApgIntentService.CURRENT_PASSPHRASE, mCurrentPassPhrase);
+ data.putString(ApgIntentService.NEW_PASSPHRASE, mNewPassPhrase);
+ data.putStringArrayList(ApgIntentService.USER_IDS, getUserIds(mUserIdsView));
ArrayList<PGPSecretKey> keys = getKeys(mKeysView);
- data.putByteArray(ApgService.KEYS, PGPConversionHelper.PGPSecretKeyListToBytes(keys));
- data.putIntegerArrayList(ApgService.KEYS_USAGES, getKeysUsages(mKeysView));
- data.putLong(ApgService.MASTER_KEY_ID, getMasterKeyId());
+ data.putByteArray(ApgIntentService.KEYS, PGPConversionHelper.PGPSecretKeyListToBytes(keys));
+ data.putIntegerArrayList(ApgIntentService.KEYS_USAGES, getKeysUsages(mKeysView));
+ data.putLong(ApgIntentService.MASTER_KEY_ID, getMasterKeyId());
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after saving is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_saving,
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this, R.string.progress_saving,
ProgressDialog.STYLE_HORIZONTAL) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
finish();
}
};
@@ -443,7 +443,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
saveHandler.showProgressDialog(this);
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java
index 65610f688..29b1ab86a 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java
@@ -29,8 +29,8 @@ 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.provider.ProviderHelper;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
-import org.thialfihar.android.apg.service.ApgService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
import org.thialfihar.android.apg.service.PassphraseCacheService;
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
import org.thialfihar.android.apg.ui.dialog.FileDialogFragment;
@@ -768,14 +768,13 @@ public class EncryptActivity extends SherlockFragmentActivity {
private void encryptStart() {
// Send all information needed to service to edit key in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
// fill values for this action
Bundle data = new Bundle();
- boolean useAsciiArmour = true;
+ boolean useAsciiArmor = true;
long encryptionKeyIds[] = null;
- long signatureKeyId = Id.key.none;
int compressionId = 0;
boolean signOnly = false;
@@ -786,78 +785,76 @@ public class EncryptActivity extends SherlockFragmentActivity {
passPhrase = null;
}
- data.putString(ApgService.SYMMETRIC_PASSPHRASE, passPhrase);
+ data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, passPhrase);
} else {
encryptionKeyIds = mEncryptionKeyIds;
- signatureKeyId = getSecretKeyId();
signOnly = (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0);
}
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_ENCRYPT_SIGN);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_ENCRYPT_SIGN);
// choose default settings, target and data bundle by target
if (mContentUri != null) {
- data.putInt(ApgService.TARGET, ApgService.TARGET_STREAM);
- data.putParcelable(ApgService.PROVIDER_URI, mContentUri);
+ data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
+ data.putParcelable(ApgIntentService.PROVIDER_URI, mContentUri);
} else if (mEncryptTarget == Id.target.file) {
- useAsciiArmour = mAsciiArmour.isChecked();
+ useAsciiArmor = mAsciiArmour.isChecked();
compressionId = ((Choice) mFileCompression.getSelectedItem()).getId();
- data.putInt(ApgService.TARGET, ApgService.TARGET_FILE);
+ data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_FILE);
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
+ mOutputFilename);
- data.putString(ApgService.INPUT_FILE, mInputFilename);
- data.putString(ApgService.OUTPUT_FILE, mOutputFilename);
+ data.putString(ApgIntentService.INPUT_FILE, mInputFilename);
+ data.putString(ApgIntentService.OUTPUT_FILE, mOutputFilename);
} else {
- useAsciiArmour = true;
+ useAsciiArmor = true;
compressionId = Preferences.getPreferences(this).getDefaultMessageCompression();
- data.putInt(ApgService.TARGET, ApgService.TARGET_BYTES);
+ data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
if (mData != null) {
- data.putByteArray(ApgService.MESSAGE_BYTES, mData);
+ data.putByteArray(ApgIntentService.MESSAGE_BYTES, mData);
} else {
String message = mMessage.getText().toString();
if (signOnly && !mReturnResult) {
fixBadCharactersForGmail(message);
}
- data.putByteArray(ApgService.MESSAGE_BYTES, message.getBytes());
+ data.putByteArray(ApgIntentService.MESSAGE_BYTES, message.getBytes());
}
}
if (mOverrideAsciiArmour) {
- useAsciiArmour = mAsciiArmourDemand;
+ useAsciiArmor = mAsciiArmourDemand;
}
- data.putLong(ApgService.SECRET_KEY_ID, getSecretKeyId());
- data.putBoolean(ApgService.USE_ASCII_AMOR, useAsciiArmour);
- data.putLongArray(ApgService.ENCRYPTION_KEYS_IDS, encryptionKeyIds);
- data.putLong(ApgService.SIGNATURE_KEY_ID, signatureKeyId);
- data.putInt(ApgService.COMPRESSION_ID, compressionId);
- data.putBoolean(ApgService.GENERATE_SIGNATURE, mGenerateSignature);
- data.putBoolean(ApgService.SIGN_ONLY, signOnly);
+ data.putLong(ApgIntentService.SECRET_KEY_ID, getSecretKeyId());
+ data.putBoolean(ApgIntentService.USE_ASCII_AMOR, useAsciiArmor);
+ data.putLongArray(ApgIntentService.ENCRYPTION_KEYS_IDS, encryptionKeyIds);
+ data.putInt(ApgIntentService.COMPRESSION_ID, compressionId);
+ data.putBoolean(ApgIntentService.GENERATE_SIGNATURE, mGenerateSignature);
+ data.putBoolean(ApgIntentService.SIGN_ONLY, signOnly);
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after encrypting is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_encrypting,
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this, R.string.progress_encrypting,
ProgressDialog.STYLE_HORIZONTAL) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
// get returned data bundle
Bundle data = message.getData();
String output;
switch (mEncryptTarget) {
case Id.target.clipboard:
- output = data.getString(ApgService.RESULT_ENCRYPTED_MESSAGE);
+ output = data.getString(ApgIntentService.RESULT_ENCRYPTED_STRING);
Log.d(Constants.TAG, "output: " + output);
Compatibility.copyToClipboard(EncryptActivity.this, output);
Toast.makeText(EncryptActivity.this,
@@ -874,7 +871,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
return;
}
- output = data.getString(ApgService.RESULT_ENCRYPTED_MESSAGE);
+ output = data.getString(ApgIntentService.RESULT_ENCRYPTED_STRING);
Log.d(Constants.TAG, "output: " + output);
Intent emailIntent = new Intent(Intent.ACTION_SEND);
@@ -913,7 +910,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/ImportFromQRCodeActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/ImportFromQRCodeActivity.java
index 4c5952b99..aac1fd15b 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/ImportFromQRCodeActivity.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/ImportFromQRCodeActivity.java
@@ -20,8 +20,8 @@ package org.thialfihar.android.apg.ui;
import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.OtherHelper;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
-import org.thialfihar.android.apg.service.ApgService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
import org.thialfihar.android.apg.R;
import android.app.AlertDialog;
@@ -157,34 +157,34 @@ public class ImportFromQRCodeActivity extends SherlockFragmentActivity {
if (mScannedContent != null) {
// Send all information needed to service to import key in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_IMPORT_KEY);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_IMPORT_KEY);
// fill values for this action
Bundle data = new Bundle();
- data.putInt(ApgService.IMPORT_KEY_TYPE, Id.type.public_key);
+ data.putInt(ApgIntentService.IMPORT_KEY_TYPE, Id.type.public_key);
- data.putInt(ApgService.TARGET, ApgService.TARGET_BYTES);
- data.putByteArray(ApgService.IMPORT_BYTES, mScannedContent.getBytes());
+ data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
+ data.putByteArray(ApgIntentService.IMPORT_BYTES, mScannedContent.getBytes());
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after importing is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this,
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this,
R.string.progress_importing, ProgressDialog.STYLE_HORIZONTAL) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
// get returned data bundle
Bundle returnData = message.getData();
- int added = returnData.getInt(ApgService.RESULT_IMPORT_ADDED);
- int updated = returnData.getInt(ApgService.RESULT_IMPORT_UPDATED);
- int bad = returnData.getInt(ApgService.RESULT_IMPORT_BAD);
+ int added = returnData.getInt(ApgIntentService.RESULT_IMPORT_ADDED);
+ int updated = returnData.getInt(ApgIntentService.RESULT_IMPORT_UPDATED);
+ int bad = returnData.getInt(ApgIntentService.RESULT_IMPORT_BAD);
String toastMessage;
if (added > 0 && updated > 0) {
toastMessage = getString(R.string.keysAddedAndUpdated, added, updated);
@@ -221,7 +221,7 @@ public class ImportFromQRCodeActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/KeyListActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/KeyListActivity.java
index 12567a9bd..3adae94a9 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/KeyListActivity.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/KeyListActivity.java
@@ -20,8 +20,8 @@ package org.thialfihar.android.apg.ui;
import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R;
-import org.thialfihar.android.apg.service.ApgService;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
import org.thialfihar.android.apg.ui.dialog.DeleteKeyDialogFragment;
import org.thialfihar.android.apg.ui.dialog.FileDialogFragment;
@@ -302,39 +302,39 @@ public class KeyListActivity extends SherlockFragmentActivity {
Log.d(Constants.TAG, "importKeys started");
// Send all information needed to service to import key in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_IMPORT_KEY);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_IMPORT_KEY);
// fill values for this action
Bundle data = new Bundle();
- data.putInt(ApgService.IMPORT_KEY_TYPE, mKeyType);
+ data.putInt(ApgIntentService.IMPORT_KEY_TYPE, mKeyType);
if (mImportData != null) {
- data.putInt(ApgService.TARGET, ApgService.TARGET_BYTES);
- data.putByteArray(ApgService.IMPORT_BYTES, mImportData.getBytes());
+ data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
+ data.putByteArray(ApgIntentService.IMPORT_BYTES, mImportData.getBytes());
} else {
- data.putInt(ApgService.TARGET, ApgService.TARGET_FILE);
- data.putString(ApgService.IMPORT_FILENAME, mImportFilename);
+ data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_FILE);
+ data.putString(ApgIntentService.IMPORT_FILENAME, mImportFilename);
}
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after importing is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_importing,
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this, R.string.progress_importing,
ProgressDialog.STYLE_HORIZONTAL) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
// get returned data bundle
Bundle returnData = message.getData();
- int added = returnData.getInt(ApgService.RESULT_IMPORT_ADDED);
- int updated = returnData.getInt(ApgService.RESULT_IMPORT_UPDATED);
- int bad = returnData.getInt(ApgService.RESULT_IMPORT_BAD);
+ int added = returnData.getInt(ApgIntentService.RESULT_IMPORT_ADDED);
+ int updated = returnData.getInt(ApgIntentService.RESULT_IMPORT_UPDATED);
+ int bad = returnData.getInt(ApgIntentService.RESULT_IMPORT_BAD);
String toastMessage;
if (added > 0 && updated > 0) {
toastMessage = getString(R.string.keysAddedAndUpdated, added, updated);
@@ -376,7 +376,7 @@ public class KeyListActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);
@@ -395,36 +395,36 @@ public class KeyListActivity extends SherlockFragmentActivity {
Log.d(Constants.TAG, "exportKeys started");
// Send all information needed to service to export key in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_EXPORT_KEY);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_EXPORT_KEY);
// fill values for this action
Bundle data = new Bundle();
- data.putString(ApgService.EXPORT_FILENAME, mExportFilename);
- data.putInt(ApgService.EXPORT_KEY_TYPE, mKeyType);
+ data.putString(ApgIntentService.EXPORT_FILENAME, mExportFilename);
+ data.putInt(ApgIntentService.EXPORT_KEY_TYPE, mKeyType);
if (keyRingId == -1) {
- data.putBoolean(ApgService.EXPORT_ALL, true);
+ data.putBoolean(ApgIntentService.EXPORT_ALL, true);
} else {
- data.putLong(ApgService.EXPORT_KEY_RING_ID, keyRingId);
+ data.putLong(ApgIntentService.EXPORT_KEY_RING_ID, keyRingId);
}
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after exporting is done in ApgService
- ApgServiceHandler exportHandler = new ApgServiceHandler(this, R.string.progress_exporting,
+ ApgIntentServiceHandler exportHandler = new ApgIntentServiceHandler(this, R.string.progress_exporting,
ProgressDialog.STYLE_HORIZONTAL) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
// get returned data bundle
Bundle returnData = message.getData();
- int exported = returnData.getInt(ApgService.RESULT_EXPORT);
+ int exported = returnData.getInt(ApgIntentService.RESULT_EXPORT);
String toastMessage;
if (exported == 1) {
toastMessage = getString(R.string.keyExported);
@@ -441,7 +441,7 @@ public class KeyListActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(exportHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
exportHandler.showProgressDialog(this);
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java b/org_apg/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java
index 6bf55a8c1..e1a93602c 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java
@@ -90,7 +90,7 @@ public class KeyListPublicFragment extends KeyListFragment implements
switch (item.getItemId()) {
case Id.menu.update:
long updateKeyId = 0;
- PGPPublicKeyRing updateKeyRing = ProviderHelper.getPGPPublicKeyRing(mKeyListActivity,
+ PGPPublicKeyRing updateKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity,
keyRingRowId);
if (updateKeyRing != null) {
updateKeyId = PGPHelper.getMasterKey(updateKeyRing).getKeyID();
@@ -119,7 +119,7 @@ public class KeyListPublicFragment extends KeyListFragment implements
case Id.menu.signKey:
long keyId = 0;
- PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRing(mKeyListActivity,
+ PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity,
keyRingRowId);
if (signKeyRing != null) {
keyId = PGPHelper.getMasterKey(signKeyRing).getKeyID();
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 98b6eccf0..7cd54bf32 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/KeyServerQueryActivity.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/KeyServerQueryActivity.java
@@ -25,8 +25,8 @@ 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.Preferences;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
-import org.thialfihar.android.apg.service.ApgService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
import org.thialfihar.android.apg.util.Log;
import org.thialfihar.android.apg.util.KeyServer.KeyInfo;
@@ -166,42 +166,42 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
Log.d(Constants.TAG, "start search with service");
// Send all information needed to service to query keys in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_QUERY_KEY);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_QUERY_KEY);
// fill values for this action
Bundle data = new Bundle();
String server = (String) mKeyServer.getSelectedItem();
- data.putString(ApgService.QUERY_KEY_SERVER, server);
+ data.putString(ApgIntentService.QUERY_KEY_SERVER, server);
- data.putInt(ApgService.QUERY_KEY_TYPE, mQueryType);
+ data.putInt(ApgIntentService.QUERY_KEY_TYPE, mQueryType);
if (mQueryType == Id.keyserver.search) {
- data.putString(ApgService.QUERY_KEY_STRING, mQueryString);
+ data.putString(ApgIntentService.QUERY_KEY_STRING, mQueryString);
} else if (mQueryType == Id.keyserver.get) {
- data.putLong(ApgService.QUERY_KEY_ID, mQueryId);
+ data.putLong(ApgIntentService.QUERY_KEY_ID, mQueryId);
}
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after querying is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_querying,
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this, R.string.progress_querying,
ProgressDialog.STYLE_SPINNER) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
// get returned data bundle
Bundle returnData = message.getData();
if (mQueryType == Id.keyserver.search) {
mSearchResult = returnData
- .getParcelableArrayList(ApgService.RESULT_QUERY_KEY_SEARCH_RESULT);
+ .getParcelableArrayList(ApgIntentService.RESULT_QUERY_KEY_SEARCH_RESULT);
} else if (mQueryType == Id.keyserver.get) {
- mKeyData = returnData.getString(ApgService.RESULT_QUERY_KEY_KEY_DATA);
+ mKeyData = returnData.getString(ApgIntentService.RESULT_QUERY_KEY_KEY_DATA);
}
// TODO: IMPROVE CODE!!! some global variables can be avoided!!!
@@ -240,7 +240,7 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/KeyServerUploadActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/KeyServerUploadActivity.java
index 8470488a2..db907ed48 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/KeyServerUploadActivity.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/KeyServerUploadActivity.java
@@ -20,8 +20,8 @@ package org.thialfihar.android.apg.ui;
import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.Preferences;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
-import org.thialfihar.android.apg.service.ApgService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
@@ -102,29 +102,29 @@ public class KeyServerUploadActivity extends SherlockFragmentActivity {
private void uploadKey() {
// Send all information needed to service to upload key in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_UPLOAD_KEY);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_UPLOAD_KEY);
// fill values for this action
Bundle data = new Bundle();
int keyRingId = getIntent().getIntExtra(EXTRA_KEYRING_ROW_ID, -1);
- data.putInt(ApgService.UPLOAD_KEY_KEYRING_ROW_ID, keyRingId);
+ data.putInt(ApgIntentService.UPLOAD_KEY_KEYRING_ROW_ID, keyRingId);
String server = (String) keyServer.getSelectedItem();
- data.putString(ApgService.UPLOAD_KEY_SERVER, server);
+ data.putString(ApgIntentService.UPLOAD_KEY_SERVER, server);
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after uploading is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_exporting,
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this, R.string.progress_exporting,
ProgressDialog.STYLE_HORIZONTAL) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
Toast.makeText(KeyServerUploadActivity.this, R.string.keySendSuccess,
Toast.LENGTH_SHORT).show();
@@ -135,7 +135,7 @@ public class KeyServerUploadActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/SignKeyActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/SignKeyActivity.java
index 9c6c1d50f..b970cb3d3 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/SignKeyActivity.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/SignKeyActivity.java
@@ -26,8 +26,8 @@ import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.Preferences;
import org.thialfihar.android.apg.provider.ProviderHelper;
-import org.thialfihar.android.apg.service.ApgService;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
import org.thialfihar.android.apg.service.PassphraseCacheService;
import org.thialfihar.android.apg.ui.dialog.PassphraseDialogFragment;
@@ -196,26 +196,26 @@ public class SignKeyActivity extends SherlockFragmentActivity {
*/
private void startSigning() {
// Send all information needed to service to sign key in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_SIGN_KEY);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_SIGN_KEY);
// fill values for this action
Bundle data = new Bundle();
- data.putLong(ApgService.SIGN_KEY_MASTER_KEY_ID, mMasterKeyId);
- data.putLong(ApgService.SIGN_KEY_PUB_KEY_ID, mPubKeyId);
+ data.putLong(ApgIntentService.SIGN_KEY_MASTER_KEY_ID, mMasterKeyId);
+ data.putLong(ApgIntentService.SIGN_KEY_PUB_KEY_ID, mPubKeyId);
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after signing is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_signing,
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this, R.string.progress_signing,
ProgressDialog.STYLE_SPINNER) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
Toast.makeText(SignKeyActivity.this, R.string.keySignSuccess,
Toast.LENGTH_SHORT).show();
@@ -236,7 +236,7 @@ public class SignKeyActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);
@@ -247,29 +247,29 @@ public class SignKeyActivity extends SherlockFragmentActivity {
private void uploadKey() {
// Send all information needed to service to upload key in other thread
- Intent intent = new Intent(this, ApgService.class);
+ Intent intent = new Intent(this, ApgIntentService.class);
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_UPLOAD_KEY);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_UPLOAD_KEY);
// fill values for this action
Bundle data = new Bundle();
- data.putLong(ApgService.UPLOAD_KEY_KEYRING_ROW_ID, mPubKeyId);
+ data.putLong(ApgIntentService.UPLOAD_KEY_KEYRING_ROW_ID, mPubKeyId);
Spinner keyServer = (Spinner) findViewById(R.id.keyServer);
String server = (String) keyServer.getSelectedItem();
- data.putString(ApgService.UPLOAD_KEY_SERVER, server);
+ data.putString(ApgIntentService.UPLOAD_KEY_SERVER, server);
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// Message is received after uploading is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_exporting,
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this, R.string.progress_exporting,
ProgressDialog.STYLE_HORIZONTAL) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
Toast.makeText(SignKeyActivity.this, R.string.keySendSuccess,
Toast.LENGTH_SHORT).show();
@@ -281,7 +281,7 @@ public class SignKeyActivity extends SherlockFragmentActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteFileDialogFragment.java b/org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteFileDialogFragment.java
index 8d111fc02..311066389 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteFileDialogFragment.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteFileDialogFragment.java
@@ -17,8 +17,8 @@
package org.thialfihar.android.apg.ui.dialog;
import org.thialfihar.android.apg.R;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
-import org.thialfihar.android.apg.service.ApgService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -70,25 +70,25 @@ public class DeleteFileDialogFragment extends DialogFragment {
dismiss();
// Send all information needed to service to edit key in other thread
- Intent intent = new Intent(activity, ApgService.class);
+ Intent intent = new Intent(activity, ApgIntentService.class);
// fill values for this action
Bundle data = new Bundle();
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_DELETE_FILE_SECURELY);
- data.putString(ApgService.DELETE_FILE, deleteFile);
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_DELETE_FILE_SECURELY);
+ data.putString(ApgIntentService.DELETE_FILE, deleteFile);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
ProgressDialogFragment deletingDialog = ProgressDialogFragment.newInstance(
R.string.progress_deletingSecurely, ProgressDialog.STYLE_HORIZONTAL);
// Message is received after deleting is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(activity, deletingDialog) {
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(activity, deletingDialog) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
Toast.makeText(activity, R.string.fileDeleteSuccessful,
Toast.LENGTH_SHORT).show();
}
@@ -97,7 +97,7 @@ public class DeleteFileDialogFragment extends DialogFragment {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
deletingDialog.show(activity.getSupportFragmentManager(), "deletingDialog");
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteKeyDialogFragment.java b/org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteKeyDialogFragment.java
index 3e2de6a67..bb5271ce7 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteKeyDialogFragment.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/dialog/DeleteKeyDialogFragment.java
@@ -76,11 +76,11 @@ public class DeleteKeyDialogFragment extends DialogFragment {
String userId = activity.getString(R.string.unknownUserId);
if (keyType == Id.type.public_key) {
- PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRing(activity,
+ PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRingByRowId(activity,
deleteKeyRingRowId);
userId = PGPHelper.getMainUserIdSafe(activity, PGPHelper.getMasterKey(keyRing));
} else {
- PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRing(activity,
+ PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByRowId(activity,
deleteKeyRingRowId);
userId = PGPHelper.getMainUserIdSafe(activity, PGPHelper.getMasterKey(keyRing));
}
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/dialog/PassphraseDialogFragment.java b/org_apg/src/org/thialfihar/android/apg/ui/dialog/PassphraseDialogFragment.java
index de2462b39..fb8f4b6d1 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/dialog/PassphraseDialogFragment.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/dialog/PassphraseDialogFragment.java
@@ -104,9 +104,8 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
private static boolean hasPassphrase(Context context, long secretKeyId) {
// check if the key has no passphrase
try {
- // TODO: by master key id???
PGPSecretKey secretKey = PGPHelper.getMasterKey(ProviderHelper
- .getPGPSecretKeyRingByMasterKeyId(context, secretKeyId));
+ .getPGPSecretKeyRingByKeyId(context, secretKeyId));
// PGPSecretKey secretKey =
// PGPHelper.getMasterKey(PGPMain.getSecretKeyRing(secretKeyId));
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/widget/SectionView.java b/org_apg/src/org/thialfihar/android/apg/ui/widget/SectionView.java
index 881aa769e..45fbbaba1 100644
--- a/org_apg/src/org/thialfihar/android/apg/ui/widget/SectionView.java
+++ b/org_apg/src/org/thialfihar/android/apg/ui/widget/SectionView.java
@@ -20,8 +20,8 @@ import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPConversionHelper;
-import org.thialfihar.android.apg.service.ApgServiceHandler;
-import org.thialfihar.android.apg.service.ApgService;
+import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
+import org.thialfihar.android.apg.service.ApgIntentService;
import org.thialfihar.android.apg.service.PassphraseCacheService;
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
import org.thialfihar.android.apg.ui.widget.Editor.EditorListener;
@@ -249,9 +249,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
private void createKey() {
// Send all information needed to service to edit key in other thread
- Intent intent = new Intent(mActivity, ApgService.class);
+ Intent intent = new Intent(mActivity, ApgIntentService.class);
- intent.putExtra(ApgService.EXTRA_ACTION, ApgService.ACTION_GENERATE_KEY);
+ intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_GENERATE_KEY);
// fill values for this action
Bundle data = new Bundle();
@@ -262,32 +262,32 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
passPhrase = PassphraseCacheService
.getCachedPassphrase(mActivity, masterKey.getKeyID());
- data.putByteArray(ApgService.MASTER_KEY,
+ data.putByteArray(ApgIntentService.MASTER_KEY,
PGPConversionHelper.PGPSecretKeyToBytes(masterKey));
} else {
passPhrase = "";
}
- data.putString(ApgService.SYMMETRIC_PASSPHRASE, passPhrase);
- data.putInt(ApgService.ALGORITHM, mNewKeyAlgorithmChoice.getId());
- data.putInt(ApgService.KEY_SIZE, mNewKeySize);
+ data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, passPhrase);
+ data.putInt(ApgIntentService.ALGORITHM, mNewKeyAlgorithmChoice.getId());
+ data.putInt(ApgIntentService.KEY_SIZE, mNewKeySize);
- intent.putExtra(ApgService.EXTRA_DATA, data);
+ intent.putExtra(ApgIntentService.EXTRA_DATA, data);
// show progress dialog
mGeneratingDialog = ProgressDialogFragment.newInstance(R.string.progress_generating,
ProgressDialog.STYLE_SPINNER);
// Message is received after generating is done in ApgService
- ApgServiceHandler saveHandler = new ApgServiceHandler(mActivity, mGeneratingDialog) {
+ ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(mActivity, mGeneratingDialog) {
public void handleMessage(Message message) {
// handle messages by standard ApgHandler first
super.handleMessage(message);
- if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
+ if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
// get new key from data bundle returned from service
Bundle data = message.getData();
PGPSecretKeyRing newKeyRing = (PGPSecretKeyRing) PGPConversionHelper
- .BytesToPGPKeyRing(data.getByteArray(ApgService.RESULT_NEW_KEY));
+ .BytesToPGPKeyRing(data.getByteArray(ApgIntentService.RESULT_NEW_KEY));
boolean isMasterKey = (mEditors.getChildCount() == 0);
@@ -317,7 +317,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
+ intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);
mGeneratingDialog.show(mActivity.getSupportFragmentManager(), "dialog");