API changes

This commit is contained in:
Dominik Schürmann
2012-12-12 19:14:09 +01:00
parent e3fea30abe
commit 2dcaad3d3b
34 changed files with 302 additions and 786 deletions

View File

@@ -68,16 +68,18 @@ import java.util.regex.Matcher;
public class DecryptActivity extends SherlockFragmentActivity {
// possible intent actions for this activity
/* Intents */
// without permission
public static final String ACTION_DECRYPT = Constants.INTENT_PREFIX + "DECRYPT";
public static final String ACTION_DECRYPT_FILE = Constants.INTENT_PREFIX + "DECRYPT_FILE";
// with permission
public static final String ACTION_DECRYPT_AND_RETURN = Constants.INTENT_PREFIX
+ "DECRYPT_AND_RETURN";
public static final String ACTION_DECRYPT_FILE = Constants.INTENT_PREFIX + "DECRYPT_FILE";
public static final String ACTION_DECRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
+ "DECRYPT_STREAM_AND_RETURN";
// possible extra keys
/* EXTRA keys for input */
public static final String EXTRA_TEXT = "text";
public static final String EXTRA_DATA = "data";
public static final String EXTRA_REPLY_TO = "replyTo";
@@ -755,32 +757,32 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (mContentUri != null) {
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
data.putParcelable(ApgIntentService.PROVIDER_URI, mContentUri);
data.putParcelable(ApgIntentService.ENCRYPT_PROVIDER_URI, mContentUri);
} else if (mDecryptTarget == Id.target.file) {
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_FILE);
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
+ mOutputFilename);
data.putString(ApgIntentService.INPUT_FILE, mInputFilename);
data.putString(ApgIntentService.OUTPUT_FILE, mOutputFilename);
data.putString(ApgIntentService.ENCRYPT_INPUT_FILE, mInputFilename);
data.putString(ApgIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename);
} else {
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
if (mDataBytes != null) {
data.putByteArray(ApgIntentService.CIPHERTEXT_BYTES, mDataBytes);
data.putByteArray(ApgIntentService.DECRYPT_CIPHERTEXT_BYTES, mDataBytes);
} else {
String message = mMessage.getText().toString();
data.putByteArray(ApgIntentService.CIPHERTEXT_BYTES, message.getBytes());
data.putByteArray(ApgIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes());
}
}
data.putLong(ApgIntentService.SECRET_KEY_ID, mSecretKeyId);
data.putLong(ApgIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyId);
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);
data.putBoolean(ApgIntentService.DECRYPT_SIGNED_ONLY, mSignedOnly);
data.putBoolean(ApgIntentService.DECRYPT_LOOKUP_UNKNOWN_KEY, mLookupUnknownKey);
data.putBoolean(ApgIntentService.DECRYPT_RETURN_BYTES, mReturnBinary);
data.putBoolean(ApgIntentService.DECRYPT_ASSUME_SYMMETRIC, mAssumeSymmetricEncryption);
intent.putExtra(ApgIntentService.EXTRA_DATA, data);

View File

