Setting to close database after Autofill selection #755

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

View File

@@ -1,6 +1,7 @@
KeePassDX(2.9) KeePassDX(2.9)
* Upgrade to Android API 30 #723 * Upgrade to Android API 30 #723
* Save new credentials with Autofill #524 * Save new credentials with Autofill #524
* Setting to close database after Autofill selection #755
* Fix biometric issues #724 #740 #731 * Fix biometric issues #724 #740 #731
* Fix autofill #725 #551 * Fix autofill #725 #551
* Small fixes and translations #732 #736 #737 #738 #742 * Small fixes and translations #732 #736 #737 #738 #742

View File

@@ -39,6 +39,7 @@ import com.kunzisoft.keepass.database.search.SearchHelper
import com.kunzisoft.keepass.model.RegisterInfo import com.kunzisoft.keepass.model.RegisterInfo
import com.kunzisoft.keepass.model.SearchInfo import com.kunzisoft.keepass.model.SearchInfo
import com.kunzisoft.keepass.settings.PreferencesUtil import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.utils.LOCK_ACTION
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
class AutofillLauncherActivity : AppCompatActivity() { class AutofillLauncherActivity : AppCompatActivity() {
@@ -82,6 +83,10 @@ class AutofillLauncherActivity : AppCompatActivity() {
{ items -> { items ->
// Items found // Items found
AutofillHelper.buildResponse(this, items) AutofillHelper.buildResponse(this, items)
if (PreferencesUtil.isAutofillCloseDatabaseEnable(this)) {
// Close the database
sendBroadcast(Intent(LOCK_ACTION))
}
finish() finish()
}, },
{ {

View File

@@ -323,6 +323,7 @@ open class PasswordActivity : SpecialModeActivity() {
}, },
{ {
// Simply close if database not opened, normally not happened // Simply close if database not opened, normally not happened
onCancelSpecialMode()
} }
) )
// Do not keep history // Do not keep history
@@ -336,6 +337,7 @@ open class PasswordActivity : SpecialModeActivity() {
{ items -> { items ->
// Response is build // Response is build
AutofillHelper.buildResponse(this, items) AutofillHelper.buildResponse(this, items)
onValidateSpecialMode()
finish() finish()
}, },
{ {
@@ -347,11 +349,13 @@ open class PasswordActivity : SpecialModeActivity() {
searchInfo, searchInfo,
readOnly) readOnly)
} else { } else {
onCancelSpecialMode()
finish() finish()
} }
}, },
{ {
// Simply close if database not opened, normally not happened // Simply close if database not opened, normally not happened
onCancelSpecialMode()
finish() finish()
} }
) )
@@ -373,6 +377,7 @@ open class PasswordActivity : SpecialModeActivity() {
}, },
{ {
// Simply close if database not opened, normally not happened // Simply close if database not opened, normally not happened
onCancelSpecialMode()
} }
) )
// Do not keep history // Do not keep history

View File

