withLongRunningApi (#3675)
This commit is contained in:
parent
bfb274b037
commit
46fe0fc671
@ -36,7 +36,7 @@ actual fun SaveContentItemAction(cItem: ChatItem, saveFileLauncher: FileChooserL
|
|||||||
writePermissionState.launchPermissionRequest()
|
writePermissionState.launchPermissionRequest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is MsgContent.MCFile, is MsgContent.MCVoice, is MsgContent.MCVideo -> withBGApi { saveFileLauncher.launch(cItem.file?.fileName ?: "") }
|
is MsgContent.MCFile, is MsgContent.MCVoice, is MsgContent.MCVideo -> withLongRunningApi { saveFileLauncher.launch(cItem.file?.fileName ?: "") }
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
showMenu.value = false
|
showMenu.value = false
|
||||||
|
@ -101,7 +101,7 @@ fun CIFileView(
|
|||||||
filePath = getLoadedFilePath(file)
|
filePath = getLoadedFilePath(file)
|
||||||
}
|
}
|
||||||
if (filePath != null) {
|
if (filePath != null) {
|
||||||
withBGApi {
|
withLongRunningApi {
|
||||||
saveFileLauncher.launch(file.fileName)
|
saveFileLauncher.launch(file.fileName)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -34,7 +34,7 @@ fun ChatArchiveView(m: ChatModel, title: String, archiveName: String, archiveTim
|
|||||||
ChatArchiveLayout(
|
ChatArchiveLayout(
|
||||||
title,
|
title,
|
||||||
archiveTime,
|
archiveTime,
|
||||||
saveArchive = { withBGApi { saveArchiveLauncher.launch(archivePath.substringAfterLast(File.separator)) }},
|
saveArchive = { withLongRunningApi { saveArchiveLauncher.launch(archivePath.substringAfterLast(File.separator)) }},
|
||||||
deleteArchiveAlert = { deleteArchiveAlert(m, archivePath) }
|
deleteArchiveAlert = { deleteArchiveAlert(m, archivePath) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ fun DatabaseLayout(
|
|||||||
SettingsActionItem(
|
SettingsActionItem(
|
||||||
painterResource(MR.images.ic_download),
|
painterResource(MR.images.ic_download),
|
||||||
stringResource(MR.strings.import_database),
|
stringResource(MR.strings.import_database),
|
||||||
{ withBGApi { importArchiveLauncher.launch("application/zip") } },
|
{ withLongRunningApi { importArchiveLauncher.launch("application/zip") } },
|
||||||
textColor = Color.Red,
|
textColor = Color.Red,
|
||||||
iconColor = Color.Red,
|
iconColor = Color.Red,
|
||||||
disabled = operationsDisabled
|
disabled = operationsDisabled
|
||||||
@ -500,7 +500,7 @@ private fun exportArchive(
|
|||||||
saveArchiveLauncher: FileChooserLauncher
|
saveArchiveLauncher: FileChooserLauncher
|
||||||
) {
|
) {
|
||||||
progressIndicator.value = true
|
progressIndicator.value = true
|
||||||
withBGApi {
|
withLongRunningApi {
|
||||||
try {
|
try {
|
||||||
val archiveFile = exportChatArchive(m, chatArchiveName, chatArchiveTime, chatArchiveFile)
|
val archiveFile = exportChatArchive(m, chatArchiveName, chatArchiveTime, chatArchiveFile)
|
||||||
chatArchiveFile.value = archiveFile
|
chatArchiveFile.value = archiveFile
|
||||||
|
@ -39,7 +39,7 @@ fun withBGApi(action: suspend CoroutineScope.() -> Unit): Job =
|
|||||||
CoroutineScope(singleThreadDispatcher).launch(block = { wrapWithLogging(action, it) })
|
CoroutineScope(singleThreadDispatcher).launch(block = { wrapWithLogging(action, it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun withLongRunningApi(slow: Long = 120_000, deadlock: Long = 240_000, action: suspend CoroutineScope.() -> Unit): Job =
|
fun withLongRunningApi(slow: Long = Long.MAX_VALUE, deadlock: Long = Long.MAX_VALUE, action: suspend CoroutineScope.() -> Unit): Job =
|
||||||
Exception().let {
|
Exception().let {
|
||||||
CoroutineScope(Dispatchers.Default).launch(block = { wrapWithLogging(action, it, slow = slow, deadlock = deadlock) })
|
CoroutineScope(Dispatchers.Default).launch(block = { wrapWithLogging(action, it, slow = slow, deadlock = deadlock) })
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ object AppearanceScope {
|
|||||||
SectionItemView({
|
SectionItemView({
|
||||||
val overrides = ThemeManager.currentThemeOverridesForExport(isInDarkTheme)
|
val overrides = ThemeManager.currentThemeOverridesForExport(isInDarkTheme)
|
||||||
theme.value = yaml.encodeToString<ThemeOverrides>(overrides)
|
theme.value = yaml.encodeToString<ThemeOverrides>(overrides)
|
||||||
withBGApi { exportThemeLauncher.launch("simplex.theme")}
|
withLongRunningApi { exportThemeLauncher.launch("simplex.theme")}
|
||||||
}) {
|
}) {
|
||||||
Text(generalGetString(MR.strings.export_theme), color = colors.primary)
|
Text(generalGetString(MR.strings.export_theme), color = colors.primary)
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ object AppearanceScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Can not limit to YAML mime type since it's unsupported by Android
|
// Can not limit to YAML mime type since it's unsupported by Android
|
||||||
SectionItemView({ withBGApi { importThemeLauncher.launch("*/*") } }) {
|
SectionItemView({ withLongRunningApi { importThemeLauncher.launch("*/*") } }) {
|
||||||
Text(generalGetString(MR.strings.import_theme), color = colors.primary)
|
Text(generalGetString(MR.strings.import_theme), color = colors.primary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ actual fun ClipboardManager.shareText(text: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actual fun shareFile(text: String, fileSource: CryptoFile) {
|
actual fun shareFile(text: String, fileSource: CryptoFile) {
|
||||||
withBGApi {
|
withLongRunningApi {
|
||||||
FileChooserLauncher(false) { to: URI? ->
|
FileChooserLauncher(false) { to: URI? ->
|
||||||
if (to != null) {
|
if (to != null) {
|
||||||
val absolutePath = if (fileSource.isAbsolutePath) fileSource.filePath else getAppFilePath(fileSource.filePath)
|
val absolutePath = if (fileSource.isAbsolutePath) fileSource.filePath else getAppFilePath(fileSource.filePath)
|
||||||
|
@ -35,7 +35,7 @@ actual fun SaveContentItemAction(cItem: ChatItem, saveFileLauncher: FileChooserL
|
|||||||
ItemAction(stringResource(MR.strings.save_verb), painterResource(if (cItem.file?.fileSource?.cryptoArgs == null) MR.images.ic_download else MR.images.ic_lock_open_right), onClick = {
|
ItemAction(stringResource(MR.strings.save_verb), painterResource(if (cItem.file?.fileSource?.cryptoArgs == null) MR.images.ic_download else MR.images.ic_lock_open_right), onClick = {
|
||||||
val saveIfExists = {
|
val saveIfExists = {
|
||||||
when (cItem.content.msgContent) {
|
when (cItem.content.msgContent) {
|
||||||
is MsgContent.MCImage, is MsgContent.MCFile, is MsgContent.MCVoice, is MsgContent.MCVideo -> withBGApi { saveFileLauncher.launch(cItem.file?.fileName ?: "") }
|
is MsgContent.MCImage, is MsgContent.MCFile, is MsgContent.MCVoice, is MsgContent.MCVideo -> withLongRunningApi { saveFileLauncher.launch(cItem.file?.fileName ?: "") }
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
showMenu.value = false
|
showMenu.value = false
|
||||||
|
@ -45,7 +45,7 @@ actual fun GetImageBottomSheet(
|
|||||||
}
|
}
|
||||||
val pickImageLauncher = rememberFileChooserLauncher(true, null, processPickedImage)
|
val pickImageLauncher = rememberFileChooserLauncher(true, null, processPickedImage)
|
||||||
ActionButton(null, stringResource(MR.strings.from_gallery_button), icon = painterResource(MR.images.ic_image)) {
|
ActionButton(null, stringResource(MR.strings.from_gallery_button), icon = painterResource(MR.images.ic_image)) {
|
||||||
withBGApi { pickImageLauncher.launch("image/*") }
|
withLongRunningApi { pickImageLauncher.launch("image/*") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user