From 9e02e398e748535ec51696d4b578a8056aca96ef Mon Sep 17 00:00:00 2001 From: Jesper Lekland Date: Thu, 16 Nov 2017 21:36:02 +0100 Subject: [PATCH] Fix example Fix android Generalize android permissions (might support most permissions in the future) --- App.js | 57 --------------- __tests__/App.js | 2 +- android/app/build.gradle | 6 +- android/app/src/main/AndroidManifest.xml | 1 + example.js | 43 ++++++++++++ index.js | 2 +- package.json | 1 + src/index.js | 12 +++- src/location/location-hoc/index.android.js | 6 +- src/location/location-hoc/index.ios.js | 11 +-- src/location/permission.android.js | 69 ++---------------- src/location/permission.ios.js | 70 +++++++++---------- src/notification/notification-hoc.js | 3 +- src/notification/permission.js | 19 ++--- src/permissions-android.js | 63 +++++++++++++++++ src/util/async-storage.js | 48 +++++++++++++ src/{util.js => util/index.js} | 0 .../constants.js => util/results.js} | 6 +- yarn.lock | 4 ++ 19 files changed, 238 insertions(+), 185 deletions(-) delete mode 100644 App.js create mode 100644 example.js create mode 100644 src/permissions-android.js create mode 100644 src/util/async-storage.js rename src/{util.js => util/index.js} (100%) rename src/{location/constants.js => util/results.js} (68%) diff --git a/App.js b/App.js deleted file mode 100644 index d4ae45c..0000000 --- a/App.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Sample React Native App - * https://github.com/facebook/react-native - * @flow - */ - -import React, { Component } from 'react'; -import { - Platform, - StyleSheet, - Text, - View -} from 'react-native'; - -const instructions = Platform.select({ - ios: 'Press Cmd+R to reload,\n' + - 'Cmd+D or shake for dev menu', - android: 'Double tap R on your keyboard to reload,\n' + - 'Shake or press menu button for dev menu', -}); - -export default class App extends Component<{}> { - render() { - return ( - - - Welcome to React Native! - - - To get started, edit App.js - - - {instructions} - - - ); - } -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#F5FCFF', - }, - welcome: { - fontSize: 20, - textAlign: 'center', - margin: 10, - }, - instructions: { - textAlign: 'center', - color: '#333333', - marginBottom: 5, - }, -}); diff --git a/__tests__/App.js b/__tests__/App.js index d0b9ee3..ad85ac0 100644 --- a/__tests__/App.js +++ b/__tests__/App.js @@ -1,6 +1,6 @@ import 'react-native'; import React from 'react'; -import App from '../App'; +import App from '../example'; // Note: test renderer must be required after react-native. import renderer from 'react-test-renderer'; diff --git a/android/app/build.gradle b/android/app/build.gradle index 59074bf..7646c11 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -94,13 +94,13 @@ def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" + compileSdkVersion 25 + buildToolsVersion "25.0.2" defaultConfig { applicationId "com.rnpermissions" minSdkVersion 16 - targetSdkVersion 22 + targetSdkVersion 23 versionCode 1 versionName "1.0" ndk { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index e668b04..5c99f4b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ + + + { 'havePermission: ' + locationPermission } + + + { test } + +