d548c5f17d11
fix: Match add-entry primary action state (v2.3.11)
- time
- 2026-06-26 01:08 UTC · 4 months ago
- machine
- koh2
- parent
- 33e27acd130d
↓ peach-android-d548c5f1.tar.gzatlas at this save
files changed4 files
app/build.gradle+2 −2app/src/main/java/com/peachpasswords/ui/vault/EntryEditScreen.kt+15 −2app/src/main/java/com/peachpasswords/ui/vault/EntryEditViewModel.kt+1 −0app/src/test/java/com/peachpasswords/ui/vault/EntryEditScreenTest.kt+14 −0app/build.gradle+2 −2
@@ -16,8 +16,8 @@1616 applicationId "com.peachpasswords"1717 minSdk 261818 targetSdk 3519- versionCode 23100020- versionName "2.3.10"19+ versionCode 23110020+ versionName "2.3.11"2121 2222 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"2323 vectorDrawables {app/src/main/java/com/peachpasswords/ui/vault/EntryEditScreen.kt+15 −2
@@ -72,15 +72,16 @@7272 ShellBackground {7373 Column(Modifier.fillMaxSize().statusBarsPadding()) {7474 Box(Modifier.fillMaxWidth().height(56.dp).padding(horizontal = 18.dp)) {75+ val canSave = canSaveEditForm(f)7576 Text("cancel", color = peachColors.T2, fontFamily = PeachType.Mono, fontSize = 11.sp,7677 modifier = Modifier.align(Alignment.CenterStart)7778 .clip(RoundedCornerShape(8.dp)).clickable(onClick = onBack).padding(8.dp))7879 Text(editTitleBarLabel(vm.isNew, f.type), color = peachColors.T1,7980 fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 18.sp,8081 modifier = Modifier.align(Alignment.Center))81- Text("save", color = accent, fontFamily = PeachType.Mono, fontSize = 11.sp,82+ Text(entryEditPrimaryActionLabel(vm.isNew, f.saving), color = if (canSave && !f.saving) accent else peachColors.T2, fontFamily = PeachType.Mono, fontSize = 11.sp,8283 modifier = Modifier.align(Alignment.CenterEnd)83- .clip(RoundedCornerShape(8.dp)).clickable { vm.save(onBack) }.padding(8.dp))84+ .clip(RoundedCornerShape(8.dp)).clickable(enabled = canSave && !f.saving) { vm.save(onBack) }.padding(8.dp))8485 }8586 8687 Box(Modifier.fillMaxSize().clipToBounds()) {@@ -228,6 +229,18 @@228229 type == "note" -> "new note"229230 type == "card" -> "new card"230231 else -> "new entry"232+}233+234+internal fun entryEditPrimaryActionLabel(isNew: Boolean, saving: Boolean): String = when {235+ saving -> "saving..."236+ isNew -> "create"237+ else -> "save"238+}239+240+internal fun canSaveEditForm(form: EditForm): Boolean {241+ if (form.title.isBlank()) return false242+ if (form.type == "card" && (form.cardholderName.isBlank() || form.cardNumber.isBlank())) return false243+ return true231244 }232245 233246 /** A brand-new note opens the full-screen notes editor instead of the form. */app/src/main/java/com/peachpasswords/ui/vault/EntryEditViewModel.kt+1 −0
@@ -193,6 +193,7 @@193193 194194 fun save(onDone: () -> Unit) {195195 val f = _form.value196+ if (f.saving) return196197 if (f.title.isBlank()) {197198 _form.update { it.copy(error = "title is required") }198199 returnapp/src/test/java/com/peachpasswords/ui/vault/EntryEditScreenTest.kt+14 −0
@@ -20,6 +20,20 @@2020 assertEquals("edit", editTitleBarLabel(isNew = false, type = "note"))2121 }2222 23+ @Test fun primary_action_label_matches_browser_add_view() {24+ assertEquals("create", entryEditPrimaryActionLabel(isNew = true, saving = false))25+ assertEquals("save", entryEditPrimaryActionLabel(isNew = false, saving = false))26+ assertEquals("saving...", entryEditPrimaryActionLabel(isNew = true, saving = true))27+ }28+29+ @Test fun save_is_disabled_until_browser_minimum_fields_are_present() {30+ assertFalse(canSaveEditForm(EditForm(type = "login", title = "")))31+ assertTrue(canSaveEditForm(EditForm(type = "login", title = "GitHub")))32+ assertFalse(canSaveEditForm(EditForm(type = "card", title = "Visa", cardholderName = "", cardNumber = "4242")))33+ assertFalse(canSaveEditForm(EditForm(type = "card", title = "Visa", cardholderName = "June", cardNumber = "")))34+ assertTrue(canSaveEditForm(EditForm(type = "card", title = "Visa", cardholderName = "June", cardNumber = "4242")))35+ }36+2337 // ── New note routes to NotesMode, not the form ────────────────────────────2438 2539 @Test fun new_note_routes_to_notes_mode() {