Skip to content

Commit c5cbacb

Browse files
authored
Merge pull request #592 from synonymdev/chore/simplify-pin-options
chore: simplify pin options
2 parents af0b488 + f9dbcfe commit c5cbacb

8 files changed

Lines changed: 12 additions & 141 deletions

File tree

app/src/main/java/to/bitkit/data/SettingsStore.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ data class SettingsData(
9494
val quickPayAmount: Int = 5,
9595
val lightningSetupStep: Int = 0,
9696
val isPinEnabled: Boolean = false,
97-
val isPinOnLaunchEnabled: Boolean = false,
9897
val isBiometricEnabled: Boolean = false,
99-
val isPinOnIdleEnabled: Boolean = false,
10098
val isPinForPaymentsEnabled: Boolean = false,
10199
val isDevModeEnabled: Boolean = Env.isDebug,
102100
val showWidgets: Boolean = true,
@@ -123,8 +121,6 @@ data class SettingsData(
123121

124122
fun SettingsData.resetPin() = this.copy(
125123
isPinEnabled = false,
126-
isPinOnLaunchEnabled = true,
127-
isPinOnIdleEnabled = false,
128124
isPinForPaymentsEnabled = false,
129125
isBiometricEnabled = false,
130126
)

app/src/main/java/to/bitkit/services/MigrationService.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,6 @@ class MigrationService @Inject constructor(
740740
else -> CoinSelectionPreference.SmallestFirst
741741
},
742742
isPinEnabled = settings.pin ?: current.isPinEnabled,
743-
isPinOnLaunchEnabled = settings.pinOnLaunch ?: current.isPinOnLaunchEnabled,
744-
isPinOnIdleEnabled = settings.pinOnIdle ?: current.isPinOnIdleEnabled,
745743
isPinForPaymentsEnabled = settings.pinForPayments ?: current.isPinForPaymentsEnabled,
746744
isBiometricEnabled = settings.biometrics ?: current.isBiometricEnabled,
747745
quickPayIntroSeen = settings.quickpayIntroSeen ?: current.quickPayIntroSeen,
@@ -1632,8 +1630,6 @@ data class RNSettings(
16321630
val enableSendAmountWarning: Boolean? = null,
16331631
val enableSwipeToHideBalance: Boolean? = null,
16341632
val pin: Boolean? = null,
1635-
val pinOnLaunch: Boolean? = null,
1636-
val pinOnIdle: Boolean? = null,
16371633
val pinForPayments: Boolean? = null,
16381634
val biometrics: Boolean? = null,
16391635
val rbf: Boolean? = null,

app/src/main/java/to/bitkit/ui/MainActivity.kt

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import to.bitkit.androidServices.LightningNodeService
3434
import to.bitkit.androidServices.LightningNodeService.Companion.CHANNEL_ID_NODE
3535
import to.bitkit.models.NewTransactionSheetDetails
3636
import to.bitkit.ui.components.AuthCheckView
37-
import to.bitkit.ui.components.InactivityTracker
3837
import to.bitkit.ui.components.IsOnlineTracker
3938
import to.bitkit.ui.components.ToastOverlay
4039
import to.bitkit.ui.onboarding.CreateWalletWithPassphraseScreen
@@ -128,19 +127,17 @@ class MainActivity : FragmentActivity() {
128127
val isAuthenticated by appViewModel.isAuthenticated.collectAsStateWithLifecycle()
129128

130129
IsOnlineTracker(appViewModel)
131-
InactivityTracker(appViewModel, settingsViewModel) {
132-
ContentView(
133-
appViewModel = appViewModel,
134-
walletViewModel = walletViewModel,
135-
blocktankViewModel = blocktankViewModel,
136-
currencyViewModel = currencyViewModel,
137-
activityListViewModel = activityListViewModel,
138-
transferViewModel = transferViewModel,
139-
settingsViewModel = settingsViewModel,
140-
backupsViewModel = backupsViewModel,
141-
modifier = Modifier.hazeSource(hazeState, zIndex = 0f)
142-
)
143-
}
130+
ContentView(
131+
appViewModel = appViewModel,
132+
walletViewModel = walletViewModel,
133+
blocktankViewModel = blocktankViewModel,
134+
currencyViewModel = currencyViewModel,
135+
activityListViewModel = activityListViewModel,
136+
transferViewModel = transferViewModel,
137+
settingsViewModel = settingsViewModel,
138+
backupsViewModel = backupsViewModel,
139+
modifier = Modifier.hazeSource(hazeState, zIndex = 0f)
140+
)
144141

145142
AnimatedVisibility(
146143
visible = !isAuthenticated,

app/src/main/java/to/bitkit/ui/components/AuthCheckScreen.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ fun AuthCheckScreen(
1717
val app = appViewModel ?: return
1818
val settings = settingsViewModel ?: return
1919

20-
val isPinOnLaunchEnabled by settings.isPinOnLaunchEnabled.collectAsStateWithLifecycle()
2120
val isBiometricEnabled by settings.isBiometricEnabled.collectAsStateWithLifecycle()
22-
val isPinOnIdleEnabled by settings.isPinOnIdleEnabled.collectAsStateWithLifecycle()
2321
val isPinForPaymentsEnabled by settings.isPinForPaymentsEnabled.collectAsStateWithLifecycle()
2422

2523
AuthCheckView(
@@ -35,16 +33,6 @@ fun AuthCheckScreen(
3533
navController.popBackStack()
3634
}
3735

38-
AuthCheckAction.TOGGLE_PIN_ON_LAUNCH -> {
39-
settings.setIsPinOnLaunchEnabled(!isPinOnLaunchEnabled)
40-
navController.popBackStack()
41-
}
42-
43-
AuthCheckAction.TOGGLE_PIN_ON_IDLE -> {
44-
settings.setIsPinOnIdleEnabled(!isPinOnIdleEnabled)
45-
navController.popBackStack()
46-
}
47-
4836
AuthCheckAction.TOGGLE_PIN_FOR_PAYMENTS -> {
4937
settings.setIsPinForPaymentsEnabled(!isPinForPaymentsEnabled)
5038
navController.popBackStack()
@@ -68,9 +56,7 @@ fun AuthCheckScreen(
6856
}
6957

7058
object AuthCheckAction {
71-
const val TOGGLE_PIN_ON_LAUNCH = "TOGGLE_PIN_ON_LAUNCH"
7259
const val TOGGLE_BIOMETRICS = "TOGGLE_BIOMETRICS"
73-
const val TOGGLE_PIN_ON_IDLE = "TOGGLE_PIN_ON_IDLE"
7460
const val TOGGLE_PIN_FOR_PAYMENTS = "TOGGLE_PIN_FOR_PAYMENTS"
7561
const val DISABLE_PIN = "DISABLE_PIN"
7662
const val NAV_TO_RESET = "NAV_TO_RESET"

app/src/main/java/to/bitkit/ui/components/InactivityTracker.kt

Lines changed: 0 additions & 53 deletions
This file was deleted.

app/src/main/java/to/bitkit/ui/settings/SecuritySettingsScreen.kt

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ fun SecuritySettingsScreen(
4040
val app = appViewModel ?: return
4141

4242
val isPinEnabled by settings.isPinEnabled.collectAsStateWithLifecycle()
43-
val isPinOnLaunchEnabled by settings.isPinOnLaunchEnabled.collectAsStateWithLifecycle()
4443
val isBiometricEnabled by settings.isBiometricEnabled.collectAsStateWithLifecycle()
45-
val isPinOnIdleEnabled by settings.isPinOnIdleEnabled.collectAsStateWithLifecycle()
4644
val isPinForPaymentsEnabled by settings.isPinForPaymentsEnabled.collectAsStateWithLifecycle()
4745
val enableSwipeToHideBalance by settings.enableSwipeToHideBalance.collectAsStateWithLifecycle()
4846
val hideBalanceOnOpen by settings.hideBalanceOnOpen.collectAsStateWithLifecycle()
@@ -51,9 +49,7 @@ fun SecuritySettingsScreen(
5149

5250
Content(
5351
isPinEnabled = isPinEnabled,
54-
isPinOnLaunchEnabled = isPinOnLaunchEnabled,
5552
isBiometricEnabled = isBiometricEnabled,
56-
isPinOnIdleEnabled = isPinOnIdleEnabled,
5753
isPinForPaymentsEnabled = isPinForPaymentsEnabled,
5854
enableSwipeToHideBalance = enableSwipeToHideBalance,
5955
hideBalanceOnOpen = hideBalanceOnOpen,
@@ -70,16 +66,6 @@ fun SecuritySettingsScreen(
7066
onChangePinClick = {
7167
navController.navigateToChangePin()
7268
},
73-
onPinOnLaunchClick = {
74-
navController.navigateToAuthCheck(
75-
onSuccessActionId = AuthCheckAction.TOGGLE_PIN_ON_LAUNCH,
76-
)
77-
},
78-
onPinOnIdleClick = {
79-
navController.navigateToAuthCheck(
80-
onSuccessActionId = AuthCheckAction.TOGGLE_PIN_ON_IDLE,
81-
)
82-
},
8369
onPinForPaymentsClick = {
8470
navController.navigateToAuthCheck(
8571
onSuccessActionId = AuthCheckAction.TOGGLE_PIN_FOR_PAYMENTS,
@@ -110,9 +96,7 @@ fun SecuritySettingsScreen(
11096
@Composable
11197
private fun Content(
11298
isPinEnabled: Boolean,
113-
isPinOnLaunchEnabled: Boolean,
11499
isBiometricEnabled: Boolean,
115-
isPinOnIdleEnabled: Boolean,
116100
isPinForPaymentsEnabled: Boolean,
117101
enableSwipeToHideBalance: Boolean,
118102
hideBalanceOnOpen: Boolean,
@@ -121,8 +105,6 @@ private fun Content(
121105
isBiometrySupported: Boolean,
122106
onPinClick: () -> Unit = {},
123107
onChangePinClick: () -> Unit = {},
124-
onPinOnLaunchClick: () -> Unit = {},
125-
onPinOnIdleClick: () -> Unit = {},
126108
onPinForPaymentsClick: () -> Unit = {},
127109
onUseBiometricsClick: () -> Unit = {},
128110
onSwipeToHideBalanceClick: () -> Unit = {},
@@ -189,18 +171,6 @@ private fun Content(
189171
onClick = onChangePinClick,
190172
modifier = Modifier.testTag("PINChange"),
191173
)
192-
SettingsSwitchRow(
193-
title = stringResource(R.string.settings__security__pin_launch),
194-
isChecked = isPinOnLaunchEnabled,
195-
onClick = onPinOnLaunchClick,
196-
modifier = Modifier.testTag("EnablePinOnLaunch"),
197-
)
198-
SettingsSwitchRow(
199-
title = stringResource(R.string.settings__security__pin_idle),
200-
isChecked = isPinOnIdleEnabled,
201-
onClick = onPinOnIdleClick,
202-
modifier = Modifier.testTag("EnablePinOnIdle"),
203-
)
204174
SettingsSwitchRow(
205175
title = stringResource(R.string.settings__security__pin_payments),
206176
isChecked = isPinForPaymentsEnabled,
@@ -239,9 +209,7 @@ private fun Preview() {
239209
AppThemeSurface {
240210
Content(
241211
isPinEnabled = true,
242-
isPinOnLaunchEnabled = true,
243212
isBiometricEnabled = false,
244-
isPinOnIdleEnabled = false,
245213
isPinForPaymentsEnabled = false,
246214
enableSwipeToHideBalance = true,
247215
hideBalanceOnOpen = false,

app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ class AppViewModel @Inject constructor(
18331833
// region security
18341834
private suspend fun resetIsAuthenticatedStateInternal() {
18351835
val settings = settingsStore.data.first()
1836-
val needsAuth = settings.isPinEnabled && settings.isPinOnLaunchEnabled
1836+
val needsAuth = settings.isPinEnabled
18371837
_isAuthenticated.value = !needsAuth
18381838
}
18391839

@@ -1873,7 +1873,6 @@ class AppViewModel @Inject constructor(
18731873

18741874
fun addPin(pin: String) {
18751875
viewModelScope.launch {
1876-
settingsStore.update { it.copy(isPinOnLaunchEnabled = true) }
18771876
settingsStore.addDismissedSuggestion(Suggestion.SECURE)
18781877
}
18791878
editPin(pin)

app/src/main/java/to/bitkit/viewmodels/SettingsViewModel.kt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,6 @@ class SettingsViewModel @Inject constructor(
108108
}
109109
}
110110

111-
val isPinOnIdleEnabled = settingsStore.data.map { it.isPinOnIdleEnabled }
112-
.asStateFlow(initialValue = false)
113-
114-
fun setIsPinOnIdleEnabled(value: Boolean) {
115-
viewModelScope.launch {
116-
settingsStore.update { it.copy(isPinOnIdleEnabled = value) }
117-
}
118-
}
119-
120111
val isPinForPaymentsEnabled = settingsStore.data.map { it.isPinForPaymentsEnabled }
121112
.asStateFlow(initialValue = false)
122113

@@ -147,15 +138,6 @@ class SettingsViewModel @Inject constructor(
147138
val isPinEnabled = settingsStore.data.map { it.isPinEnabled }
148139
.asStateFlow(SharingStarted.Eagerly, false)
149140

150-
val isPinOnLaunchEnabled = settingsStore.data.map { it.isPinOnLaunchEnabled }
151-
.asStateFlow(SharingStarted.Eagerly, false)
152-
153-
fun setIsPinOnLaunchEnabled(value: Boolean) {
154-
viewModelScope.launch {
155-
settingsStore.update { it.copy(isPinOnLaunchEnabled = value) }
156-
}
157-
}
158-
159141
val isBiometricEnabled = settingsStore.data.map { it.isBiometricEnabled }
160142
.asStateFlow(SharingStarted.Eagerly, false)
161143

0 commit comments

Comments
 (0)