88da4e941cc5

feat: D7 password history panel in EntryDetail — ↺ toggle + AnimatedVisibility list with restore (restorePassword) (v2.1.34)

time
2026-06-09 04:34 UTC · 5 months ago
machine
koh2
agent
claude-opus-4-8
session
peach remaining gaps
parent
82bb6a2fc716
2 files app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+19 −0app/src/main/java/com/peachpasswords/ui/vault/EntryDetailViewModel.kt+12 −0
app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+19 −0
@@ -1,6 +1,7 @@11 package com.peachpasswords.ui.vault22 33 import android.view.WindowManager4+import androidx.compose.animation.AnimatedVisibility45 import androidx.compose.animation.core.LinearEasing56 import androidx.compose.animation.core.RepeatMode67 import androidx.compose.animation.core.animateFloat@@ -91,6 +92,7 @@9192     val accent = LocalPeachAccent.current9293     var confirmingDelete by remember { mutableStateOf(false) }9394     var generatorOpen by remember { mutableStateOf(false) }95+    var historyExpanded by remember { mutableStateOf(false) }9496 9597     // FLAG_SECURE only while this screen is shown — blocks screenshots of secrets.9698     DisposableEffect(Unit) {@@ -256,6 +258,23 @@256258                             onSave = { vm.updateField("password", it) },257259                             onGenerate = { generatorOpen = true },258260                         )261+                    }262+                    val history = e.passwordHistory.orEmpty()263+                    if (history.isNotEmpty()) {264+                        PasswordHistoryToggle(265+                            count = history.size,266+                            expanded = historyExpanded,267+                            onToggle = { historyExpanded = !historyExpanded },268+                        )269+                        AnimatedVisibility(visible = historyExpanded) {270+                            Column(Modifier.padding(top = 8.dp, bottom = 6.dp)) {271+                                PasswordHistoryList(272+                                    history = history,273+                                    onRestore = { oldPw -> vm.restorePassword(e.id, oldPw) },274+                                    onCopy = { oldPw -> vm.copy("password", oldPw) },275+                                )276+                            }277+                        }259278                     }260279                     if (e.hasTOTP()) {261280                         Spacer(Modifier.height(4.dp))

view file

app/src/main/java/com/peachpasswords/ui/vault/EntryDetailViewModel.kt+12 −0
@@ -118,6 +118,18 @@118118         }119119     }120120 121+    /**122+     * Restore a past password as the current one. updateEntry captures the123+     * now-outgoing password into history, so this is a normal password swap.124+     */125+    fun restorePassword(entryId: String, oldPassword: String) {126+        viewModelScope.launch {127+            val current = vault.getEntry(entryId) ?: return@launch128+            if (current.password == oldPassword) return@launch129+            runCatching { vault.updateEntry(current.copy(password = oldPassword)) }130+        }131+    }132+121133     fun delete(onDone: () -> Unit) {122134         viewModelScope.launch {123135             runCatching { vault.deleteEntry(id) }

view file