Fix share to encrypt text

This commit is contained in:
Dominik Schürmann 2014-09-13 20:07:22 +02:00
parent 7d41800e57
commit d73ea5f612
2 changed files with 22 additions and 25 deletions

View File

@ -452,28 +452,12 @@ public class EncryptFileActivity extends DrawerActivity implements EncryptActivi
* Android's Action * Android's Action
*/ */
if (Intent.ACTION_SEND.equals(action) && type != null) {
// When sending to OpenKeychain Encrypt via share menu // When sending to OpenKeychain Encrypt via share menu
/* if ("text/plain".equals(type)) { if (Intent.ACTION_SEND.equals(action) && type != null) {
// TODO handle, maybe forward to "encrypt text" activity?
Plain text
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
if (sharedText != null) {
// handle like normal text encryption, override action and extras to later
// executeServiceMethod ACTION_ENCRYPT_TEXT in main actions
extras.putString(EXTRA_TEXT, sharedText);
extras.putBoolean(EXTRA_ASCII_ARMOR, true);
action = ACTION_ENCRYPT_TEXT;
}
} else */
{
// Files via content provider, override uri and action // Files via content provider, override uri and action
uris.clear(); uris.clear();
uris.add(intent.<Uri>getParcelableExtra(Intent.EXTRA_STREAM)); uris.add(intent.<Uri>getParcelableExtra(Intent.EXTRA_STREAM));
} }
}
if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);

View File

@ -409,16 +409,29 @@ public class EncryptTextActivity extends DrawerActivity implements EncryptActivi
private void handleActions(Intent intent) { private void handleActions(Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
Bundle extras = intent.getExtras(); Bundle extras = intent.getExtras();
// Should always be text/plain String type = intent.getType();
// String type = intent.getType();
ArrayList<Uri> uris = new ArrayList<Uri>();
if (extras == null) { if (extras == null) {
extras = new Bundle(); extras = new Bundle();
} }
if (intent.getData() != null) { /*
uris.add(intent.getData()); * Android's Action
*/
// When sending to OpenKeychain Encrypt via share menu
if (Intent.ACTION_SEND.equals(action) && type != null) {
// When sending to OpenKeychain Encrypt via share menu
if ("text/plain".equals(type)) {
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
if (sharedText != null) {
// handle like normal text encryption, override action and extras to later
// executeServiceMethod ACTION_ENCRYPT_TEXT in main actions
extras.putString(EXTRA_TEXT, sharedText);
action = ACTION_ENCRYPT_TEXT;
}
}
} }
String textData = extras.getString(EXTRA_TEXT); String textData = extras.getString(EXTRA_TEXT);