@papyrus-sdk/engine-native 0.2.11 → 0.2.12-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +42 -42
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/cpp/CMakeLists.txt +45 -45
- package/android/src/main/cpp/papyrus_outline.cpp +173 -173
- package/android/src/main/cpp/papyrus_outline_loader.cpp +125 -125
- package/android/src/main/cpp/papyrus_outline_loader.h +48 -48
- package/android/src/main/cpp/papyrus_outline_loader_test.cpp +240 -240
- package/android/src/main/java/com/papyrus/engine/PapyrusEngineStore.java +71 -71
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeEngineModule.java +520 -516
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeEngineModule.kt +527 -527
- package/android/src/main/java/com/papyrus/engine/PapyrusOutline.java +34 -34
- package/android/src/main/java/com/papyrus/engine/PapyrusOutlineItem.java +13 -13
- package/android/src/main/java/com/papyrus/engine/PapyrusPackage.java +24 -24
- package/android/src/main/java/com/papyrus/engine/PapyrusPageView.java +197 -128
- package/android/src/main/java/com/papyrus/engine/PapyrusPageViewManager.java +22 -16
- package/android/src/main/java/com/papyrus/engine/PapyrusPageViewModule.kt +15 -12
- package/android/src/main/java/com/papyrus/engine/PapyrusTextHit.java +15 -15
- package/android/src/main/java/com/papyrus/engine/PapyrusTextSearch.java +20 -20
- package/android/src/main/java/com/papyrus/engine/PapyrusTextSelect.java +20 -20
- package/android/src/main/java/com/papyrus/engine/PapyrusTextSelection.java +11 -11
- package/android/src/test/java/com/papyrus/engine/PapyrusOutlineTest.java +40 -40
- package/android/src/test/java/com/papyrus/engine/PapyrusPageViewTest.java +30 -30
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +32 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -41
- package/dist/index.mjs.map +1 -1
- package/ios/PapyrusNativeEngine.m +447 -447
- package/ios/PapyrusNativeEngine.podspec +15 -15
- package/ios/PapyrusPageView.h +21 -19
- package/ios/PapyrusPageView.m +194 -63
- package/ios/PapyrusPageViewManager.m +20 -19
- package/package.json +14 -11
- package/react-native.config.js +10 -10
- package/LICENSE +0 -21
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
package com.papyrus.engine;
|
|
2
|
-
|
|
3
|
-
final class PapyrusOutline {
|
|
4
|
-
interface LibraryLoader {
|
|
5
|
-
void load() throws Throwable;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface OutlineSupportProbe {
|
|
9
|
-
boolean isSupported() throws Throwable;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static final boolean AVAILABLE;
|
|
13
|
-
|
|
14
|
-
static {
|
|
15
|
-
AVAILABLE = computeAvailability(
|
|
16
|
-
() -> System.loadLibrary("papyrus_text"),
|
|
17
|
-
PapyrusOutline::nativeIsOutlineSupported);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static boolean computeAvailability(LibraryLoader loader, OutlineSupportProbe probe) {
|
|
21
|
-
try {
|
|
22
|
-
loader.load();
|
|
23
|
-
return probe.isSupported();
|
|
24
|
-
} catch (Throwable ignored) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static native boolean nativeIsOutlineSupported();
|
|
30
|
-
|
|
31
|
-
static native PapyrusOutlineItem[] nativeGetOutline(long docPtr);
|
|
32
|
-
|
|
33
|
-
static native PapyrusOutlineItem[] nativeGetOutlineFile(String filePath);
|
|
34
|
-
}
|
|
1
|
+
package com.papyrus.engine;
|
|
2
|
+
|
|
3
|
+
final class PapyrusOutline {
|
|
4
|
+
interface LibraryLoader {
|
|
5
|
+
void load() throws Throwable;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface OutlineSupportProbe {
|
|
9
|
+
boolean isSupported() throws Throwable;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static final boolean AVAILABLE;
|
|
13
|
+
|
|
14
|
+
static {
|
|
15
|
+
AVAILABLE = computeAvailability(
|
|
16
|
+
() -> System.loadLibrary("papyrus_text"),
|
|
17
|
+
PapyrusOutline::nativeIsOutlineSupported);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static boolean computeAvailability(LibraryLoader loader, OutlineSupportProbe probe) {
|
|
21
|
+
try {
|
|
22
|
+
loader.load();
|
|
23
|
+
return probe.isSupported();
|
|
24
|
+
} catch (Throwable ignored) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static native boolean nativeIsOutlineSupported();
|
|
30
|
+
|
|
31
|
+
static native PapyrusOutlineItem[] nativeGetOutline(long docPtr);
|
|
32
|
+
|
|
33
|
+
static native PapyrusOutlineItem[] nativeGetOutlineFile(String filePath);
|
|
34
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
package com.papyrus.engine;
|
|
2
|
-
|
|
3
|
-
final class PapyrusOutlineItem {
|
|
4
|
-
final String title;
|
|
5
|
-
final int pageIndex;
|
|
6
|
-
final PapyrusOutlineItem[] children;
|
|
7
|
-
|
|
8
|
-
PapyrusOutlineItem(String title, int pageIndex, PapyrusOutlineItem[] children) {
|
|
9
|
-
this.title = title != null ? title : "";
|
|
10
|
-
this.pageIndex = pageIndex;
|
|
11
|
-
this.children = children;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
package com.papyrus.engine;
|
|
2
|
+
|
|
3
|
+
final class PapyrusOutlineItem {
|
|
4
|
+
final String title;
|
|
5
|
+
final int pageIndex;
|
|
6
|
+
final PapyrusOutlineItem[] children;
|
|
7
|
+
|
|
8
|
+
PapyrusOutlineItem(String title, int pageIndex, PapyrusOutlineItem[] children) {
|
|
9
|
+
this.title = title != null ? title : "";
|
|
10
|
+
this.pageIndex = pageIndex;
|
|
11
|
+
this.children = children;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
package com.papyrus.engine;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage;
|
|
4
|
-
import com.facebook.react.bridge.NativeModule;
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
7
|
-
|
|
8
|
-
import java.util.ArrayList;
|
|
9
|
-
import java.util.Collections;
|
|
10
|
-
import java.util.List;
|
|
11
|
-
|
|
12
|
-
public class PapyrusPackage implements ReactPackage {
|
|
13
|
-
@Override
|
|
14
|
-
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
15
|
-
List<NativeModule> modules = new ArrayList<>();
|
|
16
|
-
modules.add(new PapyrusNativeEngineModule(reactContext));
|
|
17
|
-
return modules;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@Override
|
|
21
|
-
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
22
|
-
return Collections.singletonList(new PapyrusPageViewManager());
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
package com.papyrus.engine;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage;
|
|
4
|
+
import com.facebook.react.bridge.NativeModule;
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
7
|
+
|
|
8
|
+
import java.util.ArrayList;
|
|
9
|
+
import java.util.Collections;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
|
|
12
|
+
public class PapyrusPackage implements ReactPackage {
|
|
13
|
+
@Override
|
|
14
|
+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
15
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
16
|
+
modules.add(new PapyrusNativeEngineModule(reactContext));
|
|
17
|
+
return modules;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
22
|
+
return Collections.singletonList(new PapyrusPageViewManager());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,128 +1,197 @@
|
|
|
1
|
-
package com.papyrus.engine;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.graphics.Bitmap;
|
|
5
|
-
import android.graphics.Canvas;
|
|
6
|
-
import android.graphics.
|
|
7
|
-
import android.graphics.
|
|
8
|
-
import android.
|
|
9
|
-
import android.
|
|
10
|
-
import android.
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
private final
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
1
|
+
package com.papyrus.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.graphics.Bitmap;
|
|
5
|
+
import android.graphics.Canvas;
|
|
6
|
+
import android.graphics.ColorMatrix;
|
|
7
|
+
import android.graphics.ColorMatrixColorFilter;
|
|
8
|
+
import android.graphics.Paint;
|
|
9
|
+
import android.graphics.Rect;
|
|
10
|
+
import android.util.AttributeSet;
|
|
11
|
+
import android.util.Log;
|
|
12
|
+
import android.view.View;
|
|
13
|
+
|
|
14
|
+
import com.shockwave.pdfium.PdfDocument;
|
|
15
|
+
|
|
16
|
+
import java.util.concurrent.ExecutorService;
|
|
17
|
+
import java.util.concurrent.Executors;
|
|
18
|
+
|
|
19
|
+
public class PapyrusPageView extends View {
|
|
20
|
+
static final long MAX_RENDER_PIXELS = 8L * 1024L * 1024L;
|
|
21
|
+
static final int MAX_RENDER_EDGE = 4096;
|
|
22
|
+
private static final String TAG = "PapyrusPageView";
|
|
23
|
+
private static final ExecutorService RENDER_EXECUTOR = Executors.newSingleThreadExecutor();
|
|
24
|
+
private static final ColorMatrixColorFilter SEPIA_FILTER = createSepiaFilter();
|
|
25
|
+
private static final ColorMatrixColorFilter DARK_FILTER = createDarkFilter();
|
|
26
|
+
private static final ColorMatrixColorFilter HIGH_CONTRAST_FILTER = createHighContrastFilter();
|
|
27
|
+
|
|
28
|
+
private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
29
|
+
private Bitmap bitmap;
|
|
30
|
+
private String pageTheme = "normal";
|
|
31
|
+
|
|
32
|
+
public PapyrusPageView(Context context) {
|
|
33
|
+
super(context);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public PapyrusPageView(Context context, AttributeSet attrs) {
|
|
37
|
+
super(context, attrs);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public void setPageTheme(String nextPageTheme) {
|
|
41
|
+
String normalized = nextPageTheme == null ? "normal" : nextPageTheme;
|
|
42
|
+
if (normalized.equals(pageTheme)) return;
|
|
43
|
+
pageTheme = normalized;
|
|
44
|
+
invalidate();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void render(final PapyrusEngineStore.EngineState state,
|
|
48
|
+
final int pageIndex,
|
|
49
|
+
final float scale,
|
|
50
|
+
final float zoom,
|
|
51
|
+
final int rotation) {
|
|
52
|
+
if (state == null || state.document == null) return;
|
|
53
|
+
if (state.isSearching) return;
|
|
54
|
+
if (getWidth() == 0 || getHeight() == 0) {
|
|
55
|
+
post(() -> render(state, pageIndex, scale, zoom, rotation));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
final int viewWidth = getWidth();
|
|
60
|
+
final int viewHeight = getHeight();
|
|
61
|
+
final float clampedZoom = Math.max(0.1f, Math.min(5.0f, zoom));
|
|
62
|
+
final float targetScale = Math.max(0.1f, scale) * clampedZoom;
|
|
63
|
+
final int[] renderSize = constrainRenderSize(
|
|
64
|
+
Math.max(1, (int) (viewWidth * targetScale)),
|
|
65
|
+
Math.max(1, (int) (viewHeight * targetScale))
|
|
66
|
+
);
|
|
67
|
+
final int renderWidth = renderSize[0];
|
|
68
|
+
final int renderHeight = renderSize[1];
|
|
69
|
+
|
|
70
|
+
RENDER_EXECUTOR.execute(() -> {
|
|
71
|
+
PdfDocument doc = state.document;
|
|
72
|
+
if (doc == null) return;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
Bitmap rendered = null;
|
|
76
|
+
synchronized (state.pdfiumLock) {
|
|
77
|
+
if (doc != state.document) return;
|
|
78
|
+
int pageCount = state.pdfium.getPageCount(doc);
|
|
79
|
+
if (pageIndex < 0 || pageIndex >= pageCount) return;
|
|
80
|
+
state.pdfium.openPage(doc, pageIndex);
|
|
81
|
+
rendered = Bitmap.createBitmap(renderWidth, renderHeight, Bitmap.Config.ARGB_8888);
|
|
82
|
+
state.pdfium.renderPageBitmap(doc, rendered, pageIndex, 0, 0, renderWidth, renderHeight, true);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (rendered == null) return;
|
|
86
|
+
final Bitmap renderedBitmap = rendered;
|
|
87
|
+
|
|
88
|
+
post(() -> {
|
|
89
|
+
if (bitmap != null && !bitmap.isRecycled()) {
|
|
90
|
+
bitmap.recycle();
|
|
91
|
+
}
|
|
92
|
+
bitmap = renderedBitmap;
|
|
93
|
+
invalidate();
|
|
94
|
+
});
|
|
95
|
+
} catch (Throwable ignored) {
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@Override
|
|
101
|
+
protected void onDraw(Canvas canvas) {
|
|
102
|
+
super.onDraw(canvas);
|
|
103
|
+
if (bitmap == null) return;
|
|
104
|
+
Rect dest = new Rect(0, 0, getWidth(), getHeight());
|
|
105
|
+
try {
|
|
106
|
+
paint.setColorFilter(resolveThemeFilter(pageTheme));
|
|
107
|
+
canvas.drawBitmap(bitmap, null, dest, paint);
|
|
108
|
+
paint.setColorFilter(null);
|
|
109
|
+
} catch (RuntimeException error) {
|
|
110
|
+
Log.w(TAG, "Failed to draw rendered page bitmap safely", error);
|
|
111
|
+
if (bitmap != null && !bitmap.isRecycled()) {
|
|
112
|
+
bitmap.recycle();
|
|
113
|
+
}
|
|
114
|
+
bitmap = null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static int[] constrainRenderSize(int requestedWidth, int requestedHeight) {
|
|
119
|
+
int width = Math.max(1, requestedWidth);
|
|
120
|
+
int height = Math.max(1, requestedHeight);
|
|
121
|
+
double scale = 1.0d;
|
|
122
|
+
|
|
123
|
+
if (width > MAX_RENDER_EDGE || height > MAX_RENDER_EDGE) {
|
|
124
|
+
scale = Math.min(
|
|
125
|
+
scale,
|
|
126
|
+
Math.min((double) MAX_RENDER_EDGE / width, (double) MAX_RENDER_EDGE / height)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
long pixels = (long) width * (long) height;
|
|
131
|
+
if (pixels > MAX_RENDER_PIXELS) {
|
|
132
|
+
scale = Math.min(scale, Math.sqrt((double) MAX_RENDER_PIXELS / (double) pixels));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (scale >= 1.0d) {
|
|
136
|
+
return new int[] { width, height };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
int safeWidth = Math.max(1, (int) Math.floor(width * scale));
|
|
140
|
+
int safeHeight = Math.max(1, (int) Math.floor(height * scale));
|
|
141
|
+
return new int[] { safeWidth, safeHeight };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private static ColorMatrixColorFilter resolveThemeFilter(String theme) {
|
|
145
|
+
if ("sepia".equals(theme)) return SEPIA_FILTER;
|
|
146
|
+
if ("dark".equals(theme)) return DARK_FILTER;
|
|
147
|
+
if ("high-contrast".equals(theme)) return HIGH_CONTRAST_FILTER;
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private static ColorMatrixColorFilter createSepiaFilter() {
|
|
152
|
+
ColorMatrix matrix = new ColorMatrix();
|
|
153
|
+
matrix.set(new float[] {
|
|
154
|
+
0.393f, 0.769f, 0.189f, 0, 0,
|
|
155
|
+
0.349f, 0.686f, 0.168f, 0, 0,
|
|
156
|
+
0.272f, 0.534f, 0.131f, 0, 0,
|
|
157
|
+
0, 0, 0, 1, 0
|
|
158
|
+
});
|
|
159
|
+
return new ColorMatrixColorFilter(matrix);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private static ColorMatrixColorFilter createDarkFilter() {
|
|
163
|
+
ColorMatrix invert = new ColorMatrix(new float[] {
|
|
164
|
+
-1, 0, 0, 0, 255,
|
|
165
|
+
0, -1, 0, 0, 255,
|
|
166
|
+
0, 0, -1, 0, 255,
|
|
167
|
+
0, 0, 0, 1, 0
|
|
168
|
+
});
|
|
169
|
+
ColorMatrix dim = new ColorMatrix(new float[] {
|
|
170
|
+
0.92f, 0, 0, 0, 0,
|
|
171
|
+
0, 0.92f, 0, 0, 0,
|
|
172
|
+
0, 0, 0.92f, 0, 0,
|
|
173
|
+
0, 0, 0, 1, 0
|
|
174
|
+
});
|
|
175
|
+
invert.postConcat(dim);
|
|
176
|
+
return new ColorMatrixColorFilter(invert);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private static ColorMatrixColorFilter createHighContrastFilter() {
|
|
180
|
+
ColorMatrix invert = new ColorMatrix(new float[] {
|
|
181
|
+
-1, 0, 0, 0, 255,
|
|
182
|
+
0, -1, 0, 0, 255,
|
|
183
|
+
0, 0, -1, 0, 255,
|
|
184
|
+
0, 0, 0, 1, 0
|
|
185
|
+
});
|
|
186
|
+
float contrast = 1.35f;
|
|
187
|
+
float translate = 128f * (1f - contrast);
|
|
188
|
+
ColorMatrix contrastMatrix = new ColorMatrix(new float[] {
|
|
189
|
+
contrast, 0, 0, 0, translate,
|
|
190
|
+
0, contrast, 0, 0, translate,
|
|
191
|
+
0, 0, contrast, 0, translate,
|
|
192
|
+
0, 0, 0, 1, 0
|
|
193
|
+
});
|
|
194
|
+
invert.postConcat(contrastMatrix);
|
|
195
|
+
return new ColorMatrixColorFilter(invert);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
package com.papyrus.engine;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.uimanager.SimpleViewManager;
|
|
4
|
-
import com.facebook.react.uimanager.ThemedReactContext;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
1
|
+
package com.papyrus.engine;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
5
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
6
|
+
|
|
7
|
+
public class PapyrusPageViewManager extends SimpleViewManager<PapyrusPageView> {
|
|
8
|
+
@Override
|
|
9
|
+
public String getName() {
|
|
10
|
+
return "PapyrusPageView";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Override
|
|
14
|
+
protected PapyrusPageView createViewInstance(ThemedReactContext reactContext) {
|
|
15
|
+
return new PapyrusPageView(reactContext);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@ReactProp(name = "pageTheme")
|
|
19
|
+
public void setPageTheme(PapyrusPageView view, String pageTheme) {
|
|
20
|
+
view.setPageTheme(pageTheme);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
package com.papyrus.engine
|
|
2
|
-
|
|
3
|
-
import expo.modules.kotlin.modules.Module
|
|
4
|
-
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
-
|
|
6
|
-
class PapyrusPageViewModule : Module() {
|
|
7
|
-
override fun definition() = ModuleDefinition {
|
|
8
|
-
Name("PapyrusPageView")
|
|
9
|
-
View(PapyrusPageView::class) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
package com.papyrus.engine
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
|
|
6
|
+
class PapyrusPageViewModule : Module() {
|
|
7
|
+
override fun definition() = ModuleDefinition {
|
|
8
|
+
Name("PapyrusPageView")
|
|
9
|
+
View(PapyrusPageView::class) {
|
|
10
|
+
Prop("pageTheme") { view: PapyrusPageView, pageTheme: String? ->
|
|
11
|
+
view.setPageTheme(pageTheme)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
package com.papyrus.engine;
|
|
2
|
-
|
|
3
|
-
final class PapyrusTextHit {
|
|
4
|
-
final int pageIndex;
|
|
5
|
-
final int matchIndex;
|
|
6
|
-
final String text;
|
|
7
|
-
final float[] rects;
|
|
8
|
-
|
|
9
|
-
PapyrusTextHit(int pageIndex, int matchIndex, String text, float[] rects) {
|
|
10
|
-
this.pageIndex = pageIndex;
|
|
11
|
-
this.matchIndex = matchIndex;
|
|
12
|
-
this.text = text;
|
|
13
|
-
this.rects = rects;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
package com.papyrus.engine;
|
|
2
|
+
|
|
3
|
+
final class PapyrusTextHit {
|
|
4
|
+
final int pageIndex;
|
|
5
|
+
final int matchIndex;
|
|
6
|
+
final String text;
|
|
7
|
+
final float[] rects;
|
|
8
|
+
|
|
9
|
+
PapyrusTextHit(int pageIndex, int matchIndex, String text, float[] rects) {
|
|
10
|
+
this.pageIndex = pageIndex;
|
|
11
|
+
this.matchIndex = matchIndex;
|
|
12
|
+
this.text = text;
|
|
13
|
+
this.rects = rects;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
package com.papyrus.engine;
|
|
2
|
-
|
|
3
|
-
final class PapyrusTextSearch {
|
|
4
|
-
static final boolean AVAILABLE;
|
|
5
|
-
|
|
6
|
-
static {
|
|
7
|
-
boolean available = false;
|
|
8
|
-
try {
|
|
9
|
-
System.loadLibrary("papyrus_text");
|
|
10
|
-
available = true;
|
|
11
|
-
} catch (Throwable ignored) {
|
|
12
|
-
available = false;
|
|
13
|
-
}
|
|
14
|
-
AVAILABLE = available;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static native PapyrusTextHit[] nativeSearch(long docPtr, int pageCount, String query);
|
|
18
|
-
|
|
19
|
-
static native PapyrusTextHit[] nativeSearchFile(String filePath, String query);
|
|
20
|
-
}
|
|
1
|
+
package com.papyrus.engine;
|
|
2
|
+
|
|
3
|
+
final class PapyrusTextSearch {
|
|
4
|
+
static final boolean AVAILABLE;
|
|
5
|
+
|
|
6
|
+
static {
|
|
7
|
+
boolean available = false;
|
|
8
|
+
try {
|
|
9
|
+
System.loadLibrary("papyrus_text");
|
|
10
|
+
available = true;
|
|
11
|
+
} catch (Throwable ignored) {
|
|
12
|
+
available = false;
|
|
13
|
+
}
|
|
14
|
+
AVAILABLE = available;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static native PapyrusTextHit[] nativeSearch(long docPtr, int pageCount, String query);
|
|
18
|
+
|
|
19
|
+
static native PapyrusTextHit[] nativeSearchFile(String filePath, String query);
|
|
20
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
package com.papyrus.engine;
|
|
2
|
-
|
|
3
|
-
final class PapyrusTextSelect {
|
|
4
|
-
static final boolean AVAILABLE;
|
|
5
|
-
|
|
6
|
-
static {
|
|
7
|
-
boolean available = false;
|
|
8
|
-
try {
|
|
9
|
-
System.loadLibrary("papyrus_text");
|
|
10
|
-
available = true;
|
|
11
|
-
} catch (Throwable ignored) {
|
|
12
|
-
available = false;
|
|
13
|
-
}
|
|
14
|
-
AVAILABLE = available;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static native PapyrusTextSelection nativeSelectText(long docPtr, int pageIndex, float x, float y, float width, float height);
|
|
18
|
-
|
|
19
|
-
static native PapyrusTextSelection nativeSelectTextFile(String filePath, int pageIndex, float x, float y, float width, float height);
|
|
20
|
-
}
|
|
1
|
+
package com.papyrus.engine;
|
|
2
|
+
|
|
3
|
+
final class PapyrusTextSelect {
|
|
4
|
+
static final boolean AVAILABLE;
|
|
5
|
+
|
|
6
|
+
static {
|
|
7
|
+
boolean available = false;
|
|
8
|
+
try {
|
|
9
|
+
System.loadLibrary("papyrus_text");
|
|
10
|
+
available = true;
|
|
11
|
+
} catch (Throwable ignored) {
|
|
12
|
+
available = false;
|
|
13
|
+
}
|
|
14
|
+
AVAILABLE = available;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static native PapyrusTextSelection nativeSelectText(long docPtr, int pageIndex, float x, float y, float width, float height);
|
|
18
|
+
|
|
19
|
+
static native PapyrusTextSelection nativeSelectTextFile(String filePath, int pageIndex, float x, float y, float width, float height);
|
|
20
|
+
}
|