Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary intent creation #307

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.fossify.messages.activities

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.Toast
Expand Down Expand Up @@ -122,18 +121,13 @@ class ManageBlockedKeywordsActivity : SimpleActivity(), RefreshRecyclerViewListe

private fun tryImportBlockedKeywords() {
if (isQPlus()) {
Intent(Intent.ACTION_GET_CONTENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
val mimeType = "text/plain"
type = mimeType

try {
importActivityResultLauncher.launch(mimeType)
} catch (e: ActivityNotFoundException) {
toast(org.fossify.commons.R.string.system_service_disabled, Toast.LENGTH_LONG)
} catch (e: Exception) {
showErrorToast(e)
}
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)
}
} else {
handlePermission(PERMISSION_READ_STORAGE) { isAllowed ->
Expand Down Expand Up @@ -208,21 +202,15 @@ class ManageBlockedKeywordsActivity : SimpleActivity(), RefreshRecyclerViewListe
private fun tryExportBlockedNumbers() {
if (isQPlus()) {
ExportBlockedKeywordsDialog(this, config.lastBlockedKeywordExportPath, true) { file ->
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
type = "text/plain"
putExtra(Intent.EXTRA_TITLE, file.name)
addCategory(Intent.CATEGORY_OPENABLE)

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)
}
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 {
Expand Down
Loading