diff options
Diffstat (limited to 'autofill-parser')
3 files changed, 29 insertions, 26 deletions
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillStrategyDsl.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillStrategyDsl.kt index 9348fab8..35006468 100644 --- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillStrategyDsl.kt +++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillStrategyDsl.kt @@ -105,31 +105,34 @@ internal class SingleFieldMatcher( } override fun match(fields: List<FormField>, alreadyMatched: List<FormField>): List<FormField>? { - return fields.minus(alreadyMatched).filter { take(it, alreadyMatched) }.let { contestants -> - when (contestants.size) { - 1 -> return@let listOf(contestants.single()) - 0 -> return@let null - } - var current = contestants - for ((i, tieBreaker) in tieBreakers.withIndex()) { - // Successively filter matched fields via tie breakers... - val new = current.filter { tieBreaker(it, alreadyMatched) } - // skipping those tie breakers that are not satisfied for any remaining field... - if (new.isEmpty()) { - logcat { "Tie breaker #${i + 1}: Didn't match any field; skipping" } - continue + return fields + .minus(alreadyMatched) + .filter { take(it, alreadyMatched) } + .let { contestants -> + when (contestants.size) { + 1 -> return@let listOf(contestants.single()) + 0 -> return@let null } - // and return if the available options have been narrowed to a single field. - if (new.size == 1) { - logcat { "Tie breaker #${i + 1}: Success" } + var current = contestants + for ((i, tieBreaker) in tieBreakers.withIndex()) { + // Successively filter matched fields via tie breakers... + val new = current.filter { tieBreaker(it, alreadyMatched) } + // skipping those tie breakers that are not satisfied for any remaining field... + if (new.isEmpty()) { + logcat { "Tie breaker #${i + 1}: Didn't match any field; skipping" } + continue + } + // and return if the available options have been narrowed to a single field. + if (new.size == 1) { + logcat { "Tie breaker #${i + 1}: Success" } + current = new + break + } + logcat { "Tie breaker #${i + 1}: Matched ${new.size} fields; continuing" } current = new - break } - logcat { "Tie breaker #${i + 1}: Matched ${new.size} fields; continuing" } - current = new + listOf(current.singleOrNull() ?: return null) } - listOf(current.singleOrNull() ?: return null) - } } } diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt index 849113cf..2556a2f6 100644 --- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt +++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt @@ -251,8 +251,7 @@ public fun getInstalledBrowsersWithAutofillSupportLevel( .map { it to getBrowserAutofillSupportLevel(context, it.activityInfo.packageName) } .filter { it.first.isDefault || it.second != BrowserAutofillSupportLevel.None } .map { - context - .packageManager + context.packageManager .getApplicationLabel(it.first.activityInfo.applicationInfo) .toString() to it.second } diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FormField.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FormField.kt index 30d80d1d..96813be5 100644 --- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FormField.kt +++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FormField.kt @@ -182,9 +182,10 @@ internal class FormField( // Basic type detection for HTML fields private val htmlTag = node.htmlInfo?.tag private val htmlAttributes: Map<String, String> = - node.htmlInfo?.attributes?.filter { it.first != null && it.second != null }?.associate { - Pair(it.first.lowercase(Locale.US), it.second.lowercase(Locale.US)) - } + node.htmlInfo + ?.attributes + ?.filter { it.first != null && it.second != null } + ?.associate { Pair(it.first.lowercase(Locale.US), it.second.lowercase(Locale.US)) } ?: emptyMap() private val htmlAttributesDebug = htmlAttributes.entries.joinToString { "${it.key}=${it.value}" } private val htmlInputType = htmlAttributes["type"] |