diff --git a/mobile/src/API.js b/mobile/src/API.js index 66383d8..4853c49 100644 --- a/mobile/src/API.js +++ b/mobile/src/API.js @@ -2,7 +2,7 @@ import EventEmitter from "eventemitter3" import io from "socket.io-client" import { AsyncStorage } from "react-native" import autobind from "autobind-decorator" -import { localIPAddr } from "./development" +import { localIPAddr } from "./config" const authTokenKeyName = "AuthToken" const backendKeyName = "Backend" diff --git a/mobile/src/ARViewer/ARViewer.js b/mobile/src/ARViewer/ARViewer.js index 8429c89..05ceb61 100644 --- a/mobile/src/ARViewer/ARViewer.js +++ b/mobile/src/ARViewer/ARViewer.js @@ -137,6 +137,11 @@ class WorkItemSceneAR extends React.Component { }) } + @autobind + handleClick(position, source) { + // this.props.history.replace("/activity") + } + render() { const { position, scale, rotation, shouldBillboard } = this.state @@ -166,6 +171,7 @@ class WorkItemSceneAR extends React.Component { resources={shapes["hardhat"].materials} type="OBJ" onLoadEnd={this.handleLoadEnd} + onClick={this.handleClick} /> diff --git a/mobile/src/App.js b/mobile/src/App.js index 01de1a6..00cfbe3 100644 --- a/mobile/src/App.js +++ b/mobile/src/App.js @@ -4,6 +4,7 @@ import { StyleSheet, AsyncStorage, PermissionsAndroid, + Platform, } from "react-native" import { NativeRouter, Route, Link, Switch } from "react-router-native" import MapView from "react-native-maps" @@ -26,6 +27,13 @@ export const ensurePermission = ( onSuccess, onError ) => { + if (Platform.OS === "ios") { + if (onSuccess) { + onSuccess() + } + return + } + PermissionsAndroid.check(permission) .then((flag) => { if (flag) { diff --git a/mobile/src/Auth/Login.js b/mobile/src/Auth/Login.js index a4388ee..6f2ffcb 100644 --- a/mobile/src/Auth/Login.js +++ b/mobile/src/Auth/Login.js @@ -19,7 +19,7 @@ import KeyboardSpacer from "react-native-keyboard-spacer" import { versionInfo } from "../version" import autobind from "autobind-decorator" import { isIphoneX } from "react-native-iphone-x-helper" -import { defaultUser } from "../development" +import { defaultUser } from "../config" export class Login extends React.Component { static bindings = { diff --git a/mobile/src/Home/Home.js b/mobile/src/Home/Home.js index 18b49fd..33ef908 100644 --- a/mobile/src/Home/Home.js +++ b/mobile/src/Home/Home.js @@ -19,10 +19,11 @@ import { ifIphoneX } from "react-native-iphone-x-helper" import { workItemTypeText, pad, regionContainingPoints } from "../util" import { ensurePermission } from "../App" import { versionInfo } from "../version" +import { minGPSAccuracy } from "../config" import pinImage from "./images/pin.png" -const minGPSAccuracy = 20 const neverAskForLocationPermissionKeyName = "NeverAskForLocationPermission" +const neverAskForCameraKeyName = "NeverAskForCameraPermission" export class Home extends React.Component { constructor(props) { @@ -37,6 +38,7 @@ export class Home extends React.Component { longitudeDelta: 0.0922, }, positionInfo: null, + allowCameraAccess: false, } ensurePermission( @@ -57,6 +59,20 @@ export class Home extends React.Component { } ) + ensurePermission( + PermissionsAndroid.PERMISSIONS.CAMERA, + neverAskForCameraKeyName, + { + title: versionInfo.title, + message: + "This app needs access to your camera so that " + + "you can view AR items.", + }, + () => { + this.setState({ allowCameraAccess: true }) + } + ) + api .listWorkItemActivities() .then((list) => { diff --git a/mobile/src/config.js b/mobile/src/config.js new file mode 100644 index 0000000..fc23249 --- /dev/null +++ b/mobile/src/config.js @@ -0,0 +1,5 @@ +export const localIPAddr = "192.168.1.175" +export const defaultUser = "john@lyon-smith.org" +//export const defaultUser = "" +// export const minGPSAccuracy = 20 +export const minGPSAccuracy = 100 diff --git a/mobile/src/development.js b/mobile/src/development.js deleted file mode 100644 index 71e1484..0000000 --- a/mobile/src/development.js +++ /dev/null @@ -1,3 +0,0 @@ -export const localIPAddr = "192.168.1.175" -//export const defaultUser = "john@lyon-smith.org" -export const defaultUser = ""