[PR #1464] [MERGED] Android Sleep Timer cleanup part 2 #1591

Closed
opened 2026-04-24 23:59:31 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf-app/pull/1464
Author: @nichwall
Created: 2/2/2025
Status: Merged
Merged: 2/2/2025
Merged by: @advplyr

Base: masterHead: sleep_timer_cleanup_2


📝 Commits (3)

  • e7e0369 Fix: shake to reset only during grace period or while playing
  • 5fd21c8 Change: sleep timer EoC cutoff to be 10 seconds
  • e4e7679 Fix: sleep timer gets stuck at 1 second

📊 Changes

1 file changed (+20 additions, -6 deletions)

View changed files

📝 android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt (+20 -6)

📄 Description

Brief summary

This PR continues to clean up the Android sleep timer, and fixes an issue introduced by my first PR for cleaning up the sleep timer (https://github.com/advplyr/audiobookshelf-app/pull/1453).

Which issue is fixed?

Fixes https://github.com/advplyr/audiobookshelf-app/issues/1463 (first commit)
Partially fixes https://github.com/advplyr/audiobookshelf-app/issues/1097 (second commit)
Fixes https://github.com/advplyr/audiobookshelf-app/issues/1047 (third commit)

In-depth Description

The first commit adds a check of whether audio is playing or if we are in the 2 minute grace period before resetting the sleep timer due to a shake. This prevents pausing and then setting the phone down from restarting playback.

The second commit changes the threshold to go to the end of the next chapter to be 10 seconds away from the end of the current chapter to help account for auto-rewind preventing the sleep timer from getting stuck selecting the same chapter. I am not sure if the threshold should be higher than this, because I could see the benefit of having it set to the maximum rewind time, but that may be too long when getting to the end of a chapter.

The third commit adds a check to whether sleepTimeLength is the minimum value of 1 second to clear the timer. This occurs when the user tries to decrease the remaining time below 0 seconds remaining.

How have you tested this?

Built and tested on Android 15, Pixel 6a.

Tested by:

  • Setting auto sleep timer and manual sleep timers. Shaking with media paused, not started, and playing.
  • Manually reducing time past zero, pressing play (resumes correctly) or shaking (does nothing correctly).
  • Used end of chapter sleep timer, waited for it to finish, then shook to continue on to next chapter (Without using the auto-sleep timer rewind, just the normal auto rewind)

Screenshots

N/A


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf-app/pull/1464 **Author:** [@nichwall](https://github.com/nichwall) **Created:** 2/2/2025 **Status:** ✅ Merged **Merged:** 2/2/2025 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `sleep_timer_cleanup_2` --- ### 📝 Commits (3) - [`e7e0369`](https://github.com/advplyr/audiobookshelf-app/commit/e7e03697d6e05f43e9766c2320a23535802ab60e) Fix: shake to reset only during grace period or while playing - [`5fd21c8`](https://github.com/advplyr/audiobookshelf-app/commit/5fd21c83937faecc6ac3ecede262ab8ef4fa973d) Change: sleep timer EoC cutoff to be 10 seconds - [`e4e7679`](https://github.com/advplyr/audiobookshelf-app/commit/e4e76794146c2b92b5d7c260ac84cd8595eec262) Fix: sleep timer gets stuck at 1 second ### 📊 Changes **1 file changed** (+20 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt` (+20 -6) </details> ### 📄 Description <!-- For Work In Progress Pull Requests, please use the Draft PR feature, see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details. If you do not follow this template, the PR may be closed without review. Please ensure all checks pass. If you are a new contributor, the workflows will need to be manually approved before they run. --> ## Brief summary This PR continues to clean up the Android sleep timer, and fixes an issue introduced by my first PR for cleaning up the sleep timer (https://github.com/advplyr/audiobookshelf-app/pull/1453). ## Which issue is fixed? Fixes https://github.com/advplyr/audiobookshelf-app/issues/1463 (first commit) Partially fixes https://github.com/advplyr/audiobookshelf-app/issues/1097 (second commit) Fixes https://github.com/advplyr/audiobookshelf-app/issues/1047 (third commit) ## In-depth Description The first commit adds a check of whether audio is playing or if we are in the 2 minute grace period before resetting the sleep timer due to a shake. This prevents pausing and then setting the phone down from restarting playback. The second commit changes the threshold to go to the end of the *next* chapter to be 10 seconds away from the end of the current chapter to help account for auto-rewind preventing the sleep timer from getting stuck selecting the same chapter. I am not sure if the threshold should be higher than this, because I could see the benefit of having it set to the maximum rewind time, but that may be too long when getting to the end of a chapter. The third commit adds a check to whether `sleepTimeLength` is the minimum value of 1 second to clear the timer. This occurs when the user tries to decrease the remaining time below 0 seconds remaining. ## How have you tested this? Built and tested on Android 15, Pixel 6a. Tested by: - Setting auto sleep timer and manual sleep timers. Shaking with media paused, not started, and playing. - Manually reducing time past zero, pressing play (resumes correctly) or shaking (does nothing correctly). - Used end of chapter sleep timer, waited for it to finish, then shook to continue on to next chapter (Without using the auto-sleep timer rewind, just the normal auto rewind) ## Screenshots N/A --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-24 23:59:31 +02:00
adam closed this issue 2026-04-24 23:59:31 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf-app#1591