From 9f9b2c16c7988c94143be2fe6a56bb224317eb14 Mon Sep 17 00:00:00 2001 From: Darren Chan Date: Fri, 15 Sep 2023 15:29:52 -0700 Subject: [PATCH] [Android] enableReadingModeQuickMenu prop (#668) * added prop disableReadingModeQuickMenu (android only) + ios blank implementation due to hygen generated prop * Updating JS files * Updating package version * update api.md * Update API.md * change to enable for consistent with native android * change disabled to enabled for all mentions consistent with native api * Update API.md * Update DocumentViewViewManager.java * Delete example/yarn.lock not intended * Update App.js missed test line * fix logic as can't extract toolmanager as is * default true * Delete ios/RNTPTDocumentView.m unneed ios blank implementation * Delete ios/RNTPTDocumentViewManager.m same as last commit * Delete ios/RNTPTDocumentView.h ^ * Revert "Delete ios/RNTPTDocumentView.m" This reverts commit f0c13f765f8c78af25cc1f1aa42804331ba051ff. * Revert "Delete ios/RNTPTDocumentViewManager.m" This reverts commit 9703d81495b3ac5b0ffbf48500d1cd5182fe58c3. * Revert "Delete ios/RNTPTDocumentView.h" This reverts commit 9d8834d46561f4dd6b0a921a6ce8ee80dff660bd. * remove blank ios * Update RNTPTDocumentView.h random space + cleaning PR * edit mEnableQuickMenu * name for consistency * missed variable change --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- API.md | 13 ++++++++++++- .../viewmanagers/DocumentViewViewManager.java | 5 +++++ .../com/pdftron/reactnative/views/DocumentView.java | 7 +++++++ lib/src/DocumentView/DocumentView.js | 1 + package.json | 2 +- src/DocumentView/DocumentView.tsx | 1 + 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/API.md b/API.md index 2b5ac771..9a9c6ace 100644 --- a/API.md +++ b/API.md @@ -3971,4 +3971,15 @@ fieldHightlightColor | object | the form field highlight color, in the format `{ ```js this._viewer.setFormFieldHighlightColor({red: 0, green: 0, blue: 255, alpha: 128}); // blue color -``` \ No newline at end of file +``` + +#### enableReadingModeQuickMenu +bool, optional, defaults to true (Android Only) + +Defines whether the viewer disables long press quick menu in read-only. If false, the UI will not allow the user to long press to open the quick menu. + +```js + +``` diff --git a/android/src/main/java/com/pdftron/reactnative/viewmanagers/DocumentViewViewManager.java b/android/src/main/java/com/pdftron/reactnative/viewmanagers/DocumentViewViewManager.java index 91fa2b68..75150daf 100644 --- a/android/src/main/java/com/pdftron/reactnative/viewmanagers/DocumentViewViewManager.java +++ b/android/src/main/java/com/pdftron/reactnative/viewmanagers/DocumentViewViewManager.java @@ -538,6 +538,11 @@ public void setMaxSignatureCount(DocumentView documentView, int maxSignatureCoun } // Hygen Generated Props + @ReactProp(name = "enableReadingModeQuickMenu") + public void setEnableReadingModeQuickMenu(DocumentView documentView, boolean enabled) { + documentView.setEnableReadingModeQuickMenu(enabled); + } + @ReactProp(name = "forceAppTheme") public void setForceAppTheme(DocumentView documentView, @NonNull String forcedAppThemeItems) { documentView.setForceAppTheme(forcedAppThemeItems); diff --git a/android/src/main/java/com/pdftron/reactnative/views/DocumentView.java b/android/src/main/java/com/pdftron/reactnative/views/DocumentView.java index b2060f50..c42224f2 100644 --- a/android/src/main/java/com/pdftron/reactnative/views/DocumentView.java +++ b/android/src/main/java/com/pdftron/reactnative/views/DocumentView.java @@ -150,6 +150,8 @@ public class DocumentView extends com.pdftron.pdf.controls.DocumentView2 { private boolean mUseStylusAsPen = true; private boolean mSignWithStamps; + private boolean mEnableReadingModeQuickMenu = true; + public boolean isBookmarkListVisible = true; public boolean isOutlineListVisible = true; public boolean isAnnotationListVisible = true; @@ -770,6 +772,10 @@ public void setCurrentToolbar(String toolbarTag) { } // Hygen Generated Props + public void setEnableReadingModeQuickMenu(boolean enabled) { + mEnableReadingModeQuickMenu = enabled; + } + public void setForceAppTheme(String forcedAppThemeItems) { if (THEME_DARK.equals(forcedAppThemeItems)) { PdfViewCtrlSettingsManager.setColorMode(getContext(), PdfViewCtrlSettingsManager.KEY_PREF_COLOR_MODE_NIGHT); @@ -3098,6 +3104,7 @@ public void onTabDocumentLoaded(String tag) { getToolManager().setStylusAsPen(mUseStylusAsPen); getToolManager().setSignSignatureFieldsWithStamps(mSignWithStamps); + getToolManager().setReflowTextSelectionMenuEnabled(mEnableReadingModeQuickMenu); getToolManager().getUndoRedoManger().addUndoRedoStateChangeListener(mUndoRedoStateChangedListener); diff --git a/lib/src/DocumentView/DocumentView.js b/lib/src/DocumentView/DocumentView.js index c48da685..15d3b14d 100644 --- a/lib/src/DocumentView/DocumentView.js +++ b/lib/src/DocumentView/DocumentView.js @@ -156,6 +156,7 @@ const propTypes = { overrideToolbarButtonBehavior: arrayOf(Config.Buttons), onToolbarButtonPress: func(), // Hygen Generated Props + enableReadingModeQuickMenu: PropTypes.bool, forceAppTheme: oneOf(Config.ThemeOptions), signatureColors: PropTypes.arrayOf(PropTypes.exact({ red: PropTypes.number.isRequired, diff --git a/package.json b/package.json index d901899a..2cc7b947 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-native-pdftron", "title": "React Native Pdftron", - "version": "3.0.3-26", + "version": "3.0.3-27", "description": "React Native Pdftron", "main": "./lib/index.js", "typings": "index.ts", diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 41d4caba..4cf23723 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -165,6 +165,7 @@ const propTypes = { onToolbarButtonPress: func<(event: {id: string}) => void>(), // Hygen Generated Props + enableReadingModeQuickMenu: PropTypes.bool, forceAppTheme: oneOf(Config.ThemeOptions), signatureColors: PropTypes.arrayOf(PropTypes.exact({ red: PropTypes.number.isRequired,