fix: notification channel creation bug

Fixes a crash that is caused by a typo when creating a new notification channel.

Also makes VPN kill switch visible on TVs
This commit is contained in:
Zane Schepke 2024-12-11 00:03:39 -05:00
parent 6762d4733e
commit d84d9df57d
3 changed files with 63 additions and 59 deletions

View File

@ -86,13 +86,13 @@ constructor(
fun NotificationChannels.asBuilder(): NotificationCompat.Builder { fun NotificationChannels.asBuilder(): NotificationCompat.Builder {
return when (this) { return when (this) {
NotificationChannels.VPN -> { NotificationChannels.AUTO_TUNNEL -> {
NotificationCompat.Builder( NotificationCompat.Builder(
context, context,
context.getString(R.string.auto_tunnel_channel_id), context.getString(R.string.auto_tunnel_channel_id),
) )
} }
NotificationChannels.AUTO_TUNNEL -> { NotificationChannels.VPN -> {
NotificationCompat.Builder( NotificationCompat.Builder(
context, context,
context.getString(R.string.vpn_channel_id), context.getString(R.string.vpn_channel_id),

View File

@ -151,50 +151,51 @@ fun SettingsScreen(viewModel: SettingsViewModel = hiltViewModel(), appViewModel:
), ),
) )
if (!isRunningOnTv) { if (!isRunningOnTv) {
addAll( add(
listOf( SelectionItem(
SelectionItem( Icons.Outlined.VpnLock,
Icons.Outlined.VpnLock, {
{ ScaledSwitch(
ScaledSwitch( enabled = !(
enabled = !( (
( uiState.settings.isTunnelOnWifiEnabled ||
uiState.settings.isTunnelOnWifiEnabled || uiState.settings.isTunnelOnEthernetEnabled ||
uiState.settings.isTunnelOnEthernetEnabled || uiState.settings.isTunnelOnMobileDataEnabled
uiState.settings.isTunnelOnMobileDataEnabled ) &&
) && uiState.settings.isAutoTunnelEnabled
uiState.settings.isAutoTunnelEnabled ),
), onClick = { appViewModel.onToggleAlwaysOnVPN() },
onClick = { appViewModel.onToggleAlwaysOnVPN() }, checked = uiState.settings.isAlwaysOnVpnEnabled,
checked = uiState.settings.isAlwaysOnVpnEnabled, )
) },
}, title = {
title = { Text(
Text( stringResource(R.string.always_on_vpn_support),
stringResource(R.string.always_on_vpn_support), style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface),
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface), )
) },
}, onClick = { appViewModel.onToggleAlwaysOnVPN() },
onClick = { appViewModel.onToggleAlwaysOnVPN() },
),
SelectionItem(
Icons.Outlined.VpnKeyOff,
title = {
Text(
stringResource(R.string.kill_switch_options),
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface),
)
},
onClick = {
navController.navigate(Route.KillSwitch)
},
trailing = {
ForwardButton { navController.navigate(Route.KillSwitch) }
},
),
), ),
) )
} }
add(
SelectionItem(
Icons.Outlined.VpnKeyOff,
title = {
Text(
stringResource(R.string.kill_switch_options),
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface),
)
},
onClick = {
navController.navigate(Route.KillSwitch)
},
trailing = {
ForwardButton { navController.navigate(Route.KillSwitch) }
},
),
)
add( add(
SelectionItem( SelectionItem(
Icons.Outlined.Restore, Icons.Outlined.Restore,

View File

@ -26,6 +26,7 @@ import com.zaneschepke.wireguardautotunnel.ui.common.button.surface.SurfaceSelec
import com.zaneschepke.wireguardautotunnel.ui.common.navigation.TopNavBar import com.zaneschepke.wireguardautotunnel.ui.common.navigation.TopNavBar
import com.zaneschepke.wireguardautotunnel.ui.common.permission.vpn.withVpnPermission import com.zaneschepke.wireguardautotunnel.ui.common.permission.vpn.withVpnPermission
import com.zaneschepke.wireguardautotunnel.ui.screens.settings.components.ForwardButton import com.zaneschepke.wireguardautotunnel.ui.screens.settings.components.ForwardButton
import com.zaneschepke.wireguardautotunnel.util.extensions.isRunningOnTv
import com.zaneschepke.wireguardautotunnel.util.extensions.launchVpnSettings import com.zaneschepke.wireguardautotunnel.util.extensions.launchVpnSettings
import com.zaneschepke.wireguardautotunnel.util.extensions.scaledHeight import com.zaneschepke.wireguardautotunnel.util.extensions.scaledHeight
import com.zaneschepke.wireguardautotunnel.util.extensions.scaledWidth import com.zaneschepke.wireguardautotunnel.util.extensions.scaledWidth
@ -66,23 +67,25 @@ fun KillSwitchScreen(uiState: AppUiState, appViewModel: AppViewModel) {
.padding(top = 24.dp.scaledHeight()) .padding(top = 24.dp.scaledHeight())
.padding(horizontal = 24.dp.scaledWidth()), .padding(horizontal = 24.dp.scaledWidth()),
) { ) {
SurfaceSelectionGroupButton( if (!context.isRunningOnTv()) {
listOf( SurfaceSelectionGroupButton(
SelectionItem( listOf(
Icons.Outlined.AdminPanelSettings, SelectionItem(
title = { Icons.Outlined.AdminPanelSettings,
Text( title = {
stringResource(R.string.native_kill_switch), Text(
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface), stringResource(R.string.native_kill_switch),
) style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface),
}, )
onClick = { context.launchVpnSettings() }, },
trailing = { onClick = { context.launchVpnSettings() },
ForwardButton { context.launchVpnSettings() } trailing = {
}, ForwardButton { context.launchVpnSettings() }
},
),
), ),
), )
) }
SurfaceSelectionGroupButton( SurfaceSelectionGroupButton(
buildList { buildList {
add( add(