From 86083f03f5a60074cddb7496bff157b31ce8c2a3 Mon Sep 17 00:00:00 2001 From: Daniël van den Berg Date: Sat, 27 Aug 2016 15:21:21 +0200 Subject: Added the ability to share a password as plaintext using any app, including ones like BluetoothToPc. (#213) --- .../java/com/zeapo/pwdstore/crypto/PgpHandler.java | 28 ++++++++++++++++++++- .../main/res/drawable-hdpi/ic_share_white_24dp.png | Bin 0 -> 397 bytes .../main/res/drawable-mdpi/ic_share_white_24dp.png | Bin 0 -> 268 bytes .../res/drawable-xhdpi/ic_share_white_24dp.png | Bin 0 -> 496 bytes .../res/drawable-xxhdpi/ic_share_white_24dp.png | Bin 0 -> 698 bytes .../res/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 (limited to 'app') 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 399564a1..60599d6d 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 00000000..b09a6926 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png new file mode 100644 index 00000000..e944fd70 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png new file mode 100644 index 00000000..22a8783e Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png new file mode 100644 index 00000000..a35b3cd1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png new file mode 100644 index 00000000..e351c7be Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png differ diff --git a/app/src/main/res/menu/pgp_handler.xml b/app/src/main/res/menu/pgp_handler.xml index fbdef0c2..10cb42fd 100644 --- a/app/src/main/res/menu/pgp_handler.xml +++ b/app/src/main/res/menu/pgp_handler.xml @@ -2,6 +2,11 @@ xmlns:tools="http://schemas.android.com/tools" xmlns:pwstore="http://schemas.android.com/apk/res-auto" tools:context="com.zeapo.pwdstore.crypto.PgpHandler" > + Settings No external repository selected No external repository selected + Send password as plaintext using… -- cgit v1.2.3