From 07753427e4178caa51219beb2bdc5f082d75207a Mon Sep 17 00:00:00 2001
From: Pierre-Yves Nicolas <6371790+pynicolas@users.noreply.github.com>
Date: Wed, 28 Jan 2026 20:36:41 +0100
Subject: [PATCH] Specific message when no permission for export dir (#105)
---
.../app/ui/screens/export/ExportViewModel.kt | 18 ++++++++++++++++++
app/src/main/res/values-cs/strings.xml | 1 +
app/src/main/res/values-de/strings.xml | 1 +
app/src/main/res/values-es/strings.xml | 1 +
app/src/main/res/values-fr/strings.xml | 1 +
app/src/main/res/values-it/strings.xml | 1 +
app/src/main/res/values-pt-rBR/strings.xml | 1 +
app/src/main/res/values-ru/strings.xml | 1 +
app/src/main/res/values-tr/strings.xml | 1 +
app/src/main/res/values-zh-rTW/strings.xml | 1 +
app/src/main/res/values-zh/strings.xml | 1 +
app/src/main/res/values/strings.xml | 5 +++--
12 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/org/fairscan/app/ui/screens/export/ExportViewModel.kt b/app/src/main/java/org/fairscan/app/ui/screens/export/ExportViewModel.kt
index f1ddc25..0d7bfaa 100644
--- a/app/src/main/java/org/fairscan/app/ui/screens/export/ExportViewModel.kt
+++ b/app/src/main/java/org/fairscan/app/ui/screens/export/ExportViewModel.kt
@@ -39,6 +39,7 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.fairscan.app.AppContainer
+import org.fairscan.app.R
import org.fairscan.app.RecentDocument
import org.fairscan.app.data.FileManager
import org.fairscan.app.data.ImageRepository
@@ -194,6 +195,12 @@ class ExportViewModel(container: AppContainer, val imageRepository: ImageReposit
viewModelScope.launch {
try {
save(context)
+ } catch (e: MissingExportDirPermissionException) {
+ logger.e("FairScan", "Missing export dir permission", e)
+ _uiState.update {
+ it.copy(errorMessage =
+ context.getString(R.string.error_export_dir_permission_lost))
+ }
} catch (e: Exception) {
logger.e("FairScan", "Failed to save PDF", e)
_events.emit(ExportEvent.SaveError)
@@ -223,6 +230,11 @@ class ExportViewModel(container: AppContainer, val imageRepository: ImageReposit
}
} else {
// Use Storage Access Framework to save to the chosen directory
+ if (!context.contentResolver.persistedUriPermissions.any { perm ->
+ perm.uri == exportDir && perm.isWritePermission
+ }) {
+ throw MissingExportDirPermissionException(exportDir)
+ }
val safFile = saveViaSaf(context, file, exportDir, exportFormat)
SavedItem(safFile.uri, safFile.name ?: file.name, exportFormat)
}
@@ -373,3 +385,9 @@ data class ExportActions(
val save: () -> Unit,
val open: (SavedItem) -> Unit,
)
+
+class MissingExportDirPermissionException(
+ val uri: Uri
+) : IllegalStateException(
+ "Missing persisted write permission for export dir: $uri"
+)
diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml
index 939cbfc..f3eec09 100644
--- a/app/src/main/res/values-cs/strings.xml
+++ b/app/src/main/res/values-cs/strings.xml
@@ -19,6 +19,7 @@
stažených
Ukončit skenování
Chyba: %1$s
+ Vybraná složka pro export již není dostupná. Vyberte prosím jinou složku.
Nebyla nalezena žádná aplikace pro otevření tohoto souboru
Nebyl rozpoznán žádná dokument
Soubor se nepodařilo uložit
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 82fad44..a856698 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -19,6 +19,7 @@
Downloads
Scan beenden
Fehler: %1$s
+ Der ausgewählte Exportordner ist nicht mehr zugänglich. Bitte wählen Sie einen anderen Ordner.
Keine App zum Öffnen dieser Datei gefunden
Kein Dokument erkannt
Datei konnte nicht gespeichert werden
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 30a90ca..f0882c4 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -19,6 +19,7 @@
Descargas
Finalizar escaneo
Error: %1$s
+ La carpeta de exportación seleccionada ya no es accesible. Por favor, elija otra carpeta.
No se encontró ninguna aplicación para abrir este archivo
No se detectó ningún documento
No se pudo guardar el archivo
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 8b21965..0eb8923 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -19,6 +19,7 @@
Téléchargements
Terminer le scan
Erreur : %1$s
+ Le dossier d’export sélectionné n’est plus accessible. Veuillez choisir un autre dossier.
Aucune application trouvée pour ouvrir ce fichier
Aucun document détecté
Échec de l\'enregistrement du fichier
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index ac9b1fe..09540cc 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -19,6 +19,7 @@
Download
Termina scansione
Errore: %1$s
+ La cartella di esportazione selezionata non è più accessibile. Scegli un’altra cartella.
Nessuna app trovata per aprire questo file
Nessun documento rilevato
Impossibile salvare il file
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 882ac37..88578c0 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -19,6 +19,7 @@
Downloads
Finalizar digitalização
Erro: %1$s
+ A pasta de exportação selecionada não está mais acessível. Escolha outra pasta.
Nenhum app encontrado para abrir este arquivo
Nenhum documento detectado
Falha ao salvar o arquivo
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 59a0ffb..86ea4b0 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -19,6 +19,7 @@
Download
Закончить
Ошибка: %1$s
+ Выбранная папка экспорта больше недоступна. Пожалуйста, выберите другую папку.
Не найдено приложение для открытия этого файла
Документ не обнаружен
Не удалось сохранить файл
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index 76268b4..fb21ac3 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -19,6 +19,7 @@
İndirilenler
Taramayı bitir
Error: %1$s
+ Seçilen dışa aktarma dizini artık erişilebilir değil. Lütfen başka bir dizin seçin.
No app found to open this file
No document detected
Failed to save file
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 393243f..3247559 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -19,6 +19,7 @@
下載 (Downloads)
結束掃描
錯誤:%1$s
+ 所選的匯出目錄已無法存取。請選擇其他目錄。
找不到可開啟此檔案的應用程式
未偵測到文件
儲存檔案失敗
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 7bc1244..6e4c035 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -19,6 +19,7 @@
下载
结束扫描
错误: %1$s
+ 所选的导出目录已无法访问。请选择其他目录。
未找到可打开此文件的应用
未检测到任何文档
无法保存文件
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 126cff6..cd16a68 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -7,7 +7,7 @@
Camera permission was denied
The app requires camera access to scan documents. Captured images are stored only on this device and will be deleted when you close the current document.
Cancel
- Change directory
+ Change folder
Clear text
Contact
Logs copied to clipboard
@@ -20,6 +20,7 @@
Downloads
End scan
Error: %1$s
+ The selected export folder is no longer accessible. Please choose another folder.
Failed to launch system file picker on this device
Failed to set export directory
@@ -28,7 +29,7 @@
Failed to save file
Export
Export as %1$s
- Export directory
+ Export folder
Export format
Export quality
Low