Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat 0.15.0 add proximity alarm #119

Merged
merged 36 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a966a19
refactor: Move location_alarm_service.dart into own folder
Myzel394 Sep 9, 2023
a19d055
feat: Add ProximityLocationAlarm.dart
Myzel394 Sep 9, 2023
958c5e7
refactor: Add LocationRadiusSelectorMap.dart
Myzel394 Sep 12, 2023
a98359e
fix: Fix scale mode
Myzel394 Sep 13, 2023
2a489dc
fix: Add realtime update to radius
Myzel394 Sep 13, 2023
f80825f
fix: Disable location set for alarms of proximity type
Myzel394 Sep 13, 2023
92a3f2f
feat: Add current_location_service.dart for better location fetching
Myzel394 Sep 13, 2023
9091e7b
fix: Force center update on location change for proximity based alarms
Myzel394 Sep 13, 2023
c20f4dc
current stand
Myzel394 Sep 16, 2023
44be483
fix: Fix alarm previews
Myzel394 Sep 16, 2023
b8f8e96
fix: Improve alarm previews
Myzel394 Sep 16, 2023
3b9e3cf
feat: Add delete confirmation for view alarms
Myzel394 Sep 16, 2023
0eec2cd
fix: Only check for notification access if alarm is not null
Myzel394 Sep 16, 2023
ceca7aa
chore: Update flutter_logs
Myzel394 Sep 18, 2023
abb57de
fix: Fix alarm checker
Myzel394 Sep 18, 2023
0acd946
refactor: Use OOP for nostr fetching
Myzel394 Sep 23, 2023
7b5f823
feat: Add location point decrypter & improvements
Myzel394 Sep 23, 2023
a56b4b7
test: Add nonexistent nostr fetch test
Myzel394 Sep 23, 2023
2078d4d
test: Add nostr fetch
Myzel394 Sep 23, 2023
c0e7ac0
refactor: Move view_service into its own folder
Myzel394 Sep 23, 2023
064316e
fix: Fix nostr fetching timeout
Myzel394 Sep 23, 2023
8c4a93c
test: Add fetcher test
Myzel394 Sep 23, 2023
60b49f4
refactor: Use new fetchers to fetch locations
Myzel394 Sep 23, 2023
1e97823
fix: Remove unused get-locations.dart
Myzel394 Sep 23, 2023
b5062df
fix: Fix location fetchers
Myzel394 Sep 23, 2023
e863c6f
fix: Fix location fetchers
Myzel394 Sep 24, 2023
dac3042
feat: Add missing permission notification
Myzel394 Sep 24, 2023
f51a873
feat: Add repeatedly-check.dart for RequestBatteryOptimizationsDisabl…
Myzel394 Sep 24, 2023
a498beb
fix: Fix location updates
Myzel394 Sep 24, 2023
9e433ab
refactor: Improve alarm handler
Myzel394 Sep 24, 2023
c1bd92c
chore: Update packages
Myzel394 Sep 24, 2023
006d635
fix: Improve LocationsOverviewScreen.dart for iOS
Myzel394 Sep 25, 2023
6587c0d
fix: Improve map for iOS
Myzel394 Sep 26, 2023
0938858
fix: Make action destructive on iOS
Myzel394 Sep 26, 2023
1827ff0
fix: Improve spacing
Myzel394 Sep 26, 2023
4e1432f
feat: Open maps directly if one map is only available
Myzel394 Sep 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed assets/bunny.mp3
Binary file not shown.
14 changes: 7 additions & 7 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ PODS:
- Alamofire (5.6.2)
- apple_maps_flutter (0.0.1):
- Flutter
- audioplayers_darwin (0.0.1):
- Flutter
- background_fetch (1.1.6):
- Flutter
- background_locator_2 (0.0.1):
- Flutter
- battery_plus (1.0.0):
- Flutter
- clipboard_watcher (0.0.1):
Expand Down Expand Up @@ -96,8 +96,8 @@ PODS:

