From 86083f03f5a60074cddb7496bff157b31ce8c2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20den=20Berg?= Date: Sat, 27 Aug 2016 15:21:21 +0200 Subject: [PATCH] Added the ability to share a password as plaintext using any app, including ones like BluetoothToPc. (#213) --- .../com/zeapo/pwdstore/crypto/PgpHandler.java | 28 +++++++++++++++++- .../res/drawable-hdpi/ic_share_white_24dp.png | Bin 0 -> 397 bytes .../res/drawable-mdpi/ic_share_white_24dp.png | Bin 0 -> 268 bytes .../drawable-xhdpi/ic_share_white_24dp.png | Bin 0 -> 496 bytes .../drawable-xxhdpi/ic_share_white_24dp.png | Bin 0 -> 698 bytes .../drawable-xxxhdpi/ic_share_white_24dp.png | Bin 0 -> 938 bytes app/src/main/res/menu/pgp_handler.xml | 5 ++++ app/src/main/res/values/strings.xml | 1 + 8 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_share_white_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_share_white_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java index 399564a17..60599d6df 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -147,6 +147,9 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne case R.id.copy_password: copyToClipBoard(); break; + case R.id.share_password_as_plaintext: + shareAsPlaintext(); + break; case R.id.edit_password: editPassword(); break; @@ -200,12 +203,35 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne invalidateOptionsMenu(); } + public void shareAsPlaintext() { + + if (findViewById(R.id.share_password_as_plaintext) == null) + return; + + final TextView cryptoPasswordShow = (TextView) findViewById(R.id.crypto_password_show); + if (cryptoPasswordShow == null) { + return; + } + final CharSequence text = cryptoPasswordShow.getText(); + + Intent sendIntent = new Intent(); + sendIntent.setAction(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_TEXT, text); + sendIntent.setType("text/plain"); + startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_plaintext_password_to)));//Always show a picker to give the user a chance to cancel + } + public void copyToClipBoard() { if (findViewById(R.id.crypto_password_show) == null) return; - ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", ((TextView) findViewById(R.id.crypto_password_show)).getText()); + final TextView cryptoPasswordShow = (TextView) findViewById(R.id.crypto_password_show); + if (cryptoPasswordShow == null) { + return; + } + + ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", cryptoPasswordShow.getText()); clipboard.setPrimaryClip(clip); try { showToast(this.getResources().getString(R.string.clipboard_beginning_toast_text) diff --git a/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..b09a6926de5aa48dee59265aadac32da236f9e1c GIT binary patch literal 397 zcmV;80doF{P)>pxai;{B2*!N!D>LzNpR^R2)fik{R2|aH0bP5 z*MdarD7a}-Ez;H;8^R0acFB7?>Nyer70h^N-MY7?BcJR3C~UbFc^uKRQ`h0hp&@lM za=0&bFUnK#Sn5WUrS5~&57j8c2`}{x^lU0@xf-K$z+Gzw`kpzeuI-nfmQ2OyT(N5C zy>l@-b#t1gVw*GChQ69riBYL)DYQJYY2deq4n`STc6((!%2Aj4=wg&-PHHZ4XiD9R z9L`I1T#6jpc6)6i%2KtYuxQ?fferHxMOo@@yJIr8nefKYHw~583zvN|v}`i=!hTIX z1AQ+XH*Uda9ScrJS&n(GZ(vPNp{o|$QBEc|F(1{8;NsTa>qG@_iujyHwlsAj>Z++)F8i@ z;dr8?qTnEc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+(gP_7Qy#3 + Settings No external repository selected No external repository selected + Send password as plaintext using…