From 9822c097cb276aecae3ffa954b5551a5a08de83e Mon Sep 17 00:00:00 2001 From: Johannes Baiter Date: Wed, 29 Oct 2014 11:14:32 +0100 Subject: Automatically copy password to clipboard after decryption --- .../main/java/com/zeapo/pwdstore/crypto/PgpHandler.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (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 7c6c0da8..5397e026 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -145,15 +145,19 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne finish(); return true; case R.id.copy_password: - ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", ((TextView) findViewById(R.id.crypto_password_show)).getText()); - clipboard.setPrimaryClip(clip); - showToast("Password copied to clipboard, you have " - + Integer.parseInt(settings.getString("general_show_time", "45")) - + " seconds to paste it somewhere."); + copyToClipBoard(); } return super.onOptionsItemSelected(item); } + public void copyToClipBoard() { + ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", ((TextView) findViewById(R.id.crypto_password_show)).getText()); + clipboard.setPrimaryClip(clip); + showToast("Password copied to clipboard, you have " + + Integer.parseInt(settings.getString("general_show_time", "45")) + + " seconds to paste it somewhere."); + } + public void handleClick(View view) { switch (view.getId()) { case R.id.crypto_show_button: @@ -313,8 +317,6 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { case OpenPgpApi.RESULT_CODE_SUCCESS: { - showToast("SUCCESS"); - // encrypt/decrypt/sign/verify if (requestCode == REQUEST_CODE_DECRYPT_AND_VERIFY && os != null) { try { @@ -336,6 +338,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne .setText(extraContent); } new DelayShow().execute(); + copyToClipBoard(); } else { showToast(os.toString()); } -- cgit v1.2.3 From 7d4b6683ef446c4a7317fe7cc450533ff18c6061 Mon Sep 17 00:00:00 2001 From: Johannes Baiter Date: Wed, 29 Oct 2014 11:22:16 +0100 Subject: Add option to automatically copy password to clipboard after decryption --- app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java | 4 +++- app/src/main/res/xml/preference.xml | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) (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 5397e026..f2908ebd 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -338,7 +338,9 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne .setText(extraContent); } new DelayShow().execute(); - copyToClipBoard(); + if (settings.getBoolean("copy_on_decrypt", true)) { + copyToClipBoard(); + } } else { showToast(os.toString()); } diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml index 56a16f49..0833ebf8 100644 --- a/app/src/main/res/xml/preference.xml +++ b/app/src/main/res/xml/preference.xml @@ -30,5 +30,9 @@ android:dialogTitle="Set the time you want the password to be in clipboard" android:summary="Set the time you want the password to be in clipboard" android:hint="45" android:key="general_show_time" /> + \ No newline at end of file -- cgit v1.2.3 From 741ce31abb9bcb82262461f9b8ec8101b962e6f0 Mon Sep 17 00:00:00 2001 From: Johannes Baiter Date: Wed, 29 Oct 2014 11:27:48 +0100 Subject: Fix namespaces for showAsAction attributes to icons show in ActioBar --- app/src/main/res/menu/agp_intents.xml | 3 ++- app/src/main/res/menu/git_clone.xml | 3 ++- app/src/main/res/menu/pgp_handler.xml | 3 ++- app/src/main/res/menu/pwdstore.xml | 5 +++-- 4 files changed, 9 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/src/main/res/menu/agp_intents.xml b/app/src/main/res/menu/agp_intents.xml index 591b9525..8aa52dfa 100644 --- a/app/src/main/res/menu/agp_intents.xml +++ b/app/src/main/res/menu/agp_intents.xml @@ -1,8 +1,9 @@ + pwstore:showAsAction="never" /> diff --git a/app/src/main/res/menu/git_clone.xml b/app/src/main/res/menu/git_clone.xml index fa9dbf1c..e414f0b9 100644 --- a/app/src/main/res/menu/git_clone.xml +++ b/app/src/main/res/menu/git_clone.xml @@ -1,8 +1,9 @@ + pwstore:showAsAction="never" /> diff --git a/app/src/main/res/menu/pgp_handler.xml b/app/src/main/res/menu/pgp_handler.xml index f9f88da8..fac4e163 100644 --- a/app/src/main/res/menu/pgp_handler.xml +++ b/app/src/main/res/menu/pgp_handler.xml @@ -1,9 +1,10 @@ diff --git a/app/src/main/res/menu/pwdstore.xml b/app/src/main/res/menu/pwdstore.xml index a3f44f73..7263f226 100644 --- a/app/src/main/res/menu/pwdstore.xml +++ b/app/src/main/res/menu/pwdstore.xml @@ -1,10 +1,11 @@ @@ -17,7 +18,7 @@