mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add entry edit screens preference
This commit is contained in:
@@ -23,6 +23,7 @@ package com.keepassdroid.activities;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
@@ -35,6 +36,8 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.getkeepsafe.taptargetview.TapTarget;
|
||||
import com.getkeepsafe.taptargetview.TapTargetSequence;
|
||||
import com.keepassdroid.app.App;
|
||||
import com.keepassdroid.database.Database;
|
||||
import com.keepassdroid.database.ExtraFields;
|
||||
@@ -66,6 +69,7 @@ public class EntryActivity extends LockingHideActivity {
|
||||
private ImageView titleIconView;
|
||||
private TextView titleView;
|
||||
private EntryContentsView entryContentsView;
|
||||
private View editView;
|
||||
|
||||
protected PwEntry mEntry;
|
||||
private boolean mShowPassword;
|
||||
@@ -128,17 +132,49 @@ public class EntryActivity extends LockingHideActivity {
|
||||
entryContentsView.applyFontVisibilityToFields(PreferencesUtil.fieldFontIsInVisibility(this));
|
||||
|
||||
// Setup Edit Buttons
|
||||
View edit = findViewById(R.id.entry_edit);
|
||||
edit.setOnClickListener(v -> EntryEditActivity.Launch(EntryActivity.this, mEntry));
|
||||
editView = findViewById(R.id.entry_edit);
|
||||
editView.setOnClickListener(v -> EntryEditActivity.Launch(EntryActivity.this, mEntry));
|
||||
if (readOnly) {
|
||||
edit.setVisibility(View.GONE);
|
||||
editView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Init the clipboard helper
|
||||
clipboardHelper = new ClipboardHelper(this);
|
||||
firstLaunchOfActivity = true;
|
||||
|
||||
checkAndPerformedEducation();
|
||||
}
|
||||
|
||||
private void checkAndPerformedEducation() {
|
||||
if (!PreferencesUtil.isEducationEntryPerformed(this)) {
|
||||
new TapTargetSequence(this)
|
||||
.targets(
|
||||
TapTarget.forView(editView,
|
||||
getString(R.string.education_entry_edit_title),
|
||||
getString(R.string.education_entry_edit_summary))
|
||||
.tintTarget(false)
|
||||
).listener(new TapTargetSequence.Listener() {
|
||||
@Override
|
||||
public void onSequenceFinish() {
|
||||
saveEducationPreference();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {}
|
||||
|
||||
@Override
|
||||
public void onSequenceCanceled(TapTarget lastTarget) {}
|
||||
}).continueOnCancel(true).start();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveEducationPreference() {
|
||||
SharedPreferences sharedPreferences = PreferencesUtil.getEducationSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(getString(R.string.education_entry_key), true);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.keepassdroid.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
@@ -36,6 +37,8 @@ import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.getkeepsafe.taptargetview.TapTarget;
|
||||
import com.getkeepsafe.taptargetview.TapTargetSequence;
|
||||
import com.keepassdroid.app.App;
|
||||
import com.keepassdroid.database.Database;
|
||||
import com.keepassdroid.database.PwDatabase;
|
||||
@@ -60,6 +63,8 @@ import com.keepassdroid.utils.Util;
|
||||
import com.keepassdroid.view.EntryEditCustomField;
|
||||
import com.kunzisoft.keepass.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EntryEditActivity extends LockingHideActivity
|
||||
@@ -90,8 +95,11 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
private EditText entryUrlView;
|
||||
private EditText entryPasswordView;
|
||||
private EditText entryConfirmationPasswordView;
|
||||
private View generatePasswordView;
|
||||
private EditText entryCommentView;
|
||||
private ViewGroup entryExtraFieldsContainer;
|
||||
private View addNewFieldView;
|
||||
private View saveView;
|
||||
|
||||
/**
|
||||
* launch EntryEditActivity to update an existing entry
|
||||
@@ -170,15 +178,15 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
IconPickerDialogFragment.launch(EntryEditActivity.this));
|
||||
|
||||
// Generate password button
|
||||
View generatePassword = findViewById(R.id.generate_button);
|
||||
generatePassword.setOnClickListener(v -> {
|
||||
generatePasswordView = findViewById(R.id.generate_button);
|
||||
generatePasswordView.setOnClickListener(v -> {
|
||||
GeneratePasswordDialogFragment generatePasswordDialogFragment = new GeneratePasswordDialogFragment();
|
||||
generatePasswordDialogFragment.show(getSupportFragmentManager(), "PasswordGeneratorFragment");
|
||||
});
|
||||
|
||||
// Save button
|
||||
View save = findViewById(R.id.entry_save);
|
||||
save.setOnClickListener(v -> {
|
||||
saveView = findViewById(R.id.entry_save);
|
||||
saveView.setOnClickListener(v -> {
|
||||
if (!validateBeforeSaving()) {
|
||||
return;
|
||||
}
|
||||
@@ -198,9 +206,9 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
|
||||
|
||||
if (mEntry.allowExtraFields()) {
|
||||
View add = findViewById(R.id.add_new_field);
|
||||
add.setVisibility(View.VISIBLE);
|
||||
add.setOnClickListener(v -> {
|
||||
addNewFieldView = findViewById(R.id.add_new_field);
|
||||
addNewFieldView.setVisibility(View.VISIBLE);
|
||||
addNewFieldView.setOnClickListener(v -> {
|
||||
EntryEditCustomField ees = new EntryEditCustomField(EntryEditActivity.this);
|
||||
ees.setData("", new ProtectedString(false, ""));
|
||||
entryExtraFieldsContainer.addView(ees);
|
||||
@@ -209,7 +217,58 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
scrollView.post(() -> scrollView.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
});
|
||||
}
|
||||
|
||||
checkAndPerformedEducation();
|
||||
}
|
||||
|
||||
private void checkAndPerformedEducation() {
|
||||
// For the first time show the tuto
|
||||
if (!PreferencesUtil.isEducationEntryEditPerformed(this)) {
|
||||
|
||||
List<TapTarget> tapTargets = new ArrayList<>();
|
||||
|
||||
TapTarget generatePasswordTapTarget = TapTarget.forView(generatePasswordView,
|
||||
getString(R.string.education_generate_password_title),
|
||||
getString(R.string.education_generate_password_summary))
|
||||
.tintTarget(false);
|
||||
tapTargets.add(generatePasswordTapTarget);
|
||||
|
||||
if (mEntry.allowExtraFields()) {
|
||||
TapTarget newCustomFieldTapTarget = TapTarget.forView(addNewFieldView,
|
||||
getString(R.string.education_entry_new_field_title),
|
||||
getString(R.string.education_entry_new_field_summary))
|
||||
.tintTarget(false);
|
||||
tapTargets.add(newCustomFieldTapTarget);
|
||||
}
|
||||
|
||||
TapTarget saveTapTarget = TapTarget.forView(saveView,
|
||||
getString(R.string.education_entry_save_title),
|
||||
getString(R.string.education_entry_save_summary))
|
||||
.tintTarget(false);
|
||||
tapTargets.add(saveTapTarget);
|
||||
|
||||
new TapTargetSequence(this)
|
||||
.targets(tapTargets).listener(new TapTargetSequence.Listener() {
|
||||
@Override
|
||||
public void onSequenceFinish() {
|
||||
saveEducationPreference();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {}
|
||||
|
||||
@Override
|
||||
public void onSequenceCanceled(TapTarget lastTarget) {}
|
||||
}).continueOnCancel(true).start();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveEducationPreference() {
|
||||
SharedPreferences sharedPreferences = PreferencesUtil.getEducationSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(getString(R.string.education_entry_edit_key), true);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
protected boolean validateBeforeSaving() {
|
||||
// Require title
|
||||
|
||||
@@ -89,6 +89,9 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
|
||||
private FileSelectAdapter mAdapter;
|
||||
private View fileListTitle;
|
||||
private View createButtonView;
|
||||
private View browseButtonView;
|
||||
private View openButtonView;
|
||||
|
||||
private RecentFileHistory fileHistory;
|
||||
|
||||
@@ -161,8 +164,8 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
}
|
||||
|
||||
// Open button
|
||||
View openButton = findViewById(R.id.open_database);
|
||||
openButton.setOnClickListener(v -> {
|
||||
openButtonView = findViewById(R.id.open_database);
|
||||
openButtonView.setOnClickListener(v -> {
|
||||
String fileName = openFileNameView.getText().toString();
|
||||
if (fileName.isEmpty())
|
||||
fileName = defaultPath;
|
||||
@@ -170,15 +173,15 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
});
|
||||
|
||||
// Create button
|
||||
View createButton = findViewById(R.id.create_database);
|
||||
createButton.setOnClickListener(v ->
|
||||
createButtonView = findViewById(R.id.create_database);
|
||||
createButtonView .setOnClickListener(v ->
|
||||
FileSelectActivityPermissionsDispatcher
|
||||
.openCreateFileDialogFragmentWithPermissionCheck(FileSelectActivity.this)
|
||||
);
|
||||
|
||||
keyFileHelper = new KeyFileHelper(this);
|
||||
View browseButton = findViewById(R.id.browse_button);
|
||||
browseButton.setOnClickListener(keyFileHelper.getOpenFileOnClickViewListener(
|
||||
browseButtonView = findViewById(R.id.browse_button);
|
||||
browseButtonView.setOnClickListener(keyFileHelper.getOpenFileOnClickViewListener(
|
||||
() -> Uri.parse("file://" + openFileNameView.getText().toString())));
|
||||
|
||||
// Construct adapter with listeners
|
||||
@@ -224,15 +227,15 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
if (!PreferencesUtil.isEducationSelectDatabasePerformed(this)) {
|
||||
new TapTargetSequence(this)
|
||||
.targets(
|
||||
TapTarget.forView(findViewById(R.id.create_database),
|
||||
TapTarget.forView(createButtonView,
|
||||
getString(R.string.education_create_database_title),
|
||||
getString(R.string.education_create_database_summary))
|
||||
.tintTarget(false),
|
||||
TapTarget.forView(findViewById(R.id.browse_button),
|
||||
TapTarget.forView(browseButtonView,
|
||||
getString(R.string.education_select_database_title),
|
||||
getString(R.string.education_select_database_summary))
|
||||
.tintTarget(false),
|
||||
TapTarget.forView(findViewById(R.id.open_database),
|
||||
TapTarget.forView(openButtonView,
|
||||
getString(R.string.education_open_link_database_title),
|
||||
getString(R.string.education_open_link_database_summary))
|
||||
.tintTarget(false)
|
||||
|
||||
@@ -45,9 +45,12 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.getkeepsafe.taptargetview.TapTarget;
|
||||
import com.getkeepsafe.taptargetview.TapTargetSequence;
|
||||
import com.keepassdroid.activities.GroupActivity;
|
||||
import com.keepassdroid.activities.LockingActivity;
|
||||
import com.keepassdroid.app.App;
|
||||
@@ -73,6 +76,8 @@ import com.kunzisoft.keepass.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import permissions.dispatcher.NeedsPermission;
|
||||
import permissions.dispatcher.OnNeverAskAgain;
|
||||
@@ -111,6 +116,7 @@ public class PasswordActivity extends StylishActivity
|
||||
private View fingerprintContainerView;
|
||||
private FingerPrintAnimatedVector fingerPrintAnimatedVector;
|
||||
private TextView fingerprintTextView;
|
||||
private ImageView fingerprintImageView;
|
||||
private TextView filenameView;
|
||||
private EditText passwordView;
|
||||
private EditText keyFileView;
|
||||
@@ -285,15 +291,57 @@ public class PasswordActivity extends StylishActivity
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
fingerprintContainerView = findViewById(R.id.fingerprint_container);
|
||||
fingerprintTextView = findViewById(R.id.fingerprint_label);
|
||||
fingerprintImageView = findViewById(R.id.fingerprint_image);
|
||||
initForFingerprint();
|
||||
fingerPrintAnimatedVector = new FingerPrintAnimatedVector(this,
|
||||
findViewById(R.id.fingerprint_image));
|
||||
fingerprintImageView);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
autofillHelper = new AutofillHelper();
|
||||
autofillHelper.retrieveAssistStructure(getIntent());
|
||||
}
|
||||
|
||||
checkAndPerformedEducation();
|
||||
}
|
||||
|
||||
private void checkAndPerformedEducation() {
|
||||
// For the first time show the tuto
|
||||
if (!PreferencesUtil.isEducationPasswordPerformed(this)) {
|
||||
|
||||
List<TapTarget> targets = new ArrayList<>();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
TapTarget fingerprintTapTarget = TapTarget.forView(fingerprintImageView,
|
||||
getString(R.string.education_fingerprint_title),
|
||||
getString(R.string.education_fingerprint_summary))
|
||||
.tintTarget(false);
|
||||
targets.add(fingerprintTapTarget);
|
||||
}
|
||||
|
||||
if (!targets.isEmpty()) {
|
||||
new TapTargetSequence(this)
|
||||
.targets(targets).listener(new TapTargetSequence.Listener() {
|
||||
@Override
|
||||
public void onSequenceFinish() {
|
||||
saveEducationPreference();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {}
|
||||
|
||||
@Override
|
||||
public void onSequenceCanceled(TapTarget lastTarget) {}
|
||||
}).continueOnCancel(true).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveEducationPreference() {
|
||||
SharedPreferences sharedPreferences = PreferencesUtil.getEducationSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(getString(R.string.education_password_key), true);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -146,7 +146,9 @@ public class PreferencesUtil {
|
||||
}
|
||||
|
||||
public static int[] educationResourceKeys = new int[] {
|
||||
R.string.education_select_db_key, R.string.education_group_key};
|
||||
R.string.education_select_db_key, R.string.education_group_key, R.string.education_entry_key,
|
||||
R.string.education_password_key, R.string.education_entry_edit_key
|
||||
};
|
||||
|
||||
public static boolean isEducationSelectDatabasePerformed(Context context) {
|
||||
SharedPreferences prefs = getEducationSharedPreferences(context);
|
||||
@@ -159,4 +161,22 @@ public class PreferencesUtil {
|
||||
return prefs.getBoolean(context.getString(R.string.education_group_key),
|
||||
context.getResources().getBoolean(R.bool.education_group_default));
|
||||
}
|
||||
|
||||
public static boolean isEducationEntryPerformed(Context context) {
|
||||
SharedPreferences prefs = getEducationSharedPreferences(context);
|
||||
return prefs.getBoolean(context.getString(R.string.education_entry_key),
|
||||
context.getResources().getBoolean(R.bool.education_entry_default));
|
||||
}
|
||||
|
||||
public static boolean isEducationPasswordPerformed(Context context) {
|
||||
SharedPreferences prefs = getEducationSharedPreferences(context);
|
||||
return prefs.getBoolean(context.getString(R.string.education_password_key),
|
||||
context.getResources().getBoolean(R.bool.education_password_default));
|
||||
}
|
||||
|
||||
public static boolean isEducationEntryEditPerformed(Context context) {
|
||||
SharedPreferences prefs = getEducationSharedPreferences(context);
|
||||
return prefs.getBoolean(context.getString(R.string.education_entry_edit_key),
|
||||
context.getResources().getBoolean(R.bool.education_entry_default));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,6 +262,16 @@
|
||||
<string name="education_new_node_summary">Ajouter des groupes (l\'équivalent des dossiers) pour organiser votre base.\nAjouter des entrées pour gérer vos identités numériques.</string>
|
||||
<string name="education_search_title">Recherchez facilement vos entrées</string>
|
||||
<string name="education_search_summary">Recherchez des entrées par titre, nom d\'utilisateur ou d\'autres champs pour récupérer facilement vos mots de passes.</string>
|
||||
<string name="education_fingerprint_title">Débloquez votre base de données avec votre empreinte digitale</string>
|
||||
<string name="education_fingerprint_summary">Faites le lien entre votre mot de passe et empreinte digitale pour facilement dévérouillez votre base de données.</string>
|
||||
<string name="education_entry_edit_title">Editez l\'entrée</string>
|
||||
<string name="education_entry_edit_summary">Editez votre entrée avec des champs customisés, vous pouvez ajouter des références pour mutualiser les données entre les champs de différentes entrées.</string>
|
||||
<string name="education_generate_password_title">Créez un mot de passe fort</string>
|
||||
<string name="education_generate_password_summary">Générez un mot de passe fort à associer avec votre entrée, ajoutez facilement tous les critères du formulaire et n\'oubliez plus un mot de passe difficile mais sécurisé.</string>
|
||||
<string name="education_entry_new_field_title">Ajoutez des champs customisés</string>
|
||||
<string name="education_entry_new_field_summary">Vous voulez enregistrer un champ non fourni de base, renseignez simplement un nouveau champ que vous pouvez protéger.</string>
|
||||
<string name="education_entry_save_title">Sauvegardez votre entrée</string>
|
||||
<string name="education_entry_save_summary">Sauvegardez votre entrée ici une fois que tous les champs voulus sont remplis.</string>
|
||||
|
||||
<string-array name="timeout_options">
|
||||
<item>5 secondes</item>
|
||||
|
||||
@@ -70,6 +70,9 @@
|
||||
<string name="reset_education_screens_key" translatable="false">relaunch_education_screens_key</string>
|
||||
<string name="education_select_db_key" translatable="false">education_select_db_key</string>
|
||||
<string name="education_group_key" translatable="false">education_group_key</string>
|
||||
<string name="education_entry_key" translatable="false">education_entry_key</string>
|
||||
<string name="education_password_key" translatable="false">education_password_key</string>
|
||||
<string name="education_entry_edit_key" translatable="false">education_entry_edit_key</string>
|
||||
|
||||
<bool name="maskpass_default" translatable="false">true</bool>
|
||||
<bool name="keyfile_default" translatable="false">true</bool>
|
||||
@@ -89,6 +92,9 @@
|
||||
<bool name="allow_copy_password_default" translatable="false">true</bool> <!-- TODO To change after implementing the way to enter password < O -->
|
||||
<bool name="education_select_db_default" translatable="false">false</bool>
|
||||
<bool name="education_group_default" translatable="false">false</bool>
|
||||
<bool name="education_entry_default" translatable="false">false</bool>
|
||||
<bool name="education_password_default" translatable="false">false</bool>
|
||||
<bool name="education_entry_edit_default" translatable="false">false</bool>
|
||||
|
||||
<string name="app_timeout_default" translatable="false">300000</string>
|
||||
<string name="clipboard_timeout_default" translatable="false">60000</string>
|
||||
|
||||
@@ -263,6 +263,16 @@
|
||||
<string name="education_new_node_summary">Add groups (the equivalent of folders) to organize your database.\nAdd entries to manage your digital identities.</string>
|
||||
<string name="education_search_title">Easily search your entries</string>
|
||||
<string name="education_search_summary">Search for entries by title, username or other fields to easily retrieve your passwords.</string>
|
||||
<string name="education_fingerprint_title">Unlock your database with your fingerprint</string>
|
||||
<string name="education_fingerprint_summary">Make the link between your password and your fingerprint to easily unlock your database.</string>
|
||||
<string name="education_entry_edit_title">Edit the entry</string>
|
||||
<string name="education_entry_edit_summary">Edit your entry with custom fields, you can add references to pool data between fields of different entries.</string>
|
||||
<string name="education_generate_password_title">Create a strong password</string>
|
||||
<string name="education_generate_password_summary">Generate a strong password to associate with your entry, easily add all the criteria of the form and don\'t forget a hard but secure password.</string>
|
||||
<string name="education_entry_new_field_title">Add custom fields</string>
|
||||
<string name="education_entry_new_field_summary">You want to register a basic non-supplied field, just fill in a new field that you can protect.</string>
|
||||
<string name="education_entry_save_title">Save you entry</string>
|
||||
<string name="education_entry_save_summary">Save your entry here once all the desired fields are filled</string>
|
||||
|
||||
<string-array name="timeout_options">
|
||||
<item>5 seconds</item>
|
||||
|
||||
Reference in New Issue
Block a user