vibration

This commit is contained in:
unknown 2021-08-31 22:05:59 +02:00
parent 8cf642fb72
commit eaf2e2a6c4
No known key found for this signature in database
GPG Key ID: 1D070E0B09CFB257
4 changed files with 11 additions and 20 deletions

View File

@ -31,8 +31,8 @@ class UpdateProvider extends ChangeNotifier {
// Check for new releases // Check for new releases
if (_releases.length > 0) { if (_releases.length > 0) {
print("INFO: New update: ${releases.first.version}");
_available = _packageInfo != null && _releases.first.version.compareTo(Version.fromString(_packageInfo?.version ?? "")) == 1; _available = _packageInfo != null && _releases.first.version.compareTo(Version.fromString(_packageInfo?.version ?? "")) == 1;
if (_available) print("INFO: New update: ${releases.first.version}");
notifyListeners(); notifyListeners();
} }
} }

View File

@ -28,7 +28,7 @@ Future<DatabaseStruct> createSettingsTable(Database db) async {
"language": String, "start_page": int, "rounding": int, "theme": int, "accent_color": int, "news": int, "news_state": int, "developer_mode": int, "language": String, "start_page": int, "rounding": int, "theme": int, "accent_color": int, "news": int, "news_state": int, "developer_mode": int,
"update_channel": int, "config": String, // general "update_channel": int, "config": String, // general
"grade_color1": int, "grade_color2": int, "grade_color3": int, "grade_color4": int, "grade_color5": int, // grade colors "grade_color1": int, "grade_color2": int, "grade_color3": int, "grade_color4": int, "grade_color5": int, // grade colors
"vibrate": int, "vibration_strength": int, "ab_weeks": int, "swap_ab_weeks": int, "vibration_strength": int, "ab_weeks": int, "swap_ab_weeks": int,
"notifications": int, "notifications_bitfield": int, "notification_poll_interval": int, // notifications "notifications": int, "notifications_bitfield": int, "notification_poll_interval": int, // notifications
}); });

View File

@ -9,7 +9,7 @@ import 'package:provider/provider.dart';
enum Pages { home, grades, timetable, messages, absences } enum Pages { home, grades, timetable, messages, absences }
enum UpdateChannel { stable, beta, dev } enum UpdateChannel { stable, beta, dev }
enum VibrationStrength { light, medium, strong } enum VibrationStrength { off, light, medium, strong }
class SettingsProvider extends ChangeNotifier { class SettingsProvider extends ChangeNotifier {
PackageInfo? _packageInfo; PackageInfo? _packageInfo;
@ -42,8 +42,7 @@ class SettingsProvider extends ChangeNotifier {
// minutes: times 15 // minutes: times 15
int _notificationPollInterval; int _notificationPollInterval;
bool _developerMode; bool _developerMode;
bool _vibrate; VibrationStrength _vibrate;
VibrationStrength _vibrationStrength;
bool _ABweeks; bool _ABweeks;
bool _swapABweeks; bool _swapABweeks;
UpdateChannel _updateChannel; UpdateChannel _updateChannel;
@ -62,8 +61,7 @@ class SettingsProvider extends ChangeNotifier {
required int notificationsBitfield, required int notificationsBitfield,
required bool developerMode, required bool developerMode,
required int notificationPollInterval, required int notificationPollInterval,
required bool vibrate, required VibrationStrength vibrate,
required VibrationStrength vibrationStrength,
required bool ABweeks, required bool ABweeks,
required bool swapABweeks, required bool swapABweeks,
required UpdateChannel updateChannel, required UpdateChannel updateChannel,
@ -81,7 +79,6 @@ class SettingsProvider extends ChangeNotifier {
_developerMode = developerMode, _developerMode = developerMode,
_notificationPollInterval = notificationPollInterval, _notificationPollInterval = notificationPollInterval,
_vibrate = vibrate, _vibrate = vibrate,
_vibrationStrength = vibrationStrength,
_ABweeks = ABweeks, _ABweeks = ABweeks,
_swapABweeks = swapABweeks, _swapABweeks = swapABweeks,
_updateChannel = updateChannel, _updateChannel = updateChannel,
@ -111,8 +108,7 @@ class SettingsProvider extends ChangeNotifier {
notificationsBitfield: map["notifications_bitfield"], notificationsBitfield: map["notifications_bitfield"],
notificationPollInterval: map["notification_poll_interval"], notificationPollInterval: map["notification_poll_interval"],
developerMode: map["developer_mode"] == 1 ? true : false, developerMode: map["developer_mode"] == 1 ? true : false,
vibrate: map["vibrate"] == 1 ? true : false, vibrate: VibrationStrength.values[map["vibration_strength"]],
vibrationStrength: VibrationStrength.values[map["vibration_strength"]],
ABweeks: map["ab_weeks"] == 1 ? true : false, ABweeks: map["ab_weeks"] == 1 ? true : false,
swapABweeks: map["swap_ab_weeks"] == 1 ? true : false, swapABweeks: map["swap_ab_weeks"] == 1 ? true : false,
updateChannel: UpdateChannel.values[map["update_channel"]], updateChannel: UpdateChannel.values[map["update_channel"]],
@ -138,8 +134,7 @@ class SettingsProvider extends ChangeNotifier {
"grade_color4": _gradeColors[3].value, "grade_color4": _gradeColors[3].value,
"grade_color5": _gradeColors[4].value, "grade_color5": _gradeColors[4].value,
"update_channel": _updateChannel.index, "update_channel": _updateChannel.index,
"vibrate": _vibrate ? 1 : 0, "vibration_strength": _vibrate.index,
"vibration_strength": _vibrationStrength.index,
"ab_weeks": _ABweeks ? 1 : 0, "ab_weeks": _ABweeks ? 1 : 0,
"swap_ab_weeks": _swapABweeks ? 1 : 0, "swap_ab_weeks": _swapABweeks ? 1 : 0,
"notification_poll_interval": _notificationPollInterval, "notification_poll_interval": _notificationPollInterval,
@ -167,8 +162,7 @@ class SettingsProvider extends ChangeNotifier {
notificationsBitfield: 255, notificationsBitfield: 255,
developerMode: false, developerMode: false,
notificationPollInterval: 1, notificationPollInterval: 1,
vibrate: true, vibrate: VibrationStrength.medium,
vibrationStrength: VibrationStrength.medium,
ABweeks: false, ABweeks: false,
swapABweeks: false, swapABweeks: false,
updateChannel: UpdateChannel.stable, updateChannel: UpdateChannel.stable,
@ -189,8 +183,7 @@ class SettingsProvider extends ChangeNotifier {
int get notificationsBitfield => _notificationsBitfield; int get notificationsBitfield => _notificationsBitfield;
bool get developerMode => _developerMode; bool get developerMode => _developerMode;
int get notificationPollInterval => _notificationPollInterval; int get notificationPollInterval => _notificationPollInterval;
bool get vibrate => _vibrate; VibrationStrength get vibrate => _vibrate;
VibrationStrength get vibrationStrength => _vibrationStrength;
bool get ABweeks => _ABweeks; bool get ABweeks => _ABweeks;
bool get swapABweeks => _swapABweeks; bool get swapABweeks => _swapABweeks;
UpdateChannel get updateChannel => _updateChannel; UpdateChannel get updateChannel => _updateChannel;
@ -212,8 +205,7 @@ class SettingsProvider extends ChangeNotifier {
int? notificationsBitfield, int? notificationsBitfield,
bool? developerMode, bool? developerMode,
int? notificationPollInterval, int? notificationPollInterval,
bool? vibrate, VibrationStrength? vibrate,
VibrationStrength? vibrationStrength,
bool? ABweeks, bool? ABweeks,
bool? swapABweeks, bool? swapABweeks,
UpdateChannel? updateChannel, UpdateChannel? updateChannel,
@ -233,7 +225,6 @@ class SettingsProvider extends ChangeNotifier {
if (notificationPollInterval != null && notificationPollInterval != _notificationPollInterval) if (notificationPollInterval != null && notificationPollInterval != _notificationPollInterval)
_notificationPollInterval = notificationPollInterval; _notificationPollInterval = notificationPollInterval;
if (vibrate != null && vibrate != _vibrate) _vibrate = vibrate; if (vibrate != null && vibrate != _vibrate) _vibrate = vibrate;
if (vibrationStrength != null && vibrationStrength != _vibrationStrength) _vibrationStrength = vibrationStrength;
if (ABweeks != null && ABweeks != _ABweeks) _ABweeks = ABweeks; if (ABweeks != null && ABweeks != _ABweeks) _ABweeks = ABweeks;
if (swapABweeks != null && swapABweeks != _swapABweeks) _swapABweeks = swapABweeks; if (swapABweeks != null && swapABweeks != _swapABweeks) _swapABweeks = swapABweeks;
if (updateChannel != null && updateChannel != _updateChannel) _updateChannel = updateChannel; if (updateChannel != null && updateChannel != _updateChannel) _updateChannel = updateChannel;

@ -1 +1 @@
Subproject commit ebfb27a4ce56e0e6f0745a36f559162d1d39bf0e Subproject commit 51578dd62af46f365132a571461d825a594cb519