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) {
try {
if (returnToCiphertextField) {
findViewById(R.id.crypto_container).setVisibility(View.VISIBLE);
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]);
boolean showPassword = settings.getBoolean("show_password", true);
String extraContent = os.toString("UTF-8").replaceFirst(".*\n", "");
if (extraContent.length() != 0) {
((TextView) findViewById(R.id.crypto_extra_show))
if (showPassword) {
findViewById(R.id.crypto_container).setVisibility(View.VISIBLE);
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_extra_show))
.setText(extraContent);
((TextView) findViewById(R.id.crypto_password_show))
.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)) {
copyToClipBoard();
}

View file

@ -124,5 +124,8 @@
<string name="git_sync">Synchronize repository</string>
<string name="git_pull">Pull from 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>

View file

@ -125,5 +125,8 @@
<string name="git_sync">Synchronize repository</string>
<string name="git_pull">Pull from 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>

View file

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