Skip to content
Snippets Groups Projects
Verified Commit bf6c9eb2 authored by Mikolai Gütschow's avatar Mikolai Gütschow
Browse files

rename interface to UnencryptedSettings and show language names in respective language

parent ad94d1a8
No related branches found
No related tags found
1 merge request!140Settings persistence and allow changing language
...@@ -52,8 +52,8 @@ import org.briarproject.bramble.util.OsUtils.isMac ...@@ -52,8 +52,8 @@ import org.briarproject.bramble.util.OsUtils.isMac
import org.briarproject.briar.attachment.AttachmentModule import org.briarproject.briar.attachment.AttachmentModule
import org.briarproject.briar.desktop.attachment.media.ImageCompressor import org.briarproject.briar.desktop.attachment.media.ImageCompressor
import org.briarproject.briar.desktop.attachment.media.ImageCompressorImpl import org.briarproject.briar.desktop.attachment.media.ImageCompressorImpl
import org.briarproject.briar.desktop.settings.Settings import org.briarproject.briar.desktop.settings.UnencryptedSettings
import org.briarproject.briar.desktop.settings.SettingsImpl import org.briarproject.briar.desktop.settings.UnencryptedSettingsImpl
import org.briarproject.briar.desktop.threading.BriarExecutors import org.briarproject.briar.desktop.threading.BriarExecutors
import org.briarproject.briar.desktop.threading.BriarExecutorsImpl import org.briarproject.briar.desktop.threading.BriarExecutorsImpl
import org.briarproject.briar.desktop.threading.UiExecutor import org.briarproject.briar.desktop.threading.UiExecutor
...@@ -104,7 +104,7 @@ internal class DesktopModule( ...@@ -104,7 +104,7 @@ internal class DesktopModule(
@Provides @Provides
@Singleton @Singleton
fun provideSettings(settings: SettingsImpl): Settings = settings fun provideUnencryptedSettings(settings: UnencryptedSettingsImpl): UnencryptedSettings = settings
@Provides @Provides
@Singleton @Singleton
......
...@@ -37,7 +37,6 @@ import androidx.compose.ui.Alignment ...@@ -37,7 +37,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import org.briarproject.briar.desktop.ui.Constants.HEADER_SIZE import org.briarproject.briar.desktop.ui.Constants.HEADER_SIZE
import org.briarproject.briar.desktop.utils.InternationalizationUtils
import org.briarproject.briar.desktop.utils.InternationalizationUtils.i18n import org.briarproject.briar.desktop.utils.InternationalizationUtils.i18n
@Composable @Composable
...@@ -66,8 +65,8 @@ fun SettingDetails(viewModel: SettingsViewModel) { ...@@ -66,8 +65,8 @@ fun SettingDetails(viewModel: SettingsViewModel) {
OutlinedExposedDropDownMenu( OutlinedExposedDropDownMenu(
values = viewModel.languageList.map { values = viewModel.languageList.map {
if (it == Settings.Language.DEFAULT) i18n("settings.display.language.auto") if (it == UnencryptedSettings.Language.DEFAULT) i18n("settings.display.language.auto")
else it.locale.getDisplayLanguage(InternationalizationUtils.locale) else it.locale.getDisplayLanguage(it.locale)
}, },
selectedIndex = viewModel.selectedLanguage.value.ordinal, selectedIndex = viewModel.selectedLanguage.value.ordinal,
onChange = { viewModel.selectLanguage(viewModel.languageList[it]) }, onChange = { viewModel.selectLanguage(viewModel.languageList[it]) },
......
...@@ -35,31 +35,31 @@ enum class SettingCategory { ...@@ -35,31 +35,31 @@ enum class SettingCategory {
class SettingsViewModel class SettingsViewModel
@Inject @Inject
constructor( constructor(
private val settings: Settings, private val unencryptedSettings: UnencryptedSettings,
) : ViewModel { ) : ViewModel {
private val _selectedSetting = mutableStateOf(SettingCategory.DISPLAY) private val _selectedSetting = mutableStateOf(SettingCategory.DISPLAY)
val selectedSetting = _selectedSetting.asState() val selectedSetting = _selectedSetting.asState()
val themesList = Settings.Theme.values() val themesList = UnencryptedSettings.Theme.values()
val languageList = Settings.Language.values() val languageList = UnencryptedSettings.Language.values()
private val _selectedTheme = mutableStateOf(settings.theme) private val _selectedTheme = mutableStateOf(unencryptedSettings.theme)
val selectedTheme = _selectedTheme.asState() val selectedTheme = _selectedTheme.asState()
private val _selectedLanguage = mutableStateOf(settings.language) private val _selectedLanguage = mutableStateOf(unencryptedSettings.language)
val selectedLanguage = _selectedLanguage.asState() val selectedLanguage = _selectedLanguage.asState()
fun selectSetting(selectedOption: SettingCategory) { fun selectSetting(selectedOption: SettingCategory) {
_selectedSetting.value = selectedOption _selectedSetting.value = selectedOption
} }
fun selectTheme(theme: Settings.Theme) { fun selectTheme(theme: UnencryptedSettings.Theme) {
settings.theme = theme unencryptedSettings.theme = theme
_selectedTheme.value = theme _selectedTheme.value = theme
} }
fun selectLanguage(language: Settings.Language) { fun selectLanguage(language: UnencryptedSettings.Language) {
settings.language = language unencryptedSettings.language = language
_selectedLanguage.value = language _selectedLanguage.value = language
} }
} }
...@@ -21,7 +21,7 @@ package org.briarproject.briar.desktop.settings ...@@ -21,7 +21,7 @@ package org.briarproject.briar.desktop.settings
import org.briarproject.briar.desktop.viewmodel.SingleStateEvent import org.briarproject.briar.desktop.viewmodel.SingleStateEvent
import java.util.Locale import java.util.Locale
interface Settings { interface UnencryptedSettings {
enum class Theme { AUTO, LIGHT, DARK } enum class Theme { AUTO, LIGHT, DARK }
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
package org.briarproject.briar.desktop.settings package org.briarproject.briar.desktop.settings
import org.briarproject.briar.desktop.settings.Settings.Language import org.briarproject.briar.desktop.settings.UnencryptedSettings.Language
import org.briarproject.briar.desktop.settings.Settings.Language.DEFAULT import org.briarproject.briar.desktop.settings.UnencryptedSettings.Language.DEFAULT
import org.briarproject.briar.desktop.settings.Settings.Theme import org.briarproject.briar.desktop.settings.UnencryptedSettings.Theme
import org.briarproject.briar.desktop.settings.Settings.Theme.AUTO import org.briarproject.briar.desktop.settings.UnencryptedSettings.Theme.AUTO
import org.briarproject.briar.desktop.utils.InternationalizationUtils import org.briarproject.briar.desktop.utils.InternationalizationUtils
import org.briarproject.briar.desktop.viewmodel.SingleStateEvent import org.briarproject.briar.desktop.viewmodel.SingleStateEvent
import java.util.prefs.Preferences import java.util.prefs.Preferences
...@@ -30,7 +30,7 @@ import javax.inject.Inject ...@@ -30,7 +30,7 @@ import javax.inject.Inject
const val PREF_THEME = "theme" const val PREF_THEME = "theme"
const val PREF_LANG = "language" const val PREF_LANG = "language"
class SettingsImpl @Inject internal constructor() : Settings { class UnencryptedSettingsImpl @Inject internal constructor() : UnencryptedSettings {
// used for unencrypted settings, namely theme and language // used for unencrypted settings, namely theme and language
private val prefs = Preferences.userNodeForPackage(this::class.java) private val prefs = Preferences.userNodeForPackage(this::class.java)
......
...@@ -46,10 +46,10 @@ import org.briarproject.briar.desktop.DesktopFeatureFlags ...@@ -46,10 +46,10 @@ import org.briarproject.briar.desktop.DesktopFeatureFlags
import org.briarproject.briar.desktop.expiration.ExpirationBanner import org.briarproject.briar.desktop.expiration.ExpirationBanner
import org.briarproject.briar.desktop.login.ErrorScreen import org.briarproject.briar.desktop.login.ErrorScreen
import org.briarproject.briar.desktop.login.StartupScreen import org.briarproject.briar.desktop.login.StartupScreen
import org.briarproject.briar.desktop.settings.Settings
import org.briarproject.briar.desktop.settings.Settings.Theme.AUTO
import org.briarproject.briar.desktop.settings.Settings.Theme.DARK
import org.briarproject.briar.desktop.settings.SettingsViewModel import org.briarproject.briar.desktop.settings.SettingsViewModel
import org.briarproject.briar.desktop.settings.UnencryptedSettings
import org.briarproject.briar.desktop.settings.UnencryptedSettings.Theme.AUTO
import org.briarproject.briar.desktop.settings.UnencryptedSettings.Theme.DARK
import org.briarproject.briar.desktop.theme.BriarTheme import org.briarproject.briar.desktop.theme.BriarTheme
import org.briarproject.briar.desktop.ui.Screen.EXPIRED import org.briarproject.briar.desktop.ui.Screen.EXPIRED
import org.briarproject.briar.desktop.ui.Screen.MAIN import org.briarproject.briar.desktop.ui.Screen.MAIN
...@@ -89,7 +89,7 @@ constructor( ...@@ -89,7 +89,7 @@ constructor(
private val lifecycleManager: LifecycleManager, private val lifecycleManager: LifecycleManager,
private val eventBus: EventBus, private val eventBus: EventBus,
private val viewModelProvider: ViewModelProvider, private val viewModelProvider: ViewModelProvider,
private val settings: Settings, private val unencryptedSettings: UnencryptedSettings,
private val featureFlags: FeatureFlags, private val featureFlags: FeatureFlags,
private val desktopFeatureFlags: DesktopFeatureFlags, private val desktopFeatureFlags: DesktopFeatureFlags,
) : BriarUi, EventListener { ) : BriarUi, EventListener {
...@@ -137,15 +137,15 @@ constructor( ...@@ -137,15 +137,15 @@ constructor(
LocalLocalization provides platformLocalization, LocalLocalization provides platformLocalization,
) { ) {
// invalidate whole application window in case the theme or language setting is changed // invalidate whole application window in case the theme or language setting is changed
settings.invalidateScreen.react { unencryptedSettings.invalidateScreen.react {
window.title = i18n("main.title") window.title = i18n("main.title")
return@CompositionLocalProvider return@CompositionLocalProvider
} }
var showAbout by remember { mutableStateOf(false) } var showAbout by remember { mutableStateOf(false) }
val settingsViewModel: SettingsViewModel = viewModel() val settingsViewModel: SettingsViewModel = viewModel()
val isDarkTheme = settings.theme == DARK || val isDarkTheme = unencryptedSettings.theme == DARK ||
(settings.theme == AUTO && isSystemInDarkTheme()) (unencryptedSettings.theme == AUTO && isSystemInDarkTheme())
BriarTheme(isDarkTheme) { BriarTheme(isDarkTheme) {
Column(Modifier.fillMaxSize()) { Column(Modifier.fillMaxSize()) {
ExpirationBanner { screenState = EXPIRED; stop() } ExpirationBanner { screenState = EXPIRED; stop() }
......
...@@ -52,8 +52,8 @@ import org.briarproject.briar.api.test.TestAvatarCreator ...@@ -52,8 +52,8 @@ import org.briarproject.briar.api.test.TestAvatarCreator
import org.briarproject.briar.attachment.AttachmentModule import org.briarproject.briar.attachment.AttachmentModule
import org.briarproject.briar.desktop.attachment.media.ImageCompressor import org.briarproject.briar.desktop.attachment.media.ImageCompressor
import org.briarproject.briar.desktop.attachment.media.ImageCompressorImpl import org.briarproject.briar.desktop.attachment.media.ImageCompressorImpl
import org.briarproject.briar.desktop.settings.Settings import org.briarproject.briar.desktop.settings.UnencryptedSettings
import org.briarproject.briar.desktop.settings.SettingsImpl import org.briarproject.briar.desktop.settings.UnencryptedSettingsImpl
import org.briarproject.briar.desktop.testdata.DeterministicTestDataCreator import org.briarproject.briar.desktop.testdata.DeterministicTestDataCreator
import org.briarproject.briar.desktop.testdata.DeterministicTestDataCreatorImpl import org.briarproject.briar.desktop.testdata.DeterministicTestDataCreatorImpl
import org.briarproject.briar.desktop.testdata.TestAvatarCreatorImpl import org.briarproject.briar.desktop.testdata.TestAvatarCreatorImpl
...@@ -109,7 +109,7 @@ internal class DesktopTestModule( ...@@ -109,7 +109,7 @@ internal class DesktopTestModule(
@Provides @Provides
@Singleton @Singleton
fun provideSettings(settings: SettingsImpl): Settings = settings fun provideUnencryptedSettings(settings: UnencryptedSettingsImpl): UnencryptedSettings = settings
@Provides @Provides
@Singleton @Singleton
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment