mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Update Intent API
This commit is contained in:
parent
bf7fb08bca
commit
f5b53b58f7
@ -146,7 +146,6 @@
|
||||
<!-- Keychain's own Actions -->
|
||||
<intent-filter>
|
||||
<action android:name="org.sufficientlysecure.keychain.action.ENCRYPT" />
|
||||
<action android:name="org.sufficientlysecure.keychain.action.ENCRYPT_FILE" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
@ -171,7 +170,6 @@
|
||||
<!-- Keychain's own Actions -->
|
||||
<intent-filter>
|
||||
<action android:name="org.sufficientlysecure.keychain.action.DECRYPT" />
|
||||
<action android:name="org.sufficientlysecure.keychain.action.DECRYPT_FILE" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
|
@ -58,9 +58,9 @@
|
||||
|
||||
<!-- btn_lowerCase: capitalized words, no punctuation -->
|
||||
<string name="btn_signToClipboard">Sign (Clipboard)</string>
|
||||
<string name="btn_encryptToClipboard">Encrypt (Clipboard)</string>
|
||||
<string name="btn_encryptAndEmail">Encrypt (Email)</string>
|
||||
<string name="btn_signAndEmail">Sign (Email)</string>
|
||||
<string name="btn_encryptToClipboard">Encrypt to Clipboard</string>
|
||||
<string name="btn_encryptAndSend">Encrypt and send…</string>
|
||||
<string name="btn_signAndSend">Sign and send…</string>
|
||||
<string name="btn_encrypt">Encrypt</string>
|
||||
<string name="btn_sign">Sign</string>
|
||||
<string name="btn_decrypt">Decrypt</string>
|
||||
|
@ -74,19 +74,13 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
/* 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";
|
||||
|
||||
/* 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 = "reply_to";
|
||||
public static final String EXTRA_SUBJECT = "subject";
|
||||
|
||||
private long mSignatureKeyId = 0;
|
||||
|
||||
private boolean mReturnResult = false;
|
||||
private String mReplyTo = null;
|
||||
private String mSubject = null;
|
||||
private boolean mSignedOnly = false;
|
||||
private boolean mAssumeSymmetricEncryption = false;
|
||||
|
||||
@ -116,7 +110,6 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
private String mOutputFilename = null;
|
||||
|
||||
private Uri mContentUri = null;
|
||||
private byte[] mDataBytes = null;
|
||||
private boolean mReturnBinary = false;
|
||||
|
||||
private long mUnknownSignatureKeyId = 0;
|
||||
@ -310,7 +303,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
if (mDecryptImmediately
|
||||
|| (mSource.getCurrentView().getId() == R.id.sourceMessage && (mMessage.getText()
|
||||
.length() > 0 || mDataBytes != null || mContentUri != null))) {
|
||||
.length() > 0 || mContentUri != null))) {
|
||||
decryptClicked();
|
||||
}
|
||||
}
|
||||
@ -334,7 +327,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
* Android's Action
|
||||
*/
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
// When sending to APG Encrypt via share menu
|
||||
// When sending to Keychain Encrypt via share menu
|
||||
if ("text/plain".equals(type)) {
|
||||
// Plain text
|
||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
@ -348,55 +341,21 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
// Binary via content provider (could also be files)
|
||||
// override uri to get stream from send
|
||||
uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
action = ACTION_DECRYPT_FILE;
|
||||
action = ACTION_DECRYPT;
|
||||
}
|
||||
} else if (Intent.ACTION_VIEW.equals(action)) {
|
||||
// Android's Action when opening file associated to APG (see AndroidManifest.xml)
|
||||
// Android's Action when opening file associated to Keychain (see AndroidManifest.xml)
|
||||
|
||||
// override action
|
||||
action = ACTION_DECRYPT_FILE;
|
||||
|
||||
// EVERYTHING ELSE IS OLD CODE
|
||||
// This gets the Uri, where an inputStream can be opened from
|
||||
// mContentUri = intent.getData();
|
||||
|
||||
// TODO: old implementation of ACTION_VIEW. Is this used in K9?
|
||||
// Uri uri = mIntent.getData();
|
||||
// try {
|
||||
// InputStream attachment = getContentResolver().openInputStream(uri);
|
||||
// ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||
// byte bytes[] = new byte[1 << 16];
|
||||
// int length;
|
||||
// while ((length = attachment.read(bytes)) > 0) {
|
||||
// byteOut.write(bytes, 0, length);
|
||||
// }
|
||||
// byteOut.close();
|
||||
// String data = new String(byteOut.toByteArray());
|
||||
// mMessage.setText(data);
|
||||
// } catch (FileNotFoundException e) {
|
||||
// // ignore, then
|
||||
// } catch (IOException e) {
|
||||
// // ignore, then
|
||||
// }
|
||||
|
||||
// same as ACTION_DECRYPT_FILE but decrypt it immediately
|
||||
// handleActionDecryptFile(intent);
|
||||
// mDecryptImmediately = true;
|
||||
action = ACTION_DECRYPT;
|
||||
}
|
||||
|
||||
String textData = extras.getString(EXTRA_TEXT);
|
||||
|
||||
/**
|
||||
* Main Actions
|
||||
*/
|
||||
if (ACTION_DECRYPT.equals(action)) {
|
||||
mDataBytes = extras.getByteArray(EXTRA_DATA);
|
||||
String textData = null;
|
||||
if (mDataBytes == 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) {
|
||||
if (ACTION_DECRYPT.equals(action) && textData != null) {
|
||||
Log.d(Constants.TAG, "textData null, matching text ...");
|
||||
Matcher matcher = PgpMain.PGP_MESSAGE.matcher(textData);
|
||||
if (matcher.matches()) {
|
||||
@ -421,10 +380,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
Log.d(Constants.TAG, "Nothing matched!");
|
||||
}
|
||||
}
|
||||
}
|
||||
mReplyTo = extras.getString(EXTRA_REPLY_TO);
|
||||
mSubject = extras.getString(EXTRA_SUBJECT);
|
||||
} else if (ACTION_DECRYPT_FILE.equals(action)) {
|
||||
} else if (ACTION_DECRYPT.equals(action) && uri != null) {
|
||||
// get file path from uri
|
||||
String path = FileHelper.getPath(this, uri);
|
||||
|
||||
@ -439,45 +395,16 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
} else {
|
||||
Log.e(Constants.TAG,
|
||||
"Direct binary data without actual file in filesystem is not supported. This is only supported by ACTION_DECRYPT_STREAM_AND_RETURN.");
|
||||
"Direct binary data without actual file in filesystem is not supported. Please use the Remote Service API!");
|
||||
Toast.makeText(this, R.string.error_onlyFilesAreSupported, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
// end activity
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
Log.e(Constants.TAG,
|
||||
"Include the extra 'text' or an Uri with setData() in your Intent!");
|
||||
}
|
||||
// } else if (ACTION_DECRYPT_AND_RETURN.equals(action)) {
|
||||
// mReturnBinary = extras.getBoolean(EXTRA_BINARY, false);
|
||||
//
|
||||
// if (mContentUri == null) {
|
||||
// mDataBytes = 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_STREAM_AND_RETURN.equals(action)) {
|
||||
// // TODO: Implement decrypt stream
|
||||
// }
|
||||
}
|
||||
|
||||
private void guessOutputFilename() {
|
||||
@ -640,13 +567,9 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
Toast.makeText(this, getString(R.string.error_fileNotFound, e.getMessage()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
if (mDataBytes != null) {
|
||||
inStream = new ByteArrayInputStream(mDataBytes);
|
||||
} else {
|
||||
inStream = new ByteArrayInputStream(mMessage.getText().toString().getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
// get decryption key for this inStream
|
||||
try {
|
||||
@ -685,8 +608,6 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
data = data.replaceAll("(?m)^", "> ");
|
||||
data = "\n\n" + data;
|
||||
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, mSecretKeyId);
|
||||
intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, new long[] { mSignatureKeyId });
|
||||
startActivity(intent);
|
||||
@ -768,13 +689,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
} else {
|
||||
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES);
|
||||
|
||||
if (mDataBytes != null) {
|
||||
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, mDataBytes);
|
||||
} else {
|
||||
String message = mMessage.getText().toString();
|
||||
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES,
|
||||
message.getBytes());
|
||||
}
|
||||
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes());
|
||||
}
|
||||
|
||||
data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyId);
|
||||
|
@ -72,22 +72,18 @@ import com.actionbarsherlock.view.MenuItem;
|
||||
public class EncryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
/* 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";
|
||||
|
||||
/* 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 = "ascii_armor";
|
||||
public static final String EXTRA_SEND_TO = "send_to";
|
||||
public static final String EXTRA_SUBJECT = "subject";
|
||||
|
||||
// enables ASCII Armor for file encryption when uri is given
|
||||
public static final String EXTRA_ASCII_ARMOR = "ascii_armor";
|
||||
|
||||
// preselect ids, for internal use
|
||||
public static final String EXTRA_SIGNATURE_KEY_ID = "signature_key_id";
|
||||
public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryption_key_ids";
|
||||
|
||||
private String mSubject = null;
|
||||
private String mSendTo = null;
|
||||
|
||||
private long mEncryptionKeyIds[] = null;
|
||||
|
||||
private EditText mMessage = null;
|
||||
@ -116,7 +112,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
private EditText mPassPhrase = null;
|
||||
private EditText mPassPhraseAgain = null;
|
||||
private CheckBox mAsciiArmour = null;
|
||||
private CheckBox mAsciiArmor = null;
|
||||
private Spinner mFileCompression = null;
|
||||
|
||||
private EditText mFilename = null;
|
||||
@ -127,9 +123,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
private String mOutputFilename = null;
|
||||
|
||||
private boolean mAsciiArmorDemand = false;
|
||||
private boolean mOverrideAsciiArmour = false;
|
||||
private Uri mStreamAndReturnUri = null;
|
||||
private byte[] mData = null;
|
||||
private boolean mOverrideAsciiArmor = false;
|
||||
|
||||
private boolean mGenerateSignature = false;
|
||||
|
||||
@ -201,26 +195,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
updateSource();
|
||||
updateMode();
|
||||
|
||||
// if (mEncryptImmediately) {
|
||||
// mSourcePrevious.setClickable(false);
|
||||
// mSourcePrevious.setEnabled(false);
|
||||
// mSourcePrevious.setVisibility(View.INVISIBLE);
|
||||
//
|
||||
// mSourceNext.setClickable(false);
|
||||
// mSourceNext.setEnabled(false);
|
||||
// mSourceNext.setVisibility(View.INVISIBLE);
|
||||
//
|
||||
// mSourceLabel.setClickable(false);
|
||||
// mSourceLabel.setEnabled(false);
|
||||
// }
|
||||
|
||||
updateActionBarButtons();
|
||||
|
||||
// if (mEncryptImmediately
|
||||
// && (mMessage.getText().length() > 0 || mData != null)
|
||||
// && ((mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0) || mSecretKeyId != 0)) {
|
||||
// encryptClicked();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,40 +225,24 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
// handle like normal text encryption, override action and extras to later
|
||||
// execute ACTION_ENCRYPT in main actions
|
||||
extras.putString(EXTRA_TEXT, sharedText);
|
||||
extras.putBoolean(EXTRA_ASCII_ARMOUR, true);
|
||||
extras.putBoolean(EXTRA_ASCII_ARMOR, true);
|
||||
action = ACTION_ENCRYPT;
|
||||
}
|
||||
} else {
|
||||
// Files via content provider, override uri and action
|
||||
uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
action = ACTION_ENCRYPT_FILE;
|
||||
action = ACTION_ENCRYPT;
|
||||
}
|
||||
}
|
||||
|
||||
// if (ACTION_ENCRYPT_AND_RETURN.equals(action)
|
||||
// || ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) {
|
||||
// mEncryptImmediately = true;
|
||||
// }
|
||||
//
|
||||
// if (ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) {
|
||||
// mGenerateSignature = true;
|
||||
// mOverrideAsciiArmour = true;
|
||||
// mAsciiArmorDemand = false;
|
||||
// }
|
||||
|
||||
if (extras.containsKey(EXTRA_ASCII_ARMOUR)) {
|
||||
mAsciiArmorDemand = extras.getBoolean(EXTRA_ASCII_ARMOUR, true);
|
||||
mOverrideAsciiArmour = true;
|
||||
mAsciiArmour.setChecked(mAsciiArmorDemand);
|
||||
if (extras.containsKey(EXTRA_ASCII_ARMOR)) {
|
||||
mAsciiArmorDemand = extras.getBoolean(EXTRA_ASCII_ARMOR, true);
|
||||
mOverrideAsciiArmor = true;
|
||||
mAsciiArmor.setChecked(mAsciiArmorDemand);
|
||||
}
|
||||
|
||||
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);
|
||||
String textData = extras.getString(EXTRA_TEXT);
|
||||
|
||||
long signatureKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID);
|
||||
long[] encryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
|
||||
|
||||
@ -293,18 +252,18 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
/**
|
||||
* Main Actions
|
||||
*/
|
||||
// if (ACTION_ENCRYPT.equals(action) || ACTION_ENCRYPT_AND_RETURN.equals(action)
|
||||
// || ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) {
|
||||
if (ACTION_ENCRYPT.equals(action)) {
|
||||
if (textData != null) {
|
||||
if (ACTION_ENCRYPT.equals(action) && textData != null) {
|
||||
// encrypt text based on given extra
|
||||
|
||||
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)) {
|
||||
} else if (ACTION_ENCRYPT.equals(action) && uri != null) {
|
||||
// encrypt file based on Uri
|
||||
|
||||
// get file path from uri
|
||||
String path = FileHelper.getPath(this, uri);
|
||||
|
||||
@ -319,16 +278,15 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
} else {
|
||||
Log.e(Constants.TAG,
|
||||
"Direct binary data without actual file in filesystem is not supported. This is only supported by ACTION_ENCRYPT_STREAM_AND_RETURN.");
|
||||
"Direct binary data without actual file in filesystem is not supported by Intents. Please use the Remote Service API!");
|
||||
Toast.makeText(this, R.string.error_onlyFilesAreSupported, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
// end activity
|
||||
finish();
|
||||
}
|
||||
// } else if (ACTION_ENCRYPT_STREAM_AND_RETURN.equals(action)) {
|
||||
// // TODO: Set mStreamAndReturnUri that is used later to encrypt a stream!
|
||||
//
|
||||
// mStreamAndReturnUri = uri;
|
||||
} else {
|
||||
Log.e(Constants.TAG,
|
||||
"Include the extra 'text' or an Uri with setData() in your Intent!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,7 +349,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
private String guessOutputFilename(String path) {
|
||||
// output in the same directory but with additional ending
|
||||
File file = new File(path);
|
||||
String ending = (mAsciiArmour.isChecked() ? ".asc" : ".gpg");
|
||||
String ending = (mAsciiArmor.isChecked() ? ".asc" : ".gpg");
|
||||
String outputFilename = file.getParent() + File.separator + file.getName() + ending;
|
||||
|
||||
return outputFilename;
|
||||
@ -455,31 +413,19 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
mSourceLabel.setText(R.string.label_message);
|
||||
|
||||
if (mMode.getCurrentView().getId() == R.id.modeSymmetric) {
|
||||
// if (mEncryptImmediately) {
|
||||
// setActionbarButtons(true, R.string.btn_encrypt, false, 0);
|
||||
// } else {
|
||||
setActionbarButtons(true, R.string.btn_encryptAndEmail, true,
|
||||
setActionbarButtons(true, R.string.btn_encryptAndSend, true,
|
||||
R.string.btn_encryptToClipboard);
|
||||
// }
|
||||
} else {
|
||||
if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) {
|
||||
if (mSecretKeyId == 0) {
|
||||
setActionbarButtons(false, 0, false, 0);
|
||||
} else {
|
||||
// if (mEncryptImmediately) {
|
||||
// setActionbarButtons(true, R.string.btn_sign, false, 0);
|
||||
// } else {
|
||||
setActionbarButtons(true, R.string.btn_signAndEmail, true,
|
||||
setActionbarButtons(true, R.string.btn_signAndSend, true,
|
||||
R.string.btn_signToClipboard);
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
// if (mEncryptImmediately) {
|
||||
// setActionbarButtons(true, R.string.btn_encrypt, false, 0);
|
||||
// } else {
|
||||
setActionbarButtons(true, R.string.btn_encryptAndEmail, true,
|
||||
setActionbarButtons(true, R.string.btn_encryptAndSend, true,
|
||||
R.string.btn_encryptToClipboard);
|
||||
// }
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -684,13 +630,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN);
|
||||
|
||||
// choose default settings, target and data bundle by target
|
||||
if (mStreamAndReturnUri != null) {
|
||||
// mIntentDataUri is only defined when ACTION_ENCRYPT_STREAM_AND_RETURN is used
|
||||
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_STREAM);
|
||||
data.putParcelable(KeychainIntentService.ENCRYPT_PROVIDER_URI, mStreamAndReturnUri);
|
||||
|
||||
} else if (mEncryptTarget == Id.target.file) {
|
||||
useAsciiArmor = mAsciiArmour.isChecked();
|
||||
if (mEncryptTarget == Id.target.file) {
|
||||
useAsciiArmor = mAsciiArmor.isChecked();
|
||||
compressionId = ((Choice) mFileCompression.getSelectedItem()).getId();
|
||||
|
||||
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_FILE);
|
||||
@ -707,19 +648,14 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES);
|
||||
|
||||
if (mData != null) {
|
||||
data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, mData);
|
||||
} else {
|
||||
String message = mMessage.getText().toString();
|
||||
// if (signOnly && !mEncryptImmediately) {
|
||||
if (signOnly) {
|
||||
fixBadCharactersForGmail(message);
|
||||
}
|
||||
data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
if (mOverrideAsciiArmour) {
|
||||
if (mOverrideAsciiArmor) {
|
||||
useAsciiArmor = mAsciiArmorDemand;
|
||||
}
|
||||
|
||||
@ -755,31 +691,18 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
break;
|
||||
|
||||
case Id.target.email:
|
||||
// if (mEncryptImmediately) {
|
||||
// Intent intent = new Intent();
|
||||
// intent.putExtras(data);
|
||||
// setResult(RESULT_OK, intent);
|
||||
// finish();
|
||||
// return;
|
||||
// }
|
||||
|
||||
output = data.getString(KeychainIntentService.RESULT_ENCRYPTED_STRING);
|
||||
Log.d(Constants.TAG, "output: " + output);
|
||||
|
||||
Intent emailIntent = new Intent(Intent.ACTION_SEND);
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
// Type is set to text/plain so that encrypted messages can
|
||||
// be sent with Whatsapp, Hangouts, SMS etc...
|
||||
emailIntent.setType("text/plain");
|
||||
sendIntent.setType("text/plain");
|
||||
|
||||
emailIntent.putExtra(Intent.EXTRA_TEXT, output);
|
||||
if (mSubject != null) {
|
||||
emailIntent.putExtra(Intent.EXTRA_SUBJECT, mSubject);
|
||||
}
|
||||
if (mSendTo != null) {
|
||||
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { mSendTo });
|
||||
}
|
||||
startActivity(Intent.createChooser(emailIntent,
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, output);
|
||||
startActivity(Intent.createChooser(sendIntent,
|
||||
getString(R.string.title_sendEmail)));
|
||||
break;
|
||||
|
||||
@ -949,8 +872,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
mDeleteAfter = (CheckBox) findViewById(R.id.deleteAfterEncryption);
|
||||
|
||||
mAsciiArmour = (CheckBox) findViewById(R.id.asciiArmour);
|
||||
mAsciiArmour.setChecked(Preferences.getPreferences(this).getDefaultAsciiArmour());
|
||||
mAsciiArmor = (CheckBox) findViewById(R.id.asciiArmour);
|
||||
mAsciiArmor.setChecked(Preferences.getPreferences(this).getDefaultAsciiArmour());
|
||||
|
||||
mSelectKeysButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
|
12
README.md
12
README.md
@ -53,18 +53,14 @@ OpenPGP Keychain specific Intent actions:
|
||||
|
||||
* ``org.sufficientlysecure.keychain.action.ENCRYPT``
|
||||
* To encrypt text use extra ``text`` (type: ``String``)
|
||||
* To encrypt bytes use extra ``data`` (type: ``byte[]``)
|
||||
* Enable ASCII Armor (encoding to Radix-64, 33% overhead) by adding the extra ``ascii_armor`` with value ``true``
|
||||
* ``org.sufficientlysecure.keychain.action.ENCRYPT_FILE``
|
||||
* Include data ``Uri`` (``intent.setData()``) pointing to a file or content provider
|
||||
* or set data ``Uri`` (``intent.setData()``) pointing to a file
|
||||
* Enable ASCII Armor for file encryption (encoding to Radix-64, 33% overhead) by adding the extra ``ascii_armor`` with value ``true``
|
||||
* ``org.sufficientlysecure.keychain.action.DECRYPT``
|
||||
* To decrypt text use extra ``text`` (type: ``String``)
|
||||
* To decrypt bytes use extra ``data`` (type: ``byte[]``)
|
||||
* ``org.sufficientlysecure.keychain.action.DECRYPT_FILE``
|
||||
* Include data ``Uri`` (``intent.setData()``) pointing to a file or content provider
|
||||
* or set data ``Uri`` (``intent.setData()``) pointing to a file
|
||||
* ``org.sufficientlysecure.keychain.action.IMPORT_KEY``
|
||||
* Extras: ``key_bytes`` (type: ``byte[]``)
|
||||
* or Uri in data with file schema
|
||||
* or set data ``Uri`` (``intent.setData()``) pointing to a file
|
||||
* ``org.sufficientlysecure.keychain.action.IMPORT_KEY_FROM_QR_CODE``
|
||||
* without extras starts Barcode Scanner to get QR Code
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user