mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add default values in Blocklists and input password as autofill hints
This commit is contained in:
@@ -58,20 +58,22 @@ class KeeAutofillService : AutofillService() {
|
||||
|
||||
// Build search info only if applicationId or webDomain are not blocked
|
||||
var searchAllowed = true
|
||||
parseResult.applicationId?.let {
|
||||
parseResult.applicationId?.let { appId ->
|
||||
if (applicationIdBlocklist?.any { appIdBlocked ->
|
||||
it.contains(appIdBlocked)
|
||||
appId.contains(appIdBlocked)
|
||||
} == true
|
||||
) {
|
||||
searchAllowed = false
|
||||
Log.d(TAG, "Autofill not allowed for $appId")
|
||||
}
|
||||
}
|
||||
parseResult.domain?.let {
|
||||
parseResult.domain?.let { domain ->
|
||||
if (webDomainBlocklist?.any { webDomainBlocked ->
|
||||
it.contains(webDomainBlocked)
|
||||
domain.contains(webDomainBlocked)
|
||||
} == true
|
||||
) {
|
||||
searchAllowed = false
|
||||
Log.d(TAG, "Autofill not allowed for $domain")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -375,13 +375,15 @@ object PreferencesUtil {
|
||||
|
||||
fun applicationIdBlocklist(context: Context): Set<String> {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return prefs.getStringSet(context.getString(R.string.autofill_application_id_blocklist_key), null)
|
||||
return prefs.getStringSet(context.getString(R.string.autofill_application_id_blocklist_key),
|
||||
context.resources.getStringArray(R.array.autofill_application_id_blocklist_default).toMutableSet())
|
||||
?: emptySet()
|
||||
}
|
||||
|
||||
fun webDomainBlocklist(context: Context): Set<String> {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return prefs.getStringSet(context.getString(R.string.autofill_web_domain_blocklist_key), null)
|
||||
return prefs.getStringSet(context.getString(R.string.autofill_web_domain_blocklist_key),
|
||||
context.resources.getStringArray(R.array.autofill_web_domain_blocklist_default).toMutableSet())
|
||||
?: emptySet()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.preference.DialogPreference
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.icons.IconPackChooser
|
||||
import java.util.ArrayList
|
||||
|
||||
open class InputListPreference @JvmOverloads constructor(context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.kunzisoft.keepass.settings.preferencedialogfragment
|
||||
|
||||
import android.os.Bundle
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
|
||||
class AutofillBlocklistAppIdPreferenceDialogFragmentCompat
|
||||
@@ -32,6 +33,13 @@ class AutofillBlocklistAppIdPreferenceDialogFragmentCompat
|
||||
return SearchInfo().apply { this.applicationId = newSearchInfo }
|
||||
}
|
||||
|
||||
override fun getDefaultValues(): Set<String> {
|
||||
return context?.resources
|
||||
?.getStringArray(R.array.autofill_application_id_blocklist_default)
|
||||
?.toMutableSet()
|
||||
?: emptySet()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(key: String): AutofillBlocklistAppIdPreferenceDialogFragmentCompat {
|
||||
val fragment = AutofillBlocklistAppIdPreferenceDialogFragmentCompat()
|
||||
|
||||
@@ -43,6 +43,8 @@ abstract class AutofillBlocklistPreferenceDialogFragmentCompat
|
||||
|
||||
abstract fun buildSearchInfoFromString(searchInfoString: String): SearchInfo?
|
||||
|
||||
abstract fun getDefaultValues(): Set<String>
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -55,7 +57,7 @@ abstract class AutofillBlocklistPreferenceDialogFragmentCompat
|
||||
}
|
||||
} ?: run {
|
||||
// Or from preference
|
||||
preference.getPersistedStringSet(emptySet()).forEach { searchInfoString ->
|
||||
preference.getPersistedStringSet(getDefaultValues()).forEach { searchInfoString ->
|
||||
addSearchInfo(searchInfoString)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package com.kunzisoft.keepass.settings.preferencedialogfragment
|
||||
|
||||
import android.os.Bundle
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
import java.net.URI
|
||||
|
||||
class AutofillBlocklistWebDomainPreferenceDialogFragmentCompat
|
||||
: AutofillBlocklistPreferenceDialogFragmentCompat() {
|
||||
@@ -35,6 +35,13 @@ class AutofillBlocklistWebDomainPreferenceDialogFragmentCompat
|
||||
return SearchInfo().apply { webDomain = newSearchInfo }
|
||||
}
|
||||
|
||||
override fun getDefaultValues(): Set<String> {
|
||||
return context?.resources
|
||||
?.getStringArray(R.array.autofill_web_domain_blocklist_default)
|
||||
?.toMutableSet()
|
||||
?: emptySet()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(key: String): AutofillBlocklistWebDomainPreferenceDialogFragmentCompat {
|
||||
val fragment = AutofillBlocklistWebDomainPreferenceDialogFragmentCompat()
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/container"
|
||||
android:importantForAutofill="noExcludeDescendants"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:targetApi="o">
|
||||
@@ -155,7 +154,8 @@
|
||||
android:hint="@string/password"
|
||||
android:inputType="textPassword"
|
||||
android:importantForAccessibility="no"
|
||||
android:importantForAutofill="no"
|
||||
android:importantForAutofill="yes"
|
||||
android:autofillHints="password|"
|
||||
android:imeOptions="actionDone"
|
||||
android:maxLines="1"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:importantForAutofill="noExcludeDescendants"
|
||||
tools:targetApi="o">
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/card_view_master_password"
|
||||
@@ -63,7 +62,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"
|
||||
android:importantForAccessibility="no"
|
||||
android:importantForAutofill="no"
|
||||
android:importantForAutofill="yes"
|
||||
android:autofillHints="newPassword"
|
||||
android:maxLines="1"
|
||||
android:hint="@string/hint_pass"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@@ -81,7 +81,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"
|
||||
android:importantForAccessibility="no"
|
||||
android:importantForAutofill="no"
|
||||
android:importantForAutofill="yes"
|
||||
android:autofillHints="newPassword"
|
||||
android:maxLines="1"
|
||||
android:hint="@string/hint_conf_pass"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
@@ -135,7 +135,14 @@
|
||||
<string name="autofill_auto_search_key" translatable="false">autofill_auto_search_key</string>
|
||||
<bool name="autofill_auto_search_default" translatable="false">true</bool>
|
||||
<string name="autofill_application_id_blocklist_key" translatable="false">autofill_application_id_blocklist_key</string>
|
||||
<string-array name="autofill_application_id_blocklist_default">
|
||||
<item translatable="false">com.kunzisoft.keepass.libre</item>
|
||||
<item translatable="false">com.kunzisoft.keepass.free</item>
|
||||
<item translatable="false">com.kunzisoft.keepass.pro</item>
|
||||
</string-array>
|
||||
<string name="autofill_web_domain_blocklist_key" translatable="false">autofill_web_domain_blocklist_key</string>
|
||||
<string-array name="autofill_web_domain_blocklist_default">
|
||||
</string-array>
|
||||
|
||||
<!-- Advanced Unlock Settings -->
|
||||
<string name="settings_advanced_unlock_key" translatable="false">settings_advanced_unlock_key</string>
|
||||
|
||||
Reference in New Issue
Block a user