mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
improving definition send and view intents
This commit is contained in:
parent
511cc4af9f
commit
054ad2bb97
@ -24,6 +24,7 @@
|
||||
<!--
|
||||
General remarks
|
||||
===============
|
||||
- Last APG 1 version was 10900 (1.0.9 beta 00)
|
||||
- APG 2 starting with versionCode 20000!
|
||||
|
||||
|
||||
@ -88,6 +89,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
<!-- APG's own Actions -->
|
||||
<intent-filter android:label="@string/intent_import_key" >
|
||||
<action android:name="org.thialfihar.android.apg.intent.IMPORT" />
|
||||
|
||||
@ -95,6 +97,7 @@
|
||||
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
<!-- Linking "Import key" to file types -->
|
||||
<intent-filter android:label="@string/intent_import_key" >
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
@ -212,6 +215,8 @@
|
||||
android:label="@string/title_encrypt"
|
||||
android:uiOptions="splitActionBarWhenNarrow"
|
||||
android:windowSoftInputMode="stateHidden" >
|
||||
|
||||
<!-- APG's own Actions -->
|
||||
<intent-filter>
|
||||
<action android:name="org.thialfihar.android.apg.intent.ENCRYPT" />
|
||||
<action android:name="org.thialfihar.android.apg.intent.ENCRYPT_FILE" />
|
||||
@ -220,6 +225,14 @@
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
<!-- Android's Send Action -->
|
||||
<intent-filter android:label="@string/intent_send_encrypt" >
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
@ -229,6 +242,8 @@
|
||||
android:label="@string/title_decrypt"
|
||||
android:uiOptions="splitActionBarWhenNarrow"
|
||||
android:windowSoftInputMode="stateHidden" >
|
||||
|
||||
<!-- APG's own Actions -->
|
||||
<intent-filter>
|
||||
<action android:name="org.thialfihar.android.apg.intent.DECRYPT" />
|
||||
<action android:name="org.thialfihar.android.apg.intent.DECRYPT_FILE" />
|
||||
@ -238,6 +253,15 @@
|
||||
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
<!-- Android's Send Action -->
|
||||
<intent-filter android:label="@string/intent_send_decrypt" >
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
<!-- Linking "Decrypt" to file types -->
|
||||
<intent-filter android:label="@string/intent_decrypt_file" >
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
|
@ -58,11 +58,9 @@ import android.widget.Toast;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
@ -83,8 +81,6 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
private long mSignatureKeyId = 0;
|
||||
|
||||
private Intent mIntent;
|
||||
|
||||
private boolean mReturnResult = false;
|
||||
private String mReplyTo = null;
|
||||
private String mSubject = null;
|
||||
@ -253,10 +249,12 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
boolean decryptImmediately = false;
|
||||
|
||||
mIntent = getIntent();
|
||||
// Get intent, action and MIME type
|
||||
Intent intent = getIntent();
|
||||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
|
||||
// handled separately from other actions as it uses mIntent.setAction()
|
||||
if (Intent.ACTION_VIEW.equals(mIntent.getAction())) {
|
||||
if (Intent.ACTION_VIEW.equals(action)) {
|
||||
|
||||
// TODO: old implementation of ACTION_VIEW. Is this used in K9?
|
||||
|
||||
@ -279,100 +277,29 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
// }
|
||||
|
||||
// same as ACTION_DECRYPT_FILE but decrypt it immediately
|
||||
mIntent.setAction(ACTION_DECRYPT_FILE);
|
||||
handleActionDecryptFile(intent);
|
||||
decryptImmediately = true;
|
||||
}
|
||||
|
||||
if (ACTION_DECRYPT.equals(mIntent.getAction())) {
|
||||
Log.d(Constants.TAG, "Apg Intent DECRYPT startet");
|
||||
Bundle extras = mIntent.getExtras();
|
||||
if (extras == null) {
|
||||
Log.d(Constants.TAG, "extra bundle was null");
|
||||
extras = new Bundle();
|
||||
} else if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
if ("text/plain".equals(type)) {
|
||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
if (sharedText != null) {
|
||||
intent.putExtra(EXTRA_TEXT, sharedText);
|
||||
handleActionDecrypt(intent);
|
||||
decryptImmediately = true;
|
||||
}
|
||||
} else {
|
||||
Log.d(Constants.TAG, "got extras");
|
||||
}
|
||||
Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (uri != null) {
|
||||
// TODO: Implement for binary
|
||||
|
||||
mData = extras.getByteArray(EXTRA_DATA);
|
||||
String textData = null;
|
||||
if (mData == null) {
|
||||
Log.d(Constants.TAG, "EXTRA_DATA was null");
|
||||
textData = extras.getString(EXTRA_TEXT);
|
||||
} else {
|
||||
Log.d(Constants.TAG, "Got data from EXTRA_DATA");
|
||||
}
|
||||
if (textData != null) {
|
||||
Log.d(Constants.TAG, "textData null, matching text ...");
|
||||
Matcher matcher = PGPMain.PGP_MESSAGE.matcher(textData);
|
||||
if (matcher.matches()) {
|
||||
Log.d(Constants.TAG, "PGP_MESSAGE matched");
|
||||
textData = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
textData = textData.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(textData);
|
||||
} else {
|
||||
matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(textData);
|
||||
if (matcher.matches()) {
|
||||
Log.d(Constants.TAG, "PGP_SIGNED_MESSAGE matched");
|
||||
textData = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
textData = textData.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(textData);
|
||||
|
||||
mDecryptString = getString(R.string.btn_verify);
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
} else {
|
||||
Log.d(Constants.TAG, "Nothing matched!");
|
||||
}
|
||||
}
|
||||
}
|
||||
mReplyTo = extras.getString(EXTRA_REPLY_TO);
|
||||
mSubject = extras.getString(EXTRA_SUBJECT);
|
||||
} else if (ACTION_DECRYPT_FILE.equals(mIntent.getAction())) {
|
||||
mInputFilename = mIntent.getData().getPath();
|
||||
mFilename.setText(mInputFilename);
|
||||
guessOutputFilename();
|
||||
mSource.setInAnimation(null);
|
||||
mSource.setOutAnimation(null);
|
||||
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
||||
mSource.showNext();
|
||||
}
|
||||
} else if (ACTION_DECRYPT_AND_RETURN.equals(mIntent.getAction())) {
|
||||
mContentUri = mIntent.getData();
|
||||
Bundle extras = mIntent.getExtras();
|
||||
if (extras == null) {
|
||||
extras = new Bundle();
|
||||
}
|
||||
|
||||
mReturnBinary = extras.getBoolean(EXTRA_BINARY, false);
|
||||
|
||||
if (mContentUri == null) {
|
||||
mData = extras.getByteArray(EXTRA_DATA);
|
||||
String data = extras.getString(EXTRA_TEXT);
|
||||
if (data != null) {
|
||||
Matcher matcher = PGPMain.PGP_MESSAGE.matcher(data);
|
||||
if (matcher.matches()) {
|
||||
data = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
data = data.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(data);
|
||||
} else {
|
||||
matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(data);
|
||||
if (matcher.matches()) {
|
||||
data = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
data = data.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(data);
|
||||
mDecryptString = getString(R.string.btn_verify);
|
||||
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mReturnResult = true;
|
||||
} else if (ACTION_DECRYPT.equals(action)) {
|
||||
handleActionDecrypt(intent);
|
||||
} else if (ACTION_DECRYPT_FILE.equals(action)) {
|
||||
handleActionDecryptFile(intent);
|
||||
} else if (ACTION_DECRYPT_AND_RETURN.equals(action)) {
|
||||
handleActionDecryptAndReturn(intent);
|
||||
}
|
||||
|
||||
if (mSource.getCurrentView().getId() == R.id.sourceMessage
|
||||
@ -437,6 +364,118 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles activity intent with ACTION_DECRYPT
|
||||
*
|
||||
* @param intent
|
||||
*/
|
||||
private void handleActionDecrypt(Intent intent) {
|
||||
Log.d(Constants.TAG, "Apg Intent DECRYPT startet");
|
||||
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras == null) {
|
||||
Log.d(Constants.TAG, "extra bundle was null");
|
||||
extras = new Bundle();
|
||||
} else {
|
||||
Log.d(Constants.TAG, "got extras");
|
||||
}
|
||||
|
||||
mData = extras.getByteArray(EXTRA_DATA);
|
||||
String textData = null;
|
||||
if (mData == null) {
|
||||
Log.d(Constants.TAG, "EXTRA_DATA was null");
|
||||
textData = extras.getString(EXTRA_TEXT);
|
||||
} else {
|
||||
Log.d(Constants.TAG, "Got data from EXTRA_DATA");
|
||||
}
|
||||
if (textData != null) {
|
||||
Log.d(Constants.TAG, "textData null, matching text ...");
|
||||
Matcher matcher = PGPMain.PGP_MESSAGE.matcher(textData);
|
||||
if (matcher.matches()) {
|
||||
Log.d(Constants.TAG, "PGP_MESSAGE matched");
|
||||
textData = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
textData = textData.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(textData);
|
||||
} else {
|
||||
matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(textData);
|
||||
if (matcher.matches()) {
|
||||
Log.d(Constants.TAG, "PGP_SIGNED_MESSAGE matched");
|
||||
textData = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
textData = textData.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(textData);
|
||||
|
||||
mDecryptString = getString(R.string.btn_verify);
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
} else {
|
||||
Log.d(Constants.TAG, "Nothing matched!");
|
||||
}
|
||||
}
|
||||
}
|
||||
mReplyTo = extras.getString(EXTRA_REPLY_TO);
|
||||
mSubject = extras.getString(EXTRA_SUBJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles activity intent with ACTION_DECRYPT_FILE
|
||||
*
|
||||
* @param intent
|
||||
*/
|
||||
private void handleActionDecryptFile(Intent intent) {
|
||||
mInputFilename = intent.getData().getPath();
|
||||
mFilename.setText(mInputFilename);
|
||||
guessOutputFilename();
|
||||
mSource.setInAnimation(null);
|
||||
mSource.setOutAnimation(null);
|
||||
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
||||
mSource.showNext();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles activity intent with ACTION_DECRYPT_AND_RETURN
|
||||
*
|
||||
* @param intent
|
||||
*/
|
||||
private void handleActionDecryptAndReturn(Intent intent) {
|
||||
mContentUri = intent.getData();
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras == null) {
|
||||
extras = new Bundle();
|
||||
}
|
||||
|
||||
mReturnBinary = extras.getBoolean(EXTRA_BINARY, false);
|
||||
|
||||
if (mContentUri == null) {
|
||||
mData = extras.getByteArray(EXTRA_DATA);
|
||||
String data = extras.getString(EXTRA_TEXT);
|
||||
if (data != null) {
|
||||
Matcher matcher = PGPMain.PGP_MESSAGE.matcher(data);
|
||||
if (matcher.matches()) {
|
||||
data = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
data = data.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(data);
|
||||
} else {
|
||||
matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(data);
|
||||
if (matcher.matches()) {
|
||||
data = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
data = data.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(data);
|
||||
mDecryptString = getString(R.string.btn_verify);
|
||||
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mReturnResult = true;
|
||||
}
|
||||
|
||||
private void guessOutputFilename() {
|
||||
mInputFilename = mFilename.getText().toString();
|
||||
File file = new File(mInputFilename);
|
||||
|
@ -86,7 +86,6 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
public static final String EXTRA_SIGNATURE_KEY_ID = "signatureKeyId";
|
||||
public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryptionKeyIds";
|
||||
|
||||
private Intent mIntent = null;
|
||||
private String mSubject = null;
|
||||
private String mSendTo = null;
|
||||
|
||||
@ -343,104 +342,31 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
});
|
||||
|
||||
mIntent = getIntent();
|
||||
if (ACTION_ENCRYPT.equals(mIntent.getAction())
|
||||
|| ACTION_ENCRYPT_FILE.equals(mIntent.getAction())
|
||||
|| ACTION_ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
||||
|| ACTION_GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
||||
mContentUri = mIntent.getData();
|
||||
Bundle extras = mIntent.getExtras();
|
||||
if (extras == null) {
|
||||
extras = new Bundle();
|
||||
}
|
||||
// Get intent, action and MIME type
|
||||
Intent intent = getIntent();
|
||||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
|
||||
if (ACTION_ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
||||
|| ACTION_GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
||||
mReturnResult = true;
|
||||
}
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
if ("text/plain".equals(type)) {
|
||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
if (sharedText != null) {
|
||||
intent.setAction(ACTION_ENCRYPT);
|
||||
intent.putExtra(EXTRA_TEXT, sharedText);
|
||||
intent.putExtra(EXTRA_ASCII_ARMOUR, true);
|
||||
handleActionEncryptSign(intent);
|
||||
}
|
||||
} else {
|
||||
Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (uri != null) {
|
||||
// TODO: Implement for binary
|
||||
|
||||
if (ACTION_GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
||||
mGenerateSignature = true;
|
||||
mOverrideAsciiArmour = true;
|
||||
mAsciiArmourDemand = false;
|
||||
}
|
||||
|
||||
if (extras.containsKey(EXTRA_ASCII_ARMOUR)) {
|
||||
mAsciiArmourDemand = extras.getBoolean(EXTRA_ASCII_ARMOUR, true);
|
||||
mOverrideAsciiArmour = true;
|
||||
mAsciiArmour.setChecked(mAsciiArmourDemand);
|
||||
}
|
||||
|
||||
mData = extras.getByteArray(EXTRA_DATA);
|
||||
String textData = null;
|
||||
if (mData == null) {
|
||||
textData = extras.getString(EXTRA_TEXT);
|
||||
}
|
||||
mSendTo = extras.getString(EXTRA_SEND_TO);
|
||||
mSubject = extras.getString(EXTRA_SUBJECT);
|
||||
long signatureKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID);
|
||||
long encryptionKeyIds[] = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
|
||||
if (signatureKeyId != 0) {
|
||||
PGPSecretKeyRing keyRing = PGPMain.getSecretKeyRing(signatureKeyId);
|
||||
PGPSecretKey masterKey = null;
|
||||
if (keyRing != null) {
|
||||
masterKey = PGPHelper.getMasterKey(keyRing);
|
||||
if (masterKey != null) {
|
||||
Vector<PGPSecretKey> signKeys = PGPHelper.getUsableSigningKeys(keyRing);
|
||||
if (signKeys.size() > 0) {
|
||||
setSecretKeyId(masterKey.getKeyID());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (encryptionKeyIds != null) {
|
||||
Vector<Long> goodIds = new Vector<Long>();
|
||||
for (int i = 0; i < encryptionKeyIds.length; ++i) {
|
||||
PGPPublicKeyRing keyRing = PGPMain.getPublicKeyRing(encryptionKeyIds[i]);
|
||||
PGPPublicKey masterKey = null;
|
||||
if (keyRing == null) {
|
||||
continue;
|
||||
}
|
||||
masterKey = PGPHelper.getMasterKey(keyRing);
|
||||
if (masterKey == null) {
|
||||
continue;
|
||||
}
|
||||
Vector<PGPPublicKey> encryptKeys = PGPHelper.getUsableEncryptKeys(keyRing);
|
||||
if (encryptKeys.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
goodIds.add(masterKey.getKeyID());
|
||||
}
|
||||
if (goodIds.size() > 0) {
|
||||
mEncryptionKeyIds = new long[goodIds.size()];
|
||||
for (int i = 0; i < goodIds.size(); ++i) {
|
||||
mEncryptionKeyIds[i] = goodIds.get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ACTION_ENCRYPT.equals(mIntent.getAction())
|
||||
|| ACTION_ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
||||
|| ACTION_GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
||||
if (textData != null) {
|
||||
mMessage.setText(textData);
|
||||
}
|
||||
mSource.setInAnimation(null);
|
||||
mSource.setOutAnimation(null);
|
||||
while (mSource.getCurrentView().getId() != R.id.sourceMessage) {
|
||||
mSource.showNext();
|
||||
}
|
||||
} else if (ACTION_ENCRYPT_FILE.equals(mIntent.getAction())) {
|
||||
mInputFilename = mIntent.getData().getPath();
|
||||
mFilename.setText(mInputFilename);
|
||||
guessOutputFilename();
|
||||
mSource.setInAnimation(null);
|
||||
mSource.setOutAnimation(null);
|
||||
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
||||
mSource.showNext();
|
||||
}
|
||||
}
|
||||
} else if (ACTION_ENCRYPT.equals(action) || ACTION_ENCRYPT_FILE.equals(action)
|
||||
|| ACTION_ENCRYPT_AND_RETURN.equals(action)
|
||||
|| ACTION_GENERATE_SIGNATURE.equals(action)) {
|
||||
handleActionEncryptSign(intent);
|
||||
}
|
||||
|
||||
updateView();
|
||||
@ -469,6 +395,107 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles all actions with this intent
|
||||
*
|
||||
* @param intent
|
||||
*/
|
||||
private void handleActionEncryptSign(Intent intent) {
|
||||
String action = intent.getAction();
|
||||
|
||||
mContentUri = intent.getData();
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras == null) {
|
||||
extras = new Bundle();
|
||||
}
|
||||
|
||||
if (ACTION_ENCRYPT_AND_RETURN.equals(action) || ACTION_GENERATE_SIGNATURE.equals(action)) {
|
||||
mReturnResult = true;
|
||||
}
|
||||
|
||||
if (ACTION_GENERATE_SIGNATURE.equals(action)) {
|
||||
mGenerateSignature = true;
|
||||
mOverrideAsciiArmour = true;
|
||||
mAsciiArmourDemand = false;
|
||||
}
|
||||
|
||||
if (extras.containsKey(EXTRA_ASCII_ARMOUR)) {
|
||||
mAsciiArmourDemand = extras.getBoolean(EXTRA_ASCII_ARMOUR, true);
|
||||
mOverrideAsciiArmour = true;
|
||||
mAsciiArmour.setChecked(mAsciiArmourDemand);
|
||||
}
|
||||
|
||||
mData = extras.getByteArray(EXTRA_DATA);
|
||||
String textData = null;
|
||||
if (mData == null) {
|
||||
textData = extras.getString(EXTRA_TEXT);
|
||||
}
|
||||
mSendTo = extras.getString(EXTRA_SEND_TO);
|
||||
mSubject = extras.getString(EXTRA_SUBJECT);
|
||||
long signatureKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID);
|
||||
long encryptionKeyIds[] = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
|
||||
if (signatureKeyId != 0) {
|
||||
PGPSecretKeyRing keyRing = PGPMain.getSecretKeyRing(signatureKeyId);
|
||||
PGPSecretKey masterKey = null;
|
||||
if (keyRing != null) {
|
||||
masterKey = PGPHelper.getMasterKey(keyRing);
|
||||
if (masterKey != null) {
|
||||
Vector<PGPSecretKey> signKeys = PGPHelper.getUsableSigningKeys(keyRing);
|
||||
if (signKeys.size() > 0) {
|
||||
setSecretKeyId(masterKey.getKeyID());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (encryptionKeyIds != null) {
|
||||
Vector<Long> goodIds = new Vector<Long>();
|
||||
for (int i = 0; i < encryptionKeyIds.length; ++i) {
|
||||
PGPPublicKeyRing keyRing = PGPMain.getPublicKeyRing(encryptionKeyIds[i]);
|
||||
PGPPublicKey masterKey = null;
|
||||
if (keyRing == null) {
|
||||
continue;
|
||||
}
|
||||
masterKey = PGPHelper.getMasterKey(keyRing);
|
||||
if (masterKey == null) {
|
||||
continue;
|
||||
}
|
||||
Vector<PGPPublicKey> encryptKeys = PGPHelper.getUsableEncryptKeys(keyRing);
|
||||
if (encryptKeys.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
goodIds.add(masterKey.getKeyID());
|
||||
}
|
||||
if (goodIds.size() > 0) {
|
||||
mEncryptionKeyIds = new long[goodIds.size()];
|
||||
for (int i = 0; i < goodIds.size(); ++i) {
|
||||
mEncryptionKeyIds[i] = goodIds.get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ACTION_ENCRYPT.equals(action) || ACTION_ENCRYPT_AND_RETURN.equals(action)
|
||||
|| ACTION_GENERATE_SIGNATURE.equals(action)) {
|
||||
if (textData != null) {
|
||||
mMessage.setText(textData);
|
||||
}
|
||||
mSource.setInAnimation(null);
|
||||
mSource.setOutAnimation(null);
|
||||
while (mSource.getCurrentView().getId() != R.id.sourceMessage) {
|
||||
mSource.showNext();
|
||||
}
|
||||
} else if (ACTION_ENCRYPT_FILE.equals(action)) {
|
||||
mInputFilename = intent.getData().getPath();
|
||||
mFilename.setText(mInputFilename);
|
||||
guessOutputFilename();
|
||||
mSource.setInAnimation(null);
|
||||
mSource.setOutAnimation(null);
|
||||
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
||||
mSource.showNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void guessOutputFilename() {
|
||||
mInputFilename = mFilename.getText().toString();
|
||||
File file = new File(mInputFilename);
|
||||
|
Loading…
Reference in New Issue
Block a user