@@ -1,5 +1,6 @@
package com.kunzisoft.keepass.activities.selection package com.kunzisoft.keepass.activities.selection
import android.content.Intent
import android.os.Build import android.os.Build
import android.view.View import android.view.View
import android.widget.Toast 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.activities.stylish.StylishActivity
import com.kunzisoft.keepass.model.SearchInfo import com.kunzisoft.keepass.model.SearchInfo
import com.kunzisoft.keepass.settings.PreferencesUtil import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.utils.LOCK_ACTION
import com.kunzisoft.keepass.view.SpecialModeView import com.kunzisoft.keepass.view.SpecialModeView
/** /**
@@ -58,6 +60,11 @@ abstract class SpecialModeActivity : StylishActivity() {
moveTaskToBack(true) moveTaskToBack(true)
} }
} }
if (mTypeMode == TypeMode.AUTOFILL
&& PreferencesUtil.isAutofillCloseDatabaseEnable(this)) {
// Close the database
sendBroadcast(Intent(LOCK_ACTION))
}
} }
open fun onCancelSpecialMode() { open fun onCancelSpecialMode() {

View File

@@ -383,6 +383,13 @@ object PreferencesUtil {
context.resources.getBoolean(R.bool.keyboard_previous_fill_in_default)) 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 { fun isAutofillAutoSearchEnable(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context) val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.autofill_auto_search_key), return prefs.getBoolean(context.getString(R.string.autofill_auto_search_key),

View File

@@ -139,6 +139,8 @@
<bool name="keyboard_previous_database_credentials_default" translatable="false">false</bool> <bool name="keyboard_previous_database_credentials_default" translatable="false">false</bool>
<string name="keyboard_previous_fill_in_key" translatable="false">keyboard_previous_fill_in_key</string> <string name="keyboard_previous_fill_in_key" translatable="false">keyboard_previous_fill_in_key</string>
<bool name="keyboard_previous_fill_in_default" translatable="false">false</bool> <bool name="keyboard_previous_fill_in_default" translatable="false">false</bool>
<string name="autofill_close_database_key" translatable="false">autofill_close_database_key</string>
<bool name="autofill_close_database_default" translatable="false">false</bool>
<string name="autofill_auto_search_key" translatable="false">autofill_auto_search_key</string> <string name="autofill_auto_search_key" translatable="false">autofill_auto_search_key</string>
<bool name="autofill_auto_search_default" translatable="false">true</bool> <bool name="autofill_auto_search_default" translatable="false">true</bool>
<string name="autofill_save_search_info_key" translatable="false">autofill_save_search_info_key</string> <string name="autofill_save_search_info_key" translatable="false">autofill_save_search_info_key</string>

View File

@@ -403,6 +403,8 @@
<string name="keyboard_previous_database_credentials_summary">Automatically switch back to the previous keyboard on the database credentials screen</string> <string name="keyboard_previous_database_credentials_summary">Automatically switch back to the previous keyboard on the database credentials screen</string>
<string name="keyboard_previous_fill_in_title">Auto key action</string> <string name="keyboard_previous_fill_in_title">Auto key action</string>
<string name="keyboard_previous_fill_in_summary">Automatically switch back to the previous keyboard after executing "Auto key action"</string> <string name="keyboard_previous_fill_in_summary">Automatically switch back to the previous keyboard after executing "Auto key action"</string>
<string name="autofill_close_database_title">Close database</string>
<string name="autofill_close_database_summary">Close the database after an autofill selection</string>
<string name="autofill_auto_search_title">Auto search</string> <string name="autofill_auto_search_title">Auto search</string>
<string name="autofill_auto_search_summary">Automatically suggest search results from the web domain or application ID</string> <string name="autofill_auto_search_summary">Automatically suggest search results from the web domain or application ID</string>
<string name="autofill_save_search_info_title">Save search info</string> <string name="autofill_save_search_info_title">Save search info</string>

View File

@@ -19,20 +19,25 @@
--> -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory <PreferenceCategory
android:title="@string/search_label"> android:title="@string/general">
<SwitchPreference
android:key="@string/autofill_close_database_key"
android:title="@string/autofill_close_database_title"
android:summary="@string/autofill_close_database_summary"
android:defaultValue="@bool/autofill_close_database_default"/>
<SwitchPreference <SwitchPreference
android:key="@string/autofill_auto_search_key" android:key="@string/autofill_auto_search_key"
android:title="@string/autofill_auto_search_title" android:title="@string/autofill_auto_search_title"
android:summary="@string/autofill_auto_search_summary" android:summary="@string/autofill_auto_search_summary"
android:defaultValue="@bool/autofill_auto_search_default"/> android:defaultValue="@bool/autofill_auto_search_default"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/save">
<SwitchPreference <SwitchPreference
android:key="@string/autofill_save_search_info_key" android:key="@string/autofill_save_search_info_key"
android:title="@string/autofill_save_search_info_title" android:title="@string/autofill_save_search_info_title"
android:summary="@string/autofill_save_search_info_summary" android:summary="@string/autofill_save_search_info_summary"
android:defaultValue="@bool/autofill_save_search_info_default"/> android:defaultValue="@bool/autofill_save_search_info_default"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/save">
<SwitchPreference <SwitchPreference
android:key="@string/autofill_ask_to_save_data_key" android:key="@string/autofill_ask_to_save_data_key"
android:title="@string/autofill_ask_to_save_data_title" android:title="@string/autofill_ask_to_save_data_title"

View File

@@ -1,5 +1,6 @@
* Upgrade to Android API 30 #723 * Upgrade to Android API 30 #723
* Save new credentials with Autofill #524 * Save new credentials with Autofill #524
* Setting to close database after Autofill selection #755
* Fix biometric issues #724 #740 #731 * Fix biometric issues #724 #740 #731
* Fix autofill #725 #551 * Fix autofill #725 #551
* Small fixes and translations #732 #736 #737 #738 #742 * Small fixes and translations #732 #736 #737 #738 #742

View File

@@ -1,5 +1,6 @@
* Mise à jour vers Android API 30 #723 * Mise à jour vers Android API 30 #723
* Sauvegarde de nouveaux identifiants avec le remplissage automatique #524 * Sauvegarde de nouveaux identifiants avec le remplissage automatique #524
* Paramètre pour fermer la base de données après une sélection de remplissage automatique #755
* Correction de problèmes biométriques #724 #740 #731 * Correction de problèmes biométriques #724 #740 #731
* Correction de l'autofill #725 #551 * Correction de l'autofill #725 #551
* Petites corrections et traductions #732 #736 #737 #738 #742 * Petites corrections et traductions #732 #736 #737 #738 #742