Skip to content

Commit f17836d

Browse files
authored
Merge branch 'master' into master
2 parents 0537bc3 + 32260fa commit f17836d

File tree

34 files changed

+1010
-166
lines changed

34 files changed

+1010
-166
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
android/react-native-permissions.iml
22
android/build
3+
android/.idea
4+
npm-debug.log
5+
gradlew
6+
gradle-wrapper.properties
7+
gradle-wrapper.jar
8+
local.properties
9+
gradlew.bat
10+
android.iml

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Example

Example/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react-native"]
3+
}

Example/.flowconfig

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
24

3-
# We fork some components by platform.
4-
.*/*.android.js
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
57

6-
# Ignore templates with `@flow` in header
7-
.*/local-cli/generator.*
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
810

9-
# Ignore malformed json
10-
.*/node_modules/y18n/test/.*\.json
11+
; Ignore duplicate module providers
12+
; For RN Apps installed via npm, "Libraries" folder is inside
13+
; "node_modules/react-native" but in the source repo it is in the root
14+
.*/Libraries/react-native/React.js
15+
.*/Libraries/react-native/ReactNative.js
1116

1217
[include]
1318

@@ -19,23 +24,21 @@ flow/
1924
[options]
2025
module.system=haste
2126

22-
esproposal.class_static_fields=enable
23-
esproposal.class_instance_fields=enable
24-
2527
experimental.strict_type_args=true
2628

2729
munge_underscores=true
2830

29-
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
3031
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
3132

3233
suppress_type=$FlowIssue
3334
suppress_type=$FlowFixMe
3435
suppress_type=$FixMe
3536

36-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
37-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
37+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-7]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
38+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-7]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
3839
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
3940

41+
unsafe.enable_getters_and_setters=true
42+
4043
[version]
41-
^0.27.0
44+
^0.37.0

Example/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

Example/.gitignore

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,33 @@ DerivedData
2222
*.xcuserstate
2323
project.xcworkspace
2424

25-
# Android/IJ
25+
# Android/IntelliJ
2626
#
27-
*.iml
27+
build/
2828
.idea
2929
.gradle
3030
local.properties
31+
*.iml
3132

3233
# node.js
3334
#
3435
node_modules/
3536
npm-debug.log
37+
yarn-error.log
3638

3739
# BUCK
3840
buck-out/
3941
\.buckd/
4042
android/app/libs
41-
android/keystores/debug.keystore
43+
*.keystore
44+
45+
# fastlane
46+
#
47+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48+
# screenshots whenever they are needed.
49+
# For more information about the recommended setup visit:
50+
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
51+
52+
fastlane/report.xml
53+
fastlane/Preview.html
54+
fastlane/screenshots

Example/Example.js

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
View,
1313
Alert,
1414
AppState,
15+
Platform,
1516
} from 'react-native';
1617

1718
import Permissions from 'react-native-permissions'
@@ -42,11 +43,24 @@ export default class Example extends Component {
4243

4344
_updatePermissions(types) {
4445
Permissions.checkMultiplePermissions(types)
46+
.then(status => {
47+
if (this.state.isAlways) {
48+
return Permissions.getPermissionStatus('location', 'always')
49+
.then(location => ({...status, location}))
50+
}
51+
return status
52+
})
4553
.then(status => this.setState({ status }))
4654
}
4755

4856
_requestPermission(permission) {
49-
Permissions.requestPermission(permission)
57+
var options
58+
59+
if (permission == 'location') {
60+
options = this.state.isAlways ? 'always' : 'whenInUse'
61+
}
62+
63+
Permissions.requestPermission(permission, options)
5064
.then(res => {
5165
this.setState({
5266
status: {...this.state.status, [permission]: res}
@@ -64,17 +78,23 @@ export default class Example extends Component {
6478
}).catch(e => console.warn(e))
6579
}
6680

81+
_onLocationSwitchChange() {
82+
this.setState({ isAlways: !this.state.isAlways })
83+
this._updatePermissions(this.state.types)
84+
}
85+
6786
render() {
6887
return (
6988
<View style={styles.container}>
89+
7090
{this.state.types.map(p => (
7191
<TouchableHighlight
7292
style={[styles.button, styles[this.state.status[p]]]}
7393
key={p}
7494
onPress={this._requestPermission.bind(this, p)}>
7595
<View>
7696
<Text style={styles.text}>
77-
{p}
97+
{Platform.OS == 'ios' && p == 'location' ? `location ${this.state.isAlways ? 'always' : 'whenInUse'}` : p}
7898
</Text>
7999
<Text style={styles.subtext}>
80100
{this.state.status[p]}
@@ -83,13 +103,23 @@ export default class Example extends Component {
83103
</TouchableHighlight>
84104
)
85105
)}
86-
<TouchableHighlight
87-
style={styles.openSettings}
88-
onPress={Permissions.openSettings}>
89-
<Text style={styles.text}>Open settings</Text>
90-
</TouchableHighlight>
106+
<View style={styles.footer}>
107+
<TouchableHighlight
108+
style={styles['footer_'+Platform.OS]}
109+
onPress={this._onLocationSwitchChange.bind(this)}>
110+
<Text style={styles.text}>Toggle location type</Text>
111+
</TouchableHighlight>
91112

92-
<Text>Note: microphone permissions may not work on iOS simulator. Also, toggling permissions from the settings menu may cause the app to crash. This is normal on iOS. Google "ios crash permission change"</Text>
113+
<TouchableHighlight
114+
onPress={Permissions.openSettings}>
115+
<Text style={styles.text}>Open settings</Text>
116+
</TouchableHighlight>
117+
</View>
118+
119+
120+
<Text style={styles['footer_'+Platform.OS]}>
121+
Note: microphone permissions may not work on iOS simulator. Also, toggling permissions from the settings menu may cause the app to crash. This is normal on iOS. Google "ios crash permission change"
122+
</Text>
93123
</View>
94124
);
95125
}
@@ -130,8 +160,13 @@ const styles = StyleSheet.create({
130160
restricted: {
131161
backgroundColor: '#FFAB91'
132162
},
133-
openSettings: {
163+
footer: {
134164
padding: 10,
135-
alignSelf: 'flex-end',
165+
flexDirection: 'row',
166+
justifyContent: 'space-between',
167+
},
168+
footer_android: {
169+
height: 0,
170+
width: 0,
136171
}
137172
})

Example/__tests__/index.android.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'react-native';
2+
import React from 'react';
3+
import Index from '../index.android.js';
4+
5+
// Note: test renderer must be required after react-native.
6+
import renderer from 'react-test-renderer';
7+
8+
it('renders correctly', () => {
9+
const tree = renderer.create(
10+
<Index />
11+
);
12+
});

Example/__tests__/index.ios.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'react-native';
2+
import React from 'react';
3+
import Index from '../index.ios.js';
4+
5+
// Note: test renderer must be required after react-native.
6+
import renderer from 'react-test-renderer';
7+
8+
it('renders correctly', () => {
9+
const tree = renderer.create(
10+
<Index />
11+
);
12+
});

Example/android/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ android {
8888

8989
defaultConfig {
9090
applicationId "com.example"
91-
minSdkVersion 22
91+
minSdkVersion 21
9292
targetSdkVersion 23
9393
versionCode 1
9494
versionName "1.0"
@@ -135,6 +135,6 @@ dependencies {
135135
// Run this once to be able to run the application with BUCK
136136
// puts all compile dependencies into folder libs for BUCK to use
137137
task copyDownloadableDepsToLibs(type: Copy) {
138-
from configurations.compile
139-
into 'libs'
138+
from configurations.compile
139+
into 'libs'
140140
}

0 commit comments

Comments
 (0)