mirror of
https://github.com/AChep/keyguard-app.git
synced 2025-01-04 18:59:15 +01:00
improvement: Hide Inline autofill suggestions option on unsupported platforms
This commit is contained in:
parent
9fa53ea157
commit
6538c1d13e
@ -7,6 +7,7 @@ private val platform by lazy {
|
||||
.matches(".+_cheets|cheets_.+".toRegex())
|
||||
Platform.Mobile.Android(
|
||||
isChromebook = isChromebook,
|
||||
sdk = Build.VERSION.SDK_INT,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,8 @@ import com.artemchep.keyguard.common.io.launchIn
|
||||
import com.artemchep.keyguard.common.usecase.GetAutofillInlineSuggestions
|
||||
import com.artemchep.keyguard.common.usecase.PutAutofillInlineSuggestions
|
||||
import com.artemchep.keyguard.common.usecase.WindowCoroutineScope
|
||||
import com.artemchep.keyguard.platform.CurrentPlatform
|
||||
import com.artemchep.keyguard.platform.hasAutofillInlineSuggestions
|
||||
import com.artemchep.keyguard.res.Res
|
||||
import com.artemchep.keyguard.res.*
|
||||
import com.artemchep.keyguard.ui.FlatItem
|
||||
@ -32,6 +34,12 @@ fun settingAutofillInlineSuggestionsProvider(
|
||||
putAutofillInlineSuggestions: PutAutofillInlineSuggestions,
|
||||
windowCoroutineScope: WindowCoroutineScope,
|
||||
): SettingComponent = getAutofillInlineSuggestions().map { inlineSuggestions ->
|
||||
// Hide inline suggestions option if
|
||||
// it is not supported by the platform.
|
||||
if (!CurrentPlatform.hasAutofillInlineSuggestions()) {
|
||||
return@map null
|
||||
}
|
||||
|
||||
val onCheckedChange = { shouldInlineSuggestions: Boolean ->
|
||||
putAutofillInlineSuggestions(shouldInlineSuggestions)
|
||||
.launchIn(windowCoroutineScope)
|
||||
|
@ -6,6 +6,7 @@ sealed interface Platform {
|
||||
sealed interface Mobile : Platform {
|
||||
data class Android(
|
||||
val isChromebook: Boolean,
|
||||
val sdk: Int,
|
||||
) : Mobile
|
||||
}
|
||||
|
||||
|
@ -4,3 +4,8 @@ fun Platform.hasShareFeature(): Boolean = when (this) {
|
||||
is Platform.Mobile -> true
|
||||
is Platform.Desktop -> false
|
||||
}
|
||||
|
||||
fun Platform.hasAutofillInlineSuggestions(): Boolean = when (this) {
|
||||
is Platform.Mobile.Android -> sdk >= 30 // Android R
|
||||
is Platform.Desktop -> false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user