desktop: open database dir (#3019)
* desktop: open database dir * alert * move button --------- Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
parent
83b939d215
commit
67d5b6eace
@ -23,6 +23,8 @@ actual val agentDatabaseFileName: String = "files_agent.db"
|
|||||||
|
|
||||||
actual val databaseExportDir: File = androidAppContext.cacheDir
|
actual val databaseExportDir: File = androidAppContext.cacheDir
|
||||||
|
|
||||||
|
actual fun desktopOpenDatabaseDir() {}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
actual fun rememberFileChooserLauncher(getContent: Boolean, rememberedValue: Any?, onResult: (URI?) -> Unit): FileChooserLauncher {
|
actual fun rememberFileChooserLauncher(getContent: Boolean, rememberedValue: Any?, onResult: (URI?) -> Unit): FileChooserLauncher {
|
||||||
val launcher = rememberLauncherForActivityResult(
|
val launcher = rememberLauncherForActivityResult(
|
||||||
|
@ -23,6 +23,8 @@ expect val agentDatabaseFileName: String
|
|||||||
* */
|
* */
|
||||||
expect val databaseExportDir: File
|
expect val databaseExportDir: File
|
||||||
|
|
||||||
|
expect fun desktopOpenDatabaseDir()
|
||||||
|
|
||||||
fun copyFileToFile(from: File, to: URI, finally: () -> Unit) {
|
fun copyFileToFile(from: File, to: URI, finally: () -> Unit) {
|
||||||
try {
|
try {
|
||||||
to.outputStream().use { stream ->
|
to.outputStream().use { stream ->
|
||||||
|
@ -75,6 +75,7 @@ fun DatabaseView(
|
|||||||
m.chatDbEncrypted.value,
|
m.chatDbEncrypted.value,
|
||||||
m.controller.appPrefs.storeDBPassphrase.state.value,
|
m.controller.appPrefs.storeDBPassphrase.state.value,
|
||||||
m.controller.appPrefs.initialRandomDBPassphrase,
|
m.controller.appPrefs.initialRandomDBPassphrase,
|
||||||
|
m.controller.appPrefs.developerTools.state.value,
|
||||||
importArchiveLauncher,
|
importArchiveLauncher,
|
||||||
chatArchiveName,
|
chatArchiveName,
|
||||||
chatArchiveTime,
|
chatArchiveTime,
|
||||||
@ -125,6 +126,7 @@ fun DatabaseLayout(
|
|||||||
chatDbEncrypted: Boolean?,
|
chatDbEncrypted: Boolean?,
|
||||||
passphraseSaved: Boolean,
|
passphraseSaved: Boolean,
|
||||||
initialRandomDBPassphrase: SharedPreference<Boolean>,
|
initialRandomDBPassphrase: SharedPreference<Boolean>,
|
||||||
|
developerTools: Boolean,
|
||||||
importArchiveLauncher: FileChooserLauncher,
|
importArchiveLauncher: FileChooserLauncher,
|
||||||
chatArchiveName: MutableState<String?>,
|
chatArchiveName: MutableState<String?>,
|
||||||
chatArchiveTime: MutableState<Instant?>,
|
chatArchiveTime: MutableState<Instant?>,
|
||||||
@ -187,6 +189,14 @@ fun DatabaseLayout(
|
|||||||
iconColor = if (unencrypted || (appPlatform.isDesktop && passphraseSaved)) WarningOrange else MaterialTheme.colors.secondary,
|
iconColor = if (unencrypted || (appPlatform.isDesktop && passphraseSaved)) WarningOrange else MaterialTheme.colors.secondary,
|
||||||
disabled = operationsDisabled
|
disabled = operationsDisabled
|
||||||
)
|
)
|
||||||
|
if (appPlatform.isDesktop && developerTools) {
|
||||||
|
SettingsActionItem(
|
||||||
|
painterResource(MR.images.ic_folder_open),
|
||||||
|
stringResource(MR.strings.open_database_folder),
|
||||||
|
::desktopOpenDatabaseDir,
|
||||||
|
disabled = operationsDisabled
|
||||||
|
)
|
||||||
|
}
|
||||||
SettingsActionItem(
|
SettingsActionItem(
|
||||||
painterResource(MR.images.ic_ios_share),
|
painterResource(MR.images.ic_ios_share),
|
||||||
stringResource(MR.strings.export_database),
|
stringResource(MR.strings.export_database),
|
||||||
@ -661,6 +671,7 @@ fun PreviewDatabaseLayout() {
|
|||||||
chatDbEncrypted = false,
|
chatDbEncrypted = false,
|
||||||
passphraseSaved = false,
|
passphraseSaved = false,
|
||||||
initialRandomDBPassphrase = SharedPreference({ true }, {}),
|
initialRandomDBPassphrase = SharedPreference({ true }, {}),
|
||||||
|
developerTools = true,
|
||||||
importArchiveLauncher = rememberFileChooserLauncher(true) {},
|
importArchiveLauncher = rememberFileChooserLauncher(true) {},
|
||||||
chatArchiveName = remember { mutableStateOf("dummy_archive") },
|
chatArchiveName = remember { mutableStateOf("dummy_archive") },
|
||||||
chatArchiveTime = remember { mutableStateOf(Clock.System.now()) },
|
chatArchiveTime = remember { mutableStateOf(Clock.System.now()) },
|
||||||
|
@ -944,6 +944,7 @@
|
|||||||
<string name="import_database">Import database</string>
|
<string name="import_database">Import database</string>
|
||||||
<string name="new_database_archive">New database archive</string>
|
<string name="new_database_archive">New database archive</string>
|
||||||
<string name="old_database_archive">Old database archive</string>
|
<string name="old_database_archive">Old database archive</string>
|
||||||
|
<string name="open_database_folder">Open database folder</string>
|
||||||
<string name="delete_database">Delete database</string>
|
<string name="delete_database">Delete database</string>
|
||||||
<string name="error_starting_chat">Error starting chat</string>
|
<string name="error_starting_chat">Error starting chat</string>
|
||||||
<string name="stop_chat_question">Stop chat?</string>
|
<string name="stop_chat_question">Stop chat?</string>
|
||||||
|
@ -2,8 +2,10 @@ package chat.simplex.common.platform
|
|||||||
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import chat.simplex.common.*
|
import chat.simplex.common.*
|
||||||
|
import chat.simplex.common.views.helpers.AlertManager
|
||||||
import chat.simplex.common.views.helpers.generalGetString
|
import chat.simplex.common.views.helpers.generalGetString
|
||||||
import chat.simplex.res.MR
|
import chat.simplex.res.MR
|
||||||
|
import java.awt.Desktop
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
@ -19,6 +21,20 @@ actual val agentDatabaseFileName: String = "simplex_v1_agent.db"
|
|||||||
|
|
||||||
actual val databaseExportDir: File = tmpDir
|
actual val databaseExportDir: File = tmpDir
|
||||||
|
|
||||||
|
actual fun desktopOpenDatabaseDir() {
|
||||||
|
if (Desktop.isDesktopSupported()) {
|
||||||
|
try {
|
||||||
|
Desktop.getDesktop().open(dataDir);
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Log.e(TAG, e.stackTraceToString())
|
||||||
|
AlertManager.shared.showAlertMsg(
|
||||||
|
title = generalGetString(MR.strings.unknown_error),
|
||||||
|
text = e.stackTraceToString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
actual fun rememberFileChooserLauncher(getContent: Boolean, rememberedValue: Any?, onResult: (URI?) -> Unit): FileChooserLauncher =
|
actual fun rememberFileChooserLauncher(getContent: Boolean, rememberedValue: Any?, onResult: (URI?) -> Unit): FileChooserLauncher =
|
||||||
remember(rememberedValue) { FileChooserLauncher(getContent, onResult) }
|
remember(rememberedValue) { FileChooserLauncher(getContent, onResult) }
|
||||||
|
Loading…
Reference in New Issue
Block a user