feat: keep screen on for download progress #180
2 changed files with 13 additions and 0 deletions
|
@ -3,6 +3,7 @@ package im.angry.openeuicc.ui.wizard
|
|||
import android.app.assist.AssistContent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Button
|
||||
import android.widget.ProgressBar
|
||||
|
@ -315,5 +316,11 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() {
|
|||
}
|
||||
|
||||
open fun beforeNext() {}
|
||||
|
||||
protected fun setKeepScreenOn(enabled: Boolean) {
|
||||
val flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
val window = (requireActivity() as DownloadWizardActivity).window
|
||||
if (enabled) window.addFlags(flags) else window.clearFlags(flags)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -96,6 +96,7 @@ class DownloadWizardProgressFragment : DownloadWizardActivity.DownloadWizardStep
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
setKeepScreenOn(true)
|
||||
|
||||
lifecycleScope.launch {
|
||||
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? =
|
||||
if (state.downloadStarted) {
|
||||
// This will also return null if task ID is -1 (uninitialized), too
|
||||
|
|
Loading…
Add table
Reference in a new issue