From b06a47032609d8961fe8b5107c4eb2123b180882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joris=20Pelgr=C3=B6m?= Date: Thu, 5 Dec 2024 18:39:24 +0100 Subject: [PATCH 1/2] Update KeyboardOptions constructor to autoCorrectEnabled --- .../android/settings/controls/views/ManageControlsView.kt | 2 +- .../android/settings/shortcuts/views/ManageShortcutsView.kt | 2 +- .../android/settings/url/views/ExternalUrlInputView.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/controls/views/ManageControlsView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/controls/views/ManageControlsView.kt index 26b77d85145..3b526d03580 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/controls/views/ManageControlsView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/controls/views/ManageControlsView.kt @@ -230,7 +230,7 @@ fun ManageControlsView( value = panelPath, onValueChange = { panelPath = it }, label = { Text(stringResource(id = R.string.lovelace_view_dashboard)) }, - keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done, autoCorrect = false, keyboardType = KeyboardType.Uri), + keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done, autoCorrectEnabled = false, keyboardType = KeyboardType.Uri), modifier = Modifier .fillMaxWidth() .padding(all = 16.dp) diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/views/ManageShortcutsView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/views/ManageShortcutsView.kt index b54bdc771c9..24b7890cd62 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/views/ManageShortcutsView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/views/ManageShortcutsView.kt @@ -233,7 +233,7 @@ private fun CreateShortcutView( value = viewModel.shortcuts[i].path.value, onValueChange = { viewModel.shortcuts[i].path.value = it }, label = { Text(stringResource(id = R.string.lovelace_view_dashboard)) }, - keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done, autoCorrect = false, keyboardType = KeyboardType.Uri), + keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done, autoCorrectEnabled = false, keyboardType = KeyboardType.Uri), modifier = Modifier.fillMaxWidth().padding(bottom = 16.dp) ) } else { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/url/views/ExternalUrlInputView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/url/views/ExternalUrlInputView.kt index a6baff339ec..bad7756cb82 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/url/views/ExternalUrlInputView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/url/views/ExternalUrlInputView.kt @@ -54,7 +54,7 @@ fun ExternalUrlInputView( urlInput = it urlError = false }, - keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done, autoCorrect = false, keyboardType = KeyboardType.Uri), + keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done, autoCorrectEnabled = false, keyboardType = KeyboardType.Uri), keyboardActions = KeyboardActions( onDone = { urlError = !performUrlUpdate(urlInput?.trim(), url, onSaveUrl) From de2b6c4e37b8f75cbb2c9e94e5568841b7721a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joris=20Pelgr=C3=B6m?= Date: Thu, 5 Dec 2024 18:54:58 +0100 Subject: [PATCH 2/2] Replace ClickableText with LinkAnnotation --- .../android/onboarding/welcome/WelcomeView.kt | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/welcome/WelcomeView.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/welcome/WelcomeView.kt index 6531cad3b59..ae96880a694 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/welcome/WelcomeView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/welcome/WelcomeView.kt @@ -6,22 +6,22 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.verticalScroll import androidx.compose.material.Button import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.LinkAnnotation import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.TextLinkStyles import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextDecoration -import androidx.compose.ui.text.withStyle +import androidx.compose.ui.text.withLink import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -57,25 +57,22 @@ fun WelcomeView( modifier = Modifier.fillMaxWidth().padding(vertical = 16.dp) ) val annotatedString = buildAnnotatedString { - pushStringAnnotation("learn", "https://www.home-assistant.io") - withStyle( - style = SpanStyle( - color = MaterialTheme.colors.primary, - textDecoration = TextDecoration.Underline + withLink( + LinkAnnotation.Url( + url = "https://www.home-assistant.io", + styles = TextLinkStyles( + SpanStyle( + color = MaterialTheme.colors.primary, + textDecoration = TextDecoration.Underline + ) + ) ) ) { append(stringResource(id = commonR.string.learn_more)) } - pop() } - val uriHandler = LocalUriHandler.current - ClickableText( + Text( text = annotatedString, - onClick = { - annotatedString.getStringAnnotations("learn", it, it).firstOrNull()?.let { link -> - uriHandler.openUri(link.item) - } - }, modifier = Modifier.padding(bottom = 16.dp) )