mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Improve hint "on" and "off" recognition
This commit is contained in:
@@ -34,6 +34,7 @@ import java.util.*
|
|||||||
internal class StructureParser(private val structure: AssistStructure) {
|
internal class StructureParser(private val structure: AssistStructure) {
|
||||||
private var result: Result? = null
|
private var result: Result? = null
|
||||||
private var usernameCandidate: AutofillId? = null
|
private var usernameCandidate: AutofillId? = null
|
||||||
|
private var lockHint: Boolean = false
|
||||||
|
|
||||||
fun parse(): Result? {
|
fun parse(): Result? {
|
||||||
result = Result()
|
result = Result()
|
||||||
@@ -85,19 +86,25 @@ internal class StructureParser(private val structure: AssistStructure) {
|
|||||||
val autofillId = node.autofillId
|
val autofillId = node.autofillId
|
||||||
node.autofillHints?.forEach {
|
node.autofillHints?.forEach {
|
||||||
when {
|
when {
|
||||||
it == View.AUTOFILL_HINT_USERNAME
|
it.toLowerCase(Locale.ENGLISH) == View.AUTOFILL_HINT_USERNAME
|
||||||
|| it == View.AUTOFILL_HINT_EMAIL_ADDRESS
|
|| it.toLowerCase(Locale.ENGLISH) == View.AUTOFILL_HINT_EMAIL_ADDRESS
|
||||||
|| it == View.AUTOFILL_HINT_PHONE -> {
|
|| it.toLowerCase(Locale.ENGLISH) == View.AUTOFILL_HINT_PHONE -> {
|
||||||
result?.usernameId = autofillId
|
result?.usernameId = autofillId
|
||||||
Log.d(TAG, "Autofill username hint")
|
Log.d(TAG, "Autofill username hint")
|
||||||
}
|
}
|
||||||
it == View.AUTOFILL_HINT_PASSWORD
|
it.toLowerCase(Locale.ENGLISH) == View.AUTOFILL_HINT_PASSWORD
|
||||||
|| it.contains("password") -> {
|
|| it.toLowerCase(Locale.ENGLISH).contains("password") -> {
|
||||||
result?.passwordId = autofillId
|
result?.passwordId = autofillId
|
||||||
Log.d(TAG, "Autofill password hint")
|
Log.d(TAG, "Autofill password hint")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
it == "on" -> {
|
it.toLowerCase(Locale.ENGLISH) == "off" -> {
|
||||||
|
Log.d(TAG, "Autofill OFF hint")
|
||||||
|
lockHint = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.toLowerCase(Locale.ENGLISH) == "on" -> {
|
||||||
|
Log.d(TAG, "Autofill ON hint")
|
||||||
if (parseNodeByHtmlAttributes(node))
|
if (parseNodeByHtmlAttributes(node))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -108,6 +115,8 @@ internal class StructureParser(private val structure: AssistStructure) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun parseNodeByHtmlAttributes(node: AssistStructure.ViewNode): Boolean {
|
private fun parseNodeByHtmlAttributes(node: AssistStructure.ViewNode): Boolean {
|
||||||
|
if (lockHint)
|
||||||
|
return false
|
||||||
val autofillId = node.autofillId
|
val autofillId = node.autofillId
|
||||||
val nodHtml = node.htmlInfo
|
val nodHtml = node.htmlInfo
|
||||||
when (nodHtml?.tag?.toLowerCase(Locale.ENGLISH)) {
|
when (nodHtml?.tag?.toLowerCase(Locale.ENGLISH)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user