From 6531f9f104662722811583a0105fe229246cae14 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Sun, 23 Mar 2025 20:23:49 +0530 Subject: [PATCH] Remove storage permission requirement It's not necessary for importing/exporting blocked numbers or keywords. See https://github.com/FossifyOrg/Messages/discussions/309 --- app/src/main/AndroidManifest.xml | 4 -- .../ManageBlockedKeywordsActivity.kt | 71 +++++-------------- 2 files changed, 17 insertions(+), 58 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b3872b33..550c907a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,10 +15,6 @@ - - - if (isAllowed) { - pickFileToImportBlockedKeywords() - } - } - } - } - - private fun pickFileToImportBlockedKeywords() { - FilePickerDialog(this) { - importBlockedKeywords(it) + val mimeType = "text/plain" + try { + importActivityResultLauncher.launch(mimeType) + } catch (e: ActivityNotFoundException) { + toast(org.fossify.commons.R.string.system_service_disabled, Toast.LENGTH_LONG) + } catch (e: Exception) { + showErrorToast(e) } } @@ -200,32 +179,16 @@ class ManageBlockedKeywordsActivity : SimpleActivity(), RefreshRecyclerViewListe } private fun tryExportBlockedNumbers() { - if (isQPlus()) { - ExportBlockedKeywordsDialog(this, config.lastBlockedKeywordExportPath, true) { file -> - try { - exportActivityResultLauncher.launch(file.name) - } catch (e: ActivityNotFoundException) { - toast( - org.fossify.commons.R.string.system_service_disabled, - Toast.LENGTH_LONG - ) - } catch (e: Exception) { - showErrorToast(e) - } - } - } else { - handlePermission(PERMISSION_WRITE_STORAGE) { isAllowed -> - if (isAllowed) { - ExportBlockedNumbersDialog( - this, - config.lastBlockedKeywordExportPath, - false - ) { file -> - getFileOutputStream(file.toFileDirItem(this), true) { out -> - exportBlockedKeywordsTo(out) - } - } - } + ExportBlockedKeywordsDialog(this, config.lastBlockedKeywordExportPath, true) { file -> + try { + exportActivityResultLauncher.launch(file.name) + } catch (e: ActivityNotFoundException) { + toast( + org.fossify.commons.R.string.system_service_disabled, + Toast.LENGTH_LONG + ) + } catch (e: Exception) { + showErrorToast(e) } } }