Merge pull request #307 from FossifyOrg/remove_unused_instantiation
Remove unnecessary intent creation
This commit is contained in:
commit
f735763c21
1 changed files with 16 additions and 28 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
package org.fossify.messages.activities
|
package org.fossify.messages.activities
|
||||||
|
|
||||||
import android.content.ActivityNotFoundException
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
|
@ -122,18 +121,13 @@ class ManageBlockedKeywordsActivity : SimpleActivity(), RefreshRecyclerViewListe
|
||||||
|
|
||||||
private fun tryImportBlockedKeywords() {
|
private fun tryImportBlockedKeywords() {
|
||||||
if (isQPlus()) {
|
if (isQPlus()) {
|
||||||
Intent(Intent.ACTION_GET_CONTENT).apply {
|
val mimeType = "text/plain"
|
||||||
addCategory(Intent.CATEGORY_OPENABLE)
|
try {
|
||||||
val mimeType = "text/plain"
|
importActivityResultLauncher.launch(mimeType)
|
||||||
type = mimeType
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
toast(org.fossify.commons.R.string.system_service_disabled, Toast.LENGTH_LONG)
|
||||||
try {
|
} catch (e: Exception) {
|
||||||
importActivityResultLauncher.launch(mimeType)
|
showErrorToast(e)
|
||||||
} catch (e: ActivityNotFoundException) {
|
|
||||||
toast(org.fossify.commons.R.string.system_service_disabled, Toast.LENGTH_LONG)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
showErrorToast(e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handlePermission(PERMISSION_READ_STORAGE) { isAllowed ->
|
handlePermission(PERMISSION_READ_STORAGE) { isAllowed ->
|
||||||
|
|
@ -208,21 +202,15 @@ class ManageBlockedKeywordsActivity : SimpleActivity(), RefreshRecyclerViewListe
|
||||||
private fun tryExportBlockedNumbers() {
|
private fun tryExportBlockedNumbers() {
|
||||||
if (isQPlus()) {
|
if (isQPlus()) {
|
||||||
ExportBlockedKeywordsDialog(this, config.lastBlockedKeywordExportPath, true) { file ->
|
ExportBlockedKeywordsDialog(this, config.lastBlockedKeywordExportPath, true) { file ->
|
||||||
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
try {
|
||||||
type = "text/plain"
|
exportActivityResultLauncher.launch(file.name)
|
||||||
putExtra(Intent.EXTRA_TITLE, file.name)
|
} catch (e: ActivityNotFoundException) {
|
||||||
addCategory(Intent.CATEGORY_OPENABLE)
|
toast(
|
||||||
|
org.fossify.commons.R.string.system_service_disabled,
|
||||||
try {
|
Toast.LENGTH_LONG
|
||||||
exportActivityResultLauncher.launch(file.name)
|
)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: Exception) {
|
||||||
toast(
|
showErrorToast(e)
|
||||||
org.fossify.commons.R.string.system_service_disabled,
|
|
||||||
Toast.LENGTH_LONG
|
|
||||||
)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
showErrorToast(e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue