-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4921 from hippware/4828-debug-options-screen
4828 debug options screen
- Loading branch information
Showing
9 changed files
with
124 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react' | ||
import {observer} from 'mobx-react' | ||
import {TouchableOpacity, View} from 'react-native' | ||
import {RText, Switch} from './common' | ||
import {colors} from '../constants' | ||
import Screen from './Screen' | ||
import {useLocationStore, useWocky} from 'src/utils/injectors' | ||
|
||
const DebugOptionsScreen = observer(() => { | ||
const {emailLog, setLogVerbose} = useLocationStore() | ||
const {profile, userFullAudit} = useWocky() | ||
|
||
return profile ? ( | ||
<Screen style={{flex: 1, paddingVertical: 10}}> | ||
<View | ||
style={{ | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
borderBottomWidth: 1, | ||
borderColor: colors.DARK_GREY, | ||
paddingVertical: 20, | ||
paddingHorizontal: 30, | ||
}} | ||
> | ||
<RText size={16} color={colors.DARK_PURPLE}> | ||
Enable Logging | ||
</RText> | ||
<Switch | ||
isOn={!!profile.fullAudit} | ||
onColor={colors.PINK} | ||
offColor={colors.GREY} | ||
onToggle={value => { | ||
userFullAudit(value).then(_successful => { | ||
setLogVerbose(value) | ||
profile.setFullAudit(value) | ||
}) | ||
}} | ||
/> | ||
</View> | ||
{!!profile.fullAudit && ( | ||
<View | ||
style={{ | ||
marginTop: 20, | ||
alignItems: 'center', | ||
}} | ||
> | ||
<TouchableOpacity | ||
onPress={() => emailLog()} | ||
style={{ | ||
borderWidth: 1, | ||
borderRadius: 12, | ||
borderColor: colors.PINK, | ||
padding: 10, | ||
width: 225, | ||
}} | ||
> | ||
<RText | ||
size={16} | ||
color={colors.PINK} | ||
style={{ | ||
textAlign: 'center', | ||
}} | ||
> | ||
Email log | ||
</RText> | ||
</TouchableOpacity> | ||
</View> | ||
)} | ||
</Screen> | ||
) : null | ||
}) | ||
|
||
export default DebugOptionsScreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,10 +114,6 @@ const LocationStore = types | |
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, | ||
enableHeadless: true, | ||
foregroundService: true, // android only | ||
logLevel: | ||
__DEV__ || settings.configurableLocationSettings | ||
? BackgroundGeolocation.LOG_LEVEL_VERBOSE | ||
: BackgroundGeolocation.LOG_LEVEL_OFF, | ||
maxRecordsToPersist: 20, | ||
notification: { | ||
// android only | ||
|
@@ -235,7 +231,7 @@ const LocationStore = types | |
: Promise.reject(new Error('No uploadUrl')) | ||
} | ||
|
||
async function emailLog(email) { | ||
async function emailLog(email = '[email protected]') { | ||
// emailLog doesn't work in iOS simulator so fetch and dump instead | ||
if (await DeviceInfo.isEmulator()) { | ||
log(prefix, await BackgroundGeolocation.logger.getLog()) | ||
|
@@ -244,6 +240,14 @@ const LocationStore = types | |
} | ||
} | ||
|
||
function setLogVerbose(verbose: boolean) { | ||
return BackgroundGeolocation.setConfig({ | ||
logLevel: verbose | ||
? BackgroundGeolocation.LOG_LEVEL_VERBOSE | ||
: BackgroundGeolocation.LOG_LEVEL_OFF, | ||
}) | ||
} | ||
|
||
return { | ||
refreshCredentials, | ||
invalidateCredentials, | ||
|
@@ -253,6 +257,7 @@ const LocationStore = types | |
stopStandaloneGeolocation, | ||
uploadLog, | ||
emailLog, | ||
setLogVerbose, | ||
} | ||
}) | ||
.actions(self => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters