[PR #1453] [MERGED] Android sleep timer cleanup #1585

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

📋 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: masterHead: android_sleep_timer_cleanup


📝 Commits (7)

  • d81e472 Auto formatted code and added function comments
  • 16472e1 Simplify increase/decrease sleep timer
  • 161614f Fix: scale end of chapter time by playback speed
  • 13b0207 General cleanup, only disable auto-sleep temporarily
  • 4b4a2b4 Merge branch 'master' into android_sleep_timer_cleanup
  • b6ab7dc Update sleep timer modal to not show negative time remaining
  • 0509d71 Update 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.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


🔄 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 ![image](https://github.com/user-attachments/assets/60066cce-86a0-4583-bdef-05c40494d44a) ![image](https://github.com/user-attachments/assets/f8e15d51-b2d7-43de-bc55-695049639dc5) --- <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:29 +02:00
adam closed this issue 2026-04-24 23:59:29 +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#1585