mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-29 22:29:29 +02:00
Add:Android sleep timer setting to disable vibrate on reset #552
This commit is contained in:
parent
39909a398e
commit
2f243787ce
3 changed files with 30 additions and 9 deletions
|
@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -65,6 +65,13 @@
|
|||
<p class="pl-4">Disable audio fade out</p>
|
||||
<span class="material-icons-outlined ml-2" @click.stop="showInfo('disableSleepTimerFadeOut')">info</span>
|
||||
</div>
|
||||
<div class="flex items-center py-3" @click="toggleDisableSleepTimerResetFeedback">
|
||||
<div class="w-10 flex justify-center">
|
||||
<ui-toggle-switch v-model="settings.disableSleepTimerResetFeedback" @input="saveSettings" />
|
||||
</div>
|
||||
<p class="pl-4">Disable vibrate on reset</p>
|
||||
<span class="material-icons-outlined ml-2" @click.stop="showInfo('disableSleepTimerResetFeedback')">info</span>
|
||||
</div>
|
||||
<div class="flex items-center py-3" @click="toggleAutoSleepTimer">
|
||||
<div class="w-10 flex justify-center">
|
||||
<ui-toggle-switch v-model="settings.autoSleepTimer" @input="saveSettings" />
|
||||
|
@ -117,7 +124,8 @@ export default {
|
|||
autoSleepTimerStartTime: '22:00',
|
||||
autoSleepTimerEndTime: '06:00',
|
||||
sleepTimerLength: 900000, // 15 minutes
|
||||
disableSleepTimerFadeOut: false
|
||||
disableSleepTimerFadeOut: false,
|
||||
disableSleepTimerResetFeedback: false
|
||||
},
|
||||
lockCurrentOrientation: false,
|
||||
settingInfo: {
|
||||
|
@ -132,6 +140,10 @@ export default {
|
|||
disableSleepTimerFadeOut: {
|
||||
name: 'Disable audio fade out',
|
||||
message: 'Audio volume will start decreasing when there is less than 1 minute remaining on the sleep timer. Enable this setting to not fade out.'
|
||||
},
|
||||
disableSleepTimerResetFeedback: {
|
||||
name: 'Disable vibrate on reset',
|
||||
message: 'When the sleep timer gets reset your device will vibrate. Enable this setting to not vibrate when the sleep timer resets.'
|
||||
}
|
||||
},
|
||||
hapticFeedbackItems: [
|
||||
|
@ -283,6 +295,10 @@ export default {
|
|||
this.settings.disableShakeToResetSleepTimer = !this.settings.disableShakeToResetSleepTimer
|
||||
this.saveSettings()
|
||||
},
|
||||
toggleDisableSleepTimerResetFeedback() {
|
||||
this.settings.disableSleepTimerResetFeedback = !this.settings.disableSleepTimerResetFeedback
|
||||
this.saveSettings()
|
||||
},
|
||||
toggleDisableAutoRewind() {
|
||||
this.settings.disableAutoRewind = !this.settings.disableAutoRewind
|
||||
this.saveSettings()
|
||||
|
@ -347,6 +363,7 @@ export default {
|
|||
this.settings.autoSleepTimerEndTime = deviceSettings.autoSleepTimerEndTime || '06:00'
|
||||
this.settings.sleepTimerLength = !isNaN(deviceSettings.sleepTimerLength) ? deviceSettings.sleepTimerLength : 900000 // 15 minutes
|
||||
this.settings.disableSleepTimerFadeOut = !!deviceSettings.disableSleepTimerFadeOut
|
||||
this.settings.disableSleepTimerResetFeedback = !!deviceSettings.disableSleepTimerResetFeedback
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue