From d73ea5f6127ae69738d9ca4a9363fe76162755f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 13 Sep 2014 20:07:22 +0200 Subject: [PATCH] Fix share to encrypt text --- .../keychain/ui/EncryptFileActivity.java | 24 ++++--------------- .../keychain/ui/EncryptTextActivity.java | 23 ++++++++++++++---- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileActivity.java index 581145f8d..96f8bd983 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileActivity.java @@ -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.getParcelableExtra(Intent.EXTRA_STREAM)); - } + // Files via content provider, override uri and action + uris.clear(); + uris.add(intent.getParcelableExtra(Intent.EXTRA_STREAM)); } if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java index bc0d3d387..6e6e52562 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java @@ -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 uris = new ArrayList(); + 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);