mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Education screen for OTP and entry edit menu
This commit is contained in:
@@ -212,10 +212,7 @@ class EntryEditActivity : LockingActivity(),
|
||||
true
|
||||
}
|
||||
R.id.menu_add_otp -> {
|
||||
// Retrieve the current otpElement if exists
|
||||
// and open the dialog to set up the OTP
|
||||
SetOTPDialogFragment.build(mEntry?.getOtpElement()?.otpModel)
|
||||
.show(supportFragmentManager, "addOTPDialog")
|
||||
setupOTP()
|
||||
true
|
||||
}
|
||||
else -> true
|
||||
@@ -315,6 +312,13 @@ class EntryEditActivity : LockingActivity(),
|
||||
entryEditContentsView?.addEmptyCustomField()
|
||||
}
|
||||
|
||||
private fun setupOTP() {
|
||||
// Retrieve the current otpElement if exists
|
||||
// and open the dialog to set up the OTP
|
||||
SetOTPDialogFragment.build(mEntry?.getOtpElement()?.otpModel)
|
||||
.show(supportFragmentManager, "addOTPDialog")
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the new entry or update an existing entry in the database
|
||||
*/
|
||||
@@ -372,12 +376,10 @@ class EntryEditActivity : LockingActivity(),
|
||||
}
|
||||
|
||||
private fun performedNextEducation(entryEditActivityEducation: EntryEditActivityEducation) {
|
||||
val passwordView: View? = null// TODO entryEditContentsView?.generatePasswordView
|
||||
val addNewFieldView: View? = null // TODO entryEditContentsView?.addNewFieldButton
|
||||
|
||||
val generatePasswordEducationPerformed = passwordView != null
|
||||
val passwordGeneratorView: View? = entryEditAddToolBar?.findViewById(R.id.menu_generate_password)
|
||||
val generatePasswordEducationPerformed = passwordGeneratorView != null
|
||||
&& entryEditActivityEducation.checkAndPerformedGeneratePasswordEducation(
|
||||
passwordView,
|
||||
passwordGeneratorView,
|
||||
{
|
||||
openPasswordGenerator()
|
||||
},
|
||||
@@ -386,14 +388,28 @@ class EntryEditActivity : LockingActivity(),
|
||||
}
|
||||
)
|
||||
if (!generatePasswordEducationPerformed) {
|
||||
// entryNewFieldEducationPerformed
|
||||
mNewEntry != null && mNewEntry!!.allowCustomFields() && mNewEntry!!.customFields.isEmpty()
|
||||
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
|
||||
&& entryEditActivityEducation.checkAndPerformedEntryNewFieldEducation(
|
||||
addNewFieldView,
|
||||
{
|
||||
addNewCustomField()
|
||||
})
|
||||
},
|
||||
{
|
||||
performedNextEducation(entryEditActivityEducation)
|
||||
}
|
||||
)
|
||||
if (!addNewFieldEducationPerformed) {
|
||||
val setupOtpView: View? = entryEditAddToolBar?.findViewById(R.id.menu_add_otp)
|
||||
setupOtpView != null && setupOtpView.visibility == View.VISIBLE
|
||||
&& entryEditActivityEducation.checkAndPerformedSetUpOTPEducation(
|
||||
setupOtpView,
|
||||
{
|
||||
setupOTP()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,8 @@ open class Education(val activity: Activity) {
|
||||
R.string.education_copy_username_key,
|
||||
R.string.education_entry_edit_key,
|
||||
R.string.education_password_generator_key,
|
||||
R.string.education_entry_new_field_key)
|
||||
R.string.education_entry_new_field_key,
|
||||
R.string.education_setup_OTP_key)
|
||||
|
||||
|
||||
/**
|
||||
@@ -271,6 +272,18 @@ open class Education(val activity: Activity) {
|
||||
context.resources.getBoolean(R.bool.education_entry_new_field_default))
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the explanatory view to setup OTP has already been displayed.
|
||||
*
|
||||
* @param context The context to open the SharedPreferences
|
||||
* @return boolean value of education_setup_OTP_key key
|
||||
*/
|
||||
fun isEducationSetupOTPPerformed(context: Context): Boolean {
|
||||
val prefs = getEducationSharedPreferences(context)
|
||||
return prefs.getBoolean(context.getString(R.string.education_setup_OTP_key),
|
||||
context.resources.getBoolean(R.bool.education_setup_OTP_default))
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines if the reset education preference has been reclicked
|
||||
*
|
||||
|
||||
@@ -37,7 +37,7 @@ class EntryEditActivityEducation(activity: Activity)
|
||||
activity.getString(R.string.education_generate_password_title),
|
||||
activity.getString(R.string.education_generate_password_summary))
|
||||
.textColorInt(Color.WHITE)
|
||||
.tintTarget(false)
|
||||
.tintTarget(true)
|
||||
.cancelable(true),
|
||||
object : TapTargetView.Listener() {
|
||||
override fun onTargetClick(view: TapTargetView) {
|
||||
@@ -66,7 +66,7 @@ class EntryEditActivityEducation(activity: Activity)
|
||||
activity.getString(R.string.education_entry_new_field_title),
|
||||
activity.getString(R.string.education_entry_new_field_summary))
|
||||
.textColorInt(Color.WHITE)
|
||||
.tintTarget(false)
|
||||
.tintTarget(true)
|
||||
.cancelable(true),
|
||||
object : TapTargetView.Listener() {
|
||||
override fun onTargetClick(view: TapTargetView) {
|
||||
@@ -82,4 +82,33 @@ class EntryEditActivityEducation(activity: Activity)
|
||||
},
|
||||
R.string.education_entry_new_field_key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and display learning views
|
||||
* Displays the explanation to setup OTP
|
||||
*/
|
||||
fun checkAndPerformedSetUpOTPEducation(educationView: View,
|
||||
onEducationViewClick: ((TapTargetView?) -> Unit)? = null,
|
||||
onOuterViewClick: ((TapTargetView?) -> Unit)? = null): Boolean {
|
||||
return checkAndPerformedEducation(!isEducationSetupOTPPerformed(activity),
|
||||
TapTarget.forView(educationView,
|
||||
activity.getString(R.string.education_setup_OTP_title),
|
||||
activity.getString(R.string.education_setup_OTP_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_setup_OTP_key)
|
||||
}
|
||||
}
|
||||
@@ -236,6 +236,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_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>
|
||||
<bool name="education_screen_reclicked_default" translatable="false">false</bool>
|
||||
|
||||
|
||||
@@ -400,10 +400,12 @@
|
||||
<string name="education_biometric_summary">Link your password to your scanned biometric to quickly unlock your database.</string>
|
||||
<string name="education_entry_edit_title">Edit the entry</string>
|
||||
<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 for your entry.</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_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_setup_OTP_title">Setup OTP</string>
|
||||
<string name="education_setup_OTP_summary">Setup 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>
|
||||
<string name="education_unlock_summary">Enter the password and/or keyfile to unlock your database.\n\nBackup your database file in a safe place after each change.</string>
|
||||
<string name="education_read_only_title">Write protect your database</string>
|
||||
|
||||
Reference in New Issue
Block a user