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,27 +452,11 @@ public class EncryptFileActivity extends DrawerActivity implements EncryptActivi
* 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)) {
// 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
uris.clear();
uris.add(intent.<Uri>getParcelableExtra(Intent.EXTRA_STREAM));
}
// Files via content provider, override uri and action
uris.clear();
uris.add(intent.<Uri>getParcelableExtra(Intent.EXTRA_STREAM));
}
if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {

View file

@ -409,16 +409,29 @@ public class EncryptTextActivity extends DrawerActivity implements EncryptActivi
private void handleActions(Intent intent) {
String action = intent.getAction();
Bundle extras = intent.getExtras();
// Should always be text/plain
// String type = intent.getType();
ArrayList<Uri> uris = new ArrayList<Uri>();
String type = intent.getType();
if (extras == null) {
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);