Skip to content

Commit

Permalink
Update to PSPDFKit 6.5 for Android (#373)
Browse files Browse the repository at this point in the history
* Update to PSPDFKit 6.5 for Android
* Remove Maven password requirement
* Bump version to 1.29.7
  • Loading branch information
davidschreiber authored Jul 15, 2020
2 parents bb2dbe9 + 840756e commit a63f88f
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 106 deletions.
59 changes: 9 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,35 +391,7 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp
3. Step into your newly created app folder: `cd YourApp`.
4. Add `react-native-pspdfkit` module from GitHub: `yarn add github:PSPDFKit/react-native`.
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.)
6. <a id="step-7"></a>Add PSPDFKit repository to `YourApp/android/build.gradle` so PSPDFKit library can be downloaded:

```diff
allprojects {
repositories {
mavenLocal()
+ maven {
+ url 'https://customers.pspdfkit.com/maven/'
+ credentials {
+ username 'pspdfkit'
+ password 'YOUR_MAVEN_KEY_GOES_HERE'
+ }
+ }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}

google()
jcenter()
}
}
```

7. PSPDFKit targets modern platforms, so you'll have to set the `minSdkVersion` to 19. In `YourApp/android/build.gradle`:
6. PSPDFKit targets modern platforms, so you'll have to set the `minSdkVersion` to 19. In `YourApp/android/build.gradle`:

```diff
...
Expand All @@ -434,7 +406,7 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp
...
```

8. We will also need to enable MultiDex support. In `YourApp/android/app/build.gradle`:
7. We will also need to enable MultiDex support. In `YourApp/android/app/build.gradle`:

```diff
...
Expand All @@ -449,7 +421,7 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp
...
```

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

```diff
<application>
Expand All @@ -462,7 +434,7 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp
</application>
```

10. Set primary color. In `YourApp/android/app/src/main/res/values/styles.xml` replace
9. Set primary color. In `YourApp/android/app/src/main/res/values/styles.xml` replace

```xml
<!-- Customize your theme here. -->
Expand All @@ -474,7 +446,7 @@ with
<item name="colorPrimary">#3C97C9</item>
```

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:
10. <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:

```javascript
import React, { Component } from "react";
Expand Down Expand Up @@ -545,13 +517,13 @@ const styles = StyleSheet.create({
});
```

12. Before launching the app you need to copy a PDF document onto your development device or emulator.
11. Before launching the app you need to copy a PDF document onto your development device or emulator.

```bash
adb push /path/to/your/document.pdf /sdcard/document.pdf
```

13. Your app is now ready to launch. From `YourApp` directory run `react-native run-android`.
12. Your app is now ready to launch. From `YourApp` directory run `react-native run-android`.

```bash
react-native run-android
Expand All @@ -561,20 +533,7 @@ const styles = StyleSheet.create({

1. Clone the repository. `git clone https://github.com/PSPDFKit/react-native.git`.
2. Install dependencies: run `yarn install` from `samples/Catalog` directory. (Because of a [bug](https://github.com/yarnpkg/yarn/issues/2165) you may need to clean `yarn`'s cache with `yarn cache clean` before.)
3. Add your customer portal password to `samples/Catalog/android/build.gradle`:
```groovy
maven {
url 'https://customers.pspdfkit.com/maven/'
credentials {
username 'pspdfkit'
password 'YOUR_MAVEN_PASSWORD_GOES_HERE'
}
}
```
4. Update license key in `samples/Catalog/android/app/src/main/AndroidManifest.xml`:
3. Update license key in `samples/Catalog/android/app/src/main/AndroidManifest.xml`:
```xml
<application>
Expand All @@ -587,7 +546,7 @@ const styles = StyleSheet.create({
</application>
```
5. Catalog app is now ready to launch. From `samples/Catalog` directory run `react-native run-android`.
4. Catalog app is now ready to launch. From `samples/Catalog` directory run `react-native run-android`.
#### Running the Native Catalog
Expand Down
32 changes: 4 additions & 28 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Contains gradle configuration constants
*/
ext {
PSPDFKIT_VERSION = '6.4.0'
PSPDFKIT_VERSION = '6.5.0'
}

buildscript {
Expand All @@ -11,6 +11,9 @@ buildscript {
maven {
url 'https://maven.google.com'
}
maven {
url 'https://customers.pspdfkit.com/maven'
}
}

dependencies {
Expand Down Expand Up @@ -41,33 +44,6 @@ android {
}
}

def demoVersion = false;
project.repositories.each {
if (it instanceof MavenArtifactRepository) {
if ("$it.url".contains("customers.pspdfkit.com/maven")) {
// Bug: https://github.com/gradle/gradle/issues/1230
def username = it.credentials.username
def password = it.credentials.password

if (username == "pspdfkit") {
if (password != null && password.startsWith("TRIAL")) {
demoVersion = true;
} else if (password != null && password == "YOUR_MAVEN_PASSWORD_GOES_HERE") {
println "#######################################################################################################"
println "### Credentials error: edit 'YourApp/android/build.gradle' file and modify PSPDFKit maven password. ###"
println "#######################################################################################################"
}
}
}
}
}

if (demoVersion) {
println "##############################"
println "### PSPDFKit Demo Version. ###"
println "##############################"
}

dependencies {
api("com.pspdfkit:pspdfkit:${PSPDFKIT_VERSION}") {
exclude group: 'com.google.auto.value', module: 'auto-value'
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-pspdfkit",
"version": "1.29.6",
"version": "1.29.7",
"description": "A React Native module for the PSPDFKit library.",
"keywords": [
"react native",
Expand Down
5 changes: 0 additions & 5 deletions samples/Catalog/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ allprojects {
jcenter()
maven {
url 'https://customers.pspdfkit.com/maven/'

credentials {
username 'pspdfkit'
password 'YOUR_MAVEN_KEY_GOES_HERE'
}
}
maven {
// Android JSC is installed from npm
Expand Down
2 changes: 1 addition & 1 deletion samples/Catalog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Catalog",
"version": "1.29.6",
"version": "1.29.7",
"private": true,
"scripts": {
"start": "react-native start",
Expand Down
15 changes: 1 addition & 14 deletions samples/NativeCatalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,7 @@ This second, Android only, Catalog example serves to show you how you can levera

1. Clone the repository. `git clone https://github.com/PSPDFKit/react-native.git`.
2. Install dependencies: run `yarn install` from `samples/NativeCatalog` directory.
3. Add your customer portal password to `samples/NativeCatalog/android/build.gradle`:

```groovy
maven {
url 'https://customers.pspdfkit.com/maven/'
credentials {
username 'pspdfkit'
password 'YOUR_MAVEN_PASSWORD_GOES_HERE'
}
}
```

4. The Native Catalog app is now ready to launch. From `samples/NativeCatalog` directory run `react-native run-android`.
3. The Native Catalog app is now ready to launch. From `samples/NativeCatalog` directory run `react-native run-android`.

### Running this Sample on iOS

Expand Down
5 changes: 0 additions & 5 deletions samples/NativeCatalog/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ allprojects {
jcenter()
maven {
url 'https://customers.pspdfkit.com/maven/'

credentials {
username 'pspdfkit'
password 'YOUR_MAVEN_KEY_GOES_HERE'
}
}
maven { url 'https://jitpack.io' }
}
Expand Down
2 changes: 1 addition & 1 deletion samples/NativeCatalog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NativeCatalog",
"version": "1.29.6",
"version": "1.29.7",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down

0 comments on commit a63f88f

Please sign in to comment.