Add the option for not showing the passwords after decrypt

fixes #90
This commit is contained in:
Mohamed Zenadi 2015-06-17 21:18:26 +02:00
parent bfdccf4d92
commit 1db4f7bbc3
4 changed files with 88 additions and 48 deletions

View file

@ -318,22 +318,29 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
if (requestCode == REQUEST_CODE_DECRYPT_AND_VERIFY && os != null) { if (requestCode == REQUEST_CODE_DECRYPT_AND_VERIFY && os != null) {
try { try {
if (returnToCiphertextField) { if (returnToCiphertextField) {
findViewById(R.id.crypto_container).setVisibility(View.VISIBLE); boolean showPassword = settings.getBoolean("show_password", true);
Typeface type = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf");
String[] passContent = os.toString("UTF-8").split("\n");
((TextView) findViewById(R.id.crypto_password_show))
.setTypeface(type);
((TextView) findViewById(R.id.crypto_password_show))
.setText(passContent[0]);
String extraContent = os.toString("UTF-8").replaceFirst(".*\n", ""); if (showPassword) {
if (extraContent.length() != 0) { findViewById(R.id.crypto_container).setVisibility(View.VISIBLE);
((TextView) findViewById(R.id.crypto_extra_show)) Typeface type = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf");
String[] passContent = os.toString("UTF-8").split("\n");
((TextView) findViewById(R.id.crypto_password_show))
.setTypeface(type); .setTypeface(type);
((TextView) findViewById(R.id.crypto_extra_show)) ((TextView) findViewById(R.id.crypto_password_show))
.setText(extraContent); .setText(passContent[0]);
String extraContent = os.toString("UTF-8").replaceFirst(".*\n", "");
if (extraContent.length() != 0) {
((TextView) findViewById(R.id.crypto_extra_show))
.setTypeface(type);
((TextView) findViewById(R.id.crypto_extra_show))
.setText(extraContent);
}
new DelayShow().execute();
} else {
activity.setResult(RESULT_CANCELED);
activity.finish();
} }
new DelayShow().execute();
if (settings.getBoolean("copy_on_decrypt", true)) { if (settings.getBoolean("copy_on_decrypt", true)) {
copyToClipBoard(); copyToClipBoard();
} }

View file

@ -124,5 +124,8 @@
<string name="git_sync">Synchronize repository</string> <string name="git_sync">Synchronize repository</string>
<string name="git_pull">Pull from remote</string> <string name="git_pull">Pull from remote</string>
<string name="git_push">Push to remote</string> <string name="git_push">Push to remote</string>
<string name="show_password_pref_title">Show the password</string>
<string name="show_password_pref_summary">Control the visibility of the passwords once decrypted, this does not disable the password copy</string>
<string name="toast_password_copied">Password copied into the clipboard</string>
</resources> </resources>

View file

@ -125,5 +125,8 @@
<string name="git_sync">Synchronize repository</string> <string name="git_sync">Synchronize repository</string>
<string name="git_pull">Pull from remote</string> <string name="git_pull">Pull from remote</string>
<string name="git_push">Push to remote</string> <string name="git_push">Push to remote</string>
<string name="show_password_pref_title">Show the password</string>
<string name="show_password_pref_summary">Control the visibility of the passwords once decrypted, this does not disable the password copy</string>
<string name="toast_password_copied">Password copied into the clipboard</string>
</resources> </resources>

View file

@ -1,40 +1,67 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/pref_git_title"> <PreferenceCategory android:title="@string/pref_git_title">
<Preference android:title="@string/pref_edit_server_info" android:key="git_server_info"/> <Preference
<Preference android:title="@string/pref_ssh_title" android:key="ssh_key" /> android:key="git_server_info"
<Preference android:title="@string/pref_git_delete_repo" android:key="git_delete_repo" android:title="@string/pref_edit_server_info" />
android:summary="Deletes local repository"/> <Preference
<CheckBoxPreference android:title="External repository" android:key="git_external" android:key="ssh_key"
android:summary="Use an external password repository"/> android:title="@string/pref_ssh_title" />
<Preference android:title="Select external repository" android:key="pref_select_external" <Preference
android:dependency="git_external"/> android:key="git_delete_repo"
<CheckBoxPreference android:title="Enable git" android:key="git_enabled" android:summary="Deletes local repository"
android:summary="Enable Git" android:enabled="false"/> android:title="@string/pref_git_delete_repo" />
</PreferenceCategory> <CheckBoxPreference
android:key="git_external"
android:summary="Use an external password repository"
android:title="External repository" />
<Preference
android:dependency="git_external"
android:key="pref_select_external"
android:title="Select external repository" />
<CheckBoxPreference
android:enabled="false"
android:key="git_enabled"
android:summary="Enable Git"
android:title="Enable git" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_crypto_title"> <PreferenceCategory android:title="@string/pref_crypto_title">
<org.openintents.openpgp.util.OpenPgpAppPreference <org.openintents.openpgp.util.OpenPgpAppPreference
android:key="openpgp_provider_list" android:title="@string/pref_provider_title" /> android:key="openpgp_provider_list"
<org.openintents.openpgp.util.OpenPgpKeyPreference android:title="@string/pref_provider_title" />
android:key="openpgp_key" android:title="Select key" <org.openintents.openpgp.util.OpenPgpKeyPreference
android:enabled="false"/> android:enabled="false"
<Preference android:title="@string/pref_key_title" android:key="openpgp_key"
android:key="openpgp_key_id_pref" /> android:title="Select key" />
</PreferenceCategory> <Preference
android:key="openpgp_key_id_pref"
android:title="@string/pref_key_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_general_title"> <PreferenceCategory android:title="@string/pref_general_title">
<EditTextPreference android:title="@string/pref_password_title" <EditTextPreference
android:dialogTitle="@string/pref_password_dialog_title" android:defaultValue="45"
android:summary="@string/pref_password_dialog_title" android:dialogTitle="@string/pref_password_dialog_title"
android:defaultValue="45" android:key="general_show_time" android:inputType="number"
android:inputType="number" /> android:key="general_show_time"
<CheckBoxPreference android:title="@string/pref_copy_title" android:summary="@string/pref_password_dialog_title"
android:dialogTitle="@string/pref_copy_dialog_title" android:title="@string/pref_password_title" />
android:summary="@string/pref_copy_dialog_title" <CheckBoxPreference
android:key="copy_on_decrypt" android:defaultValue="true" /> android:defaultValue="true"
<CheckBoxPreference android:title="@string/pref_recursive_filter" android:title="@string/show_password_pref_title"
android:summary="@string/pref_recursive_filter_hint" android:summary="@string/show_password_pref_summary"
android:key="filter_recursively" android:defaultValue="true"/> android:key="show_password" />
</PreferenceCategory> <CheckBoxPreference
android:defaultValue="true"
android:dialogTitle="@string/pref_copy_dialog_title"
android:key="copy_on_decrypt"
android:summary="@string/pref_copy_dialog_title"
android:title="@string/pref_copy_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="filter_recursively"
android:summary="@string/pref_recursive_filter_hint"
android:title="@string/pref_recursive_filter" />
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>