Get old battery optimizations already in composable("settings")

This commit is contained in:
Juha Heinanen
2025-06-15 17:23:42 +03:00
parent c5819fc471
commit 4e4eb0e4b1

View File

@ -99,6 +99,9 @@ fun NavGraphBuilder.settingsScreenRoute(
composable("settings") {
val ctx = LocalContext.current
val powerManager = ctx.getSystemService(POWER_SERVICE) as PowerManager
oldBatteryOptimizations = powerManager.isIgnoringBatteryOptimizations(ctx.packageName) == false
oldDarkTheme = Preferences(ctx).displayTheme == AppCompatDelegate.MODE_NIGHT_YES
if (VERSION.SDK_INT >= 29) {
@ -908,8 +911,6 @@ private fun BatteryOptimizations() {
},
color = LocalCustomColors.current.itemText,
fontSize = 18.sp)
val powerManager = ctx.getSystemService(POWER_SERVICE) as PowerManager
oldBatteryOptimizations = powerManager.isIgnoringBatteryOptimizations(ctx.packageName) == false
var battery by remember { mutableStateOf(oldBatteryOptimizations) }
newBatteryOptimizations = battery
Switch(