stub 2.0.8

This commit is contained in:
Ren Juan 2021-08-30 00:19:58 +00:00
parent 8ae9271414
commit 470c231695
6 changed files with 56 additions and 33 deletions

View File

@ -20,12 +20,15 @@ export function setAdvised() : void { advised = true; }
export default function App() {
const isLoadingComplete = useCachedResources();
const colorScheme = useColorScheme();
const [isKM, setIsKM] = useState(false);
const toggleUnits = () => setIsKM(previousState => !previousState);
const [location, setLocation] = useState(Object);
const [errorMsg, setErrorMsg] = useState("");
useEffect(() => {
const [location, setLocation] = useState(Object);
const [errorMsg, setErrorMsg] = useState("");
useEffect(() => {
(async () => {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') {
@ -41,14 +44,14 @@ export default function App() {
Trips.deltaLoc(location);
}
})();
}, []);
}, []);
expoGeoState = 'Waiting..';
if (errorMsg) {
expoGeoState = 'Waiting..';
if (errorMsg) {
expoGeoState = errorMsg;
} else if (location) {
} else if (location) {
expoGeoState = JSON.stringify(location);
}
}
if (!isLoadingComplete) {

View File

@ -4,11 +4,11 @@ import { Text, View } from './components/Themed';
import { StyleSheet } from 'react-native';
import * as geolib from 'geolib';
export const ver:string = "2.0.7"
export const ver:string = "2.0.8"
var debug:number = 0;
var endIsNigh:boolean = false;
var testCount = 0;
var bgEnabled:boolean = false;
export var bgOps:boolean = false;
var expoGeoState:any = null;
export var locEnabled:boolean = false;
@ -20,6 +20,7 @@ export var locEnabled:boolean = false;
const minExpoAccuracy:number = 5;
export function getEndIsLast() : boolean { return endIsNigh; }
export function setBgOps(value:boolean) { bgOps = value; }
export function setEndIsLast(value:boolean) { endIsNigh = value; }
const styles = StyleSheet.create({
@ -133,7 +134,7 @@ class Trip {
}
public start() { this.interval = setInterval(() => this.tick(), heartbeat);
if (!bgEnabled) startTracking(this);
if (!bgOps) startTracking(this);
}
public resume() { this.lastFix.mLatitude = 0.0;
@ -143,7 +144,7 @@ class Trip {
public stop() { Trips.distance += this.ds;
this.ds = 0.0;
clearInterval(this.interval);
if (!bgEnabled) stopTracking(this);
if (!bgOps) stopTracking(this);
}
}

View File

@ -2,7 +2,7 @@
"expo": {
"name": "GT2 Green Travel Carbon App",
"slug": "GT2standalone",
"version": "2.0.7",
"version": "2.0.8",
"orientation": "default",
"description": "Travel Carbon Footprint (simplified version)",
"icon": "./assets/images/icon.png",
@ -22,7 +22,7 @@
"ios": {
"supportsTablet": true,
"bundleIdentifier": "app.greentravel.gt2",
"buildNumber": "3",
"buildNumber": "4",
"infoPlist": {
"UIBackgroundModes": [
"location",

View File

@ -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({

View File

@ -1,11 +1,11 @@
import * as React from 'react';
import { useState } from 'react';
import { Alert, BackHandler, Button, StyleSheet } from 'react-native';
import { Alert, Button, StyleSheet } from 'react-native';
import { Text, View } from '../components/Themed';
import { ScreenInfo2 } from '../components/ScreenInfo';
import { ver, locEnabled, TripDisplay, LastTrip, Trips, setEndIsLast } from '../GT2';
import { bgOps, TripDisplay, LastTrip, Trips, setEndIsLast } from '../GT2';
import { RootTabScreenProps } from '../types';
import { getAdvised, setAdvised } from './ModalScreen';
import * as Device from 'expo-device';
var debug:number = 0;
@ -34,9 +34,10 @@ const styles = StyleSheet.create({
function startTrip() {
if (!locEnabled) {
Alert.alert("Location services unavailable can't start trip.");
return;
if (!bgOps) {
if (Device.osName === 'iOS')
Alert.alert("Background location not enabled. Must be in foreground and awake during trip!");
else Alert.alert('Stay in foreground, awake during trip!');
}
Trips.start();
@ -71,10 +72,6 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>)
<Button
title={sButtonText}
onPress={() => {
if (!getAdvised()) {
Alert.alert("Note: " + ver + " doesn't run while in background or sleeping.");
setAdvised();
}
if (!Trips.inProgress) {startTrip();
if (Trips.inProgress) { setSButtonText("End"); setPButtonText('Pause');}}
else {setSButtonText('Start'); LastTrip.from(Trips); endTrip(); navigation.push('Modal'); }}
@ -101,10 +98,6 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>)
<Button
title={sButtonText}
onPress={() => {
if (!getAdvised()) {
Alert.alert("Note: GT2" + ver + " doesn't run while in background or sleeping.");
setAdvised();
}
if (!Trips.inProgress) {startTrip();
if (Trips.inProgress) { setSButtonText("End"); setPButtonText('Pause');}}
else {setSButtonText('Start'); endTrip(); LastTrip.from(Trips); navigation.push('Modal'); }}