fix: 阅读界面电量显示始终为100%

电量更新依赖 ACTION_BATTERY_CHANGED 粘性广播通过 LiveEventBus 的
observeForever 传递初始值,在某些 Android 版本上不可靠。

修复:在 onRefsReady() 和 onResume() 中通过 Context.sysBattery
直接查询系统电量,确保阅读界面打开和恢复时立即显示正确电量。
This commit is contained in:
HapeLee
2026-06-11 01:36:06 +08:00
parent aa16376dae
commit 1a0599efe1
@@ -54,6 +54,7 @@ import io.legado.app.utils.longToastOnUi
import io.legado.app.utils.navigationBarGravity
import io.legado.app.utils.setLightStatusBar
import io.legado.app.utils.setOnApplyWindowInsetsListenerCompat
import io.legado.app.utils.sysBattery
import io.legado.app.utils.sysScreenOffTime
import io.legado.app.utils.throttle
import io.legado.app.utils.toastOnUi
@@ -164,6 +165,7 @@ class ReadBookController(
}
}
newRefs.readView.upTime()
newRefs.readView.upBattery(activity.sysBattery)
}
fun onRouteInitialized() {
@@ -177,6 +179,7 @@ class ReadBookController(
setOrientation()
upSystemUiVisibility()
refs?.readView?.upTime()
refs?.readView?.upBattery(activity.sysBattery)
screenOffTimerStart()
}
@@ -1060,6 +1063,7 @@ class ReadBookController(
"2" -> activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
"3" -> activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
"4" -> activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
"5" -> activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
}
}
}