[BWA-99] feat: Add preview next TOTP code setting#6840
Closed
[BWA-99] feat: Add preview next TOTP code setting#6840
Conversation
Adds a user-controlled "Show next code" toggle in authenticator settings. When enabled, the upcoming TOTP code is rendered below the current code for each TOTP item in the list, letting users see incoming codes without waiting for the rollover. HOTP items are excluded since next-code generation requires advancing the counter.
- Localize next-code contentDescription via stringResource (next_code_x) - Use startsWith instead of contains for HOTP URI prefix check - Remove no-op nextCode assignment in copy() time-update branch
…g bug - Cache getLocalVerificationCodesFlow() as a class property so handleShowNextTotpCodeReceive reads from the already-subscribed flow instead of a new unsubscribed instance that always returns DataState.Loading (which caused the next code to never appear) - Add 10-second threshold: next code is only shown when timeLeftSeconds is at or below 10 seconds remaining in the current period - Update tests for the threshold (timeLeftSeconds = 5 / 10 / 11 cases)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎟️ Tracking
https://bitwarden.atlassian.net/browse/BWA-99
📔 Objective
Adds a user-controlled toggle in the Authenticator Settings screen that, when enabled, displays the upcoming TOTP code below the current code for each item in the authenticator list. The next code appears only in the last 10 seconds of the current period, giving users a heads-up before rollover without cluttering the UI throughout the full 30-second window.
Changes by layer:
SettingsDiskSource/SettingsRepository: newshowNextTotpCode: Booleansetting stored in SharedPreferences (defaultfalse), exposed as aStateFlow.TotpCodeManagerImpl: on code regeneration, callsgenerateTotp(uri, issueTime + periodSeconds)to populateVerificationCodeItem.nextCodefor TOTP items; HOTP items are excluded.VerificationCodeItemExtensions.toDisplayItem(): mapsnextCode → nextAuthCodeonly whenshowNextTotpCode = trueandtimeLeftSeconds ≤ 10.ItemListingViewModel: cachesgetLocalVerificationCodesFlow()as a class property (fixes a bug where re-creating the flow on each call returnedDataState.Loading); observesshowNextTotpCodeStateFlowvia an internal action.SettingsViewModel/SettingsScreen: newBitwardenSwitchwith label "Show next code" / sublabel "See incoming codes in the list".VaultVerificationCodeItem: renders next code below the current code whennextAuthCodeis non-null, with localized TalkBack content description ("Next code, [code]").📸 Screenshots