Add:Haptic feedback device setting off/light/medium/heavy #472

This commit is contained in:
advplyr 2023-01-08 15:32:15 -06:00
parent 89041c4141
commit d59f3ae0b6
25 changed files with 133 additions and 73 deletions

View file

@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.
let configuration = Realm.Configuration(
schemaVersion: 5,
schemaVersion: 6,
migrationBlock: { [weak self] migration, oldSchemaVersion in
if (oldSchemaVersion < 1) {
self?.logger.log("Realm schema version was \(oldSchemaVersion)")
@ -36,6 +36,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
newObject?["lockOrientation"] = "NONE"
}
}
if (oldSchemaVersion < 6) {
self?.logger.log("Realm schema version was \(oldSchemaVersion)... Adding hapticFeedback setting")
migration.enumerateObjects(ofType: DeviceSettings.className()) { oldObject, newObject in
newObject?["hapticFeedback"] = "LIGHT"
}
}
}
)
Realm.Configuration.defaultConfiguration = configuration

View file

@ -237,12 +237,14 @@ public class AbsDatabase: CAPPlugin {
let jumpBackwardsTime = call.getInt("jumpBackwardsTime") ?? 10
let jumpForwardTime = call.getInt("jumpForwardTime") ?? 10
let lockOrientation = call.getString("lockOrientation") ?? "NONE"
let hapticFeedback = call.getString("hapticFeedback") ?? "LIGHT"
let settings = DeviceSettings()
settings.disableAutoRewind = disableAutoRewind
settings.enableAltView = enableAltView
settings.jumpBackwardsTime = jumpBackwardsTime
settings.jumpForwardTime = jumpForwardTime
settings.lockOrientation = lockOrientation
settings.hapticFeedback = hapticFeedback
Database.shared.setDeviceSettings(deviceSettings: settings)

View file

@ -14,6 +14,7 @@ class DeviceSettings: Object {
@Persisted var jumpBackwardsTime: Int = 10
@Persisted var jumpForwardTime: Int = 10
@Persisted var lockOrientation: String = "NONE"
@Persisted var hapticFeedback: String = "LIGHT"
}
func getDefaultDeviceSettings() -> DeviceSettings {
@ -26,6 +27,7 @@ func deviceSettingsToJSON(settings: DeviceSettings) -> Dictionary<String, Any> {
"enableAltView": settings.enableAltView,
"jumpBackwardsTime": settings.jumpBackwardsTime,
"jumpForwardTime": settings.jumpForwardTime,
"lockOrientation": settings.lockOrientation
"lockOrientation": settings.lockOrientation,
"hapticFeedback": settings.hapticFeedback
]
}