Skip to content

Commit

Permalink
add prompt to inform user about data collection before enabling crash…
Browse files Browse the repository at this point in the history
… reporting
  • Loading branch information
jakub-rdx committed Dec 14, 2023
1 parent 1276e3a commit ae68529
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ fun NavGraphBuilder.appSettingsScreen(
SettingsItem.AppSettingsItem.Gateways -> {
navController.navigate(Screen.SettingsEditGatewayApiDestination.route)
}

is SettingsItem.AppSettingsItem.Backups -> {
navController.backupScreen()
}
is SettingsItem.AppSettingsItem.CrashReporting,
is SettingsItem.AppSettingsItem.DeveloperMode -> {}
SettingsItem.AppSettingsItem.EntityHiding -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
Expand All @@ -20,6 +23,7 @@ import com.babylon.wallet.android.R
import com.babylon.wallet.android.designsystem.theme.RadixTheme
import com.babylon.wallet.android.designsystem.theme.RadixWalletTheme
import com.babylon.wallet.android.presentation.settings.SettingsItem
import com.babylon.wallet.android.presentation.ui.composables.BasicPromptAlertDialog
import com.babylon.wallet.android.presentation.ui.composables.DefaultSettingsItem
import com.babylon.wallet.android.presentation.ui.composables.RadixCenteredTopAppBar
import com.babylon.wallet.android.presentation.ui.composables.SwitchSettingsItem
Expand Down Expand Up @@ -52,6 +56,19 @@ private fun AppSettingsContent(
onBackClick: () -> Unit,
onCrashReportingToggled: (Boolean) -> Unit,
) {
var crashReportingPromptVisible by remember { mutableStateOf(false) }
if (crashReportingPromptVisible) {
BasicPromptAlertDialog(
finish = { accepted ->
if (accepted) {
onCrashReportingToggled(true)
}
crashReportingPromptVisible = false
},
title = "Crash Reporting", // TODO crowdin
text = "I'm aware Radix Wallet will send crash reports together with device state." // TODO crowdin
)
}
Scaffold(
modifier = modifier,
topBar = {
Expand Down Expand Up @@ -92,6 +109,7 @@ private fun AppSettingsContent(
onCheckedChange = onDeveloperModeToggled
)
}

is SettingsItem.AppSettingsItem.CrashReporting -> {
SwitchSettingsItem(
modifier = Modifier
Expand All @@ -100,9 +118,16 @@ private fun AppSettingsContent(
titleRes = appSettingsItem.descriptionRes(),
iconResource = appSettingsItem.getIcon(),
checked = appSettingsItem.enabled,
onCheckedChange = onCrashReportingToggled
onCheckedChange = { selected ->
if (selected) {
crashReportingPromptVisible = true
} else {
onCrashReportingToggled(false)
}
}
)
}

SettingsItem.AppSettingsItem.EntityHiding -> {
DefaultSettingsItem(
title = stringResource(id = appSettingsItem.descriptionRes()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import javax.inject.Inject
@HiltViewModel
class AppSettingsViewModel @Inject constructor(
private val getProfileUseCase: GetProfileUseCase,
private val getBackupStateUseCase: GetBackupStateUseCase,
private val preferencesManager: PreferencesManager,
private val updateDeveloperModeUseCase: UpdateDeveloperModeUseCase
) : StateViewModel<AppSettingsUiState>() {
Expand Down Expand Up @@ -65,23 +64,6 @@ class AppSettingsViewModel @Inject constructor(
}
}
}
viewModelScope.launch {
getBackupStateUseCase().collect { backupState ->
_state.update { settingsUiState ->
val settingsList = if (settingsUiState.settings.any { it is SettingsItem.AppSettingsItem.Backups }) {
settingsUiState.settings.mapWhen(
predicate = { it is SettingsItem.AppSettingsItem.Backups },
mutation = { SettingsItem.AppSettingsItem.Backups(backupState = backupState) }
)
} else {
settingsUiState.settings.toMutableList().apply {
add(2, SettingsItem.AppSettingsItem.Backups(backupState))
}
}
settingsUiState.copy(settings = settingsList.toPersistentSet())
}
}
}
}

fun onDeveloperModeToggled(enabled: Boolean) = viewModelScope.launch {
Expand Down
21 changes: 11 additions & 10 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<string name="settings_depositGuarantees_title">Deposit Guarantees</string>
<string name="settings_depositGuarantees_subtitle">Set your default guaranteed minimum for estimated deposits</string>
<string name="settings_depositGuarantees_text">Set the guaranteed minimum deposit to be applied whenever a deposit in a transaction can only be estimated.

\n\n
You can always change the guarantee from this default in each transaction.</string>
<string name="settings_multiFactor">Multi-Factor Setup</string>
<string name="settings_appVersion">Version: %s build #%s</string>
Expand Down Expand Up @@ -757,12 +757,12 @@ You can always change the guarantee from this default in each transaction.</stri
<string name="addLedgerDevice_nameLedger_namePlaceholder">Green Ledger Nano S+</string>
<string name="addLedgerDevice_nameLedger_continueButtonTitle">Save and Continue</string>
<string name="profileBackup_headerTitle">Backing up your wallet ensures that you can restore access to your Accounts, Personas, and wallet settings on a new phone by re-entering your seed phrase(s).

\n\n
**For security, backups do not contain any seed phrases or private keys. You must write them down separately.**</string>
<string name="profileBackup_automaticBackups_title">Automatic Backups (recommended)</string>
<string name="profileBackup_manualBackups_title">Manual Backups</string>
<string name="profileBackup_manualBackups_subtitle">A manually exported wallet backup file may also be used for recovery, along with your seed phrase(s).

\n\n
Only the **current configuration** of your wallet is backed up with each manual export.</string>
<string name="profileBackup_manualBackups_exportButtonTitle">Export Wallet Backup File</string>
<string name="profileBackup_manualBackups_encryptBackupDialogTitle">Encrypt this backup with a password?</string>
Expand Down Expand Up @@ -792,7 +792,7 @@ Only the **current configuration** of your wallet is backed up with each manual
<string name="androidProfileBackup_backupWalletData_title">Backup Wallet Data to Cloud</string>
<string name="androidProfileBackup_backupWalletData_message">Warning: If disabled you might lose access to your Accounts and Personas.</string>
<string name="androidProfileBackup_deleteWallet_subtitle">You may delete your wallet. This will clear the Radix Wallet app, clears its contents, and delete any cloud backup.

\n\n
**Access to any Accounts or Personas will be permanently lost unless you have a manual backup file.**</string>
<string name="androidProfileBackup_deleteWallet_confirmButton">Delete Wallet</string>
<string name="iOSProfileBackup_automaticBackups_enable">Enable Backup to iCloud</string>
Expand All @@ -814,7 +814,7 @@ Only the **current configuration** of your wallet is backed up with each manual
<string name="iOSProfileBackup_totalPersonasNumberLabel">Number of Personas: %d</string>
<string name="iOSProfileBackup_incompatibleWalletDataLabel">Incompatible Wallet data</string>
<string name="iOSProfileBackup_deleteWallet_subtitle">You may delete your wallet. This will clear the Radix Wallet app, clears its contents, and delete any iCloud backup.

\n\n
**Access to any Accounts or Personas will be permanently lost unless you have a manual backup file.**</string>
<string name="iOSProfileBackup_deleteWallet_confirmButton">Delete Wallet and iCloud Backup</string>
<string name="iOSProfileBackup_profileNotFoundInCloud">Unable to find wallet backup in iCloud.</string>
Expand Down Expand Up @@ -844,9 +844,9 @@ Only the **current configuration** of your wallet is backed up with each manual
<string name="recoverSeedPhrase_header_subtitleMainSeedPhrase">Your **Personas** and the following **Accounts** are controlled by your main seed phrase. To recover control, you must re-enter it.</string>
<string name="recoverSeedPhrase_header_subtitleOtherSeedPhrase">The following **Accounts** are controlled by a seed phrase. To recover control, you must re-enter it.</string>
<string name="recoverSeedPhrase_header_subtitleNoMainSeedPhrase">The Radix Wallet always uses a single main “Babylon” seed phrase to generate new Personas and new Accounts (when not using a Ledger device).

\n\n
If you do not have access to your previous main seed phrase, you can skip entering it for now. **The Radix Wallet will create a new one, which will be used for new Personas and Accounts.**

\n\n
Your old Accounts and Personas will still be listed, but you will have to enter their original seed phrase to use them. Alternatively, you can hide them if you no longer are interested in using them.</string>
<string name="recoverSeedPhrase_skipButton">Skip This Seed Phrase For Now</string>
<string name="recoverSeedPhrase_noMainSeedPhraseButton">I Don’t Have the Main Seed Phrase</string>
Expand Down Expand Up @@ -911,12 +911,12 @@ Your old Accounts and Personas will still be listed, but you will have to enter
<string name="accountRecoveryScan_selectInactiveAccounts_continueButton">Continue</string>
<string name="recoverWalletWithoutProfileComplete_header_title">Recovery Complete</string>
<string name="recoverWalletWithoutProfileComplete_header_subtitle">Accounts discovered in the scan have been added to your wallet.

\n\n
If you have any “Legacy” Accounts (created on the Olympia network) to import - or any Accounts using a Ledger hardware wallet device - please continue and then use the **Account Recovery Scan** option in your Radix Wallet settings under **Account Security**.</string>
<string name="recoverWalletWithoutProfileComplete_continueButton">Continue</string>
<string name="recoverWalletWithoutProfileInfo_header_title">Recover Control Without Backup</string>
<string name="recoverWalletWithoutProfileInfo_header_subtitle">**If you have no wallet backup in the cloud or as an exported backup file**, you can still restore Account access only using your main “Babylon” seed phrase. You cannot recover your Account names or other wallet settings this way.

\n\n
You will be asked to enter your main seed phrase. This is a set of **24 words** that the Radix Wallet mobile app showed you to write down and save securely.</string>
<string name="recoverWalletWithoutProfileInfo_continueButton">Continue</string>
<string name="recoverWalletWithoutProfileStart_header_title">Recover Control Without Backup</string>
Expand All @@ -937,7 +937,7 @@ You will be asked to enter your main seed phrase. This is a set of **24 words**
<string name="accountRecoveryScan_babylonSection_subtitle">Scan for Accounts originally created on the **Babylon** network.</string>
<string name="accountRecoveryScan_olympiaSection_title">Olympia Accounts</string>
<string name="accountRecoveryScan_olympiaSection_subtitle">Scan for Accounts originally created on the **Olympia** network.

\n\n
(If you have Olympia Accounts in the Radix Olympia Desktop Wallet, consider using **Import from a Legacy Wallet** instead.</string>
<string name="accountRecoveryScan_olympiaSection_footnote">Note: You will still use the new **Radix Babylon** app on your Ledger device, not the old Radix Ledger app.</string>
<string name="accountRecoveryScan_seedPhraseButtonTitle">Use Seed Phrase</string>
Expand All @@ -950,4 +950,5 @@ You will be asked to enter your main seed phrase. This is a set of **24 words**
<string name="accountRecoveryScan_chooseSeedPhrase_continueButton">Continue</string>
<string name="accountRecoveryScan_olympiaLedgerNote">Note: You must still use the new *Radix Babylon* app on your Ledger device, not the old Radix Ledger app.</string>
<string name="accountRecoveryScan_derivingAccounts">Deriving Accounts</string>
<string name="appSettings_crashReporting_title">Crash Reporting</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import java.time.Instant
import javax.inject.Inject
import javax.inject.Singleton

@Suppress("TooManyFunctions")
@Singleton
class PreferencesManager @Inject constructor(
private val dataStore: DataStore<Preferences>
Expand Down Expand Up @@ -92,15 +93,6 @@ class PreferencesManager @Inject constructor(
}
}

fun getBackedUpFactorSourceIds(): Flow<Set<String>> {
return dataStore.data.map { preferences ->
preferences[KEY_BACKED_UP_FACTOR_SOURCE_IDS]?.split(",").orEmpty().toSet()
}
}

suspend fun markFirstPersonaCreated() {
dataStore.edit { preferences ->
preferences[KEY_FIRST_PERSONA_CREATED] = true
val isRadixBannerVisible: Flow<Boolean> = dataStore.data
.map { preferences ->
preferences[KEY_RADIX_BANNER_VISIBLE] ?: false
Expand Down

0 comments on commit ae68529

Please sign in to comment.