Skip to content

Commit 9e5cd12

Browse files
committed
merged in upstream
2 parents ec97809 + 0af1a22 commit 9e5cd12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1241
-216
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: 51 additions & 11 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'
@@ -40,13 +41,31 @@ export default class Example extends Component {
4041
}
4142
}
4243

44+
_openSettings() {
45+
return Permissions.openSettings()
46+
.then(() => alert('back to app!!'))
47+
}
48+
4349
_updatePermissions(types) {
4450
Permissions.checkMultiplePermissions(types)
51+
.then(status => {
52+
if (this.state.isAlways) {
53+
return Permissions.getPermissionStatus('location', 'always')
54+
.then(location => ({...status, location}))
55+
}
56+
return status
57+
})
4558
.then(status => this.setState({ status }))
4659
}
4760

4861
_requestPermission(permission) {
49-
Permissions.requestPermission(permission)
62+
var options
63+
64+
if (permission == 'location') {
65+
options = this.state.isAlways ? 'always' : 'whenInUse'
66+
}
67+
68+
Permissions.requestPermission(permission, options)
5069
.then(res => {
5170
this.setState({
5271
status: {...this.state.status, [permission]: res}
@@ -57,24 +76,30 @@ export default class Example extends Component {
5776
"There was a problem getting your permission. Please enable it from settings.",
5877
[
5978
{text: 'Cancel', style: 'cancel'},
60-
{text: 'Open Settings', onPress: Permissions.openSettings },
79+
{text: 'Open Settings', onPress: this._openSettings.bind(this) },
6180
]
6281
)
6382
}
6483
}).catch(e => console.warn(e))
6584
}
6685

86+
_onLocationSwitchChange() {
87+
this.setState({ isAlways: !this.state.isAlways })
88+
this._updatePermissions(this.state.types)
89+
}
90+
6791
render() {
6892
return (
6993
<View style={styles.container}>
94+
7095
{this.state.types.map(p => (
7196
<TouchableHighlight
7297
style={[styles.button, styles[this.state.status[p]]]}
7398
key={p}
7499
onPress={this._requestPermission.bind(this, p)}>
75100
<View>
76101
<Text style={styles.text}>
77-
{p}
102+
{Platform.OS == 'ios' && p == 'location' ? `location ${this.state.isAlways ? 'always' : 'whenInUse'}` : p}
78103
</Text>
79104
<Text style={styles.subtext}>
80105
{this.state.status[p]}
@@ -83,13 +108,23 @@ export default class Example extends Component {
83108
</TouchableHighlight>
84109
)
85110
)}
86-
<TouchableHighlight
87-
style={styles.openSettings}
88-
onPress={Permissions.openSettings}>
89-
<Text style={styles.text}>Open settings</Text>
90-
</TouchableHighlight>
111+
<View style={styles.footer}>
112+
<TouchableHighlight
113+
style={styles['footer_'+Platform.OS]}
114+
onPress={this._onLocationSwitchChange.bind(this)}>
115+
<Text style={styles.text}>Toggle location type</Text>
116+
</TouchableHighlight>
117+
118+
<TouchableHighlight
119+
onPress={this._openSettings.bind(this)}>
120+
<Text style={styles.text}>Open settings</Text>
121+
</TouchableHighlight>
122+
</View>
91123

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>
124+
125+
<Text style={styles['footer_'+Platform.OS]}>
126+
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"
127+
</Text>
93128
</View>
94129
);
95130
}
@@ -130,8 +165,13 @@ const styles = StyleSheet.create({
130165
restricted: {
131166
backgroundColor: '#FFAB91'
132167
},
133-
openSettings: {
168+
footer: {
134169
padding: 10,
135-
alignSelf: 'flex-end',
170+
flexDirection: 'row',
171+
justifyContent: 'space-between',
172+
},
173+
footer_android: {
174+
height: 0,
175+
width: 0,
136176
}
137177
})

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)