From 936dbe0a179afdd46b9dc8e9c1ab973438f5980a Mon Sep 17 00:00:00 2001 From: irgendeinich Date: Thu, 8 Nov 2018 15:32:23 +0100 Subject: [PATCH 1/3] Update react wrapper to PSPDFKit 5.0 --- README.md | 10 +++--- android/build.gradle | 17 +++++++--- .../main/java/com/pspdfkit/views/PdfView.java | 8 +++-- android/src/main/res/values/attrs.xml | 4 +++ samples/Catalog/android/app/build.gradle | 10 ++++-- .../app/src/main/res/values/colors.xml | 1 + .../app/src/main/res/values/styles.xml | 31 +------------------ samples/Catalog/android/build.gradle | 5 ++- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 9 files changed, 42 insertions(+), 46 deletions(-) create mode 100644 android/src/main/res/values/attrs.xml diff --git a/README.md b/README.md index 0cc4c927..91b26396 100644 --- a/README.md +++ b/README.md @@ -247,8 +247,8 @@ editableAnnotationTypes: ["Ink", "Highlight"]; - Android SDK - Android Build Tools 23.0.1 (React Native) -- Android Build Tools 26.0.1 (PSPDFKit module) -- PSPDFKit >= 4.6.0 +- Android Build Tools 28.0.3 (PSPDFKit module) +- PSPDFKit >= 5.0.0 - react-native >= 0.55.4 #### Getting Started @@ -287,15 +287,15 @@ Let's create a simple app that integrates PSPDFKit and uses the react-native-psp } ``` -8. PSPDFKit targets modern platforms, so you'll have to update `compileSdkVersion` and `targetSdkVersion` to at least API 26 and enable MultiDex. In `YourApp/android/app/build.gradle` (note **five** places to edit): +8. PSPDFKit targets modern platforms, so you'll have to update `compileSdkVersion` to at least API 28 and `targetSdkVersion` to at least API 26 and enable MultiDex. In `YourApp/android/app/build.gradle` (note **five** places to edit): ```diff ... android { - compileSdkVersion 23 - + compileSdkVersion 26 + + compileSdkVersion 28 - buildToolsVersion "23.0.1" - + buildToolsVersion "26.0.1" + + buildToolsVersion "28.0.3" defaultConfig { applicationId "com.yourapp" diff --git a/android/build.gradle b/android/build.gradle index 54b8a024..9b4759d4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,24 +2,27 @@ * Contains gradle configuration constants */ ext { - PSPDFKIT_VERSION = '4.8.1' + PSPDFKIT_VERSION = '5.0.0' } buildscript { repositories { jcenter() + maven { + url 'https://maven.google.com' + } } dependencies { - classpath 'com.android.tools.build:gradle:2.3.1' + classpath 'com.android.tools.build:gradle:3.2.1' } } apply plugin: 'com.android.library' android { - compileSdkVersion 26 - buildToolsVersion "26.0.1" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { minSdkVersion 19 @@ -27,6 +30,12 @@ android { versionCode 1 versionName "1.0" } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + lintOptions { abortOnError false } diff --git a/android/src/main/java/com/pspdfkit/views/PdfView.java b/android/src/main/java/com/pspdfkit/views/PdfView.java index 4842a090..5b49c26c 100644 --- a/android/src/main/java/com/pspdfkit/views/PdfView.java +++ b/android/src/main/java/com/pspdfkit/views/PdfView.java @@ -18,6 +18,7 @@ import com.pspdfkit.configuration.activity.PdfActivityConfiguration; import com.pspdfkit.configuration.activity.ThumbnailBarMode; import com.pspdfkit.document.PdfDocument; +import com.pspdfkit.document.PdfDocumentLoader; import com.pspdfkit.document.formatters.DocumentJsonFormatter; import com.pspdfkit.document.providers.DataProvider; import com.pspdfkit.forms.ChoiceFormElement; @@ -91,7 +92,8 @@ public class PdfView extends FrameLayout { @Nullable private PdfFragment fragment; private BehaviorSubject fragmentGetter = BehaviorSubject.create(); - @Nullable private PdfTextSelectionPopupToolbar textSelectionPopupToolbar; + @Nullable + private PdfTextSelectionPopupToolbar textSelectionPopupToolbar; public PdfView(@NonNull Context context) { super(context); @@ -173,7 +175,7 @@ public void setDocument(String document) { documentOpeningDisposable.dispose(); } updateState(); - documentOpeningDisposable = PdfDocument.openDocumentAsync(getContext(), Uri.parse(document)) + documentOpeningDisposable = PdfDocumentLoader.openDocumentAsync(getContext(), Uri.parse(document)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer() { @@ -240,7 +242,7 @@ private void prepareFragment(final PdfFragment pdfFragment) { public void onDocumentLoaded(@NonNull PdfDocument document) { manuallyLayoutChildren(); pdfFragment.setPageIndex(pageIndex, false); - pdfThumbnailBar.setDocument(document, configuration.getConfiguration(), pdfFragment.getEventBus()); + pdfThumbnailBar.setDocument(document, configuration.getConfiguration()); updateState(); } diff --git a/android/src/main/res/values/attrs.xml b/android/src/main/res/values/attrs.xml new file mode 100644 index 00000000..138b2671 --- /dev/null +++ b/android/src/main/res/values/attrs.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/samples/Catalog/android/app/build.gradle b/samples/Catalog/android/app/build.gradle index 29e163a9..a6dc4b83 100644 --- a/samples/Catalog/android/app/build.gradle +++ b/samples/Catalog/android/app/build.gradle @@ -88,8 +88,8 @@ def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false android { - compileSdkVersion 26 - buildToolsVersion "26.0.1" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { applicationId "com.pspdfkit.react.catalog" @@ -103,6 +103,12 @@ android { } testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + splits { abi { reset() diff --git a/samples/Catalog/android/app/src/main/res/values/colors.xml b/samples/Catalog/android/app/src/main/res/values/colors.xml index d7412df5..581bfc03 100644 --- a/samples/Catalog/android/app/src/main/res/values/colors.xml +++ b/samples/Catalog/android/app/src/main/res/values/colors.xml @@ -15,5 +15,6 @@ #3C97C9 #306F8B + #E0E0E0 \ No newline at end of file diff --git a/samples/Catalog/android/app/src/main/res/values/styles.xml b/samples/Catalog/android/app/src/main/res/values/styles.xml index a24fdf0a..0e06f067 100644 --- a/samples/Catalog/android/app/src/main/res/values/styles.xml +++ b/samples/Catalog/android/app/src/main/res/values/styles.xml @@ -22,36 +22,7 @@ true true - @style/pspdf__AlertDialog - @color/pspdf__color_error - - @color/pspdf__color_gray_light - @color/pspdf_color_dark - @color/pspdf_color - @style/pspdf__ActionBarIcons - @style/pspdf__OutlineView - @style/pspdf__SearchViewInline - @style/pspdf__SearchViewModular - @style/pspdf__ThumbnailBar - @style/pspdf__ThumbnailGrid - @style/pspdf__SearchResultHighlighter - @style/pspdf__Annotation - @style/pspdf__AnnotationSelection - @style/pspdf__AnnotationCreationToolbarIcons - @style/pspdf__AnnotationEditingToolbarIcons - @style/pspdf__TextSelectionToolbarIcons - @style/pspdf__DocumentEditingToolbarIcons - @style/pspdf__ToolbarCoordinatorLayout - @style/pspdf__SignatureLayout - @style/pspdf__PasswordView - @style/pspdf__PropertyInspector - @style/pspdf__ActionMenu - @style/pspdf__SharingDialog - @style/pspdf__StampPicker - @style/pspdf__NewPageDialog - @style/pspdf__ModalDialog - @style/pspdf__FormSelection - @style/pspdf__FormEditingBar + @color/color_gray_light