Skip to content

Commit

Permalink
delay launch with safe mode dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
qimiko committed Feb 9, 2024
1 parent 41e3e0a commit 61c018e
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions app/src/main/java/com/geode/launcher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fun UpdateProgressIndicator(
message: String,
releaseViewModel: ReleaseViewModel,
modifier: Modifier = Modifier,
progress: Float? = null
progress: (() -> Float)? = null
) {
Column(
verticalArrangement = Arrangement.Center,
Expand All @@ -159,9 +159,7 @@ fun UpdateProgressIndicator(
if (progress == null) {
LinearProgressIndicator()
} else {
LinearProgressIndicator(
progress = { progress },
)
LinearProgressIndicator(progress = progress)
}

TextButton(
Expand Down Expand Up @@ -351,8 +349,6 @@ fun UpdateCard(releaseViewModel: ReleaseViewModel, modifier: Modifier = Modifier
)
}
is ReleaseViewModel.ReleaseUIState.InDownload -> {
val progress = state.downloaded / state.outOf.toDouble()

val downloaded = remember(state.downloaded) {
formatShortFileSize(context, state.downloaded)
}
Expand All @@ -369,7 +365,10 @@ fun UpdateCard(releaseViewModel: ReleaseViewModel, modifier: Modifier = Modifier
),
modifier = modifier,
releaseViewModel = releaseViewModel,
progress = progress.toFloat()
progress = {
val progress = state.downloaded / state.outOf.toDouble()
progress.toFloat()
}
)
}
is ReleaseViewModel.ReleaseUIState.InUpdateCheck -> {
Expand Down Expand Up @@ -450,7 +449,7 @@ fun MainScreen(
) {
val context = LocalContext.current

val shouldAutomaticallyLaunch = PreferenceUtils.useBooleanPreference(
val shouldAutomaticallyLaunch by PreferenceUtils.useBooleanPreference(
preferenceKey = PreferenceUtils.Key.LOAD_AUTOMATICALLY
)

Expand Down Expand Up @@ -493,15 +492,11 @@ fun MainScreen(
)

if (gdInstalled && geodeInstalled) {
if (shouldAutomaticallyLaunch.value && !releaseViewModel.isInUpdate && !disableAutomaticLaunch) {
val stopLaunch = releaseViewModel.isInUpdate || disableAutomaticLaunch || showSafeModeDialog
if (shouldAutomaticallyLaunch && !stopLaunch) {
val countdownTimer = useCountdownTimer(
time = 3000,
onCountdownFinish = {
// just in case this changed async
if (shouldAutomaticallyLaunch.value) {
beginLaunch = true
}
}
onCountdownFinish = { beginLaunch = true }
)

if (countdownTimer != 0L) {
Expand Down

0 comments on commit 61c018e

Please sign in to comment.