diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index acf2dd3..ad88ed7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -74,7 +74,8 @@ > - + + 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 3816648..29f75ed 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/MainActivity.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/MainActivity.kt @@ -35,7 +35,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.lifecycle.lifecycleScope import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController @@ -70,7 +69,6 @@ import com.zaneschepke.wireguardautotunnel.ui.theme.WireguardAutoTunnelTheme import com.zaneschepke.wireguardautotunnel.util.Constants import com.zaneschepke.wireguardautotunnel.util.extensions.requestAutoTunnelTileServiceUpdate import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.launch import javax.inject.Inject import kotlin.system.exitProcess @@ -251,11 +249,9 @@ class MainActivity : AppCompatActivity() { TunnelAutoTunnelScreen(config, appUiState.settings) } } - BackHandler(enabled = true) { - lifecycleScope.launch { - if (!navController.popBackStack()) { - this@MainActivity.finish() - } + BackHandler { + if (navController.previousBackStackEntry == null || !navController.popBackStack()) { + this@MainActivity.finish() } } }