mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bfea71342d | |||
| a2048b6ade | |||
| 63406bd806 | |||
| 9b5e650af0 |
@@ -482,6 +482,9 @@
|
||||
<string name="loading_remote_file_desc">Please, wait while the file is being loaded from the linked mobile</string>
|
||||
<string name="file_error">File error</string>
|
||||
<string name="temporary_file_error">Temporary file error</string>
|
||||
<string name="file_already_exists">File already exists</string>
|
||||
<string name="what_would_you_like_to_do_with_file">What would you like to do?</string>
|
||||
<string name="overwrite_file">Overwrite file</string>
|
||||
|
||||
<!-- Voice messages -->
|
||||
<string name="voice_message">Voice message</string>
|
||||
|
||||
+42
-3
@@ -1,9 +1,16 @@
|
||||
package chat.simplex.common.platform
|
||||
|
||||
import SectionItemView
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import chat.simplex.common.*
|
||||
import chat.simplex.common.views.helpers.AlertManager
|
||||
import chat.simplex.common.views.helpers.generalGetString
|
||||
import chat.simplex.common.views.chatlist.acceptContactRequest
|
||||
import chat.simplex.common.views.helpers.*
|
||||
import chat.simplex.res.MR
|
||||
import java.awt.Desktop
|
||||
import java.io.*
|
||||
@@ -75,10 +82,42 @@ actual class FileChooserLauncher actual constructor() {
|
||||
res = File(res, input)
|
||||
}
|
||||
}
|
||||
onResult(res?.toURI())
|
||||
if (res == null) {
|
||||
onResult(null)
|
||||
} else if (desktopPlatform.isMac() || !res.exists()) { // mac has an alert confirmation if the file exists
|
||||
onResult(res.toURI())
|
||||
} else {
|
||||
showSaveRenameFileAlert(res, onResult)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSaveRenameFileAlert(file: File, onResult: (URI?) -> Unit) {
|
||||
AlertManager.shared.showAlertDialogButtonsColumn(
|
||||
title = generalGetString(MR.strings.file_already_exists),
|
||||
text = generalGetString(MR.strings.what_would_you_like_to_do_with_file),
|
||||
buttons = {
|
||||
Column {
|
||||
SectionItemView({
|
||||
AlertManager.shared.hideAlert()
|
||||
onResult(file.toURI())
|
||||
}) {
|
||||
Text(generalGetString(MR.strings.overwrite_file), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.error)
|
||||
}
|
||||
SectionItemView({
|
||||
AlertManager.shared.hideAlert()
|
||||
onResult(null)
|
||||
}) {
|
||||
Text(generalGetString(MR.strings.cancel_verb), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
|
||||
}
|
||||
}
|
||||
},
|
||||
onDismissRequest = {
|
||||
onResult(null)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
actual class FileChooserMultipleLauncher actual constructor() {
|
||||
lateinit var onResult: (List<URI>) -> Unit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user