Add Copy of password in settings

This commit is contained in:
J-Jamet
2018-03-22 15:48:46 +01:00
parent 3ed5db9819
commit 49ba74c38f
7 changed files with 33 additions and 10 deletions

View File

@@ -165,12 +165,14 @@ public class EntryActivity extends LockingHideActivity {
mEntry.getUsername(),
getResources()));
// Add password to notifications
if (PreferencesUtil.allowCopyPassword(this)) {
if (mEntry.getPassword().length() > 0)
notificationFields.add(
new NotificationField(
NotificationField.NotificationFieldId.PASSWORD,
mEntry.getPassword(),
getResources()));
}
// Add extra fields
if (mEntry.allowExtraFields()) {
try {
@@ -219,10 +221,12 @@ public class EntryActivity extends LockingHideActivity {
);
entryContentsView.assignPassword(mEntry.getPassword(true, pm));
if (PreferencesUtil.allowCopyPassword(this)) {
entryContentsView.assignPasswordCopyListener(view ->
clipboardHelper.timeoutCopyToClipboard(mEntry.getPassword(true, App.getDB().pm),
getString(R.string.copy_field, getString(R.string.entry_password)))
);
}
entryContentsView.assignURL(mEntry.getUrl(true, pm));

View File

@@ -131,4 +131,10 @@ public class PreferencesUtil {
return prefs.getBoolean(ctx.getString(R.string.auto_open_file_uri_key),
ctx.getResources().getBoolean(R.bool.auto_open_file_uri_default));
}
public static boolean allowCopyPassword(Context ctx) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
return prefs.getBoolean(ctx.getString(R.string.allow_copy_password_key),
ctx.getResources().getBoolean(R.bool.allow_copy_password_default));
}
}

View File

@@ -130,6 +130,7 @@ public class EntryContentsView extends LinearLayout {
passwordView.setText(password);
if (fontInVisibility)
Util.applyFontVisibilityTo(passwordView);
passwordActionView.setVisibility(GONE);
} else {
passwordContainerView.setVisibility(GONE);
}
@@ -137,6 +138,7 @@ public class EntryContentsView extends LinearLayout {
public void assignPasswordCopyListener(OnClickListener onClickListener) {
passwordActionView.setOnClickListener(onClickListener);
passwordActionView.setVisibility(VISIBLE);
}
public boolean isPasswordPresent() {

View File

@@ -243,6 +243,8 @@
<string name="monospace_font_fields_enable_summary">Change la police de caractères des champs pour une meilleure visibilité</string>
<string name="auto_open_file_uri_title">Ouvrir le fichier sélectionné automatiquement</string>
<string name="auto_open_file_uri_summary">Ouvrir automatiquement un fichier à partir de l\'écran de sélection après une sélection dans le navigateur de fichiers</string>
<string name="allow_copy_password_title">Copie de mot de passe</string>
<string name="allow_copy_password_summary">Autoriser la copie du mot de passe dans le presse-papiers. Attention: ceci est connu comme un défaut de sécurité</string>
<string-array name="clipboard_timeout_options">
<item>5 secondes</item>

View File

@@ -66,6 +66,7 @@
<string name="recycle_bin_key" translatable="true">recycle_bin_key</string>
<string name="monospace_font_fields_enable_key" translatable="true">monospace_font_extra_fields_enable_key</string>
<string name="auto_open_file_uri_key" translatable="true">auto_open_file_uri_key</string>
<string name="allow_copy_password_key" translatable="false">allow_copy_password_key</string>
<bool name="maskpass_default" translatable="false">true</bool>
<bool name="keyfile_default" translatable="false">true</bool>
@@ -82,6 +83,7 @@
<bool name="sort_recycle_bin_bottom_default" translatable="true">true</bool>
<bool name="monospace_font_fields_enable_default" translatable="true">true</bool>
<bool name="auto_open_file_uri_default" translatable="true">true</bool>
<bool name="allow_copy_password_default" translatable="true">true</bool> <!-- TODO To change after implementing the way to enter password < O -->
<string name="clipboard_timeout_default" translatable="false">300000</string>
<string-array name="clipboard_timeout_values">

View File

@@ -244,6 +244,8 @@
<string name="monospace_font_fields_enable_summary">Change the font of the fields for better character visibility</string>
<string name="auto_open_file_uri_title">Auto open selected file</string>
<string name="auto_open_file_uri_summary">Automatically open a file from the selection screen after a selection in the file browser</string>
<string name="allow_copy_password_title">Copy of password</string>
<string name="allow_copy_password_summary">Allow the copy of the password to the clipboard. Warning: this is known as a security defect</string>
<string-array name="clipboard_timeout_options">
<item>5 seconds</item>

View File

@@ -80,6 +80,11 @@
android:title="@string/maskpass_title"
android:summary="@string/maskpass_summary"
android:defaultValue="@bool/maskpass_default"/>
<SwitchPreference
android:key="@string/allow_copy_password_key"
android:title="@string/allow_copy_password_title"
android:summary="@string/allow_copy_password_summary"
android:defaultValue="@bool/allow_copy_password_default"/>
</PreferenceCategory>