diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/components/AutoTunnelRowItem.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/components/AutoTunnelRowItem.kt index efff234..84c6e62 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/components/AutoTunnelRowItem.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/components/AutoTunnelRowItem.kt @@ -5,10 +5,8 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.rounded.Bolt import androidx.compose.material3.Icon import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.scale -import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource @@ -19,12 +17,10 @@ import com.zaneschepke.wireguardautotunnel.ui.common.ExpandingRowListItem import com.zaneschepke.wireguardautotunnel.ui.common.button.ScaledSwitch import com.zaneschepke.wireguardautotunnel.ui.theme.SilverTree import com.zaneschepke.wireguardautotunnel.util.extensions.isRunningOnTv -import com.zaneschepke.wireguardautotunnel.util.extensions.scaledHeight @Composable fun AutoTunnelRowItem(appUiState: AppUiState, onToggle: () -> Unit) { val context = LocalContext.current - val itemFocusRequester = remember { FocusRequester() } ExpandingRowListItem( leading = { val icon = Icons.Rounded.Bolt @@ -33,7 +29,7 @@ fun AutoTunnelRowItem(appUiState: AppUiState, onToggle: () -> Unit) { icon.name, modifier = Modifier - .size(16.dp.scaledHeight()).scale(1.5f), + .size(16.dp).scale(1.5f), tint = if (!appUiState.autoTunnelActive) { Color.Gray @@ -53,7 +49,7 @@ fun AutoTunnelRowItem(appUiState: AppUiState, onToggle: () -> Unit) { }, onClick = { if (context.isRunningOnTv()) { - itemFocusRequester.requestFocus() + onToggle() } }, isExpanded = false, diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/components/TunnelRowItem.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/components/TunnelRowItem.kt index 82d8f55..11e2cd4 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/components/TunnelRowItem.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/components/TunnelRowItem.kt @@ -33,7 +33,6 @@ import com.zaneschepke.wireguardautotunnel.ui.common.navigation.LocalNavControll import com.zaneschepke.wireguardautotunnel.ui.common.snackbar.SnackbarController import com.zaneschepke.wireguardautotunnel.util.extensions.asColor import com.zaneschepke.wireguardautotunnel.util.extensions.isRunningOnTv -import com.zaneschepke.wireguardautotunnel.util.extensions.scaledHeight @Composable fun TunnelRowItem( @@ -56,20 +55,19 @@ fun TunnelRowItem( val itemFocusRequester = remember { FocusRequester() } ExpandingRowListItem( leading = { - val circleIcon = Icons.Rounded.Circle val icon = if (tunnel.isPrimaryTunnel) { Icons.Rounded.Star } else if (tunnel.isMobileDataTunnel) { Icons.Rounded.Smartphone } else { - circleIcon + Icons.Rounded.Circle } Icon( icon, icon.name, tint = leadingIconColor, - modifier = Modifier.size(16.dp.scaledHeight()), + modifier = Modifier.size(16.dp), ) }, text = tunnel.name, 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 c79c90d..c74b39b 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 @@ -8,6 +8,8 @@ import androidx.compose.foundation.layout.fillMaxSize 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.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Edit import androidx.compose.material.icons.outlined.NetworkPing @@ -80,6 +82,7 @@ fun OptionsScreen(optionsViewModel: OptionsViewModel = hiltViewModel(), appUiSta Modifier .fillMaxSize() .padding(it) + .verticalScroll(rememberScrollState()) .padding(top = 24.dp.scaledHeight()) .padding(horizontal = 24.dp.scaledWidth()), ) { diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/support/SupportScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/support/SupportScreen.kt index a8f919c..5bf50b2 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/support/SupportScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/support/SupportScreen.kt @@ -1,10 +1,11 @@ package com.zaneschepke.wireguardautotunnel.ui.screens.support -import android.os.Build import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AttachMoney import androidx.compose.material.icons.filled.Book @@ -48,6 +49,7 @@ fun SupportScreen() { Modifier .fillMaxSize() .padding(top = topPadding) + .verticalScroll(rememberScrollState()) .padding(horizontal = 24.dp.scaledWidth()), ) { GroupLabel(stringResource(R.string.thank_you)) @@ -129,7 +131,8 @@ fun SupportScreen() { title = { Text( stringResource(R.string.open_issue), - style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface)) + style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface), + ) }, trailing = { ForwardButton { @@ -157,7 +160,7 @@ fun SupportScreen() { context.launchSupportEmail() }, ), - ) + ), ) if (BuildConfig.FLAVOR == "fdroid") { add( @@ -180,7 +183,7 @@ fun SupportScreen() { ), ) } - } + }, ) VersionLabel() } diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/ContextExtensions.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/ContextExtensions.kt index 42377e9..af3324a 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/ContextExtensions.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/ContextExtensions.kt @@ -22,6 +22,7 @@ import com.zaneschepke.wireguardautotunnel.util.Constants private const val BASELINE_HEIGHT = 2201 private const val BASELINE_WIDTH = 1080 private const val BASELINE_DENSITY = 2.625 +private const val ANDROID_TV_SIZE_MULTIPLIER = 1.5f fun Context.openWebUrl(url: String): Result { return kotlin.runCatching { @@ -47,7 +48,8 @@ val Context.actionBarSize fun Context.resizeHeight(dp: Dp): Dp { val displayMetrics = resources.displayMetrics val density = displayMetrics.density - val height = displayMetrics.heightPixels - this.actionBarSize + val height = (displayMetrics.heightPixels - this.actionBarSize) * + (if (isRunningOnTv()) ANDROID_TV_SIZE_MULTIPLIER else 1f) val resizeHeightPercentage = (height.toFloat() / BASELINE_HEIGHT) * (BASELINE_DENSITY.toFloat() / density) return dp * resizeHeightPercentage @@ -56,7 +58,8 @@ fun Context.resizeHeight(dp: Dp): Dp { fun Context.resizeHeight(textUnit: TextUnit): TextUnit { val displayMetrics = resources.displayMetrics val density = displayMetrics.density - val height = displayMetrics.heightPixels - actionBarSize + val height = (displayMetrics.heightPixels - actionBarSize) * + (if (isRunningOnTv()) ANDROID_TV_SIZE_MULTIPLIER else 1f) val resizeHeightPercentage = (height.toFloat() / BASELINE_HEIGHT) * (BASELINE_DENSITY.toFloat() / density) return textUnit * resizeHeightPercentage * 1.1