Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.
Rust androiddocument-scannerdocximage-editorjetpack-composekotlinliquid-glassofflineopen-sourcepdfpdf-compressorpdf-editorpdf-mergerpdf-readerpdf-splitterpdf-toolspdf-viewerpptxspreadsheet-editorxlsx
fix: reopen files other apps lent from PdfCraft's copy (#5)
Joshf9f0143d493c
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.ktindex 0f1c7c6..a81bd4c 100644--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt@@ -120,6 +120,18 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {withContext(Dispatchers.IO) { recents.remove(setOf(uri.toString())) }refreshRecents()tell("This file has been moved or deleted.")+ } catch (e: SecurityException) {+ // A file another app lent for one visit (Files, Downloads: "Open with"): Android+ // takes that access back later, so Recent can't read it again. PdfCraft's own copy+ // opens instead, read-only (changes are offered as a copy, as for any file it+ // can't write to); the original needs opening again from the app it's in.+ val copy = withContext(Dispatchers.IO) { files.existingCopy(uri) }+ if (copy != null) {+ openFile(eng, uri, copy, password)+ tell("Opened PdfCraft's copy. To change the original, open it again from the app it's in.")+ } else {+ tell("PdfCraft can't open this file any more. Open it again from the app it's in, or with Open file.")+ }} catch (e: Exception) {tell(e.userMessage)} finally {