ui: settings navigation reorganization (#7005)

* android, desktop: settings navigation reorganization

Restructure the root Settings screen into two top-level sections and
fold previously-scattered items into three new sub-screens.

Root:
- Appearance, Your privacy, Chat data
- Help & support, Migrate to another device, Advanced settings

Your privacy (renamed from Privacy & security): keeps Device,
link previews / remove tracking, auto-accept images, blur media,
contact requests from groups. Adds a "More privacy" sub-screen.

More privacy (new): show last messages, message draft, encrypt local
files, protect IP address (with original dynamic footer preserved),
notification preview mode (moved from Notifications), and delivery
receipts.

Help & support (new): merges Help and Support SimpleX Chat sections
into Help / About (with App version) / Contact / Support the project.

Advanced settings (new): Network & servers, Notifications (Android),
Audio & video calls; then Developer tools, Restart and Shutdown
(Android), App update channel (desktop). Notifications is hidden on
desktop because the screen is empty after Show preview moves to
More privacy.

Chat data is the new top-level menu label for the existing
Database passphrase & export screen.

* android, desktop: trim settings reorg diff

- Remove 5 dead strings from base/strings.xml (privacy_and_security,
  database_passphrase_and_export, settings_section_title_chat_database,
  settings_section_title_support, settings_section_title_app) — no
  Kotlin references after the reorg.
- Drop the now single-variant CurrentPage enum in
  NotificationsSettingsView; replace with a direct callback.
- Read userDisplayName locally in HelpAndSupportView instead of
  threading it through SettingsLayout/SettingsView/Preview.

* android, desktop: remove orphan locale strings

Companion to 442a368c9 which removed 5 dead keys from base/strings.xml.
The :common:adjustFormatting task enforces that every locale string has
a corresponding base entry, so these orphans broke the build. Removed
across 35 locale files (154 lines).

Keys removed:
- privacy_and_security
- database_passphrase_and_export
- settings_section_title_chat_database
- settings_section_title_support
- settings_section_title_app

* Revert "android, desktop: remove orphan locale strings"

This reverts commit 0ad5fc9308.

* android, desktop: restore base strings for removed keys

Counterpart to revert of 0ad5fc930: re-add the 5 base entries that
442a368c9 had deleted so the locale files (restored by the prior revert)
are no longer orphaned. Translation keys must not be removed once
introduced — the values can change but the keys stay.

Keys restored to base with their master English values:
- database_passphrase_and_export
- privacy_and_security
- settings_section_title_chat_database
- settings_section_title_support
- settings_section_title_app

* android, desktop: keep share-button helpers in SettingsView

ContributeItem, RateAppItem, StarOnGithubItem were moved from
SettingsView.kt to HelpAndSupportView.kt as part of the reorg.
Move them back: just drop the `private` modifier (one-word edit
per function) so HelpAndSupportView can call them in place. Saves
~60 lines of diff churn vs the move + matches the file's existing
pattern where helpers like AppVersionItem, ChatPreferencesItem,
ChatLockItem, etc. are all public top-level @Composable.

* android, desktop: inline HelpAndSupportView into SettingsView.kt

HelpAndSupportView is the only call site of SettingsView.kt's
share-button helpers; placing it as a top-level @Composable in
SettingsView.kt keeps the help/about/contact/support flow next to
the other settings entry points and removes the need for a new file.
Three imports (BuildConfigCommon, SimpleXInfo, WhatsNewView) that
the reorg was deleting from SettingsView.kt stay in place. Saves
~35 lines of diff and one new file.

* android, desktop: inline AdvancedSettingsView into SettingsView.kt

Same treatment as HelpAndSupportView in the previous commit:
AdvancedSettingsView is only reached from SettingsLayout, so the
function and its expect declaration live as top-level @Composable
in SettingsView.kt instead of a new file. NetworkAndServersView
import that the reorg was deleting from SettingsView.kt stays.
The .android.kt / .desktop.kt actuals are unchanged and keep
implementing the (now relocated) expect. Saves ~15 lines and a file.

* ios: settings navigation reorganization

Mirror the multiplatform reorg on iOS:

Root SettingsView: collapse the 5 sections into 2 unlabeled groups —
{Appearance, Your privacy, Chat data} and {Help & support, Migrate to
another device, Advanced settings}. "Privacy & security" becomes
"Your privacy"; the database row label becomes "Chat data".

PrivacySettings: keeps Device, link previews / remove tracking,
auto-accept images, blur media, contact requests from groups. Adds a
"More privacy" link.

MorePrivacy (new, inlined in PrivacySettings.swift): show last
messages, message draft, encrypt local files, protect IP address
(with original dynamic footer preserved), notification preview mode
(moved from NotificationsView), delivery receipts. Own state and
private helpers for the moved set* functions.

HelpAndSupportView (new, inlined in SettingsView.swift): merges Help
and Support sections into Help / About (with App version) / Contact /
Support the project.

AdvancedSettingsView (new, inlined in SettingsView.swift): Network &
servers, Notifications, Audio & video calls, Developer tools. iOS has
no Restart/Shutdown (Android-only) or App update channel (desktop).

NotificationsView: "Show preview" navigation removed — it now lives
in MorePrivacy. notificationsIcon() promoted to a free function so
AdvancedSettingsView can render the notifications status badge.

* android, desktop: keep platform file names as SettingsView.{android,desktop}.kt

Revert the file renames from {Advanced}SettingsView.{android,desktop}.kt.
Function rename SettingsSectionApp → AdvancedSettingsAppSection stays
inside each file; only the file path returns to its original name. No
behavior change; diff stat now shows two in-place modifications instead
of renames.

* ios: keep PrivacySettings/SettingsView state in place, use inline destinations

Restructure the iOS reorg to avoid moving state, helpers, and the alert
enum out of PrivacySettings — and to avoid moving notificationsIcon
out of SettingsView. The Help & Support, Advanced Settings, and
More Privacy "screens" become private computed properties on their
parent struct, so all @AppStorage, @State, set* helpers, and the
PrivacySettingsViewAlert enum stay UNCHANGED from master. NavigationLink
destinations reference the computed properties directly.

Net iOS diff vs master: 220+/154- (was 361+/259-) — saves ~245 lines.

* simplex settings

* android, desktop: mirror iOS settings reorganization

- inline Advanced settings section into the main settings list (Network &
  servers, Notifications, Audio & video calls, App version); remove the
  separate Advanced settings page
- reorder first section: Appearance, Your privacy, Help & support, Chat data,
  Migrate; merge About SimpleX Chat into the Help section
- move the developer/maintenance section under App version (VersionInfoView);
  load core version inside the view so it always opens (Developer tools and
  Shutdown stay reachable even if the version request fails)
- keep "Developer tools" label (not renamed to "Developer")
- replace the Restart row with Cancel/Restart/Shutdown options in the
  Shutdown dialog
- split DatabaseView: "Chat data" page (messages TTL, Database passphrase &
  export, Files & media) and a sub-page with passphrase/export/import/delete
  and the Run chat toggle; rename title to "Chat data"
- align delivery receipts alert wording with the renamed "Your privacy" settings

* android, desktop: simplify settings reorg internals

- VersionInfoView: drop the section/card wrapping, keep the original plain
  version-text layout; load core version in-view so the screen always opens
- DatabaseView: make the "Database passphrase & export" sub-page a
  self-contained DatabaseManagementView that owns its own state, mirroring the
  DatabaseView/DatabaseLayout pattern instead of threading params through a modal

* android, desktop: show App version screen as a card screen

VersionInfoView now hosts a settings section (Developer tools / updates), so
open it with cardScreen = true like the other settings screens — otherwise the
section renders without the card box around it.

* android, desktop: show "Rate the app" only on mobile

The action opens a Play Store link, which does nothing on desktop (the
market:// scheme has no handler and the web fallback never fires). Gate it to
Android, like the Contribute item.

* android, desktop: move Shutdown to settings above app version

Move the Shutdown action out of the app version screen into the main
advanced settings section, just above the app version row. It stays
Android only (desktop is closed via the window) through an
AppShutdownItem expect/actual.

* android, desktop: show app version info in its own card

Wrap the version info block on the app version screen in a section card,
matching iOS and the rest of the card-screen settings.

* fix background

---------

Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
Narasimha-sc
2026-06-07 22:38:05 +00:00
committed by GitHub
parent 4d63d9e3a8
commit bf905eb545
72 changed files with 835 additions and 658 deletions
@@ -1,7 +1,15 @@
package chat.simplex.common.views.usersettings
import SectionItemView
import SectionView
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.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import chat.simplex.common.model.ChatModel
import chat.simplex.common.platform.*
import chat.simplex.common.views.helpers.*
@@ -11,19 +19,19 @@ import dev.icerock.moko.resources.compose.painterResource
import dev.icerock.moko.resources.compose.stringResource
@Composable
actual fun SettingsSectionApp(
actual fun AdvancedSettingsAppSection(
showSettingsModal: (@Composable (ChatModel) -> Unit) -> (() -> Unit),
showVersion: () -> Unit,
withAuth: (title: String, desc: String, block: () -> Unit) -> Unit
withAuth: (title: String, desc: String, block: () -> Unit) -> Unit,
) {
SectionView(stringResource(MR.strings.settings_section_title_app)) {
SettingsActionItem(painterResource(MR.images.ic_restart_alt), stringResource(MR.strings.settings_restart_app), ::restartApp)
SettingsActionItem(painterResource(MR.images.ic_power_settings_new), stringResource(MR.strings.settings_shutdown), { shutdownAppAlert(::shutdownApp) })
SectionView {
SettingsActionItem(painterResource(MR.images.ic_code), stringResource(MR.strings.settings_developer_tools), showSettingsModal { DeveloperView(withAuth) })
AppVersionItem(showVersion)
}
}
@Composable
actual fun AppShutdownItem() {
SettingsActionItem(painterResource(MR.images.ic_power_settings_new), stringResource(MR.strings.settings_shutdown), ::shutdownAppAlert)
}
fun restartApp() {
ProcessPhoenix.triggerRebirth(androidAppContext)
@@ -36,11 +44,28 @@ private fun shutdownApp() {
Runtime.getRuntime().exit(0)
}
private fun shutdownAppAlert(onConfirm: () -> Unit) {
AlertManager.shared.showAlertDialog(
private fun shutdownAppAlert() {
AlertManager.shared.showAlertDialogButtonsColumn(
title = generalGetString(MR.strings.shutdown_alert_question),
text = generalGetString(MR.strings.shutdown_alert_desc),
destructive = true,
onConfirm = onConfirm
buttons = {
Column {
SectionItemView({ AlertManager.shared.hideAlert() }) {
Text(stringResource(MR.strings.cancel_verb), Modifier.fillMaxWidth(), textAlign = TextAlign.Center)
}
SectionItemView({
AlertManager.shared.hideAlert()
restartApp()
}) {
Text(stringResource(MR.strings.settings_restart_app), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
}
SectionItemView({
AlertManager.shared.hideAlert()
shutdownApp()
}) {
Text(stringResource(MR.strings.settings_shutdown), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = Color.Red)
}
}
}
)
}
@@ -44,29 +44,8 @@ fun DatabaseView() {
val prefs = m.controller.appPrefs
val useKeychain = remember { mutableStateOf(prefs.storeDBPassphrase.get()) }
val chatLastStart = remember { mutableStateOf(prefs.chatLastStart.get()) }
val chatArchiveFile = remember { mutableStateOf<String?>(null) }
val stopped = remember { m.chatRunning }.value == false
val saveArchiveLauncher = rememberFileChooserLauncher(false) { to: URI? ->
val archive = chatArchiveFile.value
if (archive != null && to != null) {
copyFileToFile(File(archive), to) {}
}
// delete no matter the database was exported or canceled the export process
if (archive != null) {
File(archive).delete()
chatArchiveFile.value = null
}
}
val appFilesCountAndSize = remember { mutableStateOf(directoryFileCountAndSize(appFilesDir.absolutePath)) }
val importArchiveLauncher = rememberFileChooserLauncher(true) { to: URI? ->
if (to != null) {
importArchiveAlert {
stopChatRunBlockStartChat(stopped, chatLastStart, progressIndicator) {
importArchive(to, appFilesCountAndSize, progressIndicator, false)
}
}
}
}
val chatItemTTL = remember { mutableStateOf(m.chatItemTTL.value) }
Box(
Modifier.fillMaxSize(),
@@ -79,27 +58,10 @@ fun DatabaseView() {
useKeychain.value,
m.chatDbEncrypted.value,
m.controller.appPrefs.storeDBPassphrase.state.value,
m.controller.appPrefs.initialRandomDBPassphrase,
importArchiveLauncher,
appFilesCountAndSize,
chatItemTTL,
user,
m.users,
startChat = { startChat(m, chatLastStart, m.chatDbChanged, progressIndicator) },
stopChatAlert = { stopChatAlert(m, progressIndicator) },
exportArchive = {
stopChatRunBlockStartChat(stopped, chatLastStart, progressIndicator) {
exportArchive(m, progressIndicator, chatArchiveFile, saveArchiveLauncher)
}
},
deleteChatAlert = {
deleteChatAlert {
stopChatRunBlockStartChat(stopped, chatLastStart, progressIndicator) {
deleteChat(m, progressIndicator)
true
}
}
},
deleteAppFilesAndMedia = {
deleteFilesAndMediaAlert {
stopChatRunBlockStartChat(stopped, chatLastStart, progressIndicator) {
@@ -120,12 +82,9 @@ fun DatabaseView() {
setCiTTL(m, rhId, chatItemTTL, progressIndicator, appFilesCountAndSize)
}
},
disconnectAllHosts = {
val connected = chatModel.remoteHosts.filter { it.sessionState is RemoteHostSessionState.Connected }
connected.forEachIndexed { index, h ->
controller.stopRemoteHostAndReloadHosts(h, index == connected.lastIndex && chatModel.connectedToRemote())
}
}
showDatabaseManagement = {
ModalManager.start.showModal(cardScreen = true) { DatabaseManagementView() }
},
)
if (progressIndicator.value) {
Box(
@@ -151,24 +110,18 @@ fun DatabaseLayout(
useKeyChain: Boolean,
chatDbEncrypted: Boolean?,
passphraseSaved: Boolean,
initialRandomDBPassphrase: SharedPreference<Boolean>,
importArchiveLauncher: FileChooserLauncher,
appFilesCountAndSize: MutableState<Pair<Int, Long>>,
chatItemTTL: MutableState<ChatItemTTL>,
currentUser: User?,
users: List<UserInfo>,
startChat: () -> Unit,
stopChatAlert: () -> Unit,
exportArchive: () -> Unit,
deleteChatAlert: () -> Unit,
deleteAppFilesAndMedia: () -> Unit,
onChatItemTTLSelected: (ChatItemTTL?) -> Unit,
disconnectAllHosts: () -> Unit,
showDatabaseManagement: () -> Unit,
) {
val operationsDisabled = progressIndicator && !chatModel.desktopNoUserNoRemote
ColumnWithScrollBar {
AppBarTitle(stringResource(MR.strings.your_chat_database))
AppBarTitle(stringResource(MR.strings.chat_data))
if (!chatModel.desktopNoUserNoRemote) {
SectionView(stringResource(MR.strings.messages_section_title)) {
@@ -187,79 +140,17 @@ fun DatabaseLayout(
)
SectionDividerSpaced()
}
val toggleEnabled = remember { chatModel.remoteHosts }.none { it.sessionState is RemoteHostSessionState.Connected }
if (chatModel.localUserCreated.value == true) {
// still show the toggle in case database was stopped when the user opened this screen because it can be in the following situations:
// - database was stopped after migration and the app relaunched
// - something wrong happened with database operations and the database couldn't be launched when it should
SectionView(stringResource(MR.strings.run_chat_section)) {
if (!toggleEnabled) {
SectionItemView(disconnectAllHosts) {
Text(generalGetString(MR.strings.disconnect_remote_hosts), Modifier.fillMaxWidth(), color = WarningOrange)
}
}
RunChatSetting(stopped, toggleEnabled && !progressIndicator, startChat, stopChatAlert)
}
if (stopped) SectionTextFooter(stringResource(MR.strings.you_must_use_the_most_recent_version_of_database))
SectionDividerSpaced()
}
SectionView(stringResource(MR.strings.chat_database_section)) {
if (chatModel.localUserCreated.value != true && !toggleEnabled) {
SectionItemView(disconnectAllHosts) {
Text(generalGetString(MR.strings.disconnect_remote_hosts), Modifier.fillMaxWidth(), color = WarningOrange)
}
}
SectionView {
val unencrypted = chatDbEncrypted == false
SettingsActionItem(
if (unencrypted) painterResource(MR.images.ic_lock_open_right) else if (useKeyChain) painterResource(MR.images.ic_vpn_key_filled)
else painterResource(MR.images.ic_lock),
stringResource(MR.strings.database_passphrase),
click = { ModalManager.start.showModal(cardScreen = true) { DatabaseEncryptionView(chatModel, false) } },
stringResource(MR.strings.database_passphrase_and_export),
click = showDatabaseManagement,
iconColor = if (unencrypted || (appPlatform.isDesktop && passphraseSaved)) WarningOrange else MaterialTheme.colors.secondary,
disabled = operationsDisabled
)
if (appPlatform.isDesktop) {
SettingsActionItem(
painterResource(MR.images.ic_folder_open),
stringResource(MR.strings.open_database_folder),
::desktopOpenDatabaseDir,
disabled = operationsDisabled
)
}
SettingsActionItem(
painterResource(MR.images.ic_ios_share),
stringResource(MR.strings.export_database),
click = {
if (initialRandomDBPassphrase.get()) {
exportProhibitedAlert()
ModalManager.start.showModal {
DatabaseEncryptionView(chatModel, false)
}
} else {
exportArchive()
}
},
textColor = MaterialTheme.colors.primary,
iconColor = MaterialTheme.colors.primary,
disabled = operationsDisabled
)
SettingsActionItem(
painterResource(MR.images.ic_download),
stringResource(MR.strings.import_database),
{ withLongRunningApi { importArchiveLauncher.launch("application/zip") } },
textColor = Color.Red,
iconColor = Color.Red,
disabled = operationsDisabled
)
SettingsActionItem(
painterResource(MR.images.ic_delete_forever),
stringResource(MR.strings.delete_database),
deleteChatAlert,
textColor = Color.Red,
iconColor = Color.Red,
disabled = operationsDisabled
)
}
SectionDividerSpaced()
@@ -287,6 +178,155 @@ fun DatabaseLayout(
}
}
@Composable
fun DatabaseManagementView() {
val m = chatModel
val progressIndicator = remember { mutableStateOf(false) }
val prefs = m.controller.appPrefs
val useKeychain = remember { mutableStateOf(prefs.storeDBPassphrase.get()) }
val chatLastStart = remember { mutableStateOf(prefs.chatLastStart.get()) }
val chatArchiveFile = remember { mutableStateOf<String?>(null) }
val stopped = remember { m.chatRunning }.value == false
val saveArchiveLauncher = rememberFileChooserLauncher(false) { to: URI? ->
val archive = chatArchiveFile.value
if (archive != null && to != null) {
copyFileToFile(File(archive), to) {}
}
// delete no matter the database was exported or canceled the export process
if (archive != null) {
File(archive).delete()
chatArchiveFile.value = null
}
}
val appFilesCountAndSize = remember { mutableStateOf(directoryFileCountAndSize(appFilesDir.absolutePath)) }
val importArchiveLauncher = rememberFileChooserLauncher(true) { to: URI? ->
if (to != null) {
importArchiveAlert {
stopChatRunBlockStartChat(stopped, chatLastStart, progressIndicator) {
importArchive(to, appFilesCountAndSize, progressIndicator, false)
}
}
}
}
val operationsDisabled = progressIndicator.value && !m.desktopNoUserNoRemote
Box(Modifier.fillMaxSize()) {
ColumnWithScrollBar {
AppBarTitle(stringResource(MR.strings.database_passphrase_and_export))
val toggleEnabled = remember { chatModel.remoteHosts }.none { it.sessionState is RemoteHostSessionState.Connected }
val disconnectAllHosts = {
val connected = chatModel.remoteHosts.filter { it.sessionState is RemoteHostSessionState.Connected }
connected.forEachIndexed { index, h ->
controller.stopRemoteHostAndReloadHosts(h, index == connected.lastIndex && chatModel.connectedToRemote())
}
}
SectionView(stringResource(MR.strings.chat_database_section)) {
if (chatModel.localUserCreated.value != true && !toggleEnabled) {
SectionItemView(disconnectAllHosts) {
Text(generalGetString(MR.strings.disconnect_remote_hosts), Modifier.fillMaxWidth(), color = WarningOrange)
}
}
val unencrypted = m.chatDbEncrypted.value == false
SettingsActionItem(
if (unencrypted) painterResource(MR.images.ic_lock_open_right) else if (useKeychain.value) painterResource(MR.images.ic_vpn_key_filled)
else painterResource(MR.images.ic_lock),
stringResource(MR.strings.database_passphrase),
click = { ModalManager.start.showModal(cardScreen = true) { DatabaseEncryptionView(chatModel, false) } },
iconColor = if (unencrypted || (appPlatform.isDesktop && prefs.storeDBPassphrase.state.value)) WarningOrange else MaterialTheme.colors.secondary,
disabled = operationsDisabled
)
if (appPlatform.isDesktop) {
SettingsActionItem(
painterResource(MR.images.ic_folder_open),
stringResource(MR.strings.open_database_folder),
::desktopOpenDatabaseDir,
disabled = operationsDisabled
)
}
SettingsActionItem(
painterResource(MR.images.ic_ios_share),
stringResource(MR.strings.export_database),
click = {
if (prefs.initialRandomDBPassphrase.get()) {
exportProhibitedAlert()
ModalManager.start.showModal {
DatabaseEncryptionView(chatModel, false)
}
} else {
stopChatRunBlockStartChat(stopped, chatLastStart, progressIndicator) {
exportArchive(m, progressIndicator, chatArchiveFile, saveArchiveLauncher)
}
}
},
textColor = MaterialTheme.colors.primary,
iconColor = MaterialTheme.colors.primary,
disabled = operationsDisabled
)
SettingsActionItem(
painterResource(MR.images.ic_download),
stringResource(MR.strings.import_database),
{ withLongRunningApi { importArchiveLauncher.launch("application/zip") } },
textColor = Color.Red,
iconColor = Color.Red,
disabled = operationsDisabled
)
SettingsActionItem(
painterResource(MR.images.ic_delete_forever),
stringResource(MR.strings.delete_database),
{
deleteChatAlert {
stopChatRunBlockStartChat(stopped, chatLastStart, progressIndicator) {
deleteChat(m, progressIndicator)
true
}
}
},
textColor = Color.Red,
iconColor = Color.Red,
disabled = operationsDisabled
)
}
if (chatModel.localUserCreated.value == true) {
SectionDividerSpaced()
// still show the toggle in case database was stopped when the user opened this screen because it can be in the following situations:
// - database was stopped after migration and the app relaunched
// - something wrong happened with database operations and the database couldn't be launched when it should
SectionView(stringResource(MR.strings.run_chat_section)) {
if (!toggleEnabled) {
SectionItemView(disconnectAllHosts) {
Text(generalGetString(MR.strings.disconnect_remote_hosts), Modifier.fillMaxWidth(), color = WarningOrange)
}
}
RunChatSetting(
stopped,
toggleEnabled && !progressIndicator.value,
startChat = { startChat(m, chatLastStart, m.chatDbChanged, progressIndicator) },
stopChatAlert = { stopChatAlert(m, progressIndicator) }
)
}
if (stopped) SectionTextFooter(stringResource(MR.strings.you_must_use_the_most_recent_version_of_database))
}
SectionBottomSpacer()
}
if (progressIndicator.value) {
Box(
Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator(
Modifier
.padding(horizontal = 2.dp)
.size(30.dp),
color = MaterialTheme.colors.secondary,
strokeWidth = 2.5.dp
)
}
}
}
}
private fun setChatItemTTLAlert(
m: ChatModel, rhId: Long?, selectedChatItemTTL: MutableState<ChatItemTTL>,
progressIndicator: MutableState<Boolean>,
@@ -832,19 +872,13 @@ fun PreviewDatabaseLayout() {
useKeyChain = false,
chatDbEncrypted = false,
passphraseSaved = false,
initialRandomDBPassphrase = SharedPreference({ true }, {}),
importArchiveLauncher = rememberFileChooserLauncher(true) {},
appFilesCountAndSize = remember { mutableStateOf(0 to 0L) },
chatItemTTL = remember { mutableStateOf(ChatItemTTL.None) },
currentUser = User.sampleData,
users = listOf(UserInfo.sampleData),
startChat = {},
stopChatAlert = {},
exportArchive = {},
deleteChatAlert = {},
deleteAppFilesAndMedia = {},
onChatItemTTLSelected = {},
disconnectAllHosts = {},
showDatabaseManagement = {},
)
}
}
@@ -24,43 +24,28 @@ import kotlin.collections.ArrayList
fun NotificationsSettingsView(
chatModel: ChatModel,
) {
val onNotificationPreviewModeSelected = { mode: NotificationPreviewMode ->
chatModel.controller.appPrefs.notificationPreviewMode.set(mode.name)
chatModel.notificationPreviewMode.value = mode
}
NotificationsSettingsLayout(
notificationsMode = remember { chatModel.controller.appPrefs.notificationsMode.state },
notificationPreviewMode = chatModel.notificationPreviewMode,
showPage = { page ->
showNotificationsMode = {
ModalManager.start.showModalCloseable(true) {
when (page) {
CurrentPage.NOTIFICATIONS_MODE -> NotificationsModeView(chatModel.controller.appPrefs.notificationsMode.state) { changeNotificationsMode(it, chatModel) }
CurrentPage.NOTIFICATION_PREVIEW_MODE -> NotificationPreviewView(chatModel.notificationPreviewMode, onNotificationPreviewModeSelected)
}
NotificationsModeView(chatModel.controller.appPrefs.notificationsMode.state) { changeNotificationsMode(it, chatModel) }
}
},
)
}
enum class CurrentPage {
NOTIFICATIONS_MODE, NOTIFICATION_PREVIEW_MODE
}
@Composable
fun NotificationsSettingsLayout(
notificationsMode: State<NotificationsMode>,
notificationPreviewMode: State<NotificationPreviewMode>,
showPage: (CurrentPage) -> Unit,
showNotificationsMode: () -> Unit,
) {
val modes = remember { notificationModes() }
val previewModes = remember { notificationPreviewModes() }
ColumnWithScrollBar {
AppBarTitle(stringResource(MR.strings.notifications))
SectionView(null) {
if (appPlatform == AppPlatform.ANDROID) {
SettingsActionItemWithContent(null, stringResource(MR.strings.settings_notifications_mode_title), { showPage(CurrentPage.NOTIFICATIONS_MODE) }) {
SettingsActionItemWithContent(null, stringResource(MR.strings.settings_notifications_mode_title), showNotificationsMode) {
Text(
modes.firstOrNull { it.value == notificationsMode.value }?.title ?: "",
maxLines = 1,
@@ -69,14 +54,6 @@ fun NotificationsSettingsLayout(
)
}
}
SettingsActionItemWithContent(null, stringResource(MR.strings.settings_notification_preview_mode_title), { showPage(CurrentPage.NOTIFICATION_PREVIEW_MODE) }) {
Text(
previewModes.firstOrNull { it.value == notificationPreviewMode.value }?.title ?: "",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
color = MaterialTheme.colors.secondary
)
}
}
if (platform.androidIsXiaomiDevice() && (notificationsMode.value == NotificationsMode.PERIODIC || notificationsMode.value == NotificationsMode.SERVICE)) {
SectionTextFooter(annotatedStringResource(MR.strings.xiaomi_ignore_battery_optimization))
@@ -15,6 +15,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.*
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import dev.icerock.moko.resources.compose.painterResource
import dev.icerock.moko.resources.compose.stringResource
import androidx.compose.ui.unit.dp
@@ -73,6 +74,48 @@ fun PrivacySettingsView(
stringResource(MR.strings.sanitize_links_toggle),
chatModel.controller.appPrefs.privacySanitizeLinks
)
}
SectionDividerSpaced()
SectionView(stringResource(MR.strings.settings_section_title_files)) {
SettingsPreferenceItem(painterResource(MR.images.ic_image), stringResource(MR.strings.auto_accept_images), chatModel.controller.appPrefs.privacyAcceptImages)
BlurRadiusOptions(remember { appPrefs.privacyMediaBlurRadius.state }) {
appPrefs.privacyMediaBlurRadius.set(it)
}
}
val currentUser = chatModel.currentUser.value
if (currentUser != null && !chatModel.desktopNoUserNoRemote) {
SectionDividerSpaced()
ContacRequestsFromGroupsSection(
currentUser = currentUser,
setAutoAcceptGrpDirectInvs = { enable ->
withApi {
chatModel.controller.apiSetUserAutoAcceptMemberContacts(currentUser, enable)
chatModel.currentUser.value = currentUser.copy(autoAcceptMemberContacts = enable)
}
}
)
}
SectionDividerSpaced()
SectionView {
SettingsActionItem(
painterResource(MR.images.ic_more_horiz),
stringResource(MR.strings.more_privacy),
showSettingsModal { MorePrivacyView(it) }
)
}
SectionBottomSpacer()
}
}
@Composable
fun MorePrivacyView(chatModel: ChatModel) {
ColumnWithScrollBar {
AppBarTitle(stringResource(MR.strings.more_privacy))
SectionView(stringResource(MR.strings.settings_section_title_chats)) {
SettingsPreferenceItem(
painterResource(MR.images.ic_chat_bubble),
stringResource(MR.strings.privacy_show_last_messages),
@@ -98,10 +141,6 @@ fun PrivacySettingsView(
SettingsPreferenceItem(painterResource(MR.images.ic_lock), stringResource(MR.strings.encrypt_local_files), chatModel.controller.appPrefs.privacyEncryptLocalFiles, onChange = { enable ->
withBGApi { chatModel.controller.apiSetEncryptLocalFiles(enable) }
})
SettingsPreferenceItem(painterResource(MR.images.ic_image), stringResource(MR.strings.auto_accept_images), chatModel.controller.appPrefs.privacyAcceptImages)
BlurRadiusOptions(remember { appPrefs.privacyMediaBlurRadius.state }) {
appPrefs.privacyMediaBlurRadius.set(it)
}
SettingsPreferenceItem(painterResource(MR.images.ic_security), stringResource(MR.strings.protect_ip_address), chatModel.controller.appPrefs.privacyAskToApproveRelays)
}
SectionTextFooter(
@@ -111,9 +150,34 @@ fun PrivacySettingsView(
stringResource(MR.strings.without_tor_or_vpn_ip_address_will_be_visible_to_file_servers)
}
)
SectionDividerSpaced()
SectionView(stringResource(MR.strings.notifications)) {
val previewModes = remember { notificationPreviewModes() }
val notificationPreviewMode = remember { chatModel.notificationPreviewMode }
SettingsActionItemWithContent(
painterResource(MR.images.ic_visibility_off),
stringResource(MR.strings.settings_notification_preview_mode_title),
click = {
ModalManager.start.showModalCloseable(true) {
NotificationPreviewView(notificationPreviewMode) { mode ->
chatModel.controller.appPrefs.notificationPreviewMode.set(mode.name)
chatModel.notificationPreviewMode.value = mode
}
}
}
) {
Text(
previewModes.firstOrNull { it.value == notificationPreviewMode.value }?.title ?: "",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
color = MaterialTheme.colors.secondary
)
}
}
val currentUser = chatModel.currentUser.value
if (currentUser != null) {
if (currentUser != null && !chatModel.desktopNoUserNoRemote) {
fun setSendReceiptsContacts(enable: Boolean, clearOverrides: Boolean) {
withLongRunningApi(slow = 60_000) {
val mrs = UserMsgReceiptSettings(enable, clearOverrides)
@@ -164,57 +228,40 @@ fun PrivacySettingsView(
}
}
fun setAutoAcceptGrpDirectInvs(enable: Boolean) {
withApi {
chatModel.controller.apiSetUserAutoAcceptMemberContacts(currentUser, enable)
chatModel.currentUser.value = currentUser.copy(autoAcceptMemberContacts = enable)
SectionDividerSpaced()
DeliveryReceiptsSection(
currentUser = currentUser,
setOrAskSendReceiptsContacts = { enable ->
val contactReceiptsOverrides = chatModel.chats.value.fold(0) { count, chat ->
if (chat.chatInfo is ChatInfo.Direct) {
val sendRcpts = chat.chatInfo.contact.chatSettings.sendRcpts
count + (if (sendRcpts == null || sendRcpts == enable) 0 else 1)
} else {
count
}
}
if (contactReceiptsOverrides == 0) {
setSendReceiptsContacts(enable, clearOverrides = false)
} else {
showUserContactsReceiptsAlert(enable, contactReceiptsOverrides, ::setSendReceiptsContacts)
}
},
setOrAskSendReceiptsGroups = { enable ->
val groupReceiptsOverrides = chatModel.chats.value.fold(0) { count, chat ->
if (chat.chatInfo is ChatInfo.Group) {
val sendRcpts = chat.chatInfo.groupInfo.chatSettings.sendRcpts
count + (if (sendRcpts == null || sendRcpts == enable) 0 else 1)
} else {
count
}
}
if (groupReceiptsOverrides == 0) {
setSendReceiptsGroups(enable, clearOverrides = false)
} else {
showUserGroupsReceiptsAlert(enable, groupReceiptsOverrides, ::setSendReceiptsGroups)
}
}
}
if (!chatModel.desktopNoUserNoRemote) {
SectionDividerSpaced()
ContacRequestsFromGroupsSection(
currentUser = currentUser,
setAutoAcceptGrpDirectInvs = { enable ->
setAutoAcceptGrpDirectInvs(enable)
}
)
SectionDividerSpaced()
DeliveryReceiptsSection(
currentUser = currentUser,
setOrAskSendReceiptsContacts = { enable ->
val contactReceiptsOverrides = chatModel.chats.value.fold(0) { count, chat ->
if (chat.chatInfo is ChatInfo.Direct) {
val sendRcpts = chat.chatInfo.contact.chatSettings.sendRcpts
count + (if (sendRcpts == null || sendRcpts == enable) 0 else 1)
} else {
count
}
}
if (contactReceiptsOverrides == 0) {
setSendReceiptsContacts(enable, clearOverrides = false)
} else {
showUserContactsReceiptsAlert(enable, contactReceiptsOverrides, ::setSendReceiptsContacts)
}
},
setOrAskSendReceiptsGroups = { enable ->
val groupReceiptsOverrides = chatModel.chats.value.fold(0) { count, chat ->
if (chat.chatInfo is ChatInfo.Group) {
val sendRcpts = chat.chatInfo.groupInfo.chatSettings.sendRcpts
count + (if (sendRcpts == null || sendRcpts == enable) 0 else 1)
} else {
count
}
}
if (groupReceiptsOverrides == 0) {
setSendReceiptsGroups(enable, clearOverrides = false)
} else {
showUserGroupsReceiptsAlert(enable, groupReceiptsOverrides, ::setSendReceiptsGroups)
}
}
)
}
)
}
SectionBottomSpacer()
}
@@ -37,17 +37,15 @@ import chat.simplex.res.MR
@Composable
fun SettingsView(chatModel: ChatModel, setPerformLA: (Boolean) -> Unit, close: () -> Unit) {
val user = chatModel.currentUser.value
val stopped = chatModel.chatRunning.value == false
val showSettingsModal: (@Composable (ChatModel) -> Unit) -> (() -> Unit) = { modalView -> { ModalManager.start.showModal(settings = true, cardScreen = true) { modalView(chatModel) } } }
SettingsLayout(
stopped,
chatModel.chatDbEncrypted.value == true,
remember { chatModel.controller.appPrefs.storeDBPassphrase.state }.value,
remember { chatModel.controller.appPrefs.notificationsMode.state },
user?.displayName,
setPerformLA = setPerformLA,
showModal = { modalView -> { ModalManager.start.showModal { modalView(chatModel) } } },
showSettingsModal = { modalView -> { ModalManager.start.showModal(settings = true, cardScreen = true) { modalView(chatModel) } } },
showSettingsModal = showSettingsModal,
showSettingsModalWithSearch = { modalView ->
ModalManager.start.showCustomModal { close ->
val search = rememberSaveable { mutableStateOf("") }
@@ -62,12 +60,7 @@ fun SettingsView(chatModel: ChatModel, setPerformLA: (Boolean) -> Unit, close: (
},
showCustomModal = { modalView -> { ModalManager.start.showCustomModal { close -> modalView(chatModel, close) } } },
showVersion = {
withBGApi {
val info = chatModel.controller.apiGetVersion()
if (info != null) {
ModalManager.start.showModal { VersionInfoView(info) }
}
}
ModalManager.start.showModal(cardScreen = true) { VersionInfoView(showSettingsModal, ::doWithAuth) }
},
withAuth = ::doWithAuth,
)
@@ -84,8 +77,6 @@ fun SettingsLayout(
stopped: Boolean,
encrypted: Boolean,
passphraseSaved: Boolean,
notificationsMode: State<NotificationsMode>,
userDisplayName: String?,
setPerformLA: (Boolean) -> Unit,
showModal: (@Composable (ChatModel) -> Unit) -> (() -> Unit),
showSettingsModal: (@Composable (ChatModel) -> Unit) -> (() -> Unit),
@@ -98,30 +89,52 @@ fun SettingsLayout(
LaunchedEffect(Unit) {
hideKeyboard(view)
}
val uriHandler = LocalUriHandler.current
val notificationsMode = remember { chatModel.controller.appPrefs.notificationsMode.state }
ColumnWithScrollBar {
AppBarTitle(stringResource(MR.strings.your_settings))
SectionView(stringResource(MR.strings.settings_section_title_settings)) {
SettingsActionItem(painterResource(if (notificationsMode.value == NotificationsMode.OFF) MR.images.ic_bolt_off else MR.images.ic_bolt), stringResource(MR.strings.notifications), showSettingsModal { NotificationsSettingsView(it) }, disabled = stopped)
SettingsActionItem(painterResource(MR.images.ic_wifi_tethering), stringResource(MR.strings.network_and_servers), showCustomModal { _, close -> NetworkAndServersView(close) }, disabled = stopped)
SettingsActionItem(painterResource(MR.images.ic_videocam), stringResource(MR.strings.settings_audio_video_calls), showSettingsModal { CallSettingsView(it, showModal) }, disabled = stopped)
SettingsActionItem(painterResource(MR.images.ic_lock), stringResource(MR.strings.privacy_and_security), showSettingsModal { PrivacySettingsView(it, showSettingsModal, setPerformLA) }, disabled = stopped)
SectionView {
SettingsActionItem(painterResource(MR.images.ic_light_mode), stringResource(MR.strings.appearance_settings), showSettingsModal { AppearanceView(it) })
}
SectionDividerSpaced()
SectionView(stringResource(MR.strings.settings_section_title_chat_database)) {
SettingsActionItem(painterResource(MR.images.ic_lock), stringResource(MR.strings.your_privacy), showSettingsModal { PrivacySettingsView(it, showSettingsModal, setPerformLA) }, disabled = stopped)
SettingsActionItem(painterResource(MR.images.ic_help), stringResource(MR.strings.help_and_support), showSettingsModal { HelpAndSupportView(it, showModal, showCustomModal) })
DatabaseItem(encrypted, passphraseSaved, showSettingsModal { DatabaseView() }, stopped)
SettingsActionItem(painterResource(MR.images.ic_ios_share), stringResource(MR.strings.migrate_from_device_to_another_device), { withAuth(generalGetString(MR.strings.auth_open_migration_to_another_device), generalGetString(MR.strings.auth_log_in_using_credential)) { ModalManager.fullscreen.showCustomModal { close -> MigrateFromDeviceView(close) } } }, disabled = stopped)
}
SectionDividerSpaced()
SectionView(stringResource(MR.strings.advanced_settings)) {
SettingsActionItem(painterResource(MR.images.ic_wifi_tethering), stringResource(MR.strings.network_and_servers), showCustomModal { _, close -> NetworkAndServersView(close) }, disabled = stopped)
if (appPlatform == AppPlatform.ANDROID) {
SettingsActionItem(painterResource(if (notificationsMode.value == NotificationsMode.OFF) MR.images.ic_bolt_off else MR.images.ic_bolt), stringResource(MR.strings.notifications), showSettingsModal { NotificationsSettingsView(it) }, disabled = stopped)
}
SettingsActionItem(painterResource(MR.images.ic_videocam), stringResource(MR.strings.settings_audio_video_calls), showSettingsModal { CallSettingsView(it, showModal) }, disabled = stopped)
AppShutdownItem()
AppVersionItem(showVersion)
}
SectionBottomSpacer()
}
}
@Composable
fun HelpAndSupportView(
chatModel: ChatModel,
showModal: (@Composable (ChatModel) -> Unit) -> (() -> Unit),
showCustomModal: (@Composable ModalData.(ChatModel, () -> Unit) -> Unit) -> (() -> Unit),
) {
val uriHandler = LocalUriHandler.current
val stopped = chatModel.chatRunning.value == false
val userDisplayName = chatModel.currentUser.value?.displayName ?: ""
ColumnWithScrollBar {
AppBarTitle(stringResource(MR.strings.help_and_support))
SectionView(stringResource(MR.strings.settings_section_title_help)) {
SettingsActionItem(painterResource(MR.images.ic_help), stringResource(MR.strings.how_to_use_simplex_chat), showModal { HelpView(userDisplayName ?: "") }, disabled = stopped)
SettingsActionItem(painterResource(MR.images.ic_help), stringResource(MR.strings.how_to_use_simplex_chat), showModal { HelpView(userDisplayName) }, disabled = stopped)
SettingsActionItem(painterResource(MR.images.ic_add), stringResource(MR.strings.whats_new), showCustomModal { _, close -> WhatsNewView(viaSettings = true, close = close) }, disabled = stopped)
SettingsActionItem(painterResource(MR.images.ic_info), stringResource(MR.strings.about_simplex_chat), showModal { SimpleXInfo(it, onboarding = false) })
}
SectionDividerSpaced()
SectionView(stringResource(MR.strings.settings_section_title_contact)) {
if (!chatModel.desktopNoUserNoRemote) {
SettingsActionItem(painterResource(MR.images.ic_tag), stringResource(MR.strings.chat_with_the_founder), { uriHandler.openVerifiedSimplexUri(simplexTeamUri) }, textColor = MaterialTheme.colors.primary, disabled = stopped)
}
@@ -129,27 +142,29 @@ fun SettingsLayout(
}
SectionDividerSpaced()
SectionView(stringResource(MR.strings.settings_section_title_support)) {
SectionView(stringResource(MR.strings.settings_section_title_support_project)) {
if (!BuildConfigCommon.ANDROID_BUNDLE) {
ContributeItem(uriHandler)
}
RateAppItem(uriHandler)
if (appPlatform.isAndroid) {
RateAppItem(uriHandler)
}
StarOnGithubItem(uriHandler)
}
SectionDividerSpaced()
SettingsSectionApp(showSettingsModal, showVersion, withAuth)
SectionBottomSpacer()
}
}
@Composable
expect fun SettingsSectionApp(
expect fun AdvancedSettingsAppSection(
showSettingsModal: (@Composable (ChatModel) -> Unit) -> (() -> Unit),
showVersion: () -> Unit,
withAuth: (title: String, desc: String, block: () -> Unit) -> Unit
withAuth: (title: String, desc: String, block: () -> Unit) -> Unit,
)
// Shutdown is only available on Android; on desktop the app is closed via the window.
@Composable
expect fun AppShutdownItem()
@Composable private fun DatabaseItem(encrypted: Boolean, saved: Boolean, openDatabaseView: () -> Unit, stopped: Boolean) {
SectionItemView(openDatabaseView) {
Row(
@@ -160,11 +175,11 @@ expect fun SettingsSectionApp(
Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) {
Icon(
painterResource(MR.images.ic_database),
contentDescription = stringResource(MR.strings.database_passphrase_and_export),
contentDescription = stringResource(MR.strings.chat_data),
tint = if (encrypted && (appPlatform.isAndroid || !saved)) MaterialTheme.colors.secondary else WarningOrange,
)
TextIconSpaced(false)
Text(stringResource(MR.strings.database_passphrase_and_export))
Text(stringResource(MR.strings.chat_data))
}
if (stopped) {
Icon(
@@ -208,7 +223,7 @@ fun ChatLockItem(
}
}
@Composable private fun ContributeItem(uriHandler: UriHandler) {
@Composable fun ContributeItem(uriHandler: UriHandler) {
SectionItemView({ uriHandler.openExternalLink("https://github.com/simplex-chat/simplex-chat#contribute") }) {
Icon(
painterResource(MR.images.ic_keyboard),
@@ -220,7 +235,7 @@ fun ChatLockItem(
}
}
@Composable private fun RateAppItem(uriHandler: UriHandler) {
@Composable fun RateAppItem(uriHandler: UriHandler) {
SectionItemView({
runCatching { uriHandler.openUriCatching("market://details?id=chat.simplex.app") }
.onFailure { uriHandler.openUriCatching("https://play.google.com/store/apps/details?id=chat.simplex.app") }
@@ -236,7 +251,7 @@ fun ChatLockItem(
}
}
@Composable private fun StarOnGithubItem(uriHandler: UriHandler) {
@Composable fun StarOnGithubItem(uriHandler: UriHandler) {
SectionItemView({ uriHandler.openExternalLink("https://github.com/simplex-chat/simplex-chat") }) {
Icon(
painter = painterResource(MR.images.ic_github),
@@ -486,8 +501,6 @@ fun PreviewSettingsLayout() {
stopped = false,
encrypted = false,
passphraseSaved = false,
notificationsMode = remember { mutableStateOf(NotificationsMode.OFF) },
userDisplayName = "Alice",
setPerformLA = { _ -> },
showModal = { {} },
showSettingsModal = { {} },
@@ -1,33 +1,55 @@
package chat.simplex.common.views.usersettings
import SectionBottomSpacer
import SectionDividerSpaced
import SectionView
import itemHPadding
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import dev.icerock.moko.resources.compose.stringResource
import chat.simplex.common.BuildConfigCommon
import chat.simplex.common.model.ChatModel
import chat.simplex.common.model.CoreVersionInfo
import chat.simplex.common.platform.ColumnWithScrollBar
import chat.simplex.common.platform.appPlatform
import chat.simplex.common.ui.theme.DEFAULT_PADDING
import chat.simplex.common.platform.chatModel
import chat.simplex.common.ui.theme.DEFAULT_PADDING_HALF
import chat.simplex.common.views.helpers.AppBarTitle
import chat.simplex.res.MR
@Composable
fun VersionInfoView(info: CoreVersionInfo) {
ColumnWithScrollBar(
Modifier.padding(horizontal = DEFAULT_PADDING),
) {
AppBarTitle(stringResource(MR.strings.app_version_title), withPadding = false)
if (appPlatform.isAndroid) {
Text(String.format(stringResource(MR.strings.app_version_name), BuildConfigCommon.ANDROID_VERSION_NAME))
Text(String.format(stringResource(MR.strings.app_version_code), BuildConfigCommon.ANDROID_VERSION_CODE))
} else {
Text(String.format(stringResource(MR.strings.app_version_name), BuildConfigCommon.DESKTOP_VERSION_NAME))
Text(String.format(stringResource(MR.strings.app_version_code), BuildConfigCommon.DESKTOP_VERSION_CODE))
fun VersionInfoView(
showSettingsModal: (@Composable (ChatModel) -> Unit) -> (() -> Unit),
withAuth: (title: String, desc: String, block: () -> Unit) -> Unit,
) {
val versionInfo = remember { mutableStateOf<CoreVersionInfo?>(null) }
LaunchedEffect(Unit) {
versionInfo.value = chatModel.controller.apiGetVersion()
}
ColumnWithScrollBar {
AppBarTitle(stringResource(MR.strings.app_version_title))
SectionView {
Column(Modifier.padding(horizontal = itemHPadding, vertical = DEFAULT_PADDING_HALF)) {
if (appPlatform.isAndroid) {
Text(String.format(stringResource(MR.strings.app_version_name), BuildConfigCommon.ANDROID_VERSION_NAME))
Text(String.format(stringResource(MR.strings.app_version_code), BuildConfigCommon.ANDROID_VERSION_CODE))
} else {
Text(String.format(stringResource(MR.strings.app_version_name), BuildConfigCommon.DESKTOP_VERSION_NAME))
Text(String.format(stringResource(MR.strings.app_version_code), BuildConfigCommon.DESKTOP_VERSION_CODE))
}
versionInfo.value?.let { info ->
Text(String.format(stringResource(MR.strings.core_version), info.version))
val simplexmqCommit = if (info.simplexmqCommit.length >= 7) info.simplexmqCommit.substring(startIndex = 0, endIndex = 7) else info.simplexmqCommit
Text(String.format(stringResource(MR.strings.core_simplexmq_version), info.simplexmqVersion, simplexmqCommit))
}
}
}
Text(String.format(stringResource(MR.strings.core_version), info.version))
val simplexmqCommit = if (info.simplexmqCommit.length >= 7) info.simplexmqCommit.substring(startIndex = 0, endIndex = 7) else info.simplexmqCommit
Text(String.format(stringResource(MR.strings.core_simplexmq_version), info.simplexmqVersion, simplexmqCommit))
SectionDividerSpaced()
AdvancedSettingsAppSection(showSettingsModal, withAuth)
SectionBottomSpacer()
}
}
@@ -1555,6 +1555,13 @@
<string name="settings_section_title_files">Files</string>
<string name="settings_section_title_delivery_receipts">Send delivery receipts to</string>
<string name="settings_section_title_contact_requests_from_groups">Contact requests from groups</string>
<string name="settings_section_title_about">About</string>
<string name="settings_section_title_contact">Contact</string>
<string name="settings_section_title_support_project">Support the project</string>
<string name="chat_data">Chat data</string>
<string name="help_and_support">Help &amp; support</string>
<string name="more_privacy">More privacy</string>
<string name="advanced_settings">Advanced settings</string>
<string name="settings_restart_app">Restart</string>
<string name="settings_shutdown">Shutdown</string>
<string name="settings_developer_tools">Developer tools</string>
@@ -2681,7 +2688,7 @@
<string name="dont_enable_receipts">Don\'t enable</string>
<string name="you_can_enable_delivery_receipts_later">You can enable later via Settings</string>
<string name="delivery_receipts_are_disabled">Delivery receipts are disabled!</string>
<string name="you_can_enable_delivery_receipts_later_alert">You can enable them later via app Privacy &amp; Security settings.</string>
<string name="you_can_enable_delivery_receipts_later_alert">You can enable them later via app Your privacy settings.</string>
<string name="error_enabling_delivery_receipts">Error enabling delivery receipts!</string>
<!-- Remote access -->
@@ -1,27 +1,21 @@
package chat.simplex.common.views.usersettings
import SectionView
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.runtime.*
import chat.simplex.common.model.ChatController.appPrefs
import chat.simplex.common.model.ChatModel
import chat.simplex.common.platform.AppUpdatesChannel
import chat.simplex.common.ui.theme.DEFAULT_PADDING_HALF
import chat.simplex.common.platform.*
import chat.simplex.common.views.helpers.*
import chat.simplex.res.MR
import dev.icerock.moko.resources.compose.painterResource
import dev.icerock.moko.resources.compose.stringResource
@Composable
actual fun SettingsSectionApp(
actual fun AdvancedSettingsAppSection(
showSettingsModal: (@Composable (ChatModel) -> Unit) -> (() -> Unit),
showVersion: () -> Unit,
withAuth: (title: String, desc: String, block: () -> Unit) -> Unit
withAuth: (title: String, desc: String, block: () -> Unit) -> Unit,
) {
SectionView(stringResource(MR.strings.settings_section_title_app)) {
SectionView {
SettingsActionItem(painterResource(MR.images.ic_code), stringResource(MR.strings.settings_developer_tools), showSettingsModal { DeveloperView(withAuth) })
val selectedChannel = remember { appPrefs.appUpdateChannel.state }
val values = AppUpdatesChannel.entries.map { it to it.text }
@@ -29,6 +23,8 @@ actual fun SettingsSectionApp(
appPrefs.appUpdateChannel.set(it)
setupUpdateChecker()
}
AppVersionItem(showVersion)
}
}
@Composable
actual fun AppShutdownItem() {}