refactor(app): init KvPrefs in MainActivity and switch to shared SettingsStore
This commit is contained in:
@@ -112,10 +112,10 @@ import app.klottr.util.ImageBitmapCache
|
|||||||
import app.klottr.util.LastLocationStore
|
import app.klottr.util.LastLocationStore
|
||||||
import app.klottr.util.NoteDetailCache
|
import app.klottr.util.NoteDetailCache
|
||||||
import app.klottr.util.OutboxStore
|
import app.klottr.util.OutboxStore
|
||||||
import app.klottr.util.SettingsStore
|
|
||||||
import app.klottr.util.FoundStore.LAYER_DM
|
import app.klottr.util.FoundStore.LAYER_DM
|
||||||
import app.klottr.util.FoundStore.LAYER_KLOTTER
|
import app.klottr.util.FoundStore.LAYER_KLOTTER
|
||||||
import app.klottr.util.FoundStore.LAYER_WIKI
|
import app.klottr.util.FoundStore.LAYER_WIKI
|
||||||
|
import app.klottr.util.SettingsStore
|
||||||
import app.klottr.util.distanceMeters
|
import app.klottr.util.distanceMeters
|
||||||
import app.klottr.util.formatDistance
|
import app.klottr.util.formatDistance
|
||||||
import app.klottr.util.formatRelativeOrTime
|
import app.klottr.util.formatRelativeOrTime
|
||||||
@@ -161,6 +161,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
app.klottr.prefs.KvPrefs.init(applicationContext)
|
||||||
|
|
||||||
// FG + (ev) BG platstillstånd
|
// FG + (ev) BG platstillstånd
|
||||||
fgPermissionLauncher =
|
fgPermissionLauncher =
|
||||||
@@ -203,17 +204,17 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
// För att testa att :shared fungerar
|
// För att testa att :shared fungerar
|
||||||
val sharedPing = remember { SharedPing().ping() }
|
val sharedPing = remember { SharedPing().ping() }
|
||||||
|
var night by remember { mutableStateOf(SettingsStore.getNightMode()) }
|
||||||
var night by remember { mutableStateOf(SettingsStore.getNightMode(context)) }
|
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
val listener = SettingsStore.observe(context) { key ->
|
val listener = SettingsStore.observe { key ->
|
||||||
if (key == SettingsStore.KEY_NIGHT_MODE || key == null) {
|
if (key == SettingsStore.KEY_NIGHT_MODE || key == null) {
|
||||||
night = SettingsStore.getNightMode(context)
|
night = SettingsStore.getNightMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onDispose { SettingsStore.unobserve(context, listener) }
|
onDispose { SettingsStore.unobserve(listener) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ⬇️ NYTILLÄGG: logga en gång när värdet finns
|
// ⬇️ NYTILLÄGG: logga en gång när värdet finns
|
||||||
LaunchedEffect(sharedPing) {
|
LaunchedEffect(sharedPing) {
|
||||||
Log.d("Klottr", "Shared ping = $sharedPing")
|
Log.d("Klottr", "Shared ping = $sharedPing")
|
||||||
|
|||||||
Reference in New Issue
Block a user