From 8f070e24500616a78ed332fc7659e3d6b10860bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 2 Nov 2015 19:15:00 +0100 Subject: Support for Android 6 ACTION_PROCESS_TEXT --- OpenKeychain/src/main/AndroidManifest.xml | 6 +++++ .../keychain/ui/EncryptTextActivity.java | 30 ++++++++++++++++++--- .../keychain/ui/EncryptTextFragment.java | 22 ++++++++++++++- .../drawable-hdpi/ic_action_encrypt_paste_24dp.png | Bin 0 -> 590 bytes .../drawable-mdpi/ic_action_encrypt_paste_24dp.png | Bin 0 -> 433 bytes .../ic_action_encrypt_paste_24dp.png | Bin 0 -> 684 bytes .../status_signature_expired_cutout_96dp.png | Bin 0 -> 4973 bytes .../ic_action_encrypt_paste_24dp.png | Bin 0 -> 986 bytes .../ic_action_encrypt_paste_24dp.png | Bin 0 -> 1290 bytes .../src/main/res/menu/encrypt_text_fragment.xml | 8 ++++++ OpenKeychain/src/main/res/values/strings.xml | 1 + 11 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_paste_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_paste_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_paste_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_paste_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_action_encrypt_paste_24dp.png (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml index 296685684..52d85bb90 100644 --- a/OpenKeychain/src/main/AndroidManifest.xml +++ b/OpenKeychain/src/main/AndroidManifest.xml @@ -210,6 +210,12 @@ + + + + + + Constants.TEXT_LENGTH_LIMIT) { + sharedText = sharedText.substring(0, Constants.TEXT_LENGTH_LIMIT); + Notify.create(this, R.string.snack_shared_text_too_long, Style.WARN).show(); + } + // handle like normal text encryption, override action and extras to later + // executeServiceMethod ACTION_ENCRYPT_TEXT in main actions + textData = sharedText; + } + } + if (textData == null) { textData = ""; } @@ -108,7 +132,7 @@ public class EncryptTextActivity extends EncryptActivity { if (savedInstanceState == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - EncryptTextFragment encryptFragment = EncryptTextFragment.newInstance(textData); + EncryptTextFragment encryptFragment = EncryptTextFragment.newInstance(textData, returnProcessText); transaction.replace(R.id.encrypt_text_container, encryptFragment); transaction.commit(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java index 4ce241c02..10d88253d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java @@ -56,8 +56,10 @@ public class EncryptTextFragment public static final String ARG_TEXT = "text"; public static final String ARG_USE_COMPRESSION = "use_compression"; + public static final String ARG_RETURN_PROCESS_TEXT = "return_process_text"; private boolean mShareAfterEncrypt; + private boolean mReturnProcessTextAfterEncrypt; private boolean mUseCompression; private boolean mHiddenRecipients = false; @@ -66,11 +68,12 @@ public class EncryptTextFragment /** * Creates new instance of this fragment */ - public static EncryptTextFragment newInstance(String text) { + public static EncryptTextFragment newInstance(String text, boolean returnProcessTextAfterEncrypt) { EncryptTextFragment frag = new EncryptTextFragment(); Bundle args = new Bundle(); args.putString(ARG_TEXT, text); + args.putBoolean(ARG_RETURN_PROCESS_TEXT, returnProcessTextAfterEncrypt); frag.setArguments(args); return frag; @@ -128,6 +131,7 @@ public class EncryptTextFragment super.onCreate(savedInstanceState); if (savedInstanceState == null) { mMessage = getArguments().getString(ARG_TEXT); + mReturnProcessTextAfterEncrypt = getArguments().getBoolean(ARG_RETURN_PROCESS_TEXT, false); } Preferences prefs = Preferences.getPreferences(getActivity()); @@ -151,6 +155,12 @@ public class EncryptTextFragment inflater.inflate(R.menu.encrypt_text_fragment, menu); menu.findItem(R.id.check_enable_compression).setChecked(mUseCompression); + + if (mReturnProcessTextAfterEncrypt) { + menu.findItem(R.id.encrypt_paste).setVisible(true); + menu.findItem(R.id.encrypt_copy).setVisible(false); + menu.findItem(R.id.encrypt_share).setVisible(false); + } } @Override @@ -177,6 +187,11 @@ public class EncryptTextFragment cryptoOperation(new CryptoInputParcel(new Date())); break; } + case R.id.encrypt_paste: { + hideKeyboard(); + cryptoOperation(new CryptoInputParcel(new Date())); + break; + } default: { return super.onOptionsItemSelected(item); } @@ -328,6 +343,11 @@ public class EncryptTextFragment // Share encrypted message/file startActivity(Intent.createChooser(createSendIntent(result.getResultBytes()), getString(R.string.title_share_message))); + } else if (mReturnProcessTextAfterEncrypt) { + Intent resultIntent = new Intent(); + resultIntent.putExtra(Intent.EXTRA_PROCESS_TEXT, new String(result.getResultBytes())); + getActivity().setResult(Activity.RESULT_OK, resultIntent); + getActivity().finish(); } else { // Copy to clipboard copyToClipboard(result); diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_paste_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_paste_24dp.png new file mode 100644 index 000000000..356cfbe43 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_paste_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_paste_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_paste_24dp.png new file mode 100644 index 000000000..a546e152b Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_paste_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_paste_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_paste_24dp.png new file mode 100644 index 000000000..ed7fdb732 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_paste_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_96dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_96dp.png index e69de29bb..568b48c43 100644 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_96dp.png and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_96dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_paste_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_paste_24dp.png new file mode 100644 index 000000000..50987bdd6 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_paste_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_action_encrypt_paste_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_action_encrypt_paste_24dp.png new file mode 100644 index 000000000..11ad7e219 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_action_encrypt_paste_24dp.png differ diff --git a/OpenKeychain/src/main/res/menu/encrypt_text_fragment.xml b/OpenKeychain/src/main/res/menu/encrypt_text_fragment.xml index 80b78457d..4d3d53870 100644 --- a/OpenKeychain/src/main/res/menu/encrypt_text_fragment.xml +++ b/OpenKeychain/src/main/res/menu/encrypt_text_fragment.xml @@ -2,6 +2,14 @@ + + "Phrases match" "Encrypt/sign and share text" "Encrypt/sign and copy text" + "Encrypt/sign and paste text" "View certification key" "Create key" "Add file(s)" -- cgit v1.2.3