Skip to content

Commit 6b92e9a

Browse files
author
irgendeinich
committed
Update Android integration steps
1 parent 051ac33 commit 6b92e9a

File tree

3 files changed

+53
-54
lines changed

3 files changed

+53
-54
lines changed

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,9 @@ For a more detailed description of toolbar customizations, refer to our Customiz
305305
- Android SDK
306306
- Android Build Tools 23.0.1 (React Native)
307307
- Android Build Tools 28.0.3 (PSPDFKit module)
308-
- Android Gradle plugin >= 3.2.1
309-
- PSPDFKit >= 5.0.1
310-
- react-native for example app >= 0.59.2
311-
- react-native for Catalog app >= 0.57.8
308+
- Android Gradle plugin >= 3.4.1
309+
- PSPDFKit >= 5.4.2
310+
- react-native >= 0.60.4
312311

313312
#### Getting Started
314313

@@ -319,15 +318,12 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp
319318
3. Step into your newly created app folder: `cd YourApp`.
320319
4. Add `react-native-pspdfkit` module from GitHub: `yarn add github:PSPDFKit/react-native`.
321320
5. Install all the dependencies for the project: `yarn install`. (Because of a [bug](https://github.com/yarnpkg/yarn/issues/2165) you may need to clean `yarn`'s cache with `yarn cache clean` before.)
322-
6. Link module `react-native-pspdfkit`: `react-native link react-native-pspdfkit`.
323-
7. <a id="step-7"></a>Add PSPDFKit repository to `YourApp/android/build.gradle` so PSPDFKit library can be downloaded:
321+
6. <a id="step-7"></a>Add PSPDFKit repository to `YourApp/android/build.gradle` so PSPDFKit library can be downloaded:
324322

325323
```diff
326324
allprojects {
327325
repositories {
328326
mavenLocal()
329-
google()
330-
jcenter()
331327
+ maven {
332328
+ url 'https://customers.pspdfkit.com/maven/'
333329
+ credentials {
@@ -339,11 +335,18 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp
339335
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
340336
url "$rootDir/../node_modules/react-native/android"
341337
}
338+
maven {
339+
// Android JSC is installed from npm
340+
url("$rootDir/../node_modules/jsc-android/dist")
341+
}
342+
343+
google()
344+
jcenter()
342345
}
343346
}
344347
```
345348

346-
8. PSPDFKit targets modern platforms, so you'll have to set the `minSdkVersion` to 19. In `YourApp/android/build.gradle`:
349+
7. PSPDFKit targets modern platforms, so you'll have to set the `minSdkVersion` to 19. In `YourApp/android/build.gradle`:
347350

348351
```diff
349352
...
@@ -358,7 +361,7 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp
358361
...
359362
```
360363

361-
9. We will also need to enable MultiDex support. In `YourApp/android/app/build.gradle`:
364+
8. We will also need to enable MultiDex support. In `YourApp/android/app/build.gradle`:
362365

363366
```diff
364367
...
@@ -373,7 +376,7 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp
373376
...
374377
```
375378

376-
10. <a id="step-10"></a>Enter your PSPDFKit license key into `YourApp/android/app/src/main/AndroidManifest.xml` file:
379+
9. <a id="step-10"></a>Enter your PSPDFKit license key into `YourApp/android/app/src/main/AndroidManifest.xml` file:
377380

378381
```diff
379382
<application>
@@ -386,7 +389,7 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp
386389
</application>
387390
```
388391

389-
11. Set primary color. In `YourApp/android/app/src/main/res/values/styles.xml` replace
392+
10. Set primary color. In `YourApp/android/app/src/main/res/values/styles.xml` replace
390393

391394
```xml
392395
<!-- Customize your theme here. -->
@@ -398,16 +401,15 @@ with
398401
<item name="colorPrimary">#3C97C9</item>
399402
```
400403

401-
12. <a id="step-12"></a>Replace the default component from `YourApp/App.js` with a simple touch area to present a PDF document from the local device filesystem:
404+
11. <a id="step-12"></a>Replace the default component from `YourApp/App.js` with a simple touch area to present a PDF document from the local device filesystem:
402405

403406
```javascript
404407
import React, { Component } from "react";
405408
import {
406-
AppRegistry,
407409
StyleSheet,
408410
NativeModules,
409411
Text,
410-
TouchableHighlight,
412+
TouchableOpacity,
411413
View,
412414
PermissionsAndroid
413415
} from "react-native";
@@ -431,9 +433,9 @@ export default class YourApp extends Component<{}> {
431433
return (
432434
<View style={styles.container}>
433435
<Text>{PSPDFKit.versionString}</Text>
434-
<TouchableHighlight onPress={this._onPressButton}>
436+
<TouchableOpacity onPress={this._onPressButton}>
435437
<Text style={styles.text}>Tap to Open Document</Text>
436-
</TouchableHighlight>
438+
</TouchableOpacity>
437439
</View>
438440
);
439441
}
@@ -470,13 +472,13 @@ const styles = StyleSheet.create({
470472
});
471473
```
472474

473-
13. Before launching the app you need to copy a PDF document onto your development device or emulator.
475+
12. Before launching the app you need to copy a PDF document onto your development device or emulator.
474476

475477
```bash
476478
adb push /path/to/your/document.pdf /sdcard/document.pdf
477479
```
478480

479-
14. Your app is now ready to launch. From `YourApp` directory run `react-native run-android`.
481+
13. Your app is now ready to launch. From `YourApp` directory run `react-native run-android`.
480482

481483
```bash
482484
react-native run-android

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class PSPDFKitView extends React.Component {
8585
_onDataReturned = event => {
8686
let { requestId, result, error } = event.nativeEvent;
8787
let promise = this._requestMap[requestId];
88-
if (result) {
88+
if (result != undefined) {
8989
promise.resolve(result);
9090
} else {
9191
promise.reject(error);

samples/Catalog/Catalog.android.js

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@ import {
2020
PermissionsAndroid,
2121
Dimensions
2222
} from "react-native";
23-
import { StackNavigator, NavigationEvents, createStackNavigator, createAppContainer } from "react-navigation";
23+
import { createStackNavigator, createAppContainer } from "react-navigation";
2424

2525
import QRCodeScanner from "react-native-qrcode-scanner";
2626

2727
import PSPDFKitView from "react-native-pspdfkit";
2828

29-
// React Native bug that hopefully will be fixed soon:
30-
// https://github.com/facebook/react-native/issues/18868
31-
import { YellowBox } from "react-native";
32-
YellowBox.ignoreWarnings(["Warning: isMounted(...) is deprecated"]);
33-
3429
const PSPDFKit = NativeModules.PSPDFKit;
3530
const RNFS = require("react-native-fs");
3631

@@ -617,7 +612,7 @@ class PdfViewInstantJsonScreen extends Component<{}> {
617612
createdAt: "2018-07-03T13:53:03Z",
618613
isDrawnNaturally: false,
619614
lineWidth: 5,
620-
name: 'my annotation',
615+
name: "my annotation",
621616
lines: {
622617
intensities: [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5]],
623618
points: [
@@ -803,34 +798,36 @@ class InstantExampleScreen extends Component<{}> {
803798
}
804799
}
805800

806-
export default createAppContainer(createStackNavigator(
807-
{
808-
Catalog: {
809-
screen: CatalogScreen
810-
},
811-
PdfView: {
812-
screen: PdfViewScreen
813-
},
814-
PdfViewSplitScreen: {
815-
screen: PdfViewSplitScreen
816-
},
817-
PdfViewListenersScreen: {
818-
screen: PdfViewListenersScreen
819-
},
820-
PdfViewInstantJsonScreen: {
821-
screen: PdfViewInstantJsonScreen
822-
},
823-
PdfViewFormFillingScreen: {
824-
screen: PdfViewFormFillingScreen
801+
export default createAppContainer(
802+
createStackNavigator(
803+
{
804+
Catalog: {
805+
screen: CatalogScreen
806+
},
807+
PdfView: {
808+
screen: PdfViewScreen
809+
},
810+
PdfViewSplitScreen: {
811+
screen: PdfViewSplitScreen
812+
},
813+
PdfViewListenersScreen: {
814+
screen: PdfViewListenersScreen
815+
},
816+
PdfViewInstantJsonScreen: {
817+
screen: PdfViewInstantJsonScreen
818+
},
819+
PdfViewFormFillingScreen: {
820+
screen: PdfViewFormFillingScreen
821+
},
822+
InstantExampleScreen: {
823+
screen: InstantExampleScreen
824+
}
825825
},
826-
InstantExampleScreen: {
827-
screen: InstantExampleScreen
826+
{
827+
initialRouteName: "Catalog"
828828
}
829-
},
830-
{
831-
initialRouteName: "Catalog"
832-
}
833-
));
829+
)
830+
);
834831

835832
var styles = StyleSheet.create({
836833
separator: {
@@ -883,4 +880,4 @@ var styles = StyleSheet.create({
883880
fontWeight: "500",
884881
color: "#000"
885882
}
886-
});
883+
});

0 commit comments

Comments
 (0)