diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/WireGuardTunnel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/WireGuardTunnel.kt index da102fa..f108097 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/WireGuardTunnel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/WireGuardTunnel.kt @@ -56,8 +56,11 @@ constructor( return runCatching { when (val backend = backend()) { is Backend -> backend.setState(this, tunnelState.toWgState(), TunnelConfig.configFromWgQuick(tunnelConfig.wgQuick)).let { TunnelState.from(it) } - is org.amnezia.awg.backend.Backend -> backend.setState(this, tunnelState.toAmState(), TunnelConfig.configFromAmQuick(tunnelConfig.amQuick)).let { - TunnelState.from(it) + is org.amnezia.awg.backend.Backend -> { + val config = if(tunnelConfig.amQuick.isBlank()) TunnelConfig.configFromAmQuick(tunnelConfig.wgQuick) else TunnelConfig.configFromAmQuick(tunnelConfig.amQuick) + backend.setState(this, tunnelState.toAmState(), config).let { + TunnelState.from(it) + } } else -> throw NotImplementedError() } diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/MainActivity.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/MainActivity.kt index f99a8d0..4cad622 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/MainActivity.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/MainActivity.kt @@ -15,6 +15,7 @@ import androidx.compose.material3.SnackbarDuration import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.SnackbarResult +import androidx.compose.material3.Surface import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -127,6 +128,7 @@ class MainActivity : AppCompatActivity() { ) } }, + containerColor = MaterialTheme.colorScheme.background, // TODO refactor modifier = Modifier @@ -148,88 +150,90 @@ class MainActivity : AppCompatActivity() { ) }, ) { padding -> - NavHost( - navController, - startDestination = (if (isPinLockEnabled == true) Screen.Lock.route else Screen.Main.route), - modifier = - Modifier - .padding(padding) - .fillMaxSize(), - ) { - composable( - Screen.Main.route, + Surface { + NavHost( + navController, + startDestination = (if (isPinLockEnabled == true) Screen.Lock.route else Screen.Main.route), + modifier = + Modifier + .padding(padding) + .fillMaxSize(), ) { - MainScreen( - focusRequester = focusRequester, - appViewModel = appViewModel, - navController = navController, - ) - } - composable( - Screen.Settings.route, - ) { - SettingsScreen( - appViewModel = appViewModel, - navController = navController, - focusRequester = focusRequester, - ) - } - composable( - Screen.Support.route, - ) { - SupportScreen( - focusRequester = focusRequester, - navController = navController, - ) - } - composable(Screen.Support.Logs.route) { - LogsScreen() - } - composable( - "${Screen.Config.route}/{id}?configType={configType}", - arguments = - listOf( - navArgument("id") { - type = NavType.StringType - defaultValue = "0" - }, - navArgument("configType") { - type = NavType.StringType - defaultValue = ConfigType.WIREGUARD.name - }, - ), - ) { - val id = it.arguments?.getString("id") - val configType = - ConfigType.valueOf( - it.arguments?.getString("configType") ?: ConfigType.WIREGUARD.name, - ) - if (!id.isNullOrBlank()) { - ConfigScreen( - navController = navController, - tunnelId = id, - appViewModel = appViewModel, + composable( + Screen.Main.route, + ) { + MainScreen( focusRequester = focusRequester, - configType = configType, + appViewModel = appViewModel, + navController = navController, ) } - } - composable("${Screen.Option.route}/{id}") { - val id = it.arguments?.getString("id") - if (!id.isNullOrBlank()) { - OptionsScreen( - navController = navController, - tunnelId = id, + composable( + Screen.Settings.route, + ) { + SettingsScreen( appViewModel = appViewModel, + navController = navController, focusRequester = focusRequester, ) } - } - composable(Screen.Lock.route) { - PinLockScreen( - navController = navController, - appViewModel = appViewModel, - ) + composable( + Screen.Support.route, + ) { + SupportScreen( + focusRequester = focusRequester, + navController = navController, + ) + } + composable(Screen.Support.Logs.route) { + LogsScreen() + } + composable( + "${Screen.Config.route}/{id}?configType={configType}", + arguments = + listOf( + navArgument("id") { + type = NavType.StringType + defaultValue = "0" + }, + navArgument("configType") { + type = NavType.StringType + defaultValue = ConfigType.WIREGUARD.name + }, + ), + ) { + val id = it.arguments?.getString("id") + val configType = + ConfigType.valueOf( + it.arguments?.getString("configType") ?: ConfigType.WIREGUARD.name, + ) + if (!id.isNullOrBlank()) { + ConfigScreen( + navController = navController, + tunnelId = id, + appViewModel = appViewModel, + focusRequester = focusRequester, + configType = configType, + ) + } + } + composable("${Screen.Option.route}/{id}") { + val id = it.arguments?.getString("id") + if (!id.isNullOrBlank()) { + OptionsScreen( + navController = navController, + tunnelId = id, + appViewModel = appViewModel, + focusRequester = focusRequester, + ) + } + } + composable(Screen.Lock.route) { + PinLockScreen( + navController = navController, + appViewModel = appViewModel, + ) + } } } } diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/navigation/BottomNavBar.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/navigation/BottomNavBar.kt index bac9b82..df8ee04 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/navigation/BottomNavBar.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/navigation/BottomNavBar.kt @@ -6,6 +6,7 @@ import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBarItem import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigViewModel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigViewModel.kt index 0d30050..4df067b 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigViewModel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigViewModel.kt @@ -296,7 +296,7 @@ constructor( val wgQuick = buildConfig().toWgQuickString(true) val amQuick = if (configType == ConfigType.AMNEZIA) { - buildAmConfig().toAwgQuickString() + buildAmConfig().toAwgQuickString(true) } else { TunnelConfig.AM_QUICK_DEFAULT } diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt index ec90370..6a8503b 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt @@ -4,9 +4,6 @@ import android.annotation.SuppressLint import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity.RESULT_OK -import androidx.compose.animation.AnimatedVisibility -import androidx.compose.animation.fadeIn -import androidx.compose.animation.fadeOut import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.focusable import androidx.compose.foundation.gestures.ScrollableDefaults @@ -265,12 +262,8 @@ fun MainScreen( reverseLayout = false, flingBehavior = ScrollableDefaults.flingBehavior(), ) { - item { - AnimatedVisibility( - uiState.tunnels.isEmpty(), - exit = fadeOut(), - enter = fadeIn(), - ) { + if(uiState.tunnels.isEmpty()) { + item { GettingStartedLabel(onClick = { context.openWebUrl(it) }) } } diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt index 19c4880..f18712f 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt @@ -179,7 +179,7 @@ constructor( when (type) { ConfigType.AMNEZIA -> { val config = org.amnezia.awg.config.Config.parse(it) - amQuick = config.toAwgQuickString() + amQuick = config.toAwgQuickString(true) config.toWgQuickString() } @@ -252,7 +252,7 @@ constructor( org.amnezia.awg.config.Config.parse( zip, ) - amQuick = config.toAwgQuickString() + amQuick = config.toAwgQuickString(true) config.toWgQuickString() } diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt index 9b944c3..02db929 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt @@ -630,7 +630,7 @@ fun SettingsScreen( Modifier .fillMaxWidth(fillMaxWidth) .padding(vertical = 10.dp) - .padding(bottom = 140.dp), + .padding(bottom = 10.dp), ) { Column( horizontalAlignment = Alignment.Start, diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/TunnelExtensions.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/TunnelExtensions.kt index 19a0006..0b86cc2 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/TunnelExtensions.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/TunnelExtensions.kt @@ -29,7 +29,7 @@ fun TunnelStatistics.PeerStats.handshakeStatus(): HandshakeStatus { } fun Config.toWgQuickString(): String { - val amQuick = toAwgQuickString() + val amQuick = toAwgQuickString(true) val lines = amQuick.lines().toMutableList() val linesIterator = lines.iterator() while (linesIterator.hasNext()) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5cea633..d74aa92 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] accompanist = "0.34.0" activityCompose = "1.9.1" -amneziawgAndroid = "1.2.1" +amneziawgAndroid = "1.2.2" androidx-junit = "1.2.1" appcompat = "1.7.0" biometricKtx = "1.2.0-alpha05" @@ -16,7 +16,7 @@ junit = "4.13.2" kotlinx-serialization-json = "1.7.1" lifecycle-runtime-compose = "2.8.4" material3 = "1.2.1" -multifabVersion = "1.1.0" +multifabVersion = "1.1.1" navigationCompose = "2.7.7" pinLockCompose = "1.0.3" roomVersion = "2.6.1"