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 --- Graphics/drawables/ic_action_encrypt_paste.svg | 59 +++++++++++++++++++++ Graphics/drawables/ic_action_encrypt_save.svg | 11 ++-- Graphics/drawables/originals/content-paste.svg | 1 + Graphics/update-drawables.sh | 2 +- 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 + 15 files changed, 130 insertions(+), 10 deletions(-) create mode 100644 Graphics/drawables/ic_action_encrypt_paste.svg create mode 100644 Graphics/drawables/originals/content-paste.svg 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 diff --git a/Graphics/drawables/ic_action_encrypt_paste.svg b/Graphics/drawables/ic_action_encrypt_paste.svg new file mode 100644 index 000000000..588c1d2ca --- /dev/null +++ b/Graphics/drawables/ic_action_encrypt_paste.svg @@ -0,0 +1,59 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/Graphics/drawables/ic_action_encrypt_save.svg b/Graphics/drawables/ic_action_encrypt_save.svg index 7bb435a5d..8502420f3 100644 --- a/Graphics/drawables/ic_action_encrypt_save.svg +++ b/Graphics/drawables/ic_action_encrypt_save.svg @@ -12,7 +12,7 @@ height="24" viewBox="0 0 24 24" id="svg2" - inkscape:version="0.48.3.1 r9886" + inkscape:version="0.48.5 r10040" sodipodi:docname="ic_action_encrypt_save.svg"> @@ -41,8 +41,8 @@ id="namedview6" showgrid="false" inkscape:zoom="9.8333333" - inkscape:cx="12.20339" - inkscape:cy="12" + inkscape:cx="-4.7288134" + inkscape:cy="11.949153" inkscape:window-x="0" inkscape:window-y="19" inkscape:window-maximized="1" @@ -50,10 +50,11 @@ + id="path4-7" + style="fill:#000000;fill-opacity:1" /> + style="fill:#000000;fill-opacity:1" /> diff --git a/Graphics/drawables/originals/content-paste.svg b/Graphics/drawables/originals/content-paste.svg new file mode 100644 index 000000000..11ea8f23d --- /dev/null +++ b/Graphics/drawables/originals/content-paste.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Graphics/update-drawables.sh b/Graphics/update-drawables.sh index 7dcf1d60f..18ed1b63a 100755 --- a/Graphics/update-drawables.sh +++ b/Graphics/update-drawables.sh @@ -22,7 +22,7 @@ SRC_DIR=./drawables/ #inkscape -w 512 -h 512 -e "$PLAY_DIR/$NAME.png" $NAME.svg -for NAME in "ic_cloud_search" "ic_action_encrypt_file" "ic_action_encrypt_text" "ic_action_verified_cutout" "ic_action_encrypt_copy" "ic_action_encrypt_save" "ic_action_encrypt_share" "status_lock_closed" "status_lock_error" "status_lock_open" "status_signature_expired_cutout" "status_signature_invalid_cutout" "status_signature_revoked_cutout" "status_signature_unknown_cutout" "status_signature_unverified_cutout" "status_signature_verified_cutout" "key_flag_authenticate" "key_flag_certify" "key_flag_encrypt" "key_flag_sign" "yubi_icon" "ic_stat_notify" "status_signature_verified_inner" "link" "octo_link" +for NAME in "ic_cloud_search" "ic_action_encrypt_file" "ic_action_encrypt_text" "ic_action_verified_cutout" "ic_action_encrypt_copy" "ic_action_encrypt_paste" "ic_action_encrypt_save" "ic_action_encrypt_share" "status_lock_closed" "status_lock_error" "status_lock_open" "status_signature_expired_cutout" "status_signature_invalid_cutout" "status_signature_revoked_cutout" "status_signature_unknown_cutout" "status_signature_unverified_cutout" "status_signature_verified_cutout" "key_flag_authenticate" "key_flag_certify" "key_flag_encrypt" "key_flag_sign" "yubi_icon" "ic_stat_notify" "status_signature_verified_inner" "link" "octo_link" do echo $NAME inkscape -w 24 -h 24 -e "$MDPI_DIR/${NAME}_24dp.png" "$SRC_DIR/$NAME.svg" 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