Setting to delete the password entered after a connection attempt #214

This commit is contained in:
J-Jamet
2019-08-06 11:49:06 +02:00
parent 9c597665bf
commit b3b2bb90e1
5 changed files with 33 additions and 5 deletions

View File

@@ -589,6 +589,11 @@ class PasswordActivity : StylishActivity(),
loadDatabase(password, keyUri)
}
private fun removePassword() {
passwordView?.setText("")
checkboxPasswordView?.isChecked = false
}
private fun loadDatabase(password: String?, keyFile: Uri?) {
// Deactivate the open button
@@ -596,6 +601,10 @@ class PasswordActivity : StylishActivity(),
// Hide credentials
unlockContainer?.visibility = View.INVISIBLE
if (PreferencesUtil.deletePasswordAfterConnexionAttempt(this)) {
removePassword()
}
// Clear before we load
val database = App.currentDatabase
database.closeAndClear(applicationContext.filesDir)
@@ -632,12 +641,10 @@ class PasswordActivity : StylishActivity(),
reInitWithFingerprintMode()
}
// Show credentials
unlockContainer?.visibility = View.VISIBLE
// Activate the open button
confirmButtonView?.isEnabled = true
if (result.isSuccess) {
// Remove the password in view in all cases
removePassword()
if (database.validatePasswordEncoding(password)) {
launchGroupActivity()
} else {
@@ -649,10 +656,16 @@ class PasswordActivity : StylishActivity(),
}
}
} else {
// Activate the open button
confirmButtonView?.isEnabled = true
if (result.message != null && result.message!!.isNotEmpty()) {
Toast.makeText(this@PasswordActivity, result.message, Toast.LENGTH_LONG).show()
}
}
// Show credentials
unlockContainer?.visibility = View.VISIBLE
}
}
}

View File

@@ -227,6 +227,12 @@ object PreferencesUtil {
context.resources.getBoolean(R.bool.enable_read_only_default))
}
fun deletePasswordAfterConnexionAttempt(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.delete_entered_password_key),
context.resources.getBoolean(R.bool.delete_entered_password_default))
}
fun enableKeyboardNotificationEntry(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.keyboard_notification_entry_key),

View File

@@ -71,6 +71,8 @@
<bool name="allow_no_password_default" translatable="false">false</bool>
<string name="enable_read_only_key" translatable="false">enable_read_only_key</string>
<bool name="enable_read_only_default" translatable="false">false</bool>
<string name="delete_entered_password_key" translatable="false">delete_entered_password_key</string>
<bool name="delete_entered_password_default" translatable="false">true</bool>
<string name="omitbackup_key" translatable="false">omitbackup</string>
<bool name="omitbackup_default" translatable="false">true</bool>
<string name="app_timeout_key" translatable="false">app_timeout_key</string>

View File

@@ -328,6 +328,8 @@
<string name="allow_no_password_summary">Enable the \"Open\" button if no password identification is selected</string>
<string name="enable_read_only_title">Write-protected</string>
<string name="enable_read_only_summary">Open your database read-only by default</string>
<string name="delete_entered_password_title">Delete password</string>
<string name="delete_entered_password_summary">Deletes the password entered after a connection attempt</string>
<string name="enable_education_screens_title">Educational screens</string>
<string name="enable_education_screens_summary">Highlight the elements to learn how the app works</string>

View File

@@ -33,6 +33,11 @@
android:title="@string/enable_read_only_title"
android:summary="@string/enable_read_only_summary"
android:defaultValue="@bool/enable_read_only_default"/>
<SwitchPreference
android:key="@string/delete_entered_password_key"
android:title="@string/delete_entered_password_title"
android:summary="@string/delete_entered_password_summary"
android:defaultValue="@bool/delete_entered_password_default"/>
</PreferenceCategory>