Skip to content

Commit

Permalink
Update Android example to use the latest library versions (Formidable…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kadi Kraman authored Jun 4, 2019
1 parent 06220a3 commit 7627363
Show file tree
Hide file tree
Showing 12 changed files with 1,226 additions and 1,091 deletions.
3 changes: 1 addition & 2 deletions Example/AndroidExample/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/react-native/flow-github/

[options]
emoji=true
Expand Down Expand Up @@ -67,4 +66,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[version]
^0.86.0
^0.92.0
22 changes: 12 additions & 10 deletions Example/AndroidExample/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ type State = {
hasLoggedInOnce: boolean,
accessToken: ?string,
accessTokenExpirationDate: ?string,
refreshToken: ?string
refreshToken: ?string,
};

const config = {
issuer: 'https://demo.identityserver.io',
clientId: 'native.code',
redirectUrl: 'io.identityserver.demo:/oauthredirect',
additionalParameters: {},
additionalParameters: {
prompt: 'login'
},
scopes: ['openid', 'profile', 'email', 'offline_access']

// serviceConfiguration: {
Expand All @@ -32,7 +34,7 @@ export default class App extends Component<{}, State> {
hasLoggedInOnce: false,
accessToken: '',
accessTokenExpirationDate: '',
refreshToken: ''
refreshToken: '',
};

animateState(nextState: $Shape<State>, delay: number = 0) {
Expand All @@ -54,7 +56,7 @@ export default class App extends Component<{}, State> {
accessToken: authState.accessToken,
accessTokenExpirationDate: authState.accessTokenExpirationDate,
refreshToken: authState.refreshToken,
scopes: authState.scopes
scopes: authState.scopes,
},
500
);
Expand All @@ -66,14 +68,14 @@ export default class App extends Component<{}, State> {
refresh = async () => {
try {
const authState = await refresh(config, {
refreshToken: this.state.refreshToken
refreshToken: this.state.refreshToken,
});

this.animateState({
accessToken: authState.accessToken || this.state.accessToken,
accessTokenExpirationDate:
authState.accessTokenExpirationDate || this.state.accessTokenExpirationDate,
refreshToken: authState.refreshToken || this.state.refreshToken
refreshToken: authState.refreshToken || this.state.refreshToken,
});
} catch (error) {
Alert.alert('Failed to refresh token', error.message);
Expand All @@ -84,12 +86,12 @@ export default class App extends Component<{}, State> {
try {
await revoke(config, {
tokenToRevoke: this.state.accessToken,
sendClientId: true
sendClientId: true,
});
this.animateState({
accessToken: '',
accessTokenExpirationDate: '',
refreshToken: ''
refreshToken: '',
});
} catch (error) {
Alert.alert('Failed to revoke token', error.message);
Expand All @@ -112,8 +114,8 @@ export default class App extends Component<{}, State> {
<Form.Value>{state.scopes.join(', ')}</Form.Value>
</Form>
) : (
<Heading>{state.hasLoggedInOnce ? 'Goodbye.' : 'Hello, stranger.'}</Heading>
)}
<Heading>{state.hasLoggedInOnce ? 'Goodbye.' : 'Hello, stranger.'}</Heading>
)}

<ButtonContainer>
{!state.accessToken ? (
Expand Down
10 changes: 7 additions & 3 deletions Example/AndroidExample/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.rnappauthandroidexample"
Expand All @@ -112,7 +116,7 @@ android {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
Expand All @@ -126,7 +130,7 @@ android {
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package="com.rnappauthandroidexample">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application
android:name=".MainApplication"
Expand Down
12 changes: 3 additions & 9 deletions Example/AndroidExample/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

buildscript {
ext {
buildToolsVersion = "28.0.2"
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -31,9 +31,3 @@ allprojects {
}
}
}


task wrapper(type: Wrapper) {
gradleVersion = '4.7'
distributionUrl = distributionUrl.replace("bin", "all")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
4 changes: 2 additions & 2 deletions Example/AndroidExample/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ["module:metro-react-native-babel-preset"]
}
presets: ['module:metro-react-native-babel-preset'],
};
1 change: 0 additions & 1 deletion Example/AndroidExample/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @format
* @lint-ignore-every XPLATJSCOPYRIGHT1
*/

import {AppRegistry} from 'react-native';
Expand Down
17 changes: 17 additions & 0 deletions Example/AndroidExample/metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/

module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
19 changes: 10 additions & 9 deletions Example/AndroidExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
"test": "jest"
},
"dependencies": {
"react": "16.6.3",
"react-native": "0.58.6",
"react-native-app-auth": "4.1.1",
"styled-components": "^4.1.3"
"react": "16.8.3",
"react-native": "0.59.8",
"react-native-app-auth": "^4.4.0",
"styled-components": "^4.2.1"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "24.3.0",
"jest": "24.3.0",
"metro-react-native-babel-preset": "0.53.0",
"react-test-renderer": "16.6.3"
"@babel/core": "^7.4.5",
"@babel/runtime": "^7.4.5",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.54.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
Expand Down
Loading

0 comments on commit 7627363

Please sign in to comment.