Include also Dark Theme setting in backup file
This commit is contained in:
@ -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" &&
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user