Include also Dark Theme setting in backup file

This commit is contained in:
Juha Heinanen
2023-10-09 12:09:55 +03:00
parent dc3c98e818
commit 6c06661ae6
3 changed files with 18 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package com.tutpro.baresip
import android.Manifest
import android.content.Context
import androidx.appcompat.app.AppCompatDelegate
import java.io.File
import java.net.InetAddress
import java.nio.charset.StandardCharsets
@ -79,6 +80,14 @@ object Config {
BaresipService.dynDns = true
}
val darkTheme = previousVariable("dark_theme")
Preferences(ctx).displayTheme = if (darkTheme == "yes") {
config = "${config}dark_theme yes\n"
AppCompatDelegate.MODE_NIGHT_YES
} else {
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}
var contactsMode = previousVariable("contacts_mode").lowercase()
if (contactsMode != "") {
if (contactsMode != "baresip" &&

View File

@ -580,8 +580,12 @@ class ConfigActivity : AppCompatActivity() {
AppCompatDelegate.MODE_NIGHT_YES
else
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
if (oldDisplayTheme != newDisplayTheme)
if (oldDisplayTheme != newDisplayTheme) {
Preferences(applicationContext).displayTheme = newDisplayTheme
Config.replaceVariable("dark_theme",
if (darkTheme.isChecked) "yes" else "no")
save = true
}
if (oldContactsMode != contactsMode) {
Config.replaceVariable("contacts_mode", contactsMode)

View File

@ -720,11 +720,6 @@ class MainActivity : AppCompatActivity() {
}
}
if (Preferences(applicationContext).displayTheme != AppCompatDelegate.getDefaultNightMode()) {
AppCompatDelegate.setDefaultNightMode(Preferences(applicationContext).displayTheme)
delegate.applyDayNight()
}
} // OnCreate
override fun onStart() {
@ -1028,6 +1023,10 @@ class MainActivity : AppCompatActivity() {
aorSpinner.tag = BaresipService.uas[0].account.aor
}
}
if (Preferences(applicationContext).displayTheme != AppCompatDelegate.getDefaultNightMode()) {
AppCompatDelegate.setDefaultNightMode(Preferences(applicationContext).displayTheme)
delegate.applyDayNight()
}
handleNextEvent()
return
}