Skip to content

Commit

Permalink
Implement polygon-geofence management
Browse files Browse the repository at this point in the history
  • Loading branch information
transistorsoft-pkg committed Sep 29, 2023
1 parent 55d15b1 commit 3aaae37
Show file tree
Hide file tree
Showing 103 changed files with 448 additions and 119 deletions.
2 changes: 1 addition & 1 deletion App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const App = () => {

const styles = StyleSheet.create({
button: {
backgroundColor: '#fedd1e'
backgroundColor: 'transparent'
},
input: {
height: 40,
Expand Down
Binary file added images/markers/bluedot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/geofence-event-edge-circle-dwell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/geofence-event-edge-circle-enter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/geofence-event-edge-circle-exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions images/markers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const bluedot = require('./bluedot.png');

/// Directional map Marker arrows. 0 is North; each following is rotated 10 degress. 360/10 = 36 icons.

export const locationArrowBlue = require('./location-arrow-blue.png');
export const locationArrowGreen = require('./location-arrow-green.png');
export const locationArrowAmber = require('./location-arrow-amber.png');
export const locationArrowRed = require('./location-arrow-red.png');

/// Small green, yellow, red geofence edge-coordinate circles.
export const geofenceEventEdgeCircleDwell = require('./geofence-event-edge-circle-dwell.png');
export const geofenceEventEdgeCircleEnter = require('./geofence-event-edge-circle-enter.png');
export const geofenceEventEdgeCircleExit = require('./geofence-event-edge-circle-exit.png');

Binary file added images/markers/location-arrow-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/location-arrow-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/location-arrow-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/location-arrow-11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/location-arrow-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/location-arrow-13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/location-arrow-14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/location-arrow-15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/location-arrow-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/location-arrow-17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-18.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-19.png
Binary file added images/markers/[email protected]
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-2.png
Binary file added images/markers/location-arrow-20.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-21.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-22.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-23.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-24.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-25.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-26.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-27.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-28.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-29.png
Binary file added images/markers/[email protected]
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-3.png
Binary file added images/markers/location-arrow-30.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-31.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-32.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-33.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-34.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-35.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-36.png
Binary file added images/markers/[email protected]
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-4.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-5.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-6.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-7.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-8.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-9.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-amber.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-blue.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-green.png
Binary file added images/markers/[email protected]
Binary file added images/markers/location-arrow-red.png
Binary file added images/markers/[email protected]
2 changes: 2 additions & 0 deletions ios/BGGeolocation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = BGGeolocation/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = BGGeolocation;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -518,6 +519,7 @@
DEVELOPMENT_TEAM = 32A636YFGZ;
INFOPLIST_FILE = BGGeolocation/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = BGGeolocation;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
4 changes: 3 additions & 1 deletion ios/BGGeolocation/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};




// [REQUIRED] Register BackgroundFetch
[[TSBackgroundFetch sharedInstance] didFinishLaunching];

Expand Down
6 changes: 6 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require Pod::Executable.execute_command('node', ['-p',
)', __dir__]).strip

platform :ios, min_ios_version_supported
#platform :ios, '13.0'
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
Expand All @@ -26,6 +27,11 @@ if linkage != nil
end

target 'BGGeolocation' do
# for react-native-maps (enables GoogleMaps on iOS devices)
#pod 'Google-Maps-iOS-Utils', "~> 4.2.2"
#rn_maps_path = '../node_modules/react-native-maps'
#pod 'react-native-google-maps', :path => rn_maps_path

config = use_native_modules!

# Flags change depending on the env values.
Expand Down
12 changes: 9 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,13 @@ PODS:
- React-perflogger (= 0.72.4)
- RNBackgroundFetch (4.2.1):
- React-Core
- RNBackgroundGeolocation (4.13.4):
- RNBackgroundGeolocation (4.14.0):
- CocoaLumberjack (~> 3.7.2)
- React-Core
- RNCAsyncStorage (1.19.3):
- React-Core
- RNReactNativeHapticFeedback (2.2.0):
- React-Core
- RNScreens (3.25.0):
- React-Core
- React-RCTImage
Expand Down Expand Up @@ -577,6 +579,7 @@ DEPENDENCIES:
- RNBackgroundFetch (from `../node_modules/react-native-background-fetch`)
- RNBackgroundGeolocation (from `../node_modules/react-native-background-geolocation`)
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
- RNReactNativeHapticFeedback (from `../node_modules/react-native-haptic-feedback`)
- RNScreens (from `../node_modules/react-native-screens`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
Expand Down Expand Up @@ -687,6 +690,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-background-geolocation"
RNCAsyncStorage:
:path: "../node_modules/@react-native-async-storage/async-storage"
RNReactNativeHapticFeedback:
:path: "../node_modules/react-native-haptic-feedback"
RNScreens:
:path: "../node_modules/react-native-screens"
RNVectorIcons:
Expand Down Expand Up @@ -749,14 +754,15 @@ SPEC CHECKSUMS:
React-utils: b79f2411931f9d3ea5781404dcbb2fa8a837e13a
ReactCommon: 4b2bdcb50a3543e1c2b2849ad44533686610826d
RNBackgroundFetch: 501c34ad6e880818ba17e7840b23f20a2d112923
RNBackgroundGeolocation: 60c4554829087ed9325cfeaf0ad406b9c700c45a
RNBackgroundGeolocation: 93e853b3cffda58a3e46851cb8bd19b48c15fb15
RNCAsyncStorage: c913ede1fa163a71cea118ed4670bbaaa4b511bb
RNReactNativeHapticFeedback: ec56a5f81c3941206fd85625fa669ffc7b4545f9
RNScreens: 85d3880b52d34db7b8eeebe2f1a0e807c05e69fa
RNVectorIcons: 8b5bb0fa61d54cd2020af4f24a51841ce365c7e9
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 3efc43e0d48686ce2e8c60f99d4e6bd349aff981
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: da2518075847f1519f359751a8a6172933fe65e8
PODFILE CHECKSUM: f86c1747ae141435ebdc93d75e4e33545e0338bb

COCOAPODS: 1.12.1
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@expo/react-native-action-sheet": "^4.0.1",
"@react-native-async-storage/async-storage": "^1.19.3",
"@react-navigation/elements": "^1.3.18",
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.13",
"react": "18.2.0",
"react-native": "0.72.4",
"react-native-background-fetch": "^4.2.1",
"react-native-background-geolocation": "^4.13.3",
"react-native-background-geolocation": "^4.14.0",
"react-native-dropdown-picker": "^5.4.6",
"react-native-elements": "^3.4.3",
"react-native-haptic-feedback": "^2.2.0",
"react-native-maps": "^1.7.1",
"react-native-prompt-android": "https://github.com/transistorsoft/react-native-prompt-android.git",
"react-native-safe-area-context": "^4.7.1",
Expand Down
4 changes: 4 additions & 0 deletions src/advanced/AdvancedApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
Icon
} from 'react-native-elements'

import { ActionSheetProvider } from '@expo/react-native-action-sheet';

import BackgroundGeolocation from "../react-native-background-geolocation";

import HomeView from './HomeView';
Expand All @@ -18,6 +20,7 @@ const Stack = createNativeStackNavigator();
const AdvancedApp = ({route, navigation}) => {

return (
<ActionSheetProvider>
<Stack.Navigator
initialRouteName="Home"
screenOptions={{
Expand Down Expand Up @@ -64,6 +67,7 @@ const AdvancedApp = ({route, navigation}) => {
/>
</Stack.Group>
</Stack.Navigator>
</ActionSheetProvider>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/advanced/FABMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const FABMenu = (props:Props) => {
const settingsService = SettingsService.getInstance();

/// FAB Menu handler.
const onClickMainMenu = (open:boolean) => {
const onClickMainMenu = (open:boolean) => {
setIsOpen(open);
settingsService.playSound((open) ? 'OPEN' : 'CLOSE');
}
Expand Down
63 changes: 40 additions & 23 deletions src/advanced/GeofenceView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const GeofenceView = ({route, navigation}) => {
const [identifier, setIdentifier] = React.useState('');
const [identifierError, setIdentifierError] = React.useState('');

const [isPolygon, setIsPolygon] = React.useState(false);
const [radiusOpen, setRadiusOpen] = React.useState(false);
const [radius, setRadius] = React.useState(200);

Expand All @@ -65,6 +66,7 @@ const GeofenceView = ({route, navigation}) => {

React.useEffect(() => {
DropDownPicker.setListMode("SCROLLVIEW");
setIsPolygon(typeof (route.params.vertices) == 'object');
}, []);

/// [Add] button-handler. Creates the geofence.
Expand All @@ -74,7 +76,7 @@ const GeofenceView = ({route, navigation}) => {
return;
}

const geofence = {
const geofence = (!isPolygon) ? {
identifier: identifier,
radius: radius,
latitude: route.params.coordinate.latitude,
Expand All @@ -83,15 +85,50 @@ const GeofenceView = ({route, navigation}) => {
notifyOnExit: notifyOnExit,
notifyOnDwell: notifyOnDwell,
loiteringDelay: parseInt(loiteringDelay, 10)
} : {
identifier: identifier,
vertices: route.params.vertices,
notifyOnEntry: notifyOnEntry,
notifyOnExit: notifyOnExit,
};

BackgroundGeolocation.addGeofence(geofence).then((result) => {
settingsService.playSound('ADD_GEOFENCE');
navigation.goBack();
}).catch((error) => {
settingsService.alert('Add Geofence Error', error);
});
}

const renderRadiusPicker = () => {
return !isPolygon ? (
<View style={{paddingLeft: 20, paddingRight: 20, marginBottom: 20, zIndex: 1000}}>
<ListItem.Title style={styles.formLabel}>radius</ListItem.Title>
<DropDownPicker
open={radiusOpen}
value={radius}
items={[
{label: '150', value: 150},
{label: '200', value: 200},
{label: '500', value: 500},
{label: '1000', value: 1000},
{label: '2000', value: 2000},
{label: '5000', value: 5000}
]}
setOpen={setRadiusOpen}
setValue={setRadius}
style={{
borderColor: '#ccc'
}}
dropDownContainerStyle={{
backgroundColor: '#fafafa',
borderColor: '#ccc'
}}
/>
</View>
) : <View />;

}
return (
<View style={styles.form}>

Expand All @@ -114,27 +151,7 @@ const GeofenceView = ({route, navigation}) => {
containerStyle={styles.containerStyle}
/>

<View style={{paddingLeft: 20, paddingRight: 20, marginBottom: 20}}>

<ListItem.Title style={styles.formLabel}>radius</ListItem.Title>
<DropDownPicker
open={radiusOpen}
value={radius}
items={[
{label: '150', value: 150},
{label: '200', value: 200},
{label: '500', value: 500},
{label: '1000', value: 1000},
{label: '2000', value: 2000},
{label: '5000', value: 5000}
]}
setOpen={setRadiusOpen}
setValue={setRadius}
style={{
borderColor: '#ccc'
}}
/>
</View>
{renderRadiusPicker()}

<View style={styles.inlineField}>
<View style={{flex: 1}}>
Expand Down
Loading

0 comments on commit 3aaae37

Please sign in to comment.