From 6ce31056c987b8fd73513d5b4eebc8d0d763a7a2 Mon Sep 17 00:00:00 2001 From: Felix Bechstein Date: Sun, 16 Jul 2017 16:41:47 +0200 Subject: Show extra content w/o copy password, fixes #288 (#317) Show extra content even if password is not copied to clipboard. Add toggle to preferences as well. --- .../main/java/com/zeapo/pwdstore/crypto/PgpHandler.java | 14 ++++++++------ app/src/main/res/values-de/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/preference.xml | 5 +++++ 4 files changed, 17 insertions(+), 6 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 683c2561..232c7b94 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -485,15 +485,18 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne if (requestCode == REQUEST_CODE_DECRYPT_AND_VERIFY && os != null) { try { if (returnToCiphertextField) { - boolean showPassword = settings.getBoolean("show_password", true); + final boolean showPassword = settings.getBoolean("show_password", true); + final boolean showExtraContent = settings.getBoolean("show_extra_content", true); findViewById(R.id.crypto_container).setVisibility(View.VISIBLE); Typeface monoTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf"); - final String[] passContent = os.toString("UTF-8").split("\n"); + final String[] passContent = os.toString("UTF-8").split("\n", 2); + final String decodedPassword = passContent[0]; + final String extraContent = passContent.length > 1 ? passContent[1] : ""; textViewPassword .setTypeface(monoTypeface); textViewPassword - .setText(passContent[0]); + .setText(decodedPassword); Button toggleVisibilityButton = (Button) findViewById(R.id.crypto_password_toggle_show); toggleVisibilityButton.setVisibility(showPassword?View.GONE:View.VISIBLE); @@ -501,13 +504,12 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne @Override public void run() { textViewPassword - .setText(passContent[0]); + .setText(decodedPassword); } })); - decodedPassword = passContent[0]; - String extraContent = os.toString("UTF-8").replaceFirst(".*\n", ""); if (extraContent.length() != 0) { + findViewById(R.id.crypto_extra_show_layout).setVisibility(showExtraContent ? View.VISIBLE : View.GONE); ((TextView) findViewById(R.id.crypto_extra_show)) .setTypeface(monoTypeface); ((TextView) findViewById(R.id.crypto_extra_show)) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 561c9307..6b1161d1 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -171,6 +171,8 @@ Aktualisieren Zeige das Password Soll das entschlüsselte Passwort sichtbar sein? Dies deaktiviert nicht das Kopieren. + Zeige weiteren Inhalt + Soll weiterer Inhalt sichtbar sein? Passwort befindet sich zum Einfügen in der Zwischenablage Generieren "Kategorie: " diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8c5e2102..444bbf08 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -179,6 +179,8 @@ Push to remote Show the password Control the visibility of the passwords once decrypted, this does not disable the password copy + Show extra content + Control the visibility of the extra content once decrypted Password copied into the clipboard Generate "Category: " diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml index ec740836..cd072353 100644 --- a/app/src/main/res/xml/preference.xml +++ b/app/src/main/res/xml/preference.xml @@ -52,6 +52,11 @@ android:title="@string/show_password_pref_title" android:summary="@string/show_password_pref_summary" android:key="show_password" /> +