mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-05 00:02:27 -08:00
Change education for group screen
This commit is contained in:
1 parent
2c44a4d760
commit
2e5ddd80ff
8 files changed
+139
-53
No files matched your search
@@ -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,57 +263,102 @@ 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;
|
||||
}
|
||||
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)
|
||||
.cancelable(true),
|
||||
new TapTargetView.Listener() {
|
||||
@Override
|
||||
public void onTargetClick(TapTargetView view) {
|
||||
super.onTargetClick(view);
|
||||
addNodeButtonView.openButtonIfClose();
|
||||
}
|
||||
});
|
||||
PreferencesUtil.saveEducationPreference(this,
|
||||
R.string.education_new_node_key);
|
||||
|
||||
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)),
|
||||
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() {
|
||||
@Override
|
||||
public void onSequenceFinish() {
|
||||
saveEducationPreference();
|
||||
}
|
||||
// Else show the search education
|
||||
} else if (!PreferencesUtil.isEducationSearchPerformed(this)) {
|
||||
|
||||
@Override
|
||||
public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {}
|
||||
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 onTargetClick(TapTargetView view) {
|
||||
super.onTargetClick(view);
|
||||
MenuItem searchItem = menu.findItem(R.id.menu_search);
|
||||
searchItem.expandActionView();
|
||||
}
|
||||
});
|
||||
PreferencesUtil.saveEducationPreference(this,
|
||||
R.string.education_search_key);
|
||||
|
||||
@Override
|
||||
public void onSequenceCanceled(TapTarget lastTarget) {}
|
||||
}).continueOnCancel(true).start();
|
||||
// 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");
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveEducationPreference() {
|
||||
SharedPreferences sharedPreferences = PreferencesUtil.getEducationSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(getString(R.string.education_group_key), true);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
@@ -377,6 +422,9 @@ public class GroupActivity extends ListNodesActivity
|
||||
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
// Launch education screen
|
||||
new Handler().post(() -> checkAndPerformedEducation(menu));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user