mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
fix: Add validate entry education
This commit is contained in:
@@ -215,7 +215,7 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
// Lock button
|
||||
lockView?.setOnClickListener { lockAndExit() }
|
||||
// Save button
|
||||
validateButton?.setOnClickListener { saveEntry() }
|
||||
validateButton?.setOnClickListener { validateEntry() }
|
||||
|
||||
mEntryEditViewModel.onTemplateChanged.observe(this) { template ->
|
||||
this.mTemplate = template
|
||||
@@ -564,9 +564,9 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the new entry or update an existing entry in the database
|
||||
* Validate the new entry or update an existing entry in the database
|
||||
*/
|
||||
private fun saveEntry() {
|
||||
private fun validateEntry() {
|
||||
mAttachmentFileBinderManager?.stopUploadAllAttachments()
|
||||
mEntryEditViewModel.requestEntryInfoUpdate(mDatabase)
|
||||
}
|
||||
@@ -648,14 +648,29 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
)
|
||||
if (!addAttachmentEducationPerformed) {
|
||||
val setupOtpView: View? = entryEditAddToolBar?.findViewById(R.id.menu_add_otp)
|
||||
setupOtpView != null
|
||||
val validateEntryEducationPerformed = setupOtpView != null
|
||||
&& setupOtpView.isVisible
|
||||
&& mEntryEditActivityEducation.checkAndPerformedSetUpOTPEducation(
|
||||
setupOtpView,
|
||||
{
|
||||
setupOtp()
|
||||
},
|
||||
{
|
||||
performedNextEducation()
|
||||
}
|
||||
)
|
||||
if (!validateEntryEducationPerformed) {
|
||||
val entryValidateView = validateButton
|
||||
mAllowCustomFields
|
||||
&& entryValidateView != null
|
||||
&& entryValidateView.isVisible
|
||||
&& mEntryEditActivityEducation.checkAndPerformedValidateEntryEducation(
|
||||
entryValidateView,
|
||||
{
|
||||
validateEntry()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,6 +324,18 @@ open class Education(val activity: Activity) {
|
||||
context.resources.getBoolean(R.bool.education_password_generator_default))
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the explanatory view of the validate entry has already been displayed.
|
||||
*
|
||||
* @param context The context to open the SharedPreferences
|
||||
* @return boolean value of education_validate_entry_key key
|
||||
*/
|
||||
fun isEducationValidateEntryPerformed(context: Context): Boolean {
|
||||
val prefs = getEducationSharedPreferences(context)
|
||||
return prefs.getBoolean(context.getString(R.string.education_validate_entry_key),
|
||||
context.resources.getBoolean(R.bool.education_validate_entry_default))
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the explanatory view of the new fields button in an entry has already been displayed.
|
||||
*
|
||||
|
||||
@@ -59,6 +59,37 @@ class EntryEditActivityEducation(activity: Activity)
|
||||
R.string.education_password_generator_key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and display learning views
|
||||
* Displays the explanation for the entry validation
|
||||
*/
|
||||
fun checkAndPerformedValidateEntryEducation(educationView: View,
|
||||
onEducationViewClick: ((TapTargetView?) -> Unit)? = null,
|
||||
onOuterViewClick: ((TapTargetView?) -> Unit)? = null): Boolean {
|
||||
return checkAndPerformedEducation(isEducationValidateEntryPerformed(activity),
|
||||
TapTarget.forView(educationView,
|
||||
activity.getString(R.string.education_validate_entry_title),
|
||||
activity.getString(R.string.education_validate_entry_summary))
|
||||
.outerCircleColorInt(getCircleColor())
|
||||
.outerCircleAlpha(getCircleAlpha())
|
||||
.textColorInt(getTextColor())
|
||||
.tintTarget(false)
|
||||
.cancelable(true),
|
||||
object : TapTargetView.Listener() {
|
||||
override fun onTargetClick(view: TapTargetView) {
|
||||
super.onTargetClick(view)
|
||||
onEducationViewClick?.invoke(view)
|
||||
}
|
||||
|
||||
override fun onOuterCircleClick(view: TapTargetView?) {
|
||||
super.onOuterCircleClick(view)
|
||||
view?.dismiss(false)
|
||||
onOuterViewClick?.invoke(view)
|
||||
}
|
||||
},
|
||||
R.string.education_validate_entry_key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and display learning views
|
||||
* Displays the explanation to create a new field
|
||||
|
||||
@@ -345,6 +345,8 @@
|
||||
<bool name="education_entry_edit_default" translatable="false">false</bool>
|
||||
<string name="education_password_generator_key" translatable="false">education_password_generator_key</string>
|
||||
<bool name="education_password_generator_default" translatable="false">false</bool>
|
||||
<string name="education_validate_entry_key" translatable="false">education_validate_entry_key</string>
|
||||
<bool name="education_validate_entry_default" translatable="false">false</bool>
|
||||
<string name="education_entry_new_field_key" translatable="false">education_entry_new_field_key</string>
|
||||
<bool name="education_entry_new_field_default" translatable="false">false</bool>
|
||||
<string name="education_add_attachment_key" translatable="false">education_add_attachment_key</string>
|
||||
|
||||
@@ -596,6 +596,8 @@
|
||||
<string name="education_entry_edit_summary">Edit your entry with custom fields. Pool data can be referenced between different entry fields.</string>
|
||||
<string name="education_generate_password_title">Create a strong password</string>
|
||||
<string name="education_generate_password_summary">Generate a strong password to associate with your entry, easily define it according to the criteria of the form and don\'t forget secure password.</string>
|
||||
<string name="education_validate_entry_title">Validate the entry</string>
|
||||
<string name="education_validate_entry_summary">Remember to validate your entry and save your database.\n\nIf an automatic lock is activated and you forget you were making a modification, you risk losing your data.</string>
|
||||
<string name="education_entry_new_field_title">Add custom fields</string>
|
||||
<string name="education_entry_new_field_summary">Register an additional field, add a value and optionally protect it.</string>
|
||||
<string name="education_add_attachment_title">Add attachment</string>
|
||||
|
||||
Reference in New Issue
Block a user