Additional tweaks for permission checks
This commit is contained in:
@@ -2,7 +2,7 @@ import EventEmitter from "eventemitter3"
|
|||||||
import io from "socket.io-client"
|
import io from "socket.io-client"
|
||||||
import { AsyncStorage } from "react-native"
|
import { AsyncStorage } from "react-native"
|
||||||
import autobind from "autobind-decorator"
|
import autobind from "autobind-decorator"
|
||||||
import { localIPAddr } from "./development"
|
import { localIPAddr } from "./config"
|
||||||
|
|
||||||
const authTokenKeyName = "AuthToken"
|
const authTokenKeyName = "AuthToken"
|
||||||
const backendKeyName = "Backend"
|
const backendKeyName = "Backend"
|
||||||
|
|||||||
@@ -137,6 +137,11 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
|
handleClick(position, source) {
|
||||||
|
// this.props.history.replace("/activity")
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { position, scale, rotation, shouldBillboard } = this.state
|
const { position, scale, rotation, shouldBillboard } = this.state
|
||||||
|
|
||||||
@@ -166,6 +171,7 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
resources={shapes["hardhat"].materials}
|
resources={shapes["hardhat"].materials}
|
||||||
type="OBJ"
|
type="OBJ"
|
||||||
onLoadEnd={this.handleLoadEnd}
|
onLoadEnd={this.handleLoadEnd}
|
||||||
|
onClick={this.handleClick}
|
||||||
/>
|
/>
|
||||||
<ViroSurface
|
<ViroSurface
|
||||||
rotation={[-90, 0, 0]}
|
rotation={[-90, 0, 0]}
|
||||||
@@ -187,7 +193,7 @@ export class ARViewer extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
_handlePress() {
|
handleBackPress() {
|
||||||
this.props.history.replace("/")
|
this.props.history.replace("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +209,7 @@ export class ARViewer extends React.Component {
|
|||||||
<View style={{ position: "absolute", left: 30, right: 0, top: 50 }}>
|
<View style={{ position: "absolute", left: 30, right: 0, top: 50 }}>
|
||||||
<TouchableHighlight
|
<TouchableHighlight
|
||||||
style={styles.buttons}
|
style={styles.buttons}
|
||||||
onPress={this._handlePress}
|
onPress={this.handleBackPress}
|
||||||
underlayColor={"#00000000"}>
|
underlayColor={"#00000000"}>
|
||||||
<Image source={backImage} />
|
<Image source={backImage} />
|
||||||
</TouchableHighlight>
|
</TouchableHighlight>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
StyleSheet,
|
StyleSheet,
|
||||||
AsyncStorage,
|
AsyncStorage,
|
||||||
PermissionsAndroid,
|
PermissionsAndroid,
|
||||||
|
Platform,
|
||||||
} from "react-native"
|
} from "react-native"
|
||||||
import { NativeRouter, Route, Link, Switch } from "react-router-native"
|
import { NativeRouter, Route, Link, Switch } from "react-router-native"
|
||||||
import MapView from "react-native-maps"
|
import MapView from "react-native-maps"
|
||||||
@@ -26,6 +27,13 @@ export const ensurePermission = (
|
|||||||
onSuccess,
|
onSuccess,
|
||||||
onError
|
onError
|
||||||
) => {
|
) => {
|
||||||
|
if (Platform.OS === "ios") {
|
||||||
|
if (onSuccess) {
|
||||||
|
onSuccess()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
PermissionsAndroid.check(permission)
|
PermissionsAndroid.check(permission)
|
||||||
.then((flag) => {
|
.then((flag) => {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import KeyboardSpacer from "react-native-keyboard-spacer"
|
|||||||
import { versionInfo } from "../version"
|
import { versionInfo } from "../version"
|
||||||
import autobind from "autobind-decorator"
|
import autobind from "autobind-decorator"
|
||||||
import { isIphoneX } from "react-native-iphone-x-helper"
|
import { isIphoneX } from "react-native-iphone-x-helper"
|
||||||
import { defaultUser } from "../development"
|
import { defaultUser } from "../config"
|
||||||
|
|
||||||
export class Login extends React.Component {
|
export class Login extends React.Component {
|
||||||
static bindings = {
|
static bindings = {
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ import { ifIphoneX } from "react-native-iphone-x-helper"
|
|||||||
import { workItemTypeText, pad, regionContainingPoints } from "../util"
|
import { workItemTypeText, pad, regionContainingPoints } from "../util"
|
||||||
import { ensurePermission } from "../App"
|
import { ensurePermission } from "../App"
|
||||||
import { versionInfo } from "../version"
|
import { versionInfo } from "../version"
|
||||||
|
import { minGPSAccuracy } from "../config"
|
||||||
import pinImage from "./images/pin.png"
|
import pinImage from "./images/pin.png"
|
||||||
|
|
||||||
const minGPSAccuracy = 20
|
|
||||||
const neverAskForLocationPermissionKeyName = "NeverAskForLocationPermission"
|
const neverAskForLocationPermissionKeyName = "NeverAskForLocationPermission"
|
||||||
|
const neverAskForCameraKeyName = "NeverAskForCameraPermission"
|
||||||
|
|
||||||
export class Home extends React.Component {
|
export class Home extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -37,6 +38,7 @@ export class Home extends React.Component {
|
|||||||
longitudeDelta: 0.0922,
|
longitudeDelta: 0.0922,
|
||||||
},
|
},
|
||||||
positionInfo: null,
|
positionInfo: null,
|
||||||
|
allowCameraAccess: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ensurePermission(
|
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
|
api
|
||||||
.listWorkItemActivities()
|
.listWorkItemActivities()
|
||||||
.then((list) => {
|
.then((list) => {
|
||||||
|
|||||||
5
mobile/src/config.js
Normal file
5
mobile/src/config.js
Normal file
@@ -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
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export const localIPAddr = "192.168.1.175"
|
|
||||||
//export const defaultUser = "john@lyon-smith.org"
|
|
||||||
export const defaultUser = ""
|
|
||||||
Reference in New Issue
Block a user