Update displayTheme prference only if changed

This commit is contained in:
Juha Heinanen
2021-01-12 09:15:09 +02:00
parent f3a6c3c83b
commit bbbd74de6f

View File

@ -33,6 +33,7 @@ class ConfigActivity : AppCompatActivity() {
private var oldCAFile = false
private var oldLogLevel = ""
private var callVolume = BaresipService.callVolume
private var oldDisplayTheme = -1
private var save = false
private var restart = false
private var menu: Menu? = null
@ -43,6 +44,7 @@ class ConfigActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityConfigBinding.inflate(layoutInflater)
setContentView(binding.root)
@ -100,7 +102,7 @@ class ConfigActivity : AppCompatActivity() {
}
darkTheme = binding.DarkTheme
val oldDisplayTheme = Preferences(applicationContext).displayTheme
oldDisplayTheme = Preferences(applicationContext).displayTheme
darkTheme.isChecked = oldDisplayTheme == AppCompatDelegate.MODE_NIGHT_YES
debug = binding.Debug
@ -246,7 +248,8 @@ class ConfigActivity : AppCompatActivity() {
AppCompatDelegate.MODE_NIGHT_YES
else
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
Preferences(applicationContext).displayTheme = newDisplayTheme
if (oldDisplayTheme != newDisplayTheme)
Preferences(applicationContext).displayTheme = newDisplayTheme
var logLevelString = "2"
if (debug.isChecked) logLevelString = "0"
@ -259,7 +262,7 @@ class ConfigActivity : AppCompatActivity() {
BaresipService.sipTrace = sipTrace.isChecked
Api.uag_enable_sip_trace(sipTrace.isChecked)
if (reset.isChecked) {
Config.reset(this)
save = false