fix: Add validate entry education

This commit is contained in:
J-Jamet
2023-07-28 12:59:20 +02:00
parent 16f92fc895
commit b913913bf1
5 changed files with 66 additions and 4 deletions

View File

@@ -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()
}
)
}
}
}
}

View File

@@ -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.
*

View File

@@ -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

View File

@@ -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>

View File

@@ -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>