Skip to content

Commit

Permalink
Merge pull request #119 from Myzel394/feat-0.15.0-add-proximity-alarm
Browse files Browse the repository at this point in the history
Feat 0.15.0 add proximity alarm
  • Loading branch information
Myzel394 committed Sep 26, 2023
2 parents 91354a1 + 4e1432f commit b38b59c
Show file tree
Hide file tree
Showing 75 changed files with 3,453 additions and 2,495 deletions.
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

0 comments on commit b38b59c

Please sign in to comment.