From b4e1002735486bf56b67b8233c2c2abfa875eed4 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 3 Nov 2026 14:14:04 +0100 Subject: fix(app): localize the occupied store refusal Co-Authored-By: Claude Opus 5.5 --- app/src/main/java/app/passwordstore/ui/setup/PgpKeysScreen.kt | 2 +- app/src/main/java/app/passwordstore/ui/setup/PgpKeysViewModel.kt | 8 ++++---- app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/app/passwordstore/ui/setup/PgpKeysScreen.kt b/app/src/main/java/app/passwordstore/ui/setup/PgpKeysScreen.kt index 9ba96bbb..34e5bed6 100644 --- a/app/src/main/java/app/passwordstore/ui/setup/PgpKeysScreen.kt +++ b/app/src/main/java/app/passwordstore/ui/setup/PgpKeysScreen.kt @@ -261,7 +261,7 @@ fun PgpKeysDestination( viewModel.busy = true activity.lifecycleScope.launch { try { - val error = viewModel.createStore(root, row) + val error = viewModel.createStore(root, row, activity.getString(R.string.store_not_empty)) if (error != null) { activity.snackbar( message = activity.getString(R.string.store_create_failed, error), diff --git a/app/src/main/java/app/passwordstore/ui/setup/PgpKeysViewModel.kt b/app/src/main/java/app/passwordstore/ui/setup/PgpKeysViewModel.kt index afb65265..d270275f 100644 --- a/app/src/main/java/app/passwordstore/ui/setup/PgpKeysViewModel.kt +++ b/app/src/main/java/app/passwordstore/ui/setup/PgpKeysViewModel.kt @@ -208,13 +208,13 @@ constructor( /** * Creates the local store at [root] for [row]: a git repository and a `.gpg-id` naming the key by - * its uppercase long key ID ([gpgIdText]). Returns null, or why it failed. + * its uppercase long key ID ([gpgIdText]). Returns null, or why it failed; [occupied] is the + * reason given when [root] already holds a store. */ - suspend fun createStore(root: File, row: KeyRow): String? = + suspend fun createStore(root: File, row: KeyRow, occupied: String): String? = withContext(dispatcherProvider.io()) { // A restored, already-cloned store must keep its .gpg-id. - if (root.isDirectory && cloneTarget(root) == CloneTarget.Occupied) - return@withContext "the folder is not empty" + if (root.isDirectory && cloneTarget(root) == CloneTarget.Occupied) return@withContext occupied try { check(root.isDirectory || root.mkdirs()) { "Could not create $root" } PasswordRepository.createRepository(root) diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 050623b7..72bcb009 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -378,6 +378,7 @@ Importa la chiave privata per cui è cifrato questo archivio, così le sue voci si possono leggere e salvare. Destinatari dell\'archivio Impossibile creare l\'archivio: %1$s + la cartella contiene già un archivio Impossibile svuotare la cartella dell\'archivio, la clonazione non è partita. Il file supera 1 MiB: non è una chiave PGP. Una chiave privata con questo ID è già importata. La sola chiave pubblica non può sostituirla: elimina prima la chiave privata, se vuoi davvero farlo. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 055e0593..dc8069b8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -413,6 +413,7 @@ Import the private key this store is encrypted for, so its entries can be read and saved. Store recipients Could not create the store: %1$s + the folder already holds a store Could not empty the store folder, so the clone did not start. The file is larger than 1 MiB: not a PGP key. A private key with this ID is already imported. Its public key alone cannot replace it: delete the private key first if you really want to. -- cgit v1.2.3