Change education for group screen

This commit is contained in:
J-Jamet
2018-04-10 15:18:27 +02:00
parent 2c44a4d760
commit 2e5ddd80ff
8 changed files with 139 additions and 53 deletions

View File

@@ -42,7 +42,7 @@ import android.view.MenuItem;
import android.widget.ImageView;
import com.getkeepsafe.taptargetview.TapTarget;
import com.getkeepsafe.taptargetview.TapTargetSequence;
import com.getkeepsafe.taptargetview.TapTargetView;
import com.kunzisoft.keepass.R;
import com.kunzisoft.keepass.adapters.NodeAdapter;
import com.kunzisoft.keepass.app.App;
@@ -263,55 +263,100 @@ public class GroupActivity extends ListNodesActivity
addNodeButtonView.showButton();
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
boolean parentOnPrepareOptionMenu = super.onPrepareOptionsMenu(menu);
private void checkAndPerformedEducation(Menu menu) {
// Launch education screen
new Handler().post(this::checkAndPerformedEducation);
// If no node, show education to add new one
if (mAdapter.getItemCount() <= 0) {
if (!PreferencesUtil.isEducationNewNodePerformed(this)) {
return parentOnPrepareOptionMenu;
}
private void checkAndPerformedEducation() {
// For the first time show the tuto
if (!PreferencesUtil.isEducationGroupPerformed(this)) {
new TapTargetSequence(this)
.targets(
TapTarget.forToolbarMenuItem(toolbar, R.id.menu_search,
getString(R.string.education_search_title),
getString(R.string.education_search_summary)),
//TapTarget.forToolbarMenuItem(toolbar, R.id.menu_lock,
// getString(R.string.education_lock_title),
// getString(R.string.education_lock_summary)),
//TapTarget.forToolbarMenuItem(toolbar, R.id.menu_sort,
// getString(R.string.education_sort_title),
// getString(R.string.education_sort_summary)),
TapTargetView.showFor(this,
TapTarget.forView(findViewById(R.id.add_button),
getString(R.string.education_new_node_title),
getString(R.string.education_new_node_summary))
.tintTarget(false)
).listener(new TapTargetSequence.Listener() {
.cancelable(true),
new TapTargetView.Listener() {
@Override
public void onSequenceFinish() {
saveEducationPreference();
public void onTargetClick(TapTargetView view) {
super.onTargetClick(view);
addNodeButtonView.openButtonIfClose();
}
});
PreferencesUtil.saveEducationPreference(this,
R.string.education_new_node_key);
}
@Override
public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {}
// Else show the search education
} else if (!PreferencesUtil.isEducationSearchPerformed(this)) {
TapTargetView.showFor(this,
TapTarget.forToolbarMenuItem(toolbar, R.id.menu_search,
getString(R.string.education_search_title),
getString(R.string.education_search_summary))
.tintTarget(true)
.cancelable(true),
new TapTargetView.Listener() {
@Override
public void onSequenceCanceled(TapTarget lastTarget) {}
}).continueOnCancel(true).start();
public void onTargetClick(TapTargetView view) {
super.onTargetClick(view);
MenuItem searchItem = menu.findItem(R.id.menu_search);
searchItem.expandActionView();
}
});
PreferencesUtil.saveEducationPreference(this,
R.string.education_search_key);
// Else show the sort education
} else if (!PreferencesUtil.isEducationSortPerformed(this)) {
try {
TapTargetView.showFor(this,
TapTarget.forToolbarMenuItem(toolbar, R.id.menu_sort,
getString(R.string.education_sort_title),
getString(R.string.education_sort_summary))
.tintTarget(true)
.cancelable(true),
new TapTargetView.Listener() {
@Override
public void onTargetClick(TapTargetView view) {
super.onTargetClick(view);
MenuItem sortItem = menu.findItem(R.id.menu_sort);
onOptionsItemSelected(sortItem);
}
});
PreferencesUtil.saveEducationPreference(this,
R.string.education_sort_key);
} catch (Exception e) {
// If icon not visible
Log.w(TAG, "Can't performed education for sort");
}
private void saveEducationPreference() {
SharedPreferences sharedPreferences = PreferencesUtil.getEducationSharedPreferences(this);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(getString(R.string.education_group_key), true);
editor.apply();
// Else show the lock education
} else if (!PreferencesUtil.isEducationLockPerformed(this)) {
try {
TapTargetView.showFor(this,
TapTarget.forToolbarMenuItem(toolbar, R.id.menu_lock,
getString(R.string.education_lock_title),
getString(R.string.education_lock_summary))
.tintTarget(true)
.cancelable(true),
new TapTargetView.Listener() {
@Override
public void onTargetClick(TapTargetView view) {
super.onTargetClick(view);
MenuItem lockItem = menu.findItem(R.id.menu_lock);
onOptionsItemSelected(lockItem);
}
});
PreferencesUtil.saveEducationPreference(this,
R.string.education_lock_key);
} catch (Exception e) {
// If icon not visible
Log.w(TAG, "Can't performed education for lock");
}
}
}
@Override
@@ -377,6 +422,9 @@ public class GroupActivity extends ListNodesActivity
super.onCreateOptionsMenu(menu);
// Launch education screen
new Handler().post(() -> checkAndPerformedEducation(menu));
return true;
}

View File

@@ -345,6 +345,7 @@ public class PasswordActivity extends StylishActivity
.tintTarget(false);
targets.add(fingerprintTapTarget);
}
// TODO make a period for donation
if (!targets.isEmpty()) {
new TapTargetSequence(this)

View File

@@ -153,7 +153,10 @@ public class PreferencesUtil {
R.string.education_create_db_key,
R.string.education_select_db_key,
R.string.education_open_link_db_key,
R.string.education_group_key,
R.string.education_search_key,
R.string.education_new_node_key,
R.string.education_sort_key,
R.string.education_lock_key,
R.string.education_entry_key,
R.string.education_password_key,
R.string.education_entry_edit_key
@@ -186,10 +189,28 @@ public class PreferencesUtil {
context.getResources().getBoolean(R.bool.education_open_link_db_default));
}
public static boolean isEducationGroupPerformed(Context context) {
public static boolean isEducationSearchPerformed(Context context) {
SharedPreferences prefs = getEducationSharedPreferences(context);
return prefs.getBoolean(context.getString(R.string.education_group_key),
context.getResources().getBoolean(R.bool.education_group_default));
return prefs.getBoolean(context.getString(R.string.education_search_key),
context.getResources().getBoolean(R.bool.education_search_default));
}
public static boolean isEducationNewNodePerformed(Context context) {
SharedPreferences prefs = getEducationSharedPreferences(context);
return prefs.getBoolean(context.getString(R.string.education_new_node_key),
context.getResources().getBoolean(R.bool.education_new_node_default));
}
public static boolean isEducationSortPerformed(Context context) {
SharedPreferences prefs = getEducationSharedPreferences(context);
return prefs.getBoolean(context.getString(R.string.education_sort_key),
context.getResources().getBoolean(R.bool.education_sort_default));
}
public static boolean isEducationLockPerformed(Context context) {
SharedPreferences prefs = getEducationSharedPreferences(context);
return prefs.getBoolean(context.getString(R.string.education_lock_key),
context.getResources().getBoolean(R.bool.education_lock_default));
}
public static boolean isEducationEntryPerformed(Context context) {

View File

@@ -148,6 +148,15 @@ public class AddNodeButtonView extends RelativeLayout {
addButtonView.hide(onAddButtonVisibilityChangedListener);
}
/**
* Start the animation to close the button
*/
public void openButtonIfClose() {
if(state.equals(State.CLOSE)) {
startGlobalAnimation();
}
}
/**
* Start the animation to close the button
*/

View File

@@ -24,5 +24,6 @@
android:title="@string/menu_search"
app:showAsAction="always|collapseActionView"
android:orderInCategory="31"
android:iconifiedByDefault="true"
app:actionViewClass="android.support.v7.widget.SearchView" />
</menu>

View File

@@ -261,9 +261,9 @@
<string name="education_open_link_database_title">Un lien vers l\'emplacement de votre fichier suffit</string>
<string name="education_open_link_database_summary">Vous pouvez aussi ouvrir votre base avec un lien physique. (Avec file:// et content:// par exemple).</string>
<string name="education_new_node_title">Ajoutez de nouveaux éléments à votre base</string>
<string name="education_new_node_summary">Ajoutez des entrées pour gérer vos identités numériques.\nAjoutez des groupes (l\'équivalent des dossiers) pour organiser vos entrées et votre base.</string>
<string name="education_new_node_summary">Ajoutez des entrées pour gérer vos identités numériques.\n\nAjoutez des groupes (l\'équivalent des dossiers) pour organiser vos entrées et votre base.</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_search_summary">Recherchez des entrées par titre, nom d\'utilisateur ou par 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 votre empreinte digitale pour facilement dévérouiller votre base de données.</string>
<string name="education_entry_edit_title">Editez l\'entrée</string>
@@ -279,7 +279,7 @@
<string name="education_field_copy_title">Copiez un champ</string>
<string name="education_field_copy_summary">Copiez un champ facilement dans le presse-papiers pour le coller où vous voulez.</string>
<string name="education_lock_title">Vérouillez la base de données</string>
<string name="education_lock_summary">Verrouillez votre base de données rapidement, vous pouvez paramétrer l\'application pour qu\'elle se verrouille après un certain temps et lorsqu'un écran est éteint.</string>
<string name="education_lock_summary">Verrouillez votre base de données rapidement, vous pouvez paramétrer l\'application pour qu\'elle se verrouille après un certain temps et lorsqu\'un écran est éteint.</string>
<string name="education_sort_title">Triez les éléments</string>
<string name="education_sort_summary">Triez les entrées et les groupes en fonction de paramètres spécifiques.</string>
<string name="education_donation_title">Participez</string>

View File

@@ -76,7 +76,10 @@
<string name="education_create_db_key" translatable="false">education_create_db_key</string>
<string name="education_select_db_key" translatable="false">education_select_db_key</string>
<string name="education_open_link_db_key" translatable="false">education_open_link_db_key</string>
<string name="education_group_key" translatable="false">education_group_key</string>
<string name="education_search_key" translatable="false">education_search_key</string>
<string name="education_new_node_key" translatable="false">education_new_node_key</string>
<string name="education_sort_key" translatable="false">education_sort_key</string>
<string name="education_lock_key" translatable="false">education_lock_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>
@@ -100,7 +103,10 @@
<bool name="education_create_db_default" translatable="false">false</bool>
<bool name="education_select_db_default" translatable="false">false</bool>
<bool name="education_open_link_db_default" translatable="false">false</bool>
<bool name="education_group_default" translatable="false">false</bool>
<bool name="education_search_default" translatable="false">false</bool>
<bool name="education_new_node_default" translatable="false">false</bool>
<bool name="education_sort_default" translatable="false">false</bool>
<bool name="education_lock_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>

View File

@@ -265,7 +265,7 @@
<string name="education_open_link_database_title">A link to the location of your file is sufficient</string>
<string name="education_open_link_database_summary">You can also open your base with a physical link (With file:// and content:// for example).</string>
<string name="education_new_node_title">Add new items to your base</string>
<string name="education_new_node_summary">Add entries to manage your digital identities.\nAdd groups (the equivalent of folders) to organize your entries and your database.</string>
<string name="education_new_node_summary">Add entries to manage your digital identities.\n\nAdd groups (the equivalent of folders) to organize your entries and your database.</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>