diff options
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptOverviewFragment.java | 22 | ||||
-rw-r--r-- | OpenKeychain/src/main/res/values/strings.xml | 1 |
2 files changed, 20 insertions, 3 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptOverviewFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptOverviewFragment.java index 590d02c6f..44ca50e6c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptOverviewFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptOverviewFragment.java @@ -37,6 +37,7 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.ui.util.Notify; +import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.ui.util.SubtleAttentionSeeker; import org.sufficientlysecure.keychain.util.FileHelper; @@ -92,15 +93,30 @@ public class EncryptDecryptOverviewFragment extends Fragment { mDecryptFromClipboard.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent clipboardDecrypt = new Intent(getActivity(), DecryptActivity.class); - clipboardDecrypt.setAction(DecryptActivity.ACTION_DECRYPT_FROM_CLIPBOARD); - startActivityForResult(clipboardDecrypt, 0); + decryptFromClipboard(); } }); return view; } + private void decryptFromClipboard() { + + Activity activity = getActivity(); + if (activity == null) { + return; + } + + final CharSequence clipboardText = ClipboardReflection.getClipboardText(activity); + if (clipboardText == null) { + Notify.create(activity, R.string.error_clipboard_empty, Style.ERROR); + } + + Intent clipboardDecrypt = new Intent(getActivity(), DecryptActivity.class); + clipboardDecrypt.setAction(DecryptActivity.ACTION_DECRYPT_FROM_CLIPBOARD); + startActivityForResult(clipboardDecrypt, 0); + } + @Override public void onResume() { super.onResume(); diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 023fa6f44..873b8f615 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -1352,5 +1352,6 @@ <string name="file_delete_ok">"Original file deleted."</string> <string name="file_delete_none">"No file deleted! (Already deleted?)"</string> <string name="file_delete_exception">"Original file could not be deleted!"</string> + <string name="error_clipboard_empty">"Clipboard is empty!"</string> </resources> |