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 android.widget.Toast;
|
||||||
|
|
||||||
import com.getkeepsafe.taptargetview.TapTarget;
|
import com.getkeepsafe.taptargetview.TapTarget;
|
||||||
import com.getkeepsafe.taptargetview.TapTargetSequence;
|
import com.getkeepsafe.taptargetview.TapTargetView;
|
||||||
import com.kunzisoft.keepass.R;
|
import com.kunzisoft.keepass.R;
|
||||||
import com.kunzisoft.keepass.activities.GroupActivity;
|
import com.kunzisoft.keepass.activities.GroupActivity;
|
||||||
import com.kunzisoft.keepass.app.App;
|
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) {
|
private void launchPasswordActivityWithPath(String path) {
|
||||||
@@ -258,48 +262,74 @@ public class FileSelectActivity extends StylishActivity implements
|
|||||||
fileNameView.updateExternalStorageWarning();
|
fileNameView.updateExternalStorageWarning();
|
||||||
updateTitleFileListView();
|
updateTitleFileListView();
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
|
||||||
// For the first time show the tuto
|
|
||||||
checkAndPerformedEducation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndPerformedEducation() {
|
private void checkAndPerformedEducation(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
// If no recent files
|
||||||
|
if ( !fileHistory.hasRecentFiles() ) {
|
||||||
|
// Try to open the creation base education
|
||||||
if (!PreferencesUtil.isEducationSelectDatabasePerformed(this) ) {
|
if (!PreferencesUtil.isEducationSelectDatabasePerformed(this) ) {
|
||||||
new TapTargetSequence(this)
|
|
||||||
.targets(
|
TapTargetView.showFor(this,
|
||||||
TapTarget.forView(createButtonView,
|
TapTarget.forView(createButtonView,
|
||||||
getString(R.string.education_create_database_title),
|
getString(R.string.education_create_database_title),
|
||||||
getString(R.string.education_create_database_summary))
|
getString(R.string.education_create_database_summary))
|
||||||
.tintTarget(false),
|
.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,
|
TapTarget.forView(browseButtonView,
|
||||||
getString(R.string.education_select_database_title),
|
getString(R.string.education_select_database_title),
|
||||||
getString(R.string.education_select_database_summary))
|
getString(R.string.education_select_database_summary))
|
||||||
.tintTarget(false),
|
.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,
|
TapTarget.forView(openButtonView,
|
||||||
getString(R.string.education_open_link_database_title),
|
getString(R.string.education_open_link_database_title),
|
||||||
getString(R.string.education_open_link_database_summary))
|
getString(R.string.education_open_link_database_summary))
|
||||||
.tintTarget(false)
|
.tintTarget(false)
|
||||||
).listener(new TapTargetSequence.Listener() {
|
.cancelable(true),
|
||||||
|
new TapTargetView.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSequenceFinish() {
|
public void onTargetClick(TapTargetView view) {
|
||||||
saveEducationPreference();
|
super.onTargetClick(view);
|
||||||
|
// Do nothing here
|
||||||
}
|
}
|
||||||
|
});
|
||||||
@Override
|
PreferencesUtil.saveEducationPreference(FileSelectActivity.this,
|
||||||
public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {}
|
R.string.education_open_link_db_key);
|
||||||
|
|
||||||
@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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -145,17 +145,47 @@ public class PreferencesUtil {
|
|||||||
ctx.getResources().getBoolean(R.bool.allow_copy_password_default));
|
ctx.getResources().getBoolean(R.bool.allow_copy_password_default));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Education Preferences
|
||||||
|
*/
|
||||||
|
|
||||||
public static int[] educationResourceKeys = new int[] {
|
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_create_db_key,
|
||||||
R.string.education_password_key, R.string.education_entry_edit_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) {
|
public static boolean isEducationSelectDatabasePerformed(Context context) {
|
||||||
SharedPreferences prefs = getEducationSharedPreferences(context);
|
SharedPreferences prefs = getEducationSharedPreferences(context);
|
||||||
return prefs.getBoolean(context.getString(R.string.education_select_db_key),
|
return prefs.getBoolean(context.getString(R.string.education_select_db_key),
|
||||||
context.getResources().getBoolean(R.bool.education_select_db_default));
|
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) {
|
public static boolean isEducationGroupPerformed(Context context) {
|
||||||
SharedPreferences prefs = getEducationSharedPreferences(context);
|
SharedPreferences prefs = getEducationSharedPreferences(context);
|
||||||
return prefs.getBoolean(context.getString(R.string.education_group_key),
|
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_description_key" translatable="false">database_description_key</string>
|
||||||
<string name="database_version_key" translatable="false">database_version_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="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_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_group_key" translatable="false">education_group_key</string>
|
||||||
<string name="education_entry_key" translatable="false">education_entry_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_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="monospace_font_fields_enable_default" translatable="false">true</bool>
|
||||||
<bool name="auto_open_file_uri_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="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_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_group_default" translatable="false">false</bool>
|
||||||
<bool name="education_entry_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_password_default" translatable="false">false</bool>
|
||||||
|
|||||||
Reference in New Issue
Block a user