From 520521713c24d05da74ae52929a8f2c057d7bb93 Mon Sep 17 00:00:00 2001 From: Farnam Taheri Date: Mon, 11 May 2026 22:05:40 +0330 Subject: [PATCH] fix(android): confirm profile deletion Require an explicit confirmation dialog before deleting a profile from the Profiles screen. The existing delete flow remains unchanged after confirmation, but accidental one-tap deletes are prevented. --- .../vpn/ui/profiles/ProfilesScreen.kt | 33 ++++++++++++++++++- android/app/src/main/res/values/strings.xml | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/masterdns/vpn/ui/profiles/ProfilesScreen.kt b/android/app/src/main/java/com/masterdns/vpn/ui/profiles/ProfilesScreen.kt index bb76830..d7175b2 100644 --- a/android/app/src/main/java/com/masterdns/vpn/ui/profiles/ProfilesScreen.kt +++ b/android/app/src/main/java/com/masterdns/vpn/ui/profiles/ProfilesScreen.kt @@ -50,6 +50,7 @@ fun ProfilesScreen( var editingProfile by remember { mutableStateOf(null) } var importedDraft by remember { mutableStateOf(null) } var importedResolvers by remember { mutableStateOf(null) } + var profilePendingDelete by remember { mutableStateOf(null) } val context = androidx.compose.ui.platform.LocalContext.current val snackbarHostState = remember { SnackbarHostState() } val scope = rememberCoroutineScope() @@ -195,12 +196,42 @@ fun ProfilesScreen( editingProfile = profile showEditor = true }, - onDelete = { viewModel.deleteProfile(profile) } + onDelete = { profilePendingDelete = profile } ) } } } } + + profilePendingDelete?.let { profile -> + AlertDialog( + onDismissRequest = { profilePendingDelete = null }, + title = { Text(stringResource(R.string.profiles_delete_confirm_title)) }, + text = { + Text( + stringResource( + R.string.profiles_delete_confirm_message, + profile.name.ifBlank { stringResource(R.string.profiles_dialog_new_title) } + ) + ) + }, + confirmButton = { + TextButton( + onClick = { + viewModel.deleteProfile(profile) + profilePendingDelete = null + } + ) { + Text(stringResource(R.string.profiles_delete)) + } + }, + dismissButton = { + TextButton(onClick = { profilePendingDelete = null }) { + Text(stringResource(R.string.action_cancel)) + } + } + ) + } } @Composable diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 64dc1e5..69f7f50 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -78,6 +78,8 @@ Edit Settings Delete + Delete profile? + Delete "%1$s"? This cannot be undone. Edit Profile New Profile Profile Name