From a9d76484253a6bf5ac9504e0ba5e8c5005ad0734 Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Thu, 19 Sep 2024 17:44:17 -0400 Subject: [PATCH] fix: androidtv ping settings bug save for android tv will not work when you submit with keyboard closes #355 --- app/build.gradle.kts | 6 +----- .../common/config/SubmitConfigurationTextBox.kt | 16 +++++++++++++++- .../ui/screens/options/OptionsScreen.kt | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 00849b8..79edb9e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,5 +1,3 @@ -import com.android.build.gradle.internal.scope.ProjectInfo.Companion.getBaseName - plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) @@ -229,11 +227,9 @@ val incrementVersionCode by tasks.registering { } } - tasks.whenTaskAdded { if (name.startsWith("assemble")) { + if (name.contains("debug")) return@whenTaskAdded dependsOn(incrementVersionCode) } } - - diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/config/SubmitConfigurationTextBox.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/config/SubmitConfigurationTextBox.kt index 0986526..303ff72 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/config/SubmitConfigurationTextBox.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/config/SubmitConfigurationTextBox.kt @@ -3,6 +3,7 @@ package com.zaneschepke.wireguardautotunnel.ui.common.config import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.collectIsFocusedAsState import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Save @@ -22,6 +23,8 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardCapitalization +import androidx.compose.ui.text.input.KeyboardType +import androidx.core.text.isDigitsOnly import com.zaneschepke.wireguardautotunnel.R @Composable @@ -49,10 +52,21 @@ fun SubmitConfigurationTextBox( interactionSource = interactionSource, value = stateValue ?: "", onValueChange = { - stateValue = it + when (keyboardOptions.keyboardType) { + KeyboardType.Number -> { + if (it.isDigitsOnly()) stateValue = it + } + else -> stateValue = it + } }, keyboardOptions = keyboardOptions, label = label, + keyboardActions = KeyboardActions( + onDone = { + onSubmit(stateValue!!) + keyboardController?.hide() + }, + ), hint = hint, modifier = Modifier .fillMaxWidth() diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/options/OptionsScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/options/OptionsScreen.kt index fb928a5..f83e1b6 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/options/OptionsScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/options/OptionsScreen.kt @@ -296,6 +296,7 @@ fun OptionsScreen( focusRequester, keyboardOptions = KeyboardOptions( keyboardType = KeyboardType.Number, + imeAction = ImeAction.Done, ), isErrorValue = ::isSecondsError, onSubmit = {