mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
[PM-10622] Handle the skip unlock step in the onboarding, storing when the user selects to do so. (#3928)
This commit is contained in:
parent
8fe637d207
commit
05d6c2f61e
9 changed files with 108 additions and 3 deletions
|
@ -270,4 +270,16 @@ interface SettingsDiskSource {
|
|||
* enable autofill in onboarding.
|
||||
*/
|
||||
fun storeShowAutoFillSettingBadge(userId: String, showBadge: Boolean?)
|
||||
|
||||
/**
|
||||
* Gets whether or not the given [userId] has signalled they want to enable unlock options
|
||||
* later, during onboarding.
|
||||
*/
|
||||
fun getShowUnlockSettingBadge(userId: String): Boolean?
|
||||
|
||||
/**
|
||||
* Stores the given value for whether or not the given [userId] has signalled they want to
|
||||
* set up unlock options later, during onboarding.
|
||||
*/
|
||||
fun storeShowUnlockSettingBadge(userId: String, showBadge: Boolean?)
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ private const val CLEAR_CLIPBOARD_INTERVAL_KEY = "clearClipboard"
|
|||
private const val INITIAL_AUTOFILL_DIALOG_SHOWN = "addSitePromptShown"
|
||||
private const val HAS_USER_LOGGED_IN_OR_CREATED_AN_ACCOUNT_KEY = "hasUserLoggedInOrCreatedAccount"
|
||||
private const val SHOW_AUTOFILL_SETTING_BADGE = "showAutofillSettingBadge"
|
||||
private const val SHOW_UNLOCK_SETTING_BADGE = "showUnlockSettingBadge"
|
||||
|
||||
/**
|
||||
* Primary implementation of [SettingsDiskSource].
|
||||
|
@ -407,4 +408,15 @@ class SettingsDiskSourceImpl(
|
|||
key = SHOW_AUTOFILL_SETTING_BADGE.appendIdentifier(userId),
|
||||
value = showBadge,
|
||||
)
|
||||
|
||||
override fun getShowUnlockSettingBadge(userId: String): Boolean? =
|
||||
getBoolean(
|
||||
key = SHOW_UNLOCK_SETTING_BADGE.appendIdentifier(userId),
|
||||
)
|
||||
|
||||
override fun storeShowUnlockSettingBadge(userId: String, showBadge: Boolean?) =
|
||||
putBoolean(
|
||||
key = SHOW_UNLOCK_SETTING_BADGE.appendIdentifier(userId),
|
||||
value = showBadge,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -256,14 +256,26 @@ interface SettingsRepository {
|
|||
fun storeUserHasLoggedInValue(userId: String)
|
||||
|
||||
/**
|
||||
* Gets whether or not the given [userId] has signalled they want to enable autofill in
|
||||
* onboarding.
|
||||
* Gets whether or not the given [userId] has signalled they want to enable autofill
|
||||
* later, during onboarding.
|
||||
*/
|
||||
fun getShowAutoFillSettingBadge(userId: String): Boolean
|
||||
|
||||
/**
|
||||
* Stores the given value for whether or not the given [userId] has signalled they want to
|
||||
* enable autofill in onboarding.
|
||||
* enable autofill later, during onboarding.
|
||||
*/
|
||||
fun storeShowAutoFillSettingBadge(userId: String, showBadge: Boolean)
|
||||
|
||||
/**
|
||||
* Gets whether or not the given [userId] has signalled they want to enable unlock options
|
||||
* later, during onboarding.
|
||||
*/
|
||||
fun getShowUnlockSettingBadge(userId: String): Boolean
|
||||
|
||||
/**
|
||||
* Stores the given value for whether or not the given [userId] has signalled they want to
|
||||
* set up unlock options later, during onboarding.
|
||||
*/
|
||||
fun storeShowUnlockSettingBadge(userId: String, showBadge: Boolean)
|
||||
}
|
||||
|
|
|
@ -545,6 +545,13 @@ class SettingsRepositoryImpl(
|
|||
settingsDiskSource.storeShowAutoFillSettingBadge(userId, showBadge)
|
||||
}
|
||||
|
||||
override fun getShowUnlockSettingBadge(userId: String): Boolean =
|
||||
settingsDiskSource.getShowUnlockSettingBadge(userId) ?: false
|
||||
|
||||
override fun storeShowUnlockSettingBadge(userId: String, showBadge: Boolean) {
|
||||
settingsDiskSource.storeShowUnlockSettingBadge(userId, showBadge)
|
||||
}
|
||||
|
||||
/**
|
||||
* If there isn't already one generated, generate a symmetric sync key that would be used
|
||||
* for communicating via IPC.
|
||||
|
|
|
@ -95,6 +95,7 @@ class SetupUnlockViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun handleSetUpLaterClick() {
|
||||
settingsRepository.storeShowUnlockSettingBadge(state.userId, true)
|
||||
updateOnboardingStatusToNextStep()
|
||||
}
|
||||
|
||||
|
|
|
@ -1053,4 +1053,28 @@ class SettingsDiskSourceTest {
|
|||
|
||||
assertTrue(settingsDiskSource.getShowAutoFillSettingBadge(userId = mockUserId)!!)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `storeShowUnlockSettingBadge should update SharedPreferences`() {
|
||||
val mockUserId = "mockUserId"
|
||||
val showUnlockSettingBadgeKey =
|
||||
"bwPreferencesStorage:showUnlockSettingBadge_$mockUserId"
|
||||
settingsDiskSource.storeShowUnlockSettingBadge(
|
||||
userId = mockUserId,
|
||||
showBadge = true,
|
||||
)
|
||||
assertTrue(fakeSharedPreferences.getBoolean(showUnlockSettingBadgeKey, false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getShowUnlockSettingBadge should pull value from shared preferences`() {
|
||||
val mockUserId = "mockUserId"
|
||||
val showUnlockSettingBadgeKey =
|
||||
"bwPreferencesStorage:showUnlockSettingBadge_$mockUserId"
|
||||
fakeSharedPreferences.edit {
|
||||
putBoolean(showUnlockSettingBadgeKey, true)
|
||||
}
|
||||
|
||||
assertTrue(settingsDiskSource.getShowUnlockSettingBadge(userId = mockUserId)!!)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ class FakeSettingsDiskSource : SettingsDiskSource {
|
|||
private val storedAccountBiometricIntegrityValidity = mutableMapOf<String, Boolean?>()
|
||||
private val userSignIns = mutableMapOf<String, Boolean>()
|
||||
private val userShowAutoFillBadge = mutableMapOf<String, Boolean?>()
|
||||
private val userShowUnlockBadge = mutableMapOf<String, Boolean?>()
|
||||
|
||||
override var appLanguage: AppLanguage? = null
|
||||
|
||||
|
@ -292,6 +293,13 @@ class FakeSettingsDiskSource : SettingsDiskSource {
|
|||
userShowAutoFillBadge[userId] = showBadge
|
||||
}
|
||||
|
||||
override fun getShowUnlockSettingBadge(userId: String): Boolean? =
|
||||
userShowUnlockBadge[userId]
|
||||
|
||||
override fun storeShowUnlockSettingBadge(userId: String, showBadge: Boolean?) {
|
||||
userShowUnlockBadge[userId] = showBadge
|
||||
}
|
||||
|
||||
private fun getMutableScreenCaptureAllowedFlow(userId: String): MutableSharedFlow<Boolean?> {
|
||||
return mutableScreenCaptureAllowedFlowMap.getOrPut(userId) {
|
||||
bufferedMutableSharedFlow(replay = 1)
|
||||
|
|
|
@ -1175,6 +1175,33 @@ class SettingsRepositoryTest {
|
|||
fakeSettingsDiskSource.storeShowAutoFillSettingBadge(userId = userId, showBadge = true)
|
||||
assertTrue(settingsRepository.getShowAutoFillSettingBadge(userId = userId))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `storeShowUnlockSettingBadge should store value of false to disk`() {
|
||||
val userId = "userId"
|
||||
settingsRepository.storeShowUnlockSettingBadge(userId = userId, showBadge = false)
|
||||
assertFalse(fakeSettingsDiskSource.getShowUnlockSettingBadge(userId = userId)!!)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `storeShowUnlockSettingBadge should store value of true to disk`() {
|
||||
val userId = "userId"
|
||||
settingsRepository.storeShowUnlockSettingBadge(userId = userId, showBadge = true)
|
||||
assertTrue(fakeSettingsDiskSource.getShowUnlockSettingBadge(userId = userId)!!)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getUnlockSettingBadge get value of false if does not exist`() {
|
||||
val userId = "userId"
|
||||
assertFalse(settingsRepository.getShowUnlockSettingBadge(userId = userId))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getShowUnlockSettingBadge should return the value saved to disk`() {
|
||||
val userId = "userId"
|
||||
fakeSettingsDiskSource.storeShowUnlockSettingBadge(userId = userId, showBadge = true)
|
||||
assertTrue(settingsRepository.getShowUnlockSettingBadge(userId = userId))
|
||||
}
|
||||
}
|
||||
|
||||
private const val USER_ID: String = "userId"
|
||||
|
|
|
@ -40,6 +40,7 @@ class SetupUnlockViewModelTest : BaseViewModelTest() {
|
|||
every { isUnlockWithPinEnabled } returns false
|
||||
every { isUnlockWithBiometricsEnabled } returns false
|
||||
every { isAutofillEnabledStateFlow } returns mutableAutofillEnabledStateFlow
|
||||
every { storeShowUnlockSettingBadge(any(), any()) } just runs
|
||||
}
|
||||
private val biometricsEncryptionManager: BiometricsEncryptionManager = mockk {
|
||||
every { getOrCreateCipher(userId = DEFAULT_USER_ID) } returns CIPHER
|
||||
|
@ -80,6 +81,7 @@ class SetupUnlockViewModelTest : BaseViewModelTest() {
|
|||
userId = DEFAULT_USER_ID,
|
||||
status = OnboardingStatus.AUTOFILL_SETUP,
|
||||
)
|
||||
settingsRepository.storeShowUnlockSettingBadge(DEFAULT_USER_ID, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue