From cd0d712f5606e13cd12945005acafdbcf0ebd4de Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Sun, 1 Apr 2018 00:37:30 +0200 Subject: [PATCH] Add reset education screens preference --- .../com/keepassdroid/activities/GroupActivity.java | 13 ++++++++++--- .../settings/NestedSettingsFragment.java | 14 ++++++++++++++ .../com/keepassdroid/settings/PreferencesUtil.java | 3 +++ app/src/main/res/values-fr/strings.xml | 3 +++ app/src/main/res/values/donottranslate.xml | 1 + app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/app_preferences.xml | 10 ++++++++++ 7 files changed, 44 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keepassdroid/activities/GroupActivity.java b/app/src/main/java/com/keepassdroid/activities/GroupActivity.java index f4d919b97..f84d69d76 100644 --- a/app/src/main/java/com/keepassdroid/activities/GroupActivity.java +++ b/app/src/main/java/com/keepassdroid/activities/GroupActivity.java @@ -70,6 +70,8 @@ public class GroupActivity extends ListNodesActivity private static final String GROUP_ID_KEY = "GROUP_ID_KEY"; + private Toolbar toolbar; + private AddNodeButtonView addNodeButtonView; protected boolean addGroupEnabled = false; @@ -145,7 +147,7 @@ public class GroupActivity extends ListNodesActivity RecyclerView recyclerView = findViewById(R.id.nodes_list); recyclerView.addOnScrollListener(addNodeButtonView.hideButtonOnScrollListener()); - Toolbar toolbar = findViewById(R.id.toolbar); + toolbar = findViewById(R.id.toolbar); toolbar.setTitle(""); setSupportActionBar(toolbar); @@ -169,8 +171,6 @@ public class GroupActivity extends ListNodesActivity if (isRoot) { showWarnings(); } - - checkAndPerformedEducation(); } protected PwGroup initCurrentGroup() { @@ -261,6 +261,8 @@ public class GroupActivity extends ListNodesActivity super.onResume(); // Show button on resume addNodeButtonView.showButton(); + + checkAndPerformedEducation(); } private void checkAndPerformedEducation() { @@ -272,6 +274,11 @@ public class GroupActivity extends ListNodesActivity getString(R.string.education_new_node_title), getString(R.string.education_new_node_summary)) .tintTarget(false) + /* TODO Search education + TapTarget.forToolbarMenuItem(toolbar, R.id.menu_search, + getString(R.string.education_search_title), + getString(R.string.education_search_summary)) + */ ).listener(new TapTargetSequence.Listener() { @Override public void onSequenceFinish() { diff --git a/app/src/main/java/com/keepassdroid/settings/NestedSettingsFragment.java b/app/src/main/java/com/keepassdroid/settings/NestedSettingsFragment.java index 7a1907b6a..0e24553c4 100644 --- a/app/src/main/java/com/keepassdroid/settings/NestedSettingsFragment.java +++ b/app/src/main/java/com/keepassdroid/settings/NestedSettingsFragment.java @@ -22,6 +22,7 @@ package com.keepassdroid.settings; import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.content.res.Resources; import android.net.Uri; import android.os.Build; @@ -200,6 +201,19 @@ public class NestedSettingsFragment extends PreferenceFragmentCompat return false; }); } + + Preference resetEducationScreens = findPreference(getString(R.string.reset_education_screens_key)); + resetEducationScreens.setOnPreferenceClickListener(preference -> { + SharedPreferences sharedPreferences = PreferencesUtil.getEducationSharedPreferences(getContext()); + SharedPreferences.Editor editor = sharedPreferences.edit(); + for (int resourceId : PreferencesUtil.educationResourceKeys) { + editor.putBoolean(getString(resourceId), false); + } + editor.apply(); + Toast.makeText(getContext(), R.string.reset_education_screens_text, Toast.LENGTH_SHORT).show(); + return false; + }); + break; case NESTED_SCREEN_FORM_FILLING_KEY: diff --git a/app/src/main/java/com/keepassdroid/settings/PreferencesUtil.java b/app/src/main/java/com/keepassdroid/settings/PreferencesUtil.java index 3d35aca64..e3dd78072 100644 --- a/app/src/main/java/com/keepassdroid/settings/PreferencesUtil.java +++ b/app/src/main/java/com/keepassdroid/settings/PreferencesUtil.java @@ -145,6 +145,9 @@ public class PreferencesUtil { ctx.getResources().getBoolean(R.bool.allow_copy_password_default)); } + public static int[] educationResourceKeys = new int[] { + R.string.education_select_db_key, R.string.education_group_key}; + public static boolean isEducationSelectDatabasePerformed(Context context) { SharedPreferences prefs = getEducationSharedPreferences(context); return prefs.getBoolean(context.getString(R.string.education_select_db_key), diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index b2ca89465..52acd5ad9 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -249,6 +249,9 @@ ATTENTION : désactiver cette fonctionnalité peut engendrer une impossibilité d\'ouvrir ou sauvegarder les bases de données Lien du fichier Kdbx à ouvrir + Réinitialise les écrans d\'éducation + Mets en surbrillance les éléments de l\'interface pour apprendre le fonctionnement de l\'application + Ecrans d\'éducation réinitialisés Créez votre fichier de base de données Vous ne connaissez pas encore KeePass DX, créer votre premier fichier de gestion de mots de passe. Ouvrez une base de données existante diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index e986b4d05..46a804220 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -67,6 +67,7 @@ monospace_font_extra_fields_enable_key auto_open_file_uri_key allow_copy_password_key + relaunch_education_screens_key education_select_db_key education_group_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2eb26e729..2ca7fc78d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -250,6 +250,9 @@ WARNING : disabling this feature may result in an inability to open or save the databases Link of the Kdbx file to open + Reset education screens + Highlight the elements of the interface to learn how the application works + Education screens reseted Create your database file You don\'t know KeePass DX yet, create your first password management file. Open an existing database diff --git a/app/src/main/res/xml/app_preferences.xml b/app/src/main/res/xml/app_preferences.xml index dacee0a18..50e36e346 100644 --- a/app/src/main/res/xml/app_preferences.xml +++ b/app/src/main/res/xml/app_preferences.xml @@ -166,4 +166,14 @@ android:defaultValue="@bool/full_file_path_enable_default"/> + + + + + +