@@ -25,6 +25,7 @@ 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.helper.PGPConversionHelper;
import org.thialfihar.android.apg.helper.PGPMain.ApgGeneralException;
import org.thialfihar.android.apg.provider.ProviderHelper;
import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
import org.thialfihar.android.apg.service.ApgIntentService;
@@ -75,6 +76,10 @@ public class EditKeyActivity extends SherlockFragmentActivity {
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
public static final String EXTRA_KEY_ID = "keyId";
// results when saving key
public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
public static final String RESULT_EXTRA_USER_ID = "userId";
private ActionBar mActionBar;
private PGPSecretKeyRing mKeyRing = null;
@@ -121,7 +126,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
return true;
case Id.menu.option.cancel:
finish();
cancelClicked();
return true;
default:
@@ -236,7 +241,8 @@ public class EditKeyActivity extends SherlockFragmentActivity {
// fill values for this action
Bundle data = new Bundle();
data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, mCurrentPassPhrase);
data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE,
mCurrentPassPhrase);
serviceIntent.putExtra(ApgIntentService.EXTRA_DATA, data);
@@ -424,14 +430,16 @@ public class EditKeyActivity extends SherlockFragmentActivity {
// fill values for this action
Bundle data = new Bundle();
data.putString(ApgIntentService.CURRENT_PASSPHRASE, mCurrentPassPhrase);
data.putString(ApgIntentService.NEW_PASSPHRASE, mNewPassPhrase);
data.putStringArrayList(ApgIntentService.USER_IDS, getUserIds(mUserIdsView));
data.putString(ApgIntentService.SAVE_KEYRING_CURRENT_PASSPHRASE, mCurrentPassPhrase);
data.putString(ApgIntentService.SAVE_KEYRING_NEW_PASSPHRASE, mNewPassPhrase);
data.putStringArrayList(ApgIntentService.SAVE_KEYRING_USER_IDS,
getUserIds(mUserIdsView));
ArrayList<PGPSecretKey> keys = getKeys(mKeysView);
data.putByteArray(ApgIntentService.KEYS,
data.putByteArray(ApgIntentService.SAVE_KEYRING_KEYS,
PGPConversionHelper.PGPSecretKeyArrayListToBytes(keys));
data.putIntegerArrayList(ApgIntentService.KEYS_USAGES, getKeysUsages(mKeysView));
data.putLong(ApgIntentService.MASTER_KEY_ID, getMasterKeyId());
data.putIntegerArrayList(ApgIntentService.SAVE_KEYRING_KEYS_USAGES,
getKeysUsages(mKeysView));
data.putLong(ApgIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId());
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
@@ -443,6 +451,16 @@ public class EditKeyActivity extends SherlockFragmentActivity {
super.handleMessage(message);
if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
Intent data = new Intent();
data.putExtra(RESULT_EXTRA_MASTER_KEY_ID, getMasterKeyId());
ArrayList<String> userIds = null;
try {
userIds = getUserIds(mUserIdsView);
} catch (ApgGeneralException e) {
Log.e(Constants.TAG, "exception while getting user ids", e);
}
data.putExtra(RESULT_EXTRA_USER_ID, userIds.get(0));
setResult(RESULT_OK, data);
finish();
}
};
@@ -462,6 +480,11 @@ public class EditKeyActivity extends SherlockFragmentActivity {
}
}
private void cancelClicked() {
setResult(RESULT_CANCELED);
finish();
}
/**
* Returns user ids from the SectionView
*

View File

@@ -70,18 +70,20 @@ import java.util.Vector;
public class EncryptActivity extends SherlockFragmentActivity {
// possible intent actions for this activity
/* Intents */
// without permission
public static final String ACTION_ENCRYPT = Constants.INTENT_PREFIX + "ENCRYPT";
public static final String ACTION_ENCRYPT_FILE = Constants.INTENT_PREFIX + "ENCRYPT_FILE";
// with permission
public static final String ACTION_ENCRYPT_AND_RETURN = Constants.INTENT_PREFIX
+ "ENCRYPT_AND_RETURN";
public static final String ACTION_GENERATE_SIGNATURE_AND_RETURN = Constants.INTENT_PREFIX
+ "GENERATE_SIGNATURE";
public static final String ACTION_ENCRYPT_FILE = Constants.INTENT_PREFIX + "ENCRYPT_FILE";
+ "GENERATE_SIGNATURE_AND_RETURN";
public static final String ACTION_ENCRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
+ "ENCRYPT_STREAM_AND_RETURN";
// possible extra keys
/* EXTRA keys for input */
public static final String EXTRA_TEXT = "text";
public static final String EXTRA_DATA = "data";
public static final String EXTRA_ASCII_ARMOUR = "asciiArmour";
@@ -339,7 +341,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
} else if (ACTION_ENCRYPT_STREAM_AND_RETURN.equals(action)) {
// TODO: Set mStreamAndReturnUri that is used later to encrypt a stream!
mStreamAndReturnUri = null;
mStreamAndReturnUri = uri;
}
}
@@ -684,7 +686,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
passPhrase = null;
}
data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, passPhrase);
data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passPhrase);
} else {
encryptionKeyIds = mEncryptionKeyIds;
signOnly = (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0);
@@ -696,7 +698,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
if (mStreamAndReturnUri != null) {
// mIntentDataUri is only defined when ACTION_ENCRYPT_STREAM_AND_RETURN is used
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
data.putParcelable(ApgIntentService.PROVIDER_URI, mStreamAndReturnUri);
data.putParcelable(ApgIntentService.ENCRYPT_PROVIDER_URI, mStreamAndReturnUri);
} else if (mEncryptTarget == Id.target.file) {
useAsciiArmor = mAsciiArmour.isChecked();
@@ -707,8 +709,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
+ mOutputFilename);
data.putString(ApgIntentService.INPUT_FILE, mInputFilename);
data.putString(ApgIntentService.OUTPUT_FILE, mOutputFilename);
data.putString(ApgIntentService.ENCRYPT_INPUT_FILE, mInputFilename);
data.putString(ApgIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename);
} else {
useAsciiArmor = true;
@@ -717,13 +719,13 @@ public class EncryptActivity extends SherlockFragmentActivity {
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
if (mData != null) {
data.putByteArray(ApgIntentService.MESSAGE_BYTES, mData);
data.putByteArray(ApgIntentService.ENCRYPT_MESSAGE_BYTES, mData);
} else {
String message = mMessage.getText().toString();
if (signOnly && !mEncryptImmediately) {
fixBadCharactersForGmail(message);
}
data.putByteArray(ApgIntentService.MESSAGE_BYTES, message.getBytes());
data.putByteArray(ApgIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes());
}
}
@@ -731,12 +733,12 @@ public class EncryptActivity extends SherlockFragmentActivity {
useAsciiArmor = mAsciiArmorDemand;
}
data.putLong(ApgIntentService.SECRET_KEY_ID, mSecretKeyId);
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);
data.putLong(ApgIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyId);
data.putBoolean(ApgIntentService.ENCRYPT_USE_ASCII_AMOR, useAsciiArmor);
data.putLongArray(ApgIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, encryptionKeyIds);
data.putInt(ApgIntentService.ENCRYPT_COMPRESSION_ID, compressionId);
data.putBoolean(ApgIntentService.ENCRYPT_GENERATE_SIGNATURE, mGenerateSignature);
data.putBoolean(ApgIntentService.ENCRYPT_SIGN_ONLY, signOnly);
intent.putExtra(ApgIntentService.EXTRA_DATA, data);

View File

@@ -281,7 +281,7 @@ public class KeyListActivity extends SherlockFragmentActivity {
@Override
public void handleMessage(Message message) {
if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) {
// refreshList();
// no further actions needed
}
}
};
@@ -368,8 +368,6 @@ public class KeyListActivity extends SherlockFragmentActivity {
.newInstance(mImportFilename);
deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog");
}
// refreshList();
}
};
};

View File

@@ -262,14 +262,14 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
passPhrase = PassphraseCacheService
.getCachedPassphrase(mActivity, masterKey.getKeyID());
data.putByteArray(ApgIntentService.MASTER_KEY,
data.putByteArray(ApgIntentService.GENERATE_KEY_MASTER_KEY,
PGPConversionHelper.PGPSecretKeyToBytes(masterKey));
} else {
passPhrase = "";
}
data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, passPhrase);
data.putInt(ApgIntentService.ALGORITHM, mNewKeyAlgorithmChoice.getId());
data.putInt(ApgIntentService.KEY_SIZE, mNewKeySize);
data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passPhrase);
data.putInt(ApgIntentService.GENERATE_KEY_ALGORITHM, mNewKeyAlgorithmChoice.getId());
data.putInt(ApgIntentService.GENERATE_KEY_KEY_SIZE, mNewKeySize);
intent.putExtra(ApgIntentService.EXTRA_DATA, data);