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.
Set playback speed
Enable sleep timer for fixed length
Change playback speed while fixed length timer is running, verify that time does not change
Disable sleep timer
Enable sleep timer for End of Chapter, verify time remaining is scaled by playback speed
Change playback speed, verify time remaining updated to match
This was repeated for various playback speeds, fixed lengths, and different chapters.
Screenshots
🔄 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/1453
**Author:** [@nichwall](https://github.com/nichwall)
**Created:** 1/25/2025
**Status:** ✅ Merged
**Merged:** 1/26/2025
**Merged by:** [@advplyr](https://github.com/advplyr)
**Base:** `master` ← **Head:** `android_sleep_timer_cleanup`
---
### 📝 Commits (7)
- [`d81e472`](https://github.com/advplyr/audiobookshelf-app/commit/d81e47204cbf0b08da91562e84603432000fdfbb) Auto formatted code and added function comments
- [`16472e1`](https://github.com/advplyr/audiobookshelf-app/commit/16472e1de885142e5a1a8aab845db77d18f619d5) Simplify increase/decrease sleep timer
- [`161614f`](https://github.com/advplyr/audiobookshelf-app/commit/161614f6c99e26ea7138d196dcc80274b1113bf6) Fix: scale end of chapter time by playback speed
- [`13b0207`](https://github.com/advplyr/audiobookshelf-app/commit/13b020732f71af6e9198d1fe91455a5c155d1cee) General cleanup, only disable auto-sleep temporarily
- [`4b4a2b4`](https://github.com/advplyr/audiobookshelf-app/commit/4b4a2b46c18d3ce40ea75703ad14a87852d69971) Merge branch 'master' into android_sleep_timer_cleanup
- [`b6ab7dc`](https://github.com/advplyr/audiobookshelf-app/commit/b6ab7dc8a72e44dd9d6537e87cb365c102065c8c) Update sleep timer modal to not show negative time remaining
- [`0509d71`](https://github.com/advplyr/audiobookshelf-app/commit/0509d7105e6b006d4f1402696a36b3a1376eda0f) Update confirm disable auto timer message
### 📊 Changes
**3 files changed** (+278 additions, -175 deletions)
<details>
<summary>View changed files</summary>
📝 `android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt` (+272 -174)
📝 `components/modals/SleepTimerModal.vue` (+5 -1)
📝 `strings/en-us.json` (+1 -0)
</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 scales the sleep timer display by the playback speed when using the End of Chapter timer on Android.
## Which issue is fixed?
Fixes https://github.com/advplyr/audiobookshelf-app/issues/1399 (first 3 commits)
Fixes https://github.com/advplyr/audiobookshelf-app/issues/1268 and fixes https://github.com/advplyr/audiobookshelf-app/issues/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


---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/advplyr/audiobookshelf-app/pull/1453
Author: @nichwall
Created: 1/25/2025
Status: ✅ Merged
Merged: 1/26/2025
Merged by: @advplyr
Base:
master← Head:android_sleep_timer_cleanup📝 Commits (7)
d81e472Auto formatted code and added function comments16472e1Simplify increase/decrease sleep timer161614fFix: scale end of chapter time by playback speed13b0207General cleanup, only disable auto-sleep temporarily4b4a2b4Merge branch 'master' into android_sleep_timer_cleanupb6ab7dcUpdate sleep timer modal to not show negative time remaining0509d71Update confirm disable auto timer message📊 Changes
3 files changed (+278 additions, -175 deletions)
View changed files
📝
android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt(+272 -174)📝
components/modals/SleepTimerModal.vue(+5 -1)📝
strings/en-us.json(+1 -0)📄 Description
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 https://github.com/advplyr/audiobookshelf-app/issues/1399 (first 3 commits)
Fixes https://github.com/advplyr/audiobookshelf-app/issues/1268 and fixes https://github.com/advplyr/audiobookshelf-app/issues/1200 (4th commit)
In-depth Description
This PR updates the
SleepTimerManager.ktin 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.
This was repeated for various playback speeds, fixed lengths, and different chapters.
Screenshots
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.