mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-28 14:17:19 +02:00
@@ -20,7 +20,8 @@ data class DeviceSettings(
|
|||||||
var disableAutoRewind:Boolean,
|
var disableAutoRewind:Boolean,
|
||||||
var enableAltView:Boolean,
|
var enableAltView:Boolean,
|
||||||
var jumpBackwardsTime:Int,
|
var jumpBackwardsTime:Int,
|
||||||
var jumpForwardTime:Int
|
var jumpForwardTime:Int,
|
||||||
|
var disableShakeToResetSleepTimer:Boolean
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
// Static method to get default device settings
|
// Static method to get default device settings
|
||||||
@@ -29,7 +30,8 @@ data class DeviceSettings(
|
|||||||
disableAutoRewind = false,
|
disableAutoRewind = false,
|
||||||
enableAltView = false,
|
enableAltView = false,
|
||||||
jumpBackwardsTime = 10,
|
jumpBackwardsTime = 10,
|
||||||
jumpForwardTime = 10
|
jumpForwardTime = 10,
|
||||||
|
disableShakeToResetSleepTimer = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.audiobookshelf.app.player
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.*
|
import android.os.*
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import com.audiobookshelf.app.device.DeviceManager
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.concurrent.schedule
|
import kotlin.concurrent.schedule
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
@@ -203,8 +204,13 @@ class SleepTimerManager constructor(val playerNotificationService:PlayerNotifica
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handleShake() {
|
fun handleShake() {
|
||||||
Log.d(tag, "HANDLE SHAKE HERE")
|
if (sleepTimerRunning || sleepTimerFinishedAt > 0L) {
|
||||||
if (sleepTimerRunning || sleepTimerFinishedAt > 0L) checkShouldExtendSleepTimer()
|
if (DeviceManager.deviceData.deviceSettings?.disableShakeToResetSleepTimer == true) {
|
||||||
|
Log.d(tag, "Shake to reset sleep timer is disabled")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
checkShouldExtendSleepTimer()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun increaseSleepTime(time: Long) {
|
fun increaseSleepTime(time: Long) {
|
||||||
|
|||||||
+41
-4
@@ -1,16 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="w-full h-full p-8">
|
<div class="w-full h-full p-8">
|
||||||
|
<p class="uppercase text-xs font-semibold text-gray-300 mb-2">Display Settings</p>
|
||||||
<div class="flex items-center py-3" @click="toggleEnableAltView">
|
<div class="flex items-center py-3" @click="toggleEnableAltView">
|
||||||
<div class="w-10 flex justify-center">
|
<div class="w-10 flex justify-center">
|
||||||
<ui-toggle-switch v-model="settings.enableAltView" @input="saveSettings" />
|
<ui-toggle-switch v-model="settings.enableAltView" @input="saveSettings" />
|
||||||
</div>
|
</div>
|
||||||
<p class="pl-4">Alternative Bookshelf View</p>
|
<p class="pl-4">Alternative bookshelf view</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="$platform !== 'ios'" class="flex items-center py-3" @click="toggleDisableAutoRewind">
|
|
||||||
|
<p class="uppercase text-xs font-semibold text-gray-300 mb-2 mt-6">Playback Settings</p>
|
||||||
|
<div v-if="!isiOS" class="flex items-center py-3" @click="toggleDisableAutoRewind">
|
||||||
<div class="w-10 flex justify-center">
|
<div class="w-10 flex justify-center">
|
||||||
<ui-toggle-switch v-model="settings.disableAutoRewind" @input="saveSettings" />
|
<ui-toggle-switch v-model="settings.disableAutoRewind" @input="saveSettings" />
|
||||||
</div>
|
</div>
|
||||||
<p class="pl-4">Disable Auto Rewind</p>
|
<p class="pl-4">Disable auto rewind</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center py-3" @click="toggleJumpBackwards">
|
<div class="flex items-center py-3" @click="toggleJumpBackwards">
|
||||||
<div class="w-10 flex justify-center">
|
<div class="w-10 flex justify-center">
|
||||||
@@ -24,10 +27,21 @@
|
|||||||
</div>
|
</div>
|
||||||
<p class="pl-4">Jump forwards time</p>
|
<p class="pl-4">Jump forwards time</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p v-if="!isiOS" class="uppercase text-xs font-semibold text-gray-300 mb-2 mt-6">Sleep Timer Settings</p>
|
||||||
|
<div v-if="!isiOS" class="flex items-center py-3" @click="toggleDisableShakeToResetSleepTimer">
|
||||||
|
<div class="w-10 flex justify-center">
|
||||||
|
<ui-toggle-switch v-model="settings.disableShakeToResetSleepTimer" @input="saveSettings" />
|
||||||
|
</div>
|
||||||
|
<p class="pl-4">Disable shake to reset</p>
|
||||||
|
<span class="material-icons-outlined ml-2" @click.stop="showInfo('disableShakeToResetSleepTimer')">info</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { Dialog } from '@capacitor/dialog'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -36,11 +50,21 @@ export default {
|
|||||||
disableAutoRewind: false,
|
disableAutoRewind: false,
|
||||||
enableAltView: false,
|
enableAltView: false,
|
||||||
jumpForwardTime: 10,
|
jumpForwardTime: 10,
|
||||||
jumpBackwardsTime: 10
|
jumpBackwardsTime: 10,
|
||||||
|
disableShakeToResetSleepTimer: false
|
||||||
|
},
|
||||||
|
settingInfo: {
|
||||||
|
disableShakeToResetSleepTimer: {
|
||||||
|
name: 'Disable shake to reset sleep timer',
|
||||||
|
message: 'The sleep timer will start fading out when 30s is remaining. Shaking your device will reset the timer if it is within 30s OR has finished less than 2 mintues ago. Enable this setting to disable that feature.'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
isiOS() {
|
||||||
|
return this.$platform === 'ios'
|
||||||
|
},
|
||||||
jumpForwardItems() {
|
jumpForwardItems() {
|
||||||
return this.$store.state.globals.jumpForwardItems || []
|
return this.$store.state.globals.jumpForwardItems || []
|
||||||
},
|
},
|
||||||
@@ -63,6 +87,18 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
showInfo(setting) {
|
||||||
|
if (this.settingInfo[setting]) {
|
||||||
|
Dialog.alert({
|
||||||
|
title: this.settingInfo[setting].name,
|
||||||
|
message: this.settingInfo[setting].message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleDisableShakeToResetSleepTimer() {
|
||||||
|
this.settings.disableShakeToResetSleepTimer = !this.settings.disableShakeToResetSleepTimer
|
||||||
|
this.saveSettings()
|
||||||
|
},
|
||||||
toggleDisableAutoRewind() {
|
toggleDisableAutoRewind() {
|
||||||
this.settings.disableAutoRewind = !this.settings.disableAutoRewind
|
this.settings.disableAutoRewind = !this.settings.disableAutoRewind
|
||||||
this.saveSettings()
|
this.saveSettings()
|
||||||
@@ -99,6 +135,7 @@ export default {
|
|||||||
this.settings.enableAltView = !!deviceSettings.enableAltView
|
this.settings.enableAltView = !!deviceSettings.enableAltView
|
||||||
this.settings.jumpForwardTime = deviceSettings.jumpForwardTime || 10
|
this.settings.jumpForwardTime = deviceSettings.jumpForwardTime || 10
|
||||||
this.settings.jumpBackwardsTime = deviceSettings.jumpBackwardsTime || 10
|
this.settings.jumpBackwardsTime = deviceSettings.jumpBackwardsTime || 10
|
||||||
|
this.settings.disableShakeToResetSleepTimer = !!deviceSettings.disableShakeToResetSleepTimer
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|||||||
Reference in New Issue
Block a user