Browse Source

compdfkit(rn) - 解决及时测试方式问题

liuxiaolong 11 months ago
parent
commit
a7340752c3

+ 3 - 3
android/build.gradle

@@ -83,8 +83,8 @@ dependencies {
   // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
   //noinspection GradleDynamicVersion
   implementation "com.facebook.react:react-native:+"
-  api "com.compdf:compdfkit:1.13.0"
-  api "com.compdf:compdfkit-ui:1.13.0"
-  api "com.compdf:compdfkit-tools:1.13.0"
+  api "com.compdf:compdfkit:2.0.0"
+  api "com.compdf:compdfkit-ui:2.0.0"
+  api "com.compdf:compdfkit-tools:2.0.0"
 }
 

+ 24 - 0
android/src/main/java/com/compdfkitpdf/reactnative/CompdfkitPdfModule.java

@@ -18,6 +18,9 @@ import com.compdfkit.core.document.CPDFSdk;
 import com.compdfkit.tools.common.pdf.CPDFConfigurationUtils;
 import com.compdfkit.tools.common.pdf.CPDFDocumentActivity;
 import com.compdfkit.tools.common.pdf.config.CPDFConfiguration;
+import com.compdfkit.tools.common.utils.CLog;
+import com.facebook.react.bridge.Callback;
+import com.facebook.react.bridge.Promise;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.bridge.ReactContext;
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
@@ -41,6 +44,24 @@ public class CompdfkitPdfModule extends ReactContextBaseJavaModule {
     return NAME;
   }
 
+  @ReactMethod
+  public void getVersionCode(final Promise promise){
+    CLog.e("Android-", CPDFSdk.getSDKVersion());
+    getReactApplicationContext().runOnUiQueueThread(() -> {
+      try {
+        promise.resolve(CPDFSdk.getSDKVersion());
+      } catch (Exception ex) {
+        promise.reject(ex);
+      }
+    });
+  }
+
+  @ReactMethod
+  public void getSDKBuildTag(final Promise promise){
+    CLog.e("Android-", "getSDKBuildTag: "+CPDFSdk.getSDKBuildTag());
+    promise.resolve(CPDFSdk.getSDKBuildTag());
+  }
+
   @ReactMethod
   public void init_(String license) {
     CPDFSdk.init(mReactContext, license, true);
@@ -53,6 +74,7 @@ public class CompdfkitPdfModule extends ReactContextBaseJavaModule {
    */
   @ReactMethod
   public void initialize(String androidOnlineLicense, String iosOnlineLicense) {
+    CLog.e("Android-", "initialize: "+CPDFSdk.getSDKBuildTag());
     CPDFSdk.init(mReactContext, androidOnlineLicense, false);
   }
 
@@ -64,6 +86,8 @@ public class CompdfkitPdfModule extends ReactContextBaseJavaModule {
    */
   @ReactMethod
   public void openDocument(String document, String password, String configurationJson) {
+    CLog.e("Android-", "openDocument: "+ document);
+    System.out.println("openDocument:"+ document);
     Intent intent = new Intent(mReactContext, CPDFDocumentActivity.class);
     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     if (Uri.parse(document).getScheme() == null) {

+ 8 - 7
example/android/build.gradle

@@ -5,13 +5,14 @@ buildscript {
     compileSdkVersion = 34
     targetSdkVersion = 34
     kotlinVersion = "1.8.0"
-    if (System.properties['os.arch'] == "aarch64") {
-      // For M1 Users we need to use the NDK 24 which added support for aarch64
-      ndkVersion = "24.0.8215888"
-    } else {
-      // Otherwise we default to the side-by-side NDK version from AGP.
-      ndkVersion = "21.4.7075529"
-    }
+    ndkVersion = "23.1.7779620"
+//    if (System.properties['os.arch'] == "aarch64") {
+//      // For M1 Users we need to use the NDK 24 which added support for aarch64
+//      ndkVersion = "24.0.8215888"
+//    } else {
+//      // Otherwise we default to the side-by-side NDK version from AGP.
+//      ndkVersion = "21.4.7075529"
+//    }
   }
   repositories {
     google()

+ 1 - 0
example/package.json

@@ -13,6 +13,7 @@
   "dependencies": {
     "react": "18.2.0",
     "react-native": "0.73.3",
+    "react-native-compdfkit-pdf": "file:.yalc/react-native-compdfkit-pdf",
     "react-native-document-picker": "^9.1.0"
   },
   "devDependencies": {

File diff suppressed because it is too large
+ 10 - 4
example/src/App.tsx


File diff suppressed because it is too large
+ 0 - 17053
package-lock.json


+ 1 - 4
package.json

@@ -1,6 +1,6 @@
 {
   "name": "react-native-compdfkit-pdf",
-  "version": "1.13.1",
+  "version": "2.0.0",
   "description": "ComPDFKit for React Native is a comprehensive SDK that allows you to quickly add PDF functionality to Android and iOS React Native applications.",
   "main": "lib/commonjs/index",
   "module": "lib/module/index",
@@ -75,9 +75,6 @@
     "react": "*",
     "react-native": "*"
   },
-  "workspaces": [
-    "example"
-  ],
   "packageManager": "yarn@3.6.1",
   "engines": {
     "node": ">= 18.0.0"

+ 11 - 1
src/index.tsx

@@ -3,6 +3,8 @@ import { NativeModules } from 'react-native';
 declare module 'react-native' {
     interface NativeModulesStatic {
       ComPDFKit: {
+        getVersionCode() : () =>  Promise<string>;
+        getSDKBuildTag() : () => Promise<string>;
         init_: (license : string) => void;
         initialize: (androidOnlineLicense: string, iosOnlineLicense : string) => void;
         openDocument : (document : string, password : string, configuration : string) => void;
@@ -10,6 +12,14 @@ declare module 'react-native' {
     }
   }
 
+interface ComPDFKit{
+    getVersionCode() : Promise<string>;
+    getSDKBuildTag() : Promise<string>;
+    init_(license : string) : void;
+    initialize(androidOnlineLicense : string,  iosOnlineLicense : string) : void;
+    openDocument(document : string, password : string, configurationJson : string) : void;
+}
+
 const ComPDFKit = NativeModules.ComPDFKit
 
-export { ComPDFKit };
+export { ComPDFKit };

File diff suppressed because it is too large
+ 941 - 1345
yarn.lock