Skip to content

Commit 0dcee67

Browse files
committed
fix: back gesture
1 parent 7b7c8f6 commit 0dcee67

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

app/src/main/AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
>
7575
<intent-filter>
7676
<action android:name="android.intent.action.MAIN" />
77-
77+
<action android:name="android.intent.action.SHOW_APP_INFO" />
78+
<category android:name="android.intent.category.DEFAULT" />
7879
<category android:name="android.intent.category.LAUNCHER" />
7980
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
8081
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />

app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/MainActivity.kt

+3-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import androidx.compose.ui.res.stringResource
3535
import androidx.compose.ui.unit.dp
3636
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
3737
import androidx.lifecycle.compose.collectAsStateWithLifecycle
38-
import androidx.lifecycle.lifecycleScope
3938
import androidx.navigation.compose.NavHost
4039
import androidx.navigation.compose.composable
4140
import androidx.navigation.compose.rememberNavController
@@ -70,7 +69,6 @@ import com.zaneschepke.wireguardautotunnel.ui.theme.WireguardAutoTunnelTheme
7069
import com.zaneschepke.wireguardautotunnel.util.Constants
7170
import com.zaneschepke.wireguardautotunnel.util.extensions.requestAutoTunnelTileServiceUpdate
7271
import dagger.hilt.android.AndroidEntryPoint
73-
import kotlinx.coroutines.launch
7472
import javax.inject.Inject
7573
import kotlin.system.exitProcess
7674

@@ -251,11 +249,9 @@ class MainActivity : AppCompatActivity() {
251249
TunnelAutoTunnelScreen(config, appUiState.settings)
252250
}
253251
}
254-
BackHandler(enabled = true) {
255-
lifecycleScope.launch {
256-
if (!navController.popBackStack()) {
257-
this@MainActivity.finish()
258-
}
252+
BackHandler {
253+
if (navController.previousBackStackEntry == null || !navController.popBackStack()) {
254+
this@MainActivity.finish()
259255
}
260256
}
261257
}

0 commit comments

Comments
 (0)