Educational hint for attachment

This commit is contained in:
J-Jamet
2020-09-01 19:12:25 +02:00
parent 79fd53fd4c
commit 14371ecf94
5 changed files with 73 additions and 10 deletions

View File

@@ -589,8 +589,8 @@ class EntryEditActivity : LockingActivity(),
if (!generatePasswordEducationPerformed) {
val addNewFieldView: View? = entryEditAddToolBar?.findViewById(R.id.menu_add_field)
val addNewFieldEducationPerformed = mNewEntry != null
&& mNewEntry!!.allowCustomFields() && mNewEntry!!.customFields.isEmpty()
&& addNewFieldView != null && addNewFieldView.visibility == View.VISIBLE
&& mNewEntry!!.allowCustomFields() && addNewFieldView != null
&& addNewFieldView.visibility == View.VISIBLE
&& entryEditActivityEducation.checkAndPerformedEntryNewFieldEducation(
addNewFieldView,
{
@@ -601,13 +601,27 @@ class EntryEditActivity : LockingActivity(),
}
)
if (!addNewFieldEducationPerformed) {
val attachmentView: View? = entryEditAddToolBar?.findViewById(R.id.menu_add_attachment)
val addAttachmentEducationPerformed = attachmentView != null && attachmentView.visibility == View.VISIBLE
&& entryEditActivityEducation.checkAndPerformedAttachmentEducation(
attachmentView,
{
mSelectFileHelper?.selectFileOnClickViewListener?.onClick(attachmentView)
},
{
performedNextEducation(entryEditActivityEducation)
}
)
if (!addAttachmentEducationPerformed) {
val setupOtpView: View? = entryEditAddToolBar?.findViewById(R.id.menu_add_otp)
setupOtpView != null && setupOtpView.visibility == View.VISIBLE
&& entryEditActivityEducation.checkAndPerformedSetUpOTPEducation(
setupOtpView,
{
setupOTP()
})
}
)
}
}
}
}

View File

@@ -95,9 +95,9 @@ open class Education(val activity: Activity) {
R.string.education_entry_edit_key,
R.string.education_password_generator_key,
R.string.education_entry_new_field_key,
R.string.education_add_attachment_key,
R.string.education_setup_OTP_key)
/**
* Get preferences bundle for education
*/
@@ -272,6 +272,18 @@ open class Education(val activity: Activity) {
context.resources.getBoolean(R.bool.education_entry_new_field_default))
}
/**
* Determines whether the explanatory view of the new attachment button in an entry has already been displayed.
*
* @param context The context to open the SharedPreferences
* @return boolean value of education_add_attachment_key key
*/
fun isEducationAddAttachmentPerformed(context: Context): Boolean {
val prefs = getEducationSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.education_add_attachment_key),
context.resources.getBoolean(R.bool.education_add_attachment_default))
}
/**
* Determines whether the explanatory view to setup OTP has already been displayed.
*

View File

@@ -29,6 +29,10 @@ import com.kunzisoft.keepass.R
class EntryEditActivityEducation(activity: Activity)
: Education(activity) {
/**
* Check and display learning views
* Displays the explanation for the password generator
*/
fun checkAndPerformedGeneratePasswordEducation(educationView: View,
onEducationViewClick: ((TapTargetView?) -> Unit)? = null,
onOuterViewClick: ((TapTargetView?) -> Unit)? = null): Boolean {
@@ -56,7 +60,7 @@ class EntryEditActivityEducation(activity: Activity)
/**
* Check and display learning views
* Displays the explanation for the icon selection, the password generator and for a new field
* Displays the explanation to create a new field
*/
fun checkAndPerformedEntryNewFieldEducation(educationView: View,
onEducationViewClick: ((TapTargetView?) -> Unit)? = null,
@@ -83,6 +87,35 @@ class EntryEditActivityEducation(activity: Activity)
R.string.education_entry_new_field_key)
}
/**
* Check and display learning views
* Displays the explanation for to upload attachment
*/
fun checkAndPerformedAttachmentEducation(educationView: View,
onEducationViewClick: ((TapTargetView?) -> Unit)? = null,
onOuterViewClick: ((TapTargetView?) -> Unit)? = null): Boolean {
return checkAndPerformedEducation(!isEducationAddAttachmentPerformed(activity),
TapTarget.forView(educationView,
activity.getString(R.string.education_add_attachment_title),
activity.getString(R.string.education_add_attachment_summary))
.textColorInt(Color.WHITE)
.tintTarget(true)
.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_add_attachment_key)
}
/**
* Check and display learning views
* Displays the explanation to setup OTP

View File

@@ -250,6 +250,8 @@
<bool name="education_password_generator_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>
<bool name="education_add_attachment_default" translatable="false">false</bool>
<string name="education_setup_OTP_key" translatable="false">education_setup_OTP_key</string>
<bool name="education_setup_OTP_default" translatable="false">false</bool>
<string name="education_screen_reclicked_key" translatable="false">education_screen_reclicked_key</string>

View File

@@ -426,6 +426,8 @@
<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_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>
<string name="education_add_attachment_summary">Upload an attachment to your entry to save important external data.</string>
<string name="education_setup_OTP_title">Set up OTP</string>
<string name="education_setup_OTP_summary">Set up one-time password management (HOTP / TOTP) to generate a token requested for two-factor authentication (2FA).</string>
<string name="education_unlock_title">Unlock your database</string>