mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Change education for database selection
This commit is contained in:
@@ -43,7 +43,7 @@ import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.getkeepsafe.taptargetview.TapTarget;
|
||||
import com.getkeepsafe.taptargetview.TapTargetSequence;
|
||||
import com.getkeepsafe.taptargetview.TapTargetView;
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.activities.GroupActivity;
|
||||
import com.kunzisoft.keepass.app.App;
|
||||
@@ -217,6 +217,10 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// For the first time show the tuto
|
||||
checkAndPerformedEducation(savedInstanceState);
|
||||
}
|
||||
|
||||
private void launchPasswordActivityWithPath(String path) {
|
||||
@@ -258,50 +262,76 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
fileNameView.updateExternalStorageWarning();
|
||||
updateTitleFileListView();
|
||||
mAdapter.notifyDataSetChanged();
|
||||
|
||||
|
||||
// For the first time show the tuto
|
||||
checkAndPerformedEducation();
|
||||
}
|
||||
|
||||
private void checkAndPerformedEducation() {
|
||||
if (!PreferencesUtil.isEducationSelectDatabasePerformed(this)) {
|
||||
new TapTargetSequence(this)
|
||||
.targets(
|
||||
TapTarget.forView(createButtonView,
|
||||
getString(R.string.education_create_database_title),
|
||||
getString(R.string.education_create_database_summary))
|
||||
.tintTarget(false),
|
||||
TapTarget.forView(browseButtonView,
|
||||
getString(R.string.education_select_database_title),
|
||||
getString(R.string.education_select_database_summary))
|
||||
.tintTarget(false),
|
||||
TapTarget.forView(openButtonView,
|
||||
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();
|
||||
}
|
||||
private void checkAndPerformedEducation(Bundle savedInstanceState) {
|
||||
|
||||
@Override
|
||||
public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {}
|
||||
// If no recent files
|
||||
if ( !fileHistory.hasRecentFiles() ) {
|
||||
// Try to open the creation base education
|
||||
if (!PreferencesUtil.isEducationSelectDatabasePerformed(this) ) {
|
||||
|
||||
@Override
|
||||
public void onSequenceCanceled(TapTarget lastTarget) {}
|
||||
}).continueOnCancel(true).start();
|
||||
TapTargetView.showFor(this,
|
||||
TapTarget.forView(createButtonView,
|
||||
getString(R.string.education_create_database_title),
|
||||
getString(R.string.education_create_database_summary))
|
||||
.tintTarget(false)
|
||||
.cancelable(true),
|
||||
new TapTargetView.Listener() {
|
||||
@Override
|
||||
public void onTargetClick(TapTargetView view) {
|
||||
super.onTargetClick(view);
|
||||
FileSelectActivityPermissionsDispatcher
|
||||
.openCreateFileDialogFragmentWithPermissionCheck(FileSelectActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTargetCancel(TapTargetView view) {
|
||||
super.onTargetCancel(view);
|
||||
// But if the user cancel, it can also select a database
|
||||
TapTargetView.showFor(FileSelectActivity.this,
|
||||
TapTarget.forView(browseButtonView,
|
||||
getString(R.string.education_select_database_title),
|
||||
getString(R.string.education_select_database_summary))
|
||||
.tintTarget(false)
|
||||
.cancelable(true),
|
||||
new TapTargetView.Listener() {
|
||||
@Override
|
||||
public void onTargetClick(TapTargetView view) {
|
||||
super.onTargetClick(view);
|
||||
keyFileHelper.getOpenFileOnClickViewListener().onClick(view);
|
||||
}
|
||||
});
|
||||
PreferencesUtil.saveEducationPreference(FileSelectActivity.this,
|
||||
R.string.education_select_db_key);
|
||||
}
|
||||
});
|
||||
PreferencesUtil.saveEducationPreference(FileSelectActivity.this,
|
||||
R.string.education_create_db_key);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!PreferencesUtil.isEducationOpenLinkDatabasePerformed(this) ) {
|
||||
|
||||
TapTargetView.showFor(FileSelectActivity.this,
|
||||
TapTarget.forView(openButtonView,
|
||||
getString(R.string.education_open_link_database_title),
|
||||
getString(R.string.education_open_link_database_summary))
|
||||
.tintTarget(false)
|
||||
.cancelable(true),
|
||||
new TapTargetView.Listener() {
|
||||
@Override
|
||||
public void onTargetClick(TapTargetView view) {
|
||||
super.onTargetClick(view);
|
||||
// Do nothing here
|
||||
}
|
||||
});
|
||||
PreferencesUtil.saveEducationPreference(FileSelectActivity.this,
|
||||
R.string.education_open_link_db_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
@@ -145,17 +145,47 @@ public class PreferencesUtil {
|
||||
ctx.getResources().getBoolean(R.bool.allow_copy_password_default));
|
||||
}
|
||||
|
||||
/**
|
||||
* Education Preferences
|
||||
*/
|
||||
|
||||
public static int[] educationResourceKeys = new int[] {
|
||||
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
|
||||
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_entry_key,
|
||||
R.string.education_password_key,
|
||||
R.string.education_entry_edit_key
|
||||
};
|
||||
|
||||
public static void saveEducationPreference(Context context, int... educationKeys) {
|
||||
SharedPreferences sharedPreferences = PreferencesUtil.getEducationSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
for (int key : educationKeys) {
|
||||
editor.putBoolean(context.getString(key), true);
|
||||
}
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static boolean isEducationCreateDatabasePerformed(Context context) {
|
||||
SharedPreferences prefs = getEducationSharedPreferences(context);
|
||||
return prefs.getBoolean(context.getString(R.string.education_create_db_key),
|
||||
context.getResources().getBoolean(R.bool.education_create_db_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));
|
||||
}
|
||||
|
||||
public static boolean isEducationOpenLinkDatabasePerformed(Context context) {
|
||||
SharedPreferences prefs = getEducationSharedPreferences(context);
|
||||
return prefs.getBoolean(context.getString(R.string.education_open_link_db_key),
|
||||
context.getResources().getBoolean(R.bool.education_open_link_db_default));
|
||||
}
|
||||
|
||||
public static boolean isEducationGroupPerformed(Context context) {
|
||||
SharedPreferences prefs = getEducationSharedPreferences(context);
|
||||
return prefs.getBoolean(context.getString(R.string.education_group_key),
|
||||
|
||||
@@ -73,7 +73,9 @@
|
||||
<string name="database_description_key" translatable="false">database_description_key</string>
|
||||
<string name="database_version_key" translatable="false">database_version_key</string>
|
||||
<string name="reset_education_screens_key" translatable="false">relaunch_education_screens_key</string>
|
||||
<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_entry_key" translatable="false">education_entry_key</string>
|
||||
<string name="education_password_key" translatable="false">education_password_key</string>
|
||||
@@ -95,7 +97,9 @@
|
||||
<bool name="monospace_font_fields_enable_default" translatable="false">true</bool>
|
||||
<bool name="auto_open_file_uri_default" translatable="false">true</bool>
|
||||
<bool name="allow_copy_password_default" translatable="false">true</bool> <!-- TODO To change after implementing the way to enter password < O -->
|
||||
<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_entry_default" translatable="false">false</bool>
|
||||
<bool name="education_password_default" translatable="false">false</bool>
|
||||
|
||||
Reference in New Issue
Block a user