fix(updater): auto-resume installation after unknown sources permission is granted
This commit is contained in:
parent
ba0fd498c3
commit
93112a0c9a
2 changed files with 18 additions and 0 deletions
|
|
@ -158,6 +158,7 @@ class UpdateViewModel @Inject constructor(
|
|||
return
|
||||
}
|
||||
|
||||
_uiState.update { it.copy(showUnknownSourcesDialog = false) }
|
||||
ApkInstaller.launchInstall(context, apkFile)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ import com.nuvio.tv.ui.theme.NuvioColors
|
|||
import com.nuvio.tv.updater.UpdateUiState
|
||||
import kotlinx.coroutines.delay
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import com.nuvio.tv.R
|
||||
|
||||
@OptIn(ExperimentalTvMaterial3Api::class)
|
||||
|
|
@ -114,6 +118,19 @@ fun UpdatePromptDialog(
|
|||
}
|
||||
}
|
||||
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
DisposableEffect(lifecycleOwner, state.showUnknownSourcesDialog) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_RESUME) {
|
||||
if (state.showUnknownSourcesDialog) {
|
||||
onInstall()
|
||||
}
|
||||
}
|
||||
}
|
||||
lifecycleOwner.lifecycle.addObserver(observer)
|
||||
onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
|
||||
}
|
||||
|
||||
Dialog(
|
||||
onDismissRequest = onDismiss,
|
||||
properties = androidx.compose.ui.window.DialogProperties(usePlatformDefaultWidth = false)
|
||||
|
|
|
|||
Loading…
Reference in a new issue