diff --git a/lib/Backend/Bluetooth/bluetooth_manager.dart b/lib/Backend/Bluetooth/bluetooth_manager.dart index f2ac8480b..5b7b5ff6b 100644 --- a/lib/Backend/Bluetooth/bluetooth_manager.dart +++ b/lib/Backend/Bluetooth/bluetooth_manager.dart @@ -15,7 +15,7 @@ final log.Logger bluetoothLog = log.Logger('Bluetooth'); class KnownDevices extends _$KnownDevices { @override Map build() { - List storedDevices = HiveProxy.getAll('devices').toList(); + List storedDevices = HiveProxy.getAll(devicesBox).toList(); Map results = {}; try { if (storedDevices.isNotEmpty) { @@ -50,7 +50,7 @@ class KnownDevices extends _$KnownDevices { } Future store() async { - await HiveProxy.clear('devices'); - await HiveProxy.addAll('devices', state.values.map((e) => e.baseStoredDevice)); + await HiveProxy.clear(devicesBox); + await HiveProxy.addAll(devicesBox, state.values.map((e) => e.baseStoredDevice)); } } diff --git a/lib/Backend/move_lists.dart b/lib/Backend/move_lists.dart index dabb1d616..03c8df948 100644 --- a/lib/Backend/move_lists.dart +++ b/lib/Backend/move_lists.dart @@ -166,7 +166,7 @@ class MoveLists extends _$MoveLists { List build() { List results = []; try { - results = HiveProxy.getAll('sequences').toList(growable: true); + results = HiveProxy.getAll(sequencesBox).toList(growable: true); } catch (e, s) { sequencesLogger.severe("Unable to load sequences: $e", e, s); } @@ -189,8 +189,8 @@ class MoveLists extends _$MoveLists { Future store() async { sequencesLogger.info("Storing sequences"); - await HiveProxy.clear('sequences'); - await HiveProxy.addAll('sequences', state); + await HiveProxy.clear(sequencesBox); + await HiveProxy.addAll(sequencesBox, state); } } diff --git a/lib/Backend/plausible_dio.dart b/lib/Backend/plausible_dio.dart index f1d765922..4f1c6e2cf 100644 --- a/lib/Backend/plausible_dio.dart +++ b/lib/Backend/plausible_dio.dart @@ -35,8 +35,8 @@ class PlausibleDio extends Plausible { page = "app://localhost/$page?utm_source=${(await InstallReferrer.referrer).name}"; referrer = "app://localhost/$referrer"; props = Map.of(props); - props['Number Of Devices'] = HiveProxy.getAll('devices').length.toString(); - props['Number Of Sequences'] = HiveProxy.getAll('sequences').length.toString(); + props['Number Of Devices'] = HiveProxy.getAll(devicesBox).length.toString(); + props['Number Of Sequences'] = HiveProxy.getAll(sequencesBox).length.toString(); props['Number Of Triggers'] = HiveProxy.getAll(triggerBox).length.toString(); props['App Version'] = (await PackageInfo.fromPlatform()).version; props['App Build'] = (await PackageInfo.fromPlatform()).buildNumber; diff --git a/lib/constants.dart b/lib/constants.dart index 5be28a860..e912b8bd1 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -21,6 +21,7 @@ const String hasCompletedOnboarding = 'hasCompletedOnboardingVersion'; const String showDebugging = 'showDebugging'; const String alwaysScanning = 'alwaysScanning'; const String showDemoGear = 'showDemoGear'; +const String showAdvancedSettings = 'showAdvancedSettings'; // Notification Settings const String allowNewsletterNotifications = 'allowNewsletterNotifications'; @@ -43,10 +44,11 @@ const bool showDebuggingDefault = false; const bool alwaysScanningDefault = true; const bool allowNewsletterNotificationsDefault = false; const bool showDemoGearDefault = false; +const bool showAdvancedSettingsDefault = false; -// Triggers labels const String triggerBox = 'triggers'; - +const String sequencesBox = 'sequences'; +const String devicesBox = 'devices'; const String favoriteActionsBox = 'favoriteActions'; const String audioActionsBox = 'audioActions'; const int hasCompletedOnboardingVersionToAgree = 1; diff --git a/lib/main.dart b/lib/main.dart index d1a1167e0..ff38cbe27 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -217,8 +217,8 @@ Future initHive() async { await SentryHive.openBox(triggerBox); await SentryHive.openBox(favoriteActionsBox); await SentryHive.openBox(audioActionsBox); - await SentryHive.openBox('sequences'); - await SentryHive.openBox('devices'); + await SentryHive.openBox(sequencesBox); + await SentryHive.openBox(devicesBox); await SentryHive.openBox(notificationBox); // Do not set type here } diff --git a/test/Backend/device_registry_test.dart b/test/Backend/device_registry_test.dart index 238df1b8d..c473e22ab 100644 --- a/test/Backend/device_registry_test.dart +++ b/test/Backend/device_registry_test.dart @@ -75,20 +75,20 @@ void main() { String name = 'MiTail'; String name2 = 'EG2'; expect(container.read(knownDevicesProvider).length, 0); - expect(HiveProxy.getAll('devices').length, 0); + expect(HiveProxy.getAll(devicesBox).length, 0); BaseStatefulDevice baseStatefulDevice = await createAndStoreGear(name, container); expect(baseStatefulDevice.baseDeviceDefinition.btName, name); expect(container.read(knownDevicesProvider).length, 1); expect(container.read(knownDevicesProvider).values.first, baseStatefulDevice); - expect(HiveProxy.getAll('devices').length, 1); - expect(HiveProxy.getAll('devices').first, baseStatefulDevice.baseStoredDevice); + expect(HiveProxy.getAll(devicesBox).length, 1); + expect(HiveProxy.getAll(devicesBox).first, baseStatefulDevice.baseStoredDevice); BaseStatefulDevice baseStatefulDevice2 = await createAndStoreGear(name2, container); expect(baseStatefulDevice2.baseDeviceDefinition.btName, name2); expect(container.read(knownDevicesProvider).length, 2); expect(container.read(knownDevicesProvider).values.contains(baseStatefulDevice2), true); - expect(HiveProxy.getAll('devices').length, 2); - expect(HiveProxy.getAll('devices').contains(baseStatefulDevice2.baseStoredDevice), true); + expect(HiveProxy.getAll(devicesBox).length, 2); + expect(HiveProxy.getAll(devicesBox).contains(baseStatefulDevice2.baseStoredDevice), true); BaseAction baseAction = BaseAction(name: "name", deviceCategory: [DeviceType.tail], actionCategory: ActionCategory.hidden, uuid: "uuid"); BaseAction baseAction2 = BaseAction(name: "name1", deviceCategory: [DeviceType.ears], actionCategory: ActionCategory.hidden, uuid: "uuid1"); diff --git a/test/Backend/move_lists_test.dart b/test/Backend/move_lists_test.dart index 6119d5b72..4f76ed836 100644 --- a/test/Backend/move_lists_test.dart +++ b/test/Backend/move_lists_test.dart @@ -87,7 +87,7 @@ void main() { await container.read(moveListsProvider.notifier).add(moveList); expect(container.read(moveListsProvider).length, 1); expect(container.read(moveListsProvider).first, moveList); - expect(HiveProxy.getAll('sequences').length, 1); + expect(HiveProxy.getAll(sequencesBox).length, 1); //verify movelists are read again from hive container.invalidate(moveListsProvider); expect(container.read(moveListsProvider).length, 1); @@ -95,7 +95,7 @@ void main() { await container.read(moveListsProvider.notifier).remove(moveList); expect(container.read(moveListsProvider).isEmpty, true); - expect(HiveProxy.getAll('sequences').isEmpty, true); + expect(HiveProxy.getAll(sequencesBox).isEmpty, true); }); }); test('Editing Move List record', () { diff --git a/test/testing_utils/gear_utils.dart b/test/testing_utils/gear_utils.dart index 1633b5ae0..d0d431447 100644 --- a/test/testing_utils/gear_utils.dart +++ b/test/testing_utils/gear_utils.dart @@ -5,6 +5,7 @@ import 'package:tail_app/Backend/Bluetooth/bluetooth_manager_plus.dart'; import 'package:tail_app/Backend/Definitions/Device/device_definition.dart'; import 'package:tail_app/Backend/LoggingWrappers.dart'; import 'package:tail_app/Backend/device_registry.dart'; +import 'package:tail_app/constants.dart'; Future createAndStoreGear(String gearBtName, ProviderContainer ref, {String gearMacPrefix = 'Dev'}) async { BaseDeviceDefinition baseDeviceDefinition = DeviceRegistry.getByName(gearBtName)!; @@ -26,12 +27,12 @@ Future testGearAdd(String name, {String gearMacPrefix = 'DEV' overrides: [], ); expect(container.read(knownDevicesProvider).length, 0); - expect(HiveProxy.getAll('devices').length, 0); + expect(HiveProxy.getAll(devicesBox).length, 0); BaseStatefulDevice baseStatefulDevice = await createAndStoreGear(name, container, gearMacPrefix: gearMacPrefix); expect(baseStatefulDevice.baseDeviceDefinition.btName, name); expect(container.read(knownDevicesProvider).length, 1); expect(container.read(knownDevicesProvider).values.first, baseStatefulDevice); - expect(HiveProxy.getAll('devices').length, 1); - expect(HiveProxy.getAll('devices').first, baseStatefulDevice.baseStoredDevice); + expect(HiveProxy.getAll(devicesBox).length, 1); + expect(HiveProxy.getAll(devicesBox).first, baseStatefulDevice.baseStoredDevice); return container; }