Setting to close database after Autofill selection #755

This commit is contained in:
J-Jamet committed 2020-10-19 14:10:16 +02:00
1 parent efcbecc218
commit c8a952616f
10 files changed
+40 -4

No files matched your search

@@ -39,6 +39,7 @@ import com.kunzisoft.keepass.database.search.SearchHelper
import com.kunzisoft.keepass.model.RegisterInfo
import com.kunzisoft.keepass.model.SearchInfo
import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.utils.LOCK_ACTION
@RequiresApi(api = Build.VERSION_CODES.O)
class AutofillLauncherActivity : AppCompatActivity() {
@@ -82,6 +83,10 @@ class AutofillLauncherActivity : AppCompatActivity() {
{ items ->
// Items found
AutofillHelper.buildResponse(this, items)
if (PreferencesUtil.isAutofillCloseDatabaseEnable(this)) {
// Close the database
sendBroadcast(Intent(LOCK_ACTION))
}
finish()
},
{
@@ -323,6 +323,7 @@ open class PasswordActivity : SpecialModeActivity() {
},
{
// Simply close if database not opened, normally not happened
onCancelSpecialMode()
}
)
// Do not keep history
@@ -336,6 +337,7 @@ open class PasswordActivity : SpecialModeActivity() {
{ items ->
// Response is build
AutofillHelper.buildResponse(this, items)
onValidateSpecialMode()
finish()
},
{
@@ -347,11 +349,13 @@ open class PasswordActivity : SpecialModeActivity() {
searchInfo,
readOnly)
} else {
onCancelSpecialMode()
finish()
}
},
{
// Simply close if database not opened, normally not happened
onCancelSpecialMode()
finish()
}
)
@@ -373,6 +377,7 @@ open class PasswordActivity : SpecialModeActivity() {
},
{
// Simply close if database not opened, normally not happened
onCancelSpecialMode()
}
)
// Do not keep history
@@ -1,5 +1,6 @@
package com.kunzisoft.keepass.activities.selection
import android.content.Intent
import android.os.Build
import android.view.View
import android.widget.Toast
@@ -10,6 +11,7 @@ import com.kunzisoft.keepass.activities.helpers.TypeMode
import com.kunzisoft.keepass.activities.stylish.StylishActivity
import com.kunzisoft.keepass.model.SearchInfo
import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.utils.LOCK_ACTION
import com.kunzisoft.keepass.view.SpecialModeView
/**
@@ -58,6 +60,11 @@ abstract class SpecialModeActivity : StylishActivity() {
moveTaskToBack(true)
}
}
if (mTypeMode == TypeMode.AUTOFILL
&& PreferencesUtil.isAutofillCloseDatabaseEnable(this)) {
// Close the database
sendBroadcast(Intent(LOCK_ACTION))
}
}
open fun onCancelSpecialMode() {
@@ -383,6 +383,13 @@ object PreferencesUtil {
context.resources.getBoolean(R.bool.keyboard_previous_fill_in_default))
}
fun isAutofillCloseDatabaseEnable(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.autofill_close_database_key),
context.resources.getBoolean(R.bool.autofill_close_database_default))
}
fun isAutofillAutoSearchEnable(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.autofill_auto_search_key),