Add education to database selection

This commit is contained in:
J-Jamet committed 2018-03-31 21:24:39 +02:00
1 parent 8105f89088
commit 2c9a6d7c26
6 files changed
+69

No files matched your search

@@ -42,6 +42,8 @@ import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.getkeepsafe.taptargetview.TapTarget;
import com.getkeepsafe.taptargetview.TapTargetSequence;
import com.keepassdroid.activities.GroupActivity;
import com.keepassdroid.app.App;
import com.keepassdroid.autofill.AutofillHelper;
@@ -212,8 +214,45 @@ public class FileSelectActivity extends StylishActivity implements
}
}
}
// For the first time show the tuto
if (!PreferencesUtil.isEducationSelectDatabasePerformed(this)) {
new TapTargetSequence(this)
.targets(
TapTarget.forView(findViewById(R.id.create_database),
getString(R.string.education_create_database_title),
getString(R.string.education_create_database_summary))
.tintTarget(false),
TapTarget.forView(findViewById(R.id.browse_button),
getString(R.string.education_select_database_title),
getString(R.string.education_select_database_summary))
.tintTarget(false),
TapTarget.forView(findViewById(R.id.open_database),
getString(R.string.education_open_link_database_title),
getString(R.string.education_open_link_database_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_select_db_key), true);
editor.apply();
}
private void launchPasswordActivityWithPath(String path) {
try {
AssistStructure assistStructure = null;
@@ -33,6 +33,7 @@ import java.util.Set;
public class PreferencesUtil {
private static final String NO_BACKUP_PREFERENCE_FILE_NAME = "nobackup";
private static final String EDUCATION_PREFERENCE = "kdbxeducation";
public static SharedPreferences getNoBackupSharedPreferences(Context ctx) {
return ctx.getSharedPreferences(
@@ -40,6 +41,12 @@ public class PreferencesUtil {
Context.MODE_PRIVATE);
}
public static SharedPreferences getEducationSharedPreferences(Context ctx) {
return ctx.getSharedPreferences(
PreferencesUtil.EDUCATION_PREFERENCE,
Context.MODE_PRIVATE);
}
public static void deleteAllValuesFromNoBackupPreferences(Context ctx) {
SharedPreferences prefsNoBackup = getNoBackupSharedPreferences(ctx);
SharedPreferences.Editor sharedPreferencesEditor = prefsNoBackup.edit();
@@ -137,4 +144,10 @@ public class PreferencesUtil {
return prefs.getBoolean(ctx.getString(R.string.allow_copy_password_key),
ctx.getResources().getBoolean(R.bool.allow_copy_password_default));
}
public static boolean isEducationSelectDatabasePerformed(Context context) {
SharedPreferences prefs = getEducationSharedPreferences(context);
return prefs.getBoolean(context.getString(R.string.education_select_db_key),
context.getResources().getBoolean(R.bool.education_select_db_default));
}
}