Skip to content

Commit

Permalink
KM-5777: Updated Delete Account Flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kp-iva-nedeleva committed Sep 25, 2024
1 parent 151ea78 commit d675dc6
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 60 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/kape/vpn/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ class MainActivity : AppCompatActivity() {
Settings.Route -> {
shortcutPrefs.setShortcutSettings(true)
}

VpnRegionSelection.Main -> {
shortcutPrefs.setShortcutChangeServer(true)
}

Connection.Main -> {
shortcutPrefs.setShortcutConnectToVpn(true)
}
Expand Down Expand Up @@ -273,6 +275,9 @@ class MainActivity : AppCompatActivity() {
composable(WebContent.NoInAppRegistration) {
InAppBrowser(url = getString(com.kape.ui.R.string.url_registration))
}
composable(WebContent.DeleteAccount) {
InAppBrowser(url = getString(com.kape.ui.R.string.url_delete_account))
}
composable(PerAppSettings.Main) {
PerAppSettingsScreen()
}
Expand Down
1 change: 1 addition & 0 deletions capabilities/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<string name="url_support" translatable="false">https://www.privateinternetaccess.com/helpdesk/</string>
<string name="url_registration" translatable="false">https://www.privateinternetaccess.com/account/client-sign-in#subscription-overview</string>
<string name="url_support_new_ticket" translatable="false">https://www.privateinternetaccess.com/helpdesk/new-ticket</string>
<string name="url_delete_account" translatable="false">https://helpdesk.privateinternetaccess.com/guides/account-changes/change-account-information/delete-pia-account</string>

<string name="qs_title">Connect to PIA</string>
<string name="change_server">Change Server</string>
Expand Down
1 change: 1 addition & 0 deletions core/router/src/main/java/com/kape/router/AppFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sealed class EnterFlow : AppFlow {
data object VpnRegionSelection : EnterFlow()
data object ShadowsocksRegionSelection : EnterFlow()
data object Profile : EnterFlow()
data object DeleteAccount : EnterFlow()
data object Subscribe : EnterFlow()
data object TermsOfService : EnterFlow()
data object PrivacyPolicy : EnterFlow()
Expand Down
1 change: 1 addition & 0 deletions core/router/src/main/java/com/kape/router/Destinations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ object WebContent {
const val Privacy = "web-screen-privacy"
const val Support = "web-screen-support"
const val NoInAppRegistration = "web-screen-registration"
const val DeleteAccount = "delete-account"
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class MobileRouter : Router {
EnterFlow.Subscribe -> navigation.value = Subscribe.Main
EnterFlow.PrivacyPolicy -> navigation.value = WebContent.Privacy
EnterFlow.TermsOfService -> navigation.value = WebContent.Terms
EnterFlow.DeleteAccount -> navigation.value = WebContent.DeleteAccount
EnterFlow.Settings -> navigation.value = Settings.Route
EnterFlow.AutomationSettings -> navigation.value = Settings.Automation
EnterFlow.PerAppSettings -> navigation.value = PerAppSettings.Main
Expand Down
3 changes: 2 additions & 1 deletion core/router/src/main/java/com/kape/router/tv/TvRouter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class TvRouter : Router {
EnterFlow.Customization,
EnterFlow.AccountDeleted,
EnterFlow.DedicatedIpPlans,
EnterFlow.NoInAppRegistration,
EnterFlow.DeleteAccount,
-> throw IllegalStateException("Unsupported on TV")
EnterFlow.NoInAppRegistration -> TODO()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -47,7 +43,6 @@ fun ProfileScreen() = Screen {
appBarText(stringResource(id = R.string.account))
}
val state by remember(viewModel) { viewModel.screenState }.collectAsState()
val showDialog = remember { mutableStateOf(false) }

Column {
AppBar(
Expand Down Expand Up @@ -111,57 +106,12 @@ fun ProfileScreen() = Screen {
HyperlinkRed(
content = stringResource(id = R.string.account_deletion_action),
modifier = Modifier.clickable {
showDialog.value = true
viewModel.navigateToDeleteAccount()
},
)
Spacer(modifier = Modifier.height(16.dp))
}
}

if (showDialog.value) {
DeleteAccountConfirmationDialog(
onDismiss = { showDialog.value = false },
onConfirm = {
viewModel.deleteAccount()
showDialog.value = false
},
)
}
}
}
}

@Composable
fun DeleteAccountConfirmationDialog(onDismiss: () -> Unit, onConfirm: () -> Unit) {
AlertDialog(
onDismissRequest = onDismiss,
confirmButton = {
TextButton(onClick = onConfirm) {
Text(
text = stringResource(id = R.string.account_deletion_dialog_positive_action),
color = LocalColors.current.error,
)
}
},
dismissButton = {
TextButton(onClick = onDismiss) {
Text(
text = stringResource(id = R.string.account_deletion_dialog_negative_action),
color = LocalColors.current.primary,
)
}
},
title = {
Text(
text = stringResource(id = R.string.account_deletion_dialog_title),
style = MaterialTheme.typography.titleMedium,
)
},
text = {
Text(
text = stringResource(id = R.string.account_deletion_dialog_message),
style = MaterialTheme.typography.bodyMedium,
)
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,7 @@ class ProfileViewModel(
router.handleFlow(Exit)
}

fun deleteAccount() = viewModelScope.launch {
_state.emit(LOADING)
deleteAccountUseCase.deleteAccount().collect {
logoutUseCase.logout().collect {
router.handleFlow(EnterFlow.AccountDeleted)
}
}
}
fun navigateToDeleteAccount() = router.handleFlow(EnterFlow.DeleteAccount)

fun logout() = viewModelScope.launch {
logoutUseCase.logout().collect {
Expand Down

0 comments on commit d675dc6

Please sign in to comment.