summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorDaniƫl van den Berg <danielvandenberg95@gmail.com>2016-08-27 15:21:21 +0200
committerMohamed Zenadi <zeapo@users.noreply.github.com>2016-08-27 15:21:21 +0200
commit86083f03f5a60074cddb7496bff157b31ce8c2a3 (patch)
tree6ab7109fc184a33b6e8c443ae6bff918bbb9a194 /app/src/main/java
parent4075fddd6005e5bd516e2a5ec43ed28804e8a318 (diff)
Added the ability to share a password as plaintext using any app, including ones like BluetoothToPc. (#213)
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java28
1 files changed, 27 insertions, 1 deletions
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)