diff --git a/android/app/src/main/java/com/audiobookshelf/app/data/DeviceClasses.kt b/android/app/src/main/java/com/audiobookshelf/app/data/DeviceClasses.kt index ca23cf45..b858fb0e 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/data/DeviceClasses.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/data/DeviceClasses.kt @@ -103,7 +103,8 @@ data class DeviceSettings( var autoSleepTimerStartTime: String, var autoSleepTimerEndTime: String, var sleepTimerLength: Long, // Time in milliseconds - var disableSleepTimerFadeOut: Boolean + var disableSleepTimerFadeOut: Boolean, + var disableSleepTimerResetFeedback: Boolean ) { companion object { // Static method to get default device settings @@ -121,7 +122,8 @@ data class DeviceSettings( autoSleepTimerStartTime = "22:00", autoSleepTimerEndTime = "06:00", sleepTimerLength = 900000L, // 15 minutes - disableSleepTimerFadeOut = false + disableSleepTimerFadeOut = false, + disableSleepTimerResetFeedback = false ) } } diff --git a/android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt b/android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt index a8f8bb11..67fe74e9 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt @@ -156,8 +156,10 @@ class SleepTimerManager constructor(private val playerNotificationService: Playe playerNotificationService.clientEventEmitter?.onSleepTimerSet(0, false) } - // Vibrate when extending sleep timer by shaking - private fun vibrate() { + // Vibrate when resetting sleep timer + private fun vibrateFeedback() { + if (DeviceManager.deviceData.deviceSettings?.disableSleepTimerResetFeedback == true) return + val context = playerNotificationService.getContext() val vibrator:Vibrator if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { @@ -207,7 +209,7 @@ class SleepTimerManager constructor(private val playerNotificationService: Playe private fun resetChapterTimer() { this.getChapterEndTime()?.let { chapterEndTime -> Log.d(tag, "Resetting stopped sleep timer to end of chapter $chapterEndTime") - vibrate() + vibrateFeedback() setSleepTimer(chapterEndTime, true) play() } @@ -232,7 +234,7 @@ class SleepTimerManager constructor(private val playerNotificationService: Playe resetChapterTimer() } else { Log.d(tag, "Resetting stopped sleep timer to length $sleepTimerLength") - vibrate() + vibrateFeedback() setSleepTimer(sleepTimerLength, false) play() } @@ -242,14 +244,14 @@ class SleepTimerManager constructor(private val playerNotificationService: Playe // Does not apply to chapter sleep timers and timer must be running for at least 3 seconds if (sleepTimerLength > 0L && sleepTimerElapsed > 3000L) { Log.d(tag, "Resetting running sleep timer to length $sleepTimerLength") - vibrate() + vibrateFeedback() setSleepTimer(sleepTimerLength, false) } else if (sleepTimerLength == 0L) { // When navigating to previous chapters make sure this is still the end of the current chapter this.getChapterEndTime()?.let { chapterEndTime -> if (chapterEndTime != sleepTimerEndTime) { Log.d(tag, "Resetting chapter sleep timer to end of chapter $chapterEndTime from $sleepTimerEndTime") - vibrate() + vibrateFeedback() setSleepTimer(chapterEndTime, true) play() } diff --git a/pages/settings.vue b/pages/settings.vue index d1033a60..66a8a5e3 100644 --- a/pages/settings.vue +++ b/pages/settings.vue @@ -65,6 +65,13 @@
Disable audio fade out
+Disable vibrate on reset
+ +