From cb39e5482d6fe22cdc893dbc1e778fa57014ad4e Mon Sep 17 00:00:00 2001 From: Kris <40046803-KrisKS@users.noreply.gitlab.com> Date: Mon, 17 Aug 2026 19:19:57 -0400 Subject: [PATCH] Preserve sleep when reopening LCDPet --- .../today/notfeelingit/lcdpet/MainActivity.kt | 53 ++++--------------- 1 file changed, 10 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/today/notfeelingit/lcdpet/MainActivity.kt b/app/src/main/java/today/notfeelingit/lcdpet/MainActivity.kt index 0784ea3..a9321e9 100644 --- a/app/src/main/java/today/notfeelingit/lcdpet/MainActivity.kt +++ b/app/src/main/java/today/notfeelingit/lcdpet/MainActivity.kt @@ -2577,17 +2577,14 @@ fun Greeting(name: String, modifier: Modifier = Modifier) { LaunchedEffect(saveLoaded, restoredAutoSleep) { if (saveLoaded && restoredAutoSleep && isSleeping && sleepMode == "Auto") { activityMood = "Asleep" - roughWakeDarkFlash = true + roughWakeDarkFlash = false if (framePropAnimation != "Nap") { startFrameAnimation("Nap") } - delay(if (testingMode) 1_500L else 2_000L) - - if (isSleeping && sleepMode == "Auto") { - wakeFromAutoSleep() - } + // Reopening LCDPet no longer wakes an exhausted sleeping pet. + restoredAutoSleep = false } } @@ -2601,46 +2598,16 @@ fun Greeting(name: String, modifier: Modifier = Modifier) { return@LaunchedEffect } - val wakeAtMs = autoSleepStartedAtMs - val napStillActive = - wakeAtMs <= 0L || System.currentTimeMillis() < wakeAtMs - - if (!napStillActive) { - // The original Nap finished while LCDPet was closed. - // Release the gate so the normal Nap completion effect can finish it. - restoredManualNap = false - return@LaunchedEffect - } - - // LCDPet was reopened before the manual Nap was finished. - roughWakeDarkFlash = true + // Reopening during a Nap no longer wakes the pet. + // Release the restore gate so the original fixed wake deadline continues. + roughWakeDarkFlash = false activityMood = "Asleep" - frameProp = "" - framePropAnimation = "" - framePropStyle = 0 - delay(if (testingMode) 1_500L else 1_200L) - - if ( - restoredManualNap && - isSleeping && - sleepMode == "Nap" - ) { - isSleeping = false - sleepMode = "" - autoSleepStartedAtMs = 0L - restoredManualNap = false - roughWakeDarkFlash = false - roughWakeNervousHold = false - - status = "Nervous" - activityMood = "RoughWake" - roughWakeAlert = true - frameProp = "!?!" - framePropAnimation = "" - framePropStyle = 0 - happiness = (happiness - 1).coerceAtLeast(0) + if (framePropAnimation != "Nap") { + startFrameAnimation("Nap") } + + restoredManualNap = false } LaunchedEffect(