Compare commits

..

1 commit

Author SHA1 Message Date
8591f035a4
feat: keep screen on for download wizard 2025-03-16 12:00:01 +08:00
2 changed files with 11 additions and 9 deletions

View file

@ -316,15 +316,11 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() {
} }
open fun beforeNext() {} open fun beforeNext() {}
}
override fun onStart() { protected fun setKeepScreenOn(enabled: Boolean) {
super.onStart() val flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) val window = (requireActivity() as DownloadWizardActivity).window
if (enabled) window.addFlags(flags) else window.clearFlags(flags)
} }
override fun onStop() {
super.onStop()
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} }
} }

View file

@ -96,6 +96,7 @@ class DownloadWizardProgressFragment : DownloadWizardActivity.DownloadWizardStep
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
setKeepScreenOn(true)
lifecycleScope.launch { lifecycleScope.launch {
showProgressBar(-1) // set indeterminate first showProgressBar(-1) // set indeterminate first
@ -140,6 +141,11 @@ class DownloadWizardProgressFragment : DownloadWizardActivity.DownloadWizardStep
} }
} }
override fun onStop() {
super.onStop()
setKeepScreenOn(false)
}
private suspend fun startDownloadOrSubscribe(): EuiccChannelManagerService.ForegroundTaskSubscriberFlow? = private suspend fun startDownloadOrSubscribe(): EuiccChannelManagerService.ForegroundTaskSubscriberFlow? =
if (state.downloadStarted) { if (state.downloadStarted) {
// This will also return null if task ID is -1 (uninitialized), too // This will also return null if task ID is -1 (uninitialized), too