pdf: use share menu instead of open with menu #64
- Commit
575d93e20311b842a0af3de8164ac2542d97fd66- Author
- Vayun Mathur <[email protected]>
- When
- 2026-04-23 15:35 UTC (7 months ago)
- Parents
3af75a3
Diff
pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt
diff --git a/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt b/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.ktindex ea381950cf..6c92dc4818 100644--- a/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt+++ b/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt@@ -571,10 +571,12 @@ fun PdfViewerScreen(pdfDocument: EditablePdfDocument, pdfName: String) { IconButton({ showSearchBar = true }) { IconSearch() } IconButton({ downloadLauncher.launch(pdfName) }) { IconSave() } IconButton({- val intent = Intent(Intent.ACTION_SEND)- intent.type = "application/pdf"- intent.putExtra(Intent.EXTRA_STREAM, pdfDocument.uri)- context.startActivity(intent)+ val intent = Intent(Intent.ACTION_SEND).apply {+ type = "application/pdf"+ putExtra(Intent.EXTRA_STREAM, pdfDocument.uri)+ addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)+ }+ context.startActivity(Intent.createChooser(intent, context.getString(R.string.share_pdf))) }) { IconShare() }
pdf/src/main/res/values/strings.xml
diff --git a/pdf/src/main/res/values/strings.xml b/pdf/src/main/res/values/strings.xmlindex cd71ee4fcb..2c5cf97b13 100644--- a/pdf/src/main/res/values/strings.xml+++ b/pdf/src/main/res/values/strings.xml@@ -15,4 +15,5 @@ <string name="upload_image">Upload Image</string> <string name="pdf_saved">PDF saved successfully</string> <string name="pdf_save_error">Error saving PDF</string>+ <string name="share_pdf">Share PDF</string> </resources>\ No newline at end of file