From aaf6ceb8ecbc71f6948c84b1a19fb83abfe8a418 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 25 Apr 2022 10:47:02 +0530 Subject: all: reformat with ktfmt 0.36 --- .../autofillparser/AutofillStrategyDsl.kt | 45 ++++++++++++---------- .../autofillparser/FeatureAndTrustDetection.kt | 3 +- .../autofillparser/FormField.kt | 7 ++-- 3 files changed, 29 insertions(+), 26 deletions(-) (limited to 'autofill-parser') 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, alreadyMatched: List): List? { - 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 = - 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"] -- cgit v1.2.3