[PR #6840] [BWA-99] feat: Add preview next TOTP code setting #55126

Open
opened 2026-05-01 21:05:05 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/6840
Author: @aj-rosado
Created: 4/27/2026
Status: 🔄 Open

Base: mainHead: BWA-99/add-preview-next-totp-code-setting


📝 Commits (4)

  • 90f8994 claude-feature-plan
  • 79c15ea [BWA-99] feat: Add Preview Next TOTP Code setting
  • 380dcad [BWA-99] fix: Address code review findings
  • 8cd0894 [BWA-99] fix: Show next code only in last 10 seconds; fix flow caching bug

📊 Changes

22 files changed (+821 additions, -12 deletions)

View changed files

.claude/outputs/plans/BWA-99-PREVIEW-NEXT-TOTP-CODE-PLAN.md (+340 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/data/authenticator/manager/TotpCodeManagerImpl.kt (+33 -3)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/data/authenticator/manager/model/VerificationCodeItem.kt (+3 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/disk/SettingsDiskSource.kt (+15 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/disk/SettingsDiskSourceImpl.kt (+13 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/repository/SettingsRepository.kt (+10 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/repository/SettingsRepositoryImpl.kt (+16 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/itemlisting/ItemListingViewModel.kt (+41 -1)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/util/VerificationCodeItemExtensions.kt (+13 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/platform/components/listitem/VaultVerificationCodeItem.kt (+43 -8)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/platform/components/listitem/model/VerificationCodeDisplayItem.kt (+1 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/platform/feature/settings/SettingsScreen.kt (+16 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/platform/feature/settings/SettingsViewModel.kt (+20 -0)
📝 authenticator/src/test/kotlin/com/bitwarden/authenticator/data/authenticator/manager/util/TotpCodeManagerTest.kt (+68 -0)
📝 authenticator/src/test/kotlin/com/bitwarden/authenticator/data/authenticator/manager/util/VerificationCodeItemUtil.kt (+2 -0)
📝 authenticator/src/test/kotlin/com/bitwarden/authenticator/data/platform/repository/SettingsRepositoryTest.kt (+33 -0)
📝 authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/itemlisting/ItemListingScreenTest.kt (+1 -0)
📝 authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/itemlisting/ItemListingViewModelTest.kt (+47 -0)
📝 authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/util/VerificationCodeItemExtensionsTest.kt (+68 -0)
📝 authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/platform/feature/settings/SettingsScreenTest.kt (+1 -0)

...and 2 more files

📄 Description

🎟️ 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:

  • PersistenceSettingsDiskSource/SettingsRepository: new showNextTotpCode: Boolean setting stored in SharedPreferences (default false), exposed as a StateFlow.
  • TOTP managerTotpCodeManagerImpl: on code regeneration, calls generateTotp(uri, issueTime + periodSeconds) to populate VerificationCodeItem.nextCode for TOTP items; HOTP items are excluded.
  • MappingVerificationCodeItemExtensions.toDisplayItem(): maps nextCode → nextAuthCode only when showNextTotpCode = true and timeLeftSeconds ≤ 10.
  • ViewModel wiringItemListingViewModel: caches getLocalVerificationCodesFlow() as a class property (fixes a bug where re-creating the flow on each call returned DataState.Loading); observes showNextTotpCodeStateFlow via an internal action.
  • Settings UISettingsViewModel/SettingsScreen: new BitwardenSwitch with label "Show next code" / sublabel "See incoming codes in the list".
  • List item UIVaultVerificationCodeItem: renders next code below the current code when nextAuthCode is non-null, with localized TalkBack content description ("Next code, [code]").

📸 Screenshots


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/6840 **Author:** [@aj-rosado](https://github.com/aj-rosado) **Created:** 4/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `BWA-99/add-preview-next-totp-code-setting` --- ### 📝 Commits (4) - [`90f8994`](https://github.com/bitwarden/android/commit/90f8994a2f55bd28272e8ec1f2895e9986cab9ab) claude-feature-plan - [`79c15ea`](https://github.com/bitwarden/android/commit/79c15ea9d52ccc702d994d9d6e251106393b0a1e) [BWA-99] feat: Add Preview Next TOTP Code setting - [`380dcad`](https://github.com/bitwarden/android/commit/380dcaddbb6d1b0e942f7d301c48a3aefe09465f) [BWA-99] fix: Address code review findings - [`8cd0894`](https://github.com/bitwarden/android/commit/8cd0894aff55f5f7d46be60b9853639d6ff7d5c5) [BWA-99] fix: Show next code only in last 10 seconds; fix flow caching bug ### 📊 Changes **22 files changed** (+821 additions, -12 deletions) <details> <summary>View changed files</summary> ➕ `.claude/outputs/plans/BWA-99-PREVIEW-NEXT-TOTP-CODE-PLAN.md` (+340 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/data/authenticator/manager/TotpCodeManagerImpl.kt` (+33 -3) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/data/authenticator/manager/model/VerificationCodeItem.kt` (+3 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/disk/SettingsDiskSource.kt` (+15 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/disk/SettingsDiskSourceImpl.kt` (+13 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/repository/SettingsRepository.kt` (+10 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/repository/SettingsRepositoryImpl.kt` (+16 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/itemlisting/ItemListingViewModel.kt` (+41 -1) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/util/VerificationCodeItemExtensions.kt` (+13 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/platform/components/listitem/VaultVerificationCodeItem.kt` (+43 -8) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/platform/components/listitem/model/VerificationCodeDisplayItem.kt` (+1 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/platform/feature/settings/SettingsScreen.kt` (+16 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/platform/feature/settings/SettingsViewModel.kt` (+20 -0) 📝 `authenticator/src/test/kotlin/com/bitwarden/authenticator/data/authenticator/manager/util/TotpCodeManagerTest.kt` (+68 -0) 📝 `authenticator/src/test/kotlin/com/bitwarden/authenticator/data/authenticator/manager/util/VerificationCodeItemUtil.kt` (+2 -0) 📝 `authenticator/src/test/kotlin/com/bitwarden/authenticator/data/platform/repository/SettingsRepositoryTest.kt` (+33 -0) 📝 `authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/itemlisting/ItemListingScreenTest.kt` (+1 -0) 📝 `authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/itemlisting/ItemListingViewModelTest.kt` (+47 -0) 📝 `authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/util/VerificationCodeItemExtensionsTest.kt` (+68 -0) 📝 `authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/platform/feature/settings/SettingsScreenTest.kt` (+1 -0) _...and 2 more files_ </details> ### 📄 Description ## 🎟️ 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:** - **Persistence** — `SettingsDiskSource`/`SettingsRepository`: new `showNextTotpCode: Boolean` setting stored in SharedPreferences (default `false`), exposed as a `StateFlow`. - **TOTP manager** — `TotpCodeManagerImpl`: on code regeneration, calls `generateTotp(uri, issueTime + periodSeconds)` to populate `VerificationCodeItem.nextCode` for TOTP items; HOTP items are excluded. - **Mapping** — `VerificationCodeItemExtensions.toDisplayItem()`: maps `nextCode → nextAuthCode` only when `showNextTotpCode = true` and `timeLeftSeconds ≤ 10`. - **ViewModel wiring** — `ItemListingViewModel`: caches `getLocalVerificationCodesFlow()` as a class property (fixes a bug where re-creating the flow on each call returned `DataState.Loading`); observes `showNextTotpCodeStateFlow` via an internal action. - **Settings UI** — `SettingsViewModel`/`SettingsScreen`: new `BitwardenSwitch` with label "Show next code" / sublabel "See incoming codes in the list". - **List item UI** — `VaultVerificationCodeItem`: renders next code below the current code when `nextAuthCode` is non-null, with localized TalkBack content description (`"Next code, [code]"`). ## 📸 Screenshots <!-- Required for any UI changes; delete if not applicable. Use fixed width images for better display. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-01 21:05:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#55126