DEPENDENCIES:
- apple_maps_flutter (from `.symlinks/plugins/apple_maps_flutter/ios`)
- audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`)
- background_fetch (from `.symlinks/plugins/background_fetch/ios`)
- background_locator_2 (from `.symlinks/plugins/background_locator_2/ios`)
- battery_plus (from `.symlinks/plugins/battery_plus/ios`)
- clipboard_watcher (from `.symlinks/plugins/clipboard_watcher/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
Expand Down Expand Up @@ -135,10 +135,10 @@ SPEC REPOS:
EXTERNAL SOURCES:
apple_maps_flutter:
:path: ".symlinks/plugins/apple_maps_flutter/ios"
audioplayers_darwin:
:path: ".symlinks/plugins/audioplayers_darwin/ios"
background_fetch:
:path: ".symlinks/plugins/background_fetch/ios"
background_locator_2:
:path: ".symlinks/plugins/background_locator_2/ios"
battery_plus:
:path: ".symlinks/plugins/battery_plus/ios"
clipboard_watcher:
Expand Down Expand Up @@ -187,8 +187,8 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Alamofire: d368e1ff8a298e6dde360e35a3e68e6c610e7204
apple_maps_flutter: c59725efea39e13e703cde52a1d2b14866ad68a8
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
background_fetch: bc9b44b0bf8b434e282a2ac9be8662800a0296ed
background_locator_2: bc8a422343ab656d5bd98e08694c6f89fef20418
battery_plus: 9bff772a7e5e4d5381ca3ca92a97373a3d8b2738
clipboard_watcher: 86fb70421aca6f4944e0591a8292605da7784666
device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea
Expand Down Expand Up @@ -221,4 +221,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 819f6e738594296500811eae0a41f3dceed5a207

COCOAPODS: 1.11.3
COCOAPODS: 1.12.1
103 changes: 0 additions & 103 deletions lib/api/get-locations.dart

This file was deleted.

19 changes: 19 additions & 0 deletions lib/api/nostr-fetch.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';
import 'dart:ui';

import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_logs/flutter_logs.dart';
import 'package:nostr/nostr.dart';

Expand All @@ -15,6 +16,7 @@ class NostrFetch {
required this.request,
});

// TODO: Refactor all of nostr fetching logic
Future<WebSocket> _connectToRelay({
required final String relay,
required final Future<void> Function(Message message, String relay) onEvent,
Expand Down Expand Up @@ -98,13 +100,28 @@ class NostrFetch {
}
});

socket.timeout(
3.seconds,
onTimeout: (event) {
FlutterLogs.logError(
LOG_TAG,
"Nostr Socket $relay",
"Socket timed out.",
);

socket.close();
onEmptyEnd?.call();
},
);

return socket;
}

VoidCallback fetchEvents({
required final Future<void> Function(Message message, String relay) onEvent,
required final void Function() onEnd,
final void Function()? onEmptyEnd,
final VoidCallback? onError,
}) {
final List<WebSocket> sockets = [];

Expand Down Expand Up @@ -136,6 +153,8 @@ class NostrFetch {
"Nostr Socket",
"Error for socket: $error",
);

onError?.call();
});
}

Expand Down
2 changes: 2 additions & 0 deletions lib/constants/notifications.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
enum AndroidChannelIDs {
locationAlarms,
appIssues,
}

enum NotificationActionType {
openTaskView,
openPermissionsSettings,
}
64 changes: 57 additions & 7 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,6 @@
"logs_title": "Locus automatically creates logs",
"logs_description": "Logs are kept for 7 days and are automatically deleted afterwards.",
"locationPointsScreen_title": "Location Points",
"bunny_unavailable": "Sorry, but it seems as if your friend is as lost as this song.",
"bunny_unavailable_action": "What's this song?",
"locationAlarm_radiusBasedRegion_notificationTitle_whenEnter": "{name} entered zone {zone}",
"@locationAlarm_radiusBasedRegion_notificationTitle_whenEnter": {
"description": "Notification title when entering a zone; Try to keep this short, will be truncated to 80 characters",
Expand Down Expand Up @@ -668,12 +666,38 @@
}
}
},
"locationAlarm_proximityLocation_notificationTitle_whenEnter": "{name} is within {proximity}m",
"@locationAlarm_proximityLocation_notificationTitle_whenEnter": {
"description": "Notification title when entering a proximity location; Try to keep this short, will be truncated to 80 characters",
"placeholders": {
"name": {
"type": "String"
},
"proximity": {
"type": "int"
}
}
},
"locationAlarm_proximityLocation_notificationTitle_whenLeave": "{name} is outside of {proximity}m",
"@locationAlarm_proximityLocation_notificationTitle_whenLeave": {
"description": "Notification title when leaving a proximity location; Try to keep this short, will be truncated to 80 characters",
"placeholders": {
"name": {
"type": "String"
},
"proximity": {
"type": "int"
}
}
},
"locationAlarm_notification_description": "Tap for more information",
"androidNotificationChannel_locationAlarms_name": "Location Alarms",
"androidNotificationChannel_locationAlarms_description": "Receive notifications for location alarms",
"androidNotificationChannel_appIssues_name": "Important Issues",
"androidNotificationChannel_appIssues_description": "Receive notifications for important issues about Locus (when a task is not updating, location can't be updated, etc.)",
"location_manageAlarms_title": "Manage Alarms",
"location_manageAlarms_empty_title": "No Alarms",
"location_manageAlarms_empty_description": "Add alarms to be notified when certain conditions are met (e.g. when this person enters a certain area).",
"location_manageAlarms_empty_description": "Add alarms to be notified when certain conditions are met",
"location_manageAlarms_addNewAlarm_actionLabel": "Add Alarm",
"location_manageAlarms_lastCheck_description": "Last checked at {date}",
"@location_manageAlarms_lastCheck_description": {
Expand All @@ -685,18 +709,42 @@
}
}
},
"location_addAlarm_radiusBased_title": "Add radius-based Alarm",
"location_addAlarm_geo_title": "Add geo-based alarm",
"location_addAlarm_geo_description": "Define a region and get notified when your friend enters or leaves this region",
"location_addAlarm_geo_name_description": "Please enter a name for this region",
"location_addAlarm_geo_help_tapDescription": "Tap on the map to mark the center of your region",
"location_addAlarm_proximity_title": "Add proximity alarm",
"location_addAlarm_proximity_description": "Get notified when your friend is within a certain distance of you",
"location_addAlarm_radiusBased_radius_meters": "Radius: {value} meters",
"location_removeAlarm_title": "Remove Alarm",
"location_removeAlarm_description": "Are you sure you want to remove this alarm?",
"location_removeAlarm_confirm": "Remove",
"@location_addAlarm_radiusBased_radius_meters": {
"placeholders": {
"value": {
"type": "int"
}
}
},
"location_addAlarm_radiusBased_radius_kilometers": "Radius: {value} km",
"@location_addAlarm_radiusBased_radius_kilometers": {
"placeholders": {
"value": {
"type": "double"
}
}
},
"location_addAlarm_radiusBased_isInScaleMode": "You can now scale the radius by pinching and zooming into the map. Tap on the screen to go back to normal mode.",
"location_addAlarm_radiusBased_addLabel": "Select region",
"location_addAlarm_radiusBased_help_title": "Radius-based Alarms",
"location_addAlarm_radiusBased_help_description": "Radius-based alarms are triggered either when leaving or entering a region. After defining your region, you can decide when your alarm should trigger.",
"location_addAlarm_radiusBased_help_tapDescription": "Tap on the map to mark the center of your region",
"location_addAlarm_radiusBased_help_pinchDescription": "Press and hold to enter into scale mode. You can then change the radius by pinching and zooming into the map.",
"location_addAlarm_radiusBased_trigger_title": "When should your alarm trigger?",
"location_addAlarm_radiusBased_trigger_whenEnter": "Trigger when entering",
"location_addAlarm_radiusBased_trigger_whenLeave": "Trigger when leaving",
"location_addAlarm_radiusBased_name_description": "Please enter a name for this region",
"location_addAlarm_actionLabel": "Add Alarm",
"location_addAlarm_selectType_title": "Select Alarm Type",
"location_addAlarm_selectType_description": "What kind of alarm do you want to add?",
"permissions_openSettings_label": "Open settings",
"permissions_openSettings_failed_title": "Settings could not be opened",
"permissions_location_askPermission_title": "Grant access to your location",
Expand Down Expand Up @@ -803,5 +851,7 @@
}
},
"locations_values_batteryState_description": "Battery state",
"locations_values_batteryState_value": "{state, select, full {full} charging {charging} discharging {discharging} other {unknown}}"
"locations_values_batteryState_value": "{state, select, full {full} charging {charging} discharging {discharging} other {unknown}}",
"permissionsMissing_title": "Permissions missing",
"permissionsMissing_message": "Please allow access to your location in the background"
}
9 changes: 5 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:locus/App.dart';
import 'package:locus/screens/locations_overview_screen_widgets/LocationFetchers.dart';
import 'package:locus/services/app_update_service.dart';
import 'package:locus/services/current_location_service.dart';
import 'package:locus/services/log_service.dart';
import 'package:locus/services/manager_service/background_fetch.dart';
import 'package:locus/services/settings_service/index.dart';
import 'package:locus/services/task_service/index.dart';
import 'package:locus/services/view_service.dart';
import 'package:locus/services/view_service/index.dart';
import 'package:provider/provider.dart';

const storage = FlutterSecureStorage();
Expand Down Expand Up @@ -86,11 +87,11 @@ void main() async {
ChangeNotifierProvider<AppUpdateService>(
create: (_) => appUpdateService),
ChangeNotifierProvider<LocationFetchers>(
create: (_) => LocationFetchers()),
create: (_) => LocationFetchers(viewService.views)),
ChangeNotifierProvider<CurrentLocationService>(
create: (_) => CurrentLocationService()),
],
child: const App(),
),
);

registerBackgroundFetch();
}
2 changes: 1 addition & 1 deletion lib/models/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:convert';

import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:locus/services/location_alarm_service.dart';
import 'package:locus/services/location_alarm_service/enums.dart';
import 'package:locus/services/task_service/index.dart';
import 'package:uuid/uuid.dart';

Expand Down
Loading
Loading