Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android sleep timer cleanup #1453

Merged
merged 7 commits into from
Jan 26, 2025

Conversation

nichwall
Copy link
Contributor

@nichwall nichwall commented Jan 25, 2025

Brief summary

This PR scales the sleep timer display by the playback speed when using the End of Chapter timer on Android.

Which issue is fixed?

Fixes #1399 (first 3 commits)
Fixes #1268 and fixes #1200 (4th commit)

In-depth Description

This PR updates the SleepTimerManager.kt in 3 commits. The first commit is just applying the autoformatting and adding function comments so it is easier to see what is going on.

The second commit simplifies the Increase and Decrease time functions by using built in functions to select max/min of values.

The third commit (which actually fixes the issue) adds scaling to time remaining functions when the "end time" for the chapter is used instead of "time remaining" for the fixed length.

The fourth commit cleans up general function calls to reduce code duplication and simplify the logic.

How have you tested this?

Built and tested on Android 15, Pixel 6a.

  1. Set playback speed
  2. Enable sleep timer for fixed length
  3. Change playback speed while fixed length timer is running, verify that time does not change
  4. Disable sleep timer
  5. Enable sleep timer for End of Chapter, verify time remaining is scaled by playback speed
  6. Change playback speed, verify time remaining updated to match

This was repeated for various playback speeds, fixed lengths, and different chapters.

Screenshots

image
image

@nichwall
Copy link
Contributor Author

This new commit does more general cleanup of the sleep timer for Android. It also addresses #1268 (sleep timer not disabling outside of active hours) and #1200 (only disable auto-sleep timer for the rest of the day).

@nichwall nichwall changed the title Android "End of Chapter" sleep timer scaling Android sleep timer cleanup Jan 26, 2025
@advplyr
Copy link
Owner

advplyr commented Jan 26, 2025

I tested this pretty thoroughly and it's working well. I removed the separate string for disabling auto sleep timer on ios because auto sleep timer isn't supported yet there and can be implemented the same way when it is.
The code cleanup is much appreciated, thanks!

@advplyr advplyr merged commit 3060d18 into advplyr:master Jan 26, 2025
2 checks passed
@nichwall
Copy link
Contributor Author

Ah, thanks. I wasn't sure about the iOS functionality, so good to know that it's Android only for the auto sleep timer.

@nichwall nichwall deleted the android_sleep_timer_cleanup branch January 26, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants