feat: add shake detection functionality (#36)

* feat: add shake detection functionality and integrate vibration support

* feat: add shake detector settings page
This commit is contained in:
Dr.Blank 2024-09-28 01:27:56 -04:00 committed by GitHub
parent 2e3b1de529
commit b229c4f2f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 1423 additions and 158 deletions

View file

@ -24,6 +24,10 @@ _$AppSettingsImpl _$$AppSettingsImplFromJson(Map<String, dynamic> json) =>
? const NotificationSettings()
: NotificationSettings.fromJson(
json['notificationSettings'] as Map<String, dynamic>),
shakeDetectionSettings: json['shakeDetectionSettings'] == null
? const ShakeDetectionSettings()
: ShakeDetectionSettings.fromJson(
json['shakeDetectionSettings'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$AppSettingsImplToJson(_$AppSettingsImpl instance) =>
@ -32,6 +36,7 @@ Map<String, dynamic> _$$AppSettingsImplToJson(_$AppSettingsImpl instance) =>
'playerSettings': instance.playerSettings,
'downloadSettings': instance.downloadSettings,
'notificationSettings': instance.notificationSettings,
'shakeDetectionSettings': instance.shakeDetectionSettings,
};
_$ThemeSettingsImpl _$$ThemeSettingsImplFromJson(Map<String, dynamic> json) =>
@ -274,3 +279,63 @@ const _$NotificationMediaControlEnumMap = {
NotificationMediaControl.skipToNextChapter: 'skipToNextChapter',
NotificationMediaControl.skipToPreviousChapter: 'skipToPreviousChapter',
};
_$ShakeDetectionSettingsImpl _$$ShakeDetectionSettingsImplFromJson(
Map<String, dynamic> json) =>
_$ShakeDetectionSettingsImpl(
isEnabled: json['isEnabled'] as bool? ?? true,
direction:
$enumDecodeNullable(_$ShakeDirectionEnumMap, json['direction']) ??
ShakeDirection.horizontal,
threshold: (json['threshold'] as num?)?.toDouble() ?? 5,
shakeAction:
$enumDecodeNullable(_$ShakeActionEnumMap, json['shakeAction']) ??
ShakeAction.resetSleepTimer,
feedback: (json['feedback'] as List<dynamic>?)
?.map((e) => $enumDecode(_$ShakeDetectedFeedbackEnumMap, e))
.toSet() ??
const {ShakeDetectedFeedback.vibrate, ShakeDetectedFeedback.beep},
beepVolume: (json['beepVolume'] as num?)?.toDouble() ?? 0.5,
shakeTriggerCoolDown: json['shakeTriggerCoolDown'] == null
? const Duration(seconds: 5)
: Duration(
microseconds: (json['shakeTriggerCoolDown'] as num).toInt()),
shakeTriggerCount: (json['shakeTriggerCount'] as num?)?.toInt() ?? 2,
samplingPeriod: json['samplingPeriod'] == null
? const Duration(milliseconds: 100)
: Duration(microseconds: (json['samplingPeriod'] as num).toInt()),
);
Map<String, dynamic> _$$ShakeDetectionSettingsImplToJson(
_$ShakeDetectionSettingsImpl instance) =>
<String, dynamic>{
'isEnabled': instance.isEnabled,
'direction': _$ShakeDirectionEnumMap[instance.direction]!,
'threshold': instance.threshold,
'shakeAction': _$ShakeActionEnumMap[instance.shakeAction]!,
'feedback': instance.feedback
.map((e) => _$ShakeDetectedFeedbackEnumMap[e]!)
.toList(),
'beepVolume': instance.beepVolume,
'shakeTriggerCoolDown': instance.shakeTriggerCoolDown.inMicroseconds,
'shakeTriggerCount': instance.shakeTriggerCount,
'samplingPeriod': instance.samplingPeriod.inMicroseconds,
};
const _$ShakeDirectionEnumMap = {
ShakeDirection.horizontal: 'horizontal',
ShakeDirection.vertical: 'vertical',
};
const _$ShakeActionEnumMap = {
ShakeAction.none: 'none',
ShakeAction.playPause: 'playPause',
ShakeAction.resetSleepTimer: 'resetSleepTimer',
ShakeAction.fastForward: 'fastForward',
ShakeAction.rewind: 'rewind',
};
const _$ShakeDetectedFeedbackEnumMap = {
ShakeDetectedFeedback.vibrate: 'vibrate',
ShakeDetectedFeedback.beep: 'beep',
};