Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Ren Juan | 5960dfe2c3 | |
Ren Juan | c47192a293 |
|
@ -1,83 +0,0 @@
|
|||
import React from 'react';
|
||||
import { useState } from 'react';
|
||||
import { StyleSheet } from 'react-native';
|
||||
import { Alert, Pressable } from 'react-native';
|
||||
import { Text, View } from './components/Themed.tsx';
|
||||
import * as TaskManager from 'expo-task-manager';
|
||||
import * as Location from 'expo-location';
|
||||
import { bgOps, Trips, setBgOps } from './GT2';
|
||||
|
||||
const BACKGROUND_LOCATION_TRACKER = 'BACKGROUND_LOCATION_TRACKER'
|
||||
|
||||
|
||||
const getUpdates = async () => {
|
||||
|
||||
await Location.startLocationUpdatesAsync(BACKGROUND_LOCATION_TRACKER , {
|
||||
accuracy: Location.Accuracy.Highest
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
export default function PermissionsButton() {
|
||||
|
||||
const [fuBgOps, setfuBgOps] = useState(0);
|
||||
|
||||
const requestPermissions = async () => {
|
||||
const { status } = await Location.requestBackgroundPermissionsAsync();
|
||||
setBgOps((status === 'granted'));
|
||||
setfuBgOps(fuBgOps => fuBgOps + 1);
|
||||
};
|
||||
|
||||
if (!bgOps)
|
||||
return(
|
||||
<View style={styles.container} lightColor="lime" darkColor="forestgreen">
|
||||
<Pressable style={styles.button}
|
||||
onPressIn={requestPermissions }>
|
||||
<Text style={styles.text}>{'Enable background operations'}</Text>
|
||||
<Text style={styles.text2}>{' (Only used during a trip)'}</Text>
|
||||
</Pressable>
|
||||
</View>);
|
||||
else
|
||||
return(
|
||||
<View style={styles.container} lightColor="lime" darkColor="forestgreen">
|
||||
<Text style={styles.text}>{'Trips can run in background.'}</Text>
|
||||
</View>);
|
||||
|
||||
}
|
||||
|
||||
TaskManager.defineTask(BACKGROUND_LOCATION_TRACKER , async ({ data, error }) => {
|
||||
|
||||
if (error) {
|
||||
// Error occurred - check `error.message` for more details.
|
||||
console.log(error.message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
const { location } = data;
|
||||
Trips.deltaLoc( location );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
marginVertical: 2,
|
||||
marginTop: -20,
|
||||
marginBottom: 15,
|
||||
alignItems: 'center',
|
||||
},
|
||||
button: {
|
||||
fontSize: 10,
|
||||
backgroundColor: 'lime',
|
||||
},
|
||||
text: {
|
||||
fontSize: 14,
|
||||
fontWeight: 'bold',
|
||||
color: "blue",
|
||||
},
|
||||
text2: {
|
||||
fontSize: 10,
|
||||
color: "navy",
|
||||
}
|
||||
});
|
|
@ -35,8 +35,7 @@
|
|||
"permissions": [
|
||||
"ACCESS_COARSE_LOCATION",
|
||||
"ACCESS_FINE_LOCATION",
|
||||
"FOREGROUND_SERVICE",
|
||||
"ACCESS_BACKGROUND_LOCATION"
|
||||
"FOREGROUND_SERVICE"
|
||||
],
|
||||
"adaptiveIcon": {
|
||||
"foregroundImage": "./assets/images/adaptive-icon.png",
|
||||
|
|
|
@ -2,7 +2,8 @@ import React from 'react';
|
|||
import { StyleSheet, TouchableOpacity } from 'react-native';
|
||||
import { Text, View } from './Themed';
|
||||
import * as Device from 'expo-device';
|
||||
import { ver } from '../GT2';
|
||||
import { bgOps, ver } from '../GT2';
|
||||
import PermissionsButton from '../BGEO';
|
||||
|
||||
export default function ScreenInfo() {
|
||||
return (
|
||||
|
@ -55,6 +56,7 @@ export function ScreenInfo5() {
|
|||
}
|
||||
|
||||
export function ScreenInfo3() {
|
||||
if (bgOps)
|
||||
return (
|
||||
<View style={styles.splashContainer}>
|
||||
<Text
|
||||
|
@ -77,6 +79,30 @@ export function ScreenInfo3() {
|
|||
</Text>
|
||||
</View>
|
||||
);
|
||||
else
|
||||
return (
|
||||
<View style={styles.splashContainer}>
|
||||
<Text
|
||||
style={styles.titleText}
|
||||
lightColor="rgba(0,0,0,0.8)"
|
||||
darkColor="rgba(255,255,255,0.8)">
|
||||
{'Green Travel Calculator v. ' + ver }
|
||||
</Text>
|
||||
<Text
|
||||
style={styles.versionText}
|
||||
lightColor="rgba(0,0,0,0.8)"
|
||||
darkColor="rgba(255,255,255,0.8)">
|
||||
expo {Device.osName == 'iOS' ? 'iOS ' : 'android '} version
|
||||
</Text>
|
||||
<PermissionsButton />
|
||||
<Text
|
||||
style={styles.cautionText}
|
||||
lightColor="rgba(0,0,0,0.8)"
|
||||
darkColor="rgba(255,255,255,0.8)">
|
||||
{'\nNote: accuracy depends on sensitivity setting, your device, and carrier.'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,40 +12,38 @@
|
|||
"preset": "jest-expo"
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/vector-icons": "^13.0.0",
|
||||
"@expo/webpack-config": "^0.17.0",
|
||||
"@expo/vector-icons": "^12.0.0",
|
||||
"@react-navigation/bottom-tabs": "^6.0.5",
|
||||
"@react-navigation/native": "^6.0.2",
|
||||
"@react-navigation/native-stack": "^6.1.0",
|
||||
"@react-navigation/stack": "^6.0.7",
|
||||
"expo": "~46.0.0",
|
||||
"expo-asset": "~8.6.1",
|
||||
"expo-constants": "~13.2.3",
|
||||
"expo-device": "~4.3.0",
|
||||
"expo-font": "~10.2.0",
|
||||
"expo-linking": "~3.2.2",
|
||||
"expo-location": "~14.3.0",
|
||||
"expo-modules-core": "^0.11.4",
|
||||
"expo-splash-screen": "~0.16.1",
|
||||
"expo-status-bar": "~1.4.0",
|
||||
"expo-task-manager": "~10.3.0",
|
||||
"expo-web-browser": "~11.0.0",
|
||||
"expo": "~42.0.1",
|
||||
"expo-asset": "~8.3.2",
|
||||
"expo-constants": "~11.0.1",
|
||||
"expo-device": "^3.3.0",
|
||||
"expo-font": "~9.2.1",
|
||||
"expo-linking": "~2.3.1",
|
||||
"expo-location": "~12.1.2",
|
||||
"expo-splash-screen": "~0.11.2",
|
||||
"expo-status-bar": "~1.0.4",
|
||||
"expo-task-manager": "~9.2.2",
|
||||
"expo-web-browser": "~9.2.0",
|
||||
"geolib": "^3.3.1",
|
||||
"react": "18.0",
|
||||
"react-dom": "18.0",
|
||||
"react-native": "0.69.4",
|
||||
"react-native-gesture-handler": "~2.5.0",
|
||||
"react-native-reanimated": "~2.9.1",
|
||||
"react-native-safe-area-context": "4.3.1",
|
||||
"react-native-screens": "~3.15.0",
|
||||
"react-native-web": "^0.18.7"
|
||||
"react": "16.13.1",
|
||||
"react-dom": "16.13.1",
|
||||
"react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
|
||||
"react-native-gesture-handler": "~1.10.2",
|
||||
"react-native-reanimated": "~2.2.0",
|
||||
"react-native-safe-area-context": "3.2.0",
|
||||
"react-native-screens": "~3.4.0",
|
||||
"react-native-web": "~0.13.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@types/react": "~18.0",
|
||||
"@types/react-native": "~0.69.4",
|
||||
"@types/react": "~16.9.35",
|
||||
"@types/react-native": "~0.63.2",
|
||||
"jest-expo": "~41.0.0-beta.0",
|
||||
"typescript": "~4.7.0"
|
||||
"typescript": "~4.0.0"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import { ScreenInfo2 } from '../components/ScreenInfo';
|
|||
import { bgOps, TripDisplay, LastTrip, Trips, setEndIsLast } from '../GT2';
|
||||
import { RootTabScreenProps } from '../types';
|
||||
import * as Device from 'expo-device';
|
||||
import PermissionsButton from '../BGEO';
|
||||
|
||||
var debug:number = 0;
|
||||
|
||||
|
@ -56,7 +55,6 @@ function pauseTrip() {
|
|||
|
||||
}
|
||||
|
||||
|
||||
function endTrip() { Trips.end(); }
|
||||
|
||||
export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>) {
|
||||
|
@ -67,7 +65,6 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>)
|
|||
if (Trips.nTrips < 1)
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<PermissionsButton />
|
||||
<Text style={styles.title}>Trip Control</Text>
|
||||
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
|
||||
<ScreenInfo2 />
|
||||
|
@ -94,7 +91,6 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>)
|
|||
else
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<PermissionsButton />
|
||||
<Text style={styles.title}>Trip Control</Text>
|
||||
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
|
||||
<ScreenInfo2 />
|
||||
|
|
41
README.md
41
README.md
|
@ -1,38 +1,31 @@
|
|||
# Personal Carbon App
|
||||
## [greentravel.app](https://greentravel.app/doc)
|
||||
#### Originally Green Travel Carbon Calculator
|
||||
# GT2 [greentravel.app](https://greentravel.app/doc)
|
||||
<span style="font-size: 12px">Originally Green Travel Carbon Calculator</span>
|
||||
|
||||
## 2.0.0
|
||||
|
||||
- An Expo version of the same functionality as the original 2011 app but a completed [x-platform](https://apps.apple.com/ao/app/gt2-green-travel-carbon-app/id1583117880) app
|
||||
that actually reports trip distance and time and thus carbon impact accurately.
|
||||
that actually reports trip carbon impact accurately.
|
||||
|
||||
The 2.0.n series is a replacement on google and first version on apple and will be maintained
|
||||
separate from the subsequent production line which will use the [common mechanism](https://devops1.sameboat.network/sb-app)
|
||||
separate from the subsequent production line which will use the [common mechanism](https://sameboat.live/sb-app)
|
||||
for delivery of my apps from 2.1 forward.
|
||||
|
||||
2.0.7 was feature complete at the end of August 2021.
|
||||
2.0.7 was feature complete at the end of August 2011. 2.0.8 will be the stable baseline of same thing
|
||||
with background operation, maintained with stack and platform major version increments.
|
||||
|
||||
2.0.8 the stable baseline of same thing but with background operation, with subsequent change only for stack maintenance was complete in Sept 2023.
|
||||
## 2.n.m
|
||||
|
||||
## 1.n.m (semantic reset)
|
||||
- Roadmap for regular production Personal Carbon Accounting domain
|
||||
|
||||
PCA which is sold as Green Travel 2.n.m, n > 0 is a maintained instance of the [PMTA](https://sameboat.network/personaleco) generic base.
|
||||
- 2.1.0 1st embedded product line release
|
||||
- 2.2.0 Wearable extension
|
||||
- 2.3.0 Maintain trip histories in cloud
|
||||
- 2.4.0 Group Aggregation
|
||||
- 2.5.0 Reporting
|
||||
|
||||
- Roadmap for regular production Personal Carbon Accounting domain, PCA 1
|
||||
|
||||
- 1.1.0 [Product baseline](https://devops1.sameboat.network/sb-app)
|
||||
- 1.2.0 Wearable extension
|
||||
- 1.3.0 Maintain trip histories in cloud
|
||||
- 1.4.0 Group Aggregation
|
||||
- 1.5.0 Reporting
|
||||
|
||||
The product line version, unlike the standalone 2.0.n series will be based on the Domain Space App and so the semantic numbering resets.
|
||||
It will also be free but with feature sets at higher levels of [entitlement](https://eg.meansofproduction.biz/eg/index.php/AKPERSON), vended in-app.
|
||||
|
||||
The product line source app will greatly expand upon the cause for being of the 2011 app which was to demonstrate working GPS (see below).
|
||||
Motion/travel tracking remains the core function but there will be additional reusable infra for a number of purposes, in particular
|
||||
wearable extensions. PCA 1 is an application of this new code which is available to entitled users of git.meansofproduction.biz.
|
||||
The product line version, unlike the standalone 2.0.n series will have an evolving domain model. It will also be free but with feature sets
|
||||
that are available to users at different levels of [entitlement](https://eg.meansofproduction.biz/index.php/AKPERSON) in my domains,
|
||||
vended in in the common domain content mgt app.
|
||||
|
||||
|
||||
2011 Stub App
|
||||
|
@ -51,6 +44,6 @@ PCA which is sold as Green Travel 2.n.m, n > 0 is a maintained instance of the [
|
|||
|
||||
Note: going over the sources there are references to a PDF. This refers to the origins of the project.
|
||||
An individual had taken on the task of making an application for NRDC Boston and got stuck on the GPS.
|
||||
The PDF was what that app was supposed to do. I completed it up to doing the basic thing it was supposed
|
||||
The PDF was what that app was supposed to do. I completed it up doing the basic thing it was supposed
|
||||
to do.
|
||||
|
||||
|
|
Loading…
Reference in New Issue