From 3abcc2c536ca9171accfcea123e838dbe7e285e9 Mon Sep 17 00:00:00 2001 From: Dima Date: Tue, 25 Jun 2024 18:24:36 +0900 Subject: [PATCH] =?UTF-8?q?Upping=20version=20of=20PSPDFKIT=20to=202024.3.?= =?UTF-8?q?1=20which=20adds=20proper=20stylus=20handling=20and=20palm=20re?= =?UTF-8?q?jection.=20Can=20now=20draw=20annotations=20with=20the=20stylus?= =?UTF-8?q?=20while=20moving=20the=20page=20or=20switching=20pages=20with?= =?UTF-8?q?=20a=20finger.=20Hide=20PSPDFKit=20Strikethrough=20and=20Underl?= =?UTF-8?q?ine=20in=20text-selection=20popup.=20Closes=20#137.=20Closes=20?= =?UTF-8?q?#123=20Fix=20for=20=E2=80=9CCan't=20edit=20selected=20annotatio?= =?UTF-8?q?n=E2=80=9D.=20Where=20tapping=20on=20the=20same=20annotation=20?= =?UTF-8?q?twice=20didn=E2=80=99t=20open=20edit=20dialog.=20Closes=20#118.?= =?UTF-8?q?=20Potentially=20fixed=20an=20issue=20where=20text=20highlights?= =?UTF-8?q?=20were=20split=20when=20there=20was=20a=20tiny=20gap=20in=20a?= =?UTF-8?q?=20sentence.=20Upping=20versionCode=20ot=2079?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/pdf/reader/PdfReaderViewModel.kt | 17 +++++++++++------ buildSrc/src/main/kotlin/BuildConfig.kt | 2 +- buildSrc/src/main/kotlin/Libs.kt | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/zotero/android/pdf/reader/PdfReaderViewModel.kt b/app/src/main/java/org/zotero/android/pdf/reader/PdfReaderViewModel.kt index cef2bfeb..0f4bd326 100644 --- a/app/src/main/java/org/zotero/android/pdf/reader/PdfReaderViewModel.kt +++ b/app/src/main/java/org/zotero/android/pdf/reader/PdfReaderViewModel.kt @@ -217,6 +217,13 @@ class PdfReaderViewModel @Inject constructor( @Subscribe(threadMode = ThreadMode.MAIN) fun onEvent(pdfAnnotationCommentResult: PdfAnnotationCommentResult) { setComment(pdfAnnotationCommentResult.annotationKey, pdfAnnotationCommentResult.comment) + if (isTablet) { + // Fix for a bug where selecting an already selected annotation again didn't trigger Annotation Edit Popup/Screen. + // Unfortunately PSPDFKIT's onAnnotationSelected method is not triggered when user is selecting the same annotation again. Because technically the same annotation just stays selected. + // That's why after finishing annotation editing we have to make PSPDFKIT to deselect the currently selected annotation. + // Drawback to this is that of course visually annotation gets deselected as well. + this.fragment.clearSelectedAnnotations() + } } @Subscribe(threadMode = ThreadMode.MAIN) @@ -432,7 +439,7 @@ class PdfReaderViewModel @Inject constructor( private fun loadRawDocument() { this.rawDocument = - PdfDocumentLoader.openDocument(context, this.document.documentSource.fileUri) + PdfDocumentLoader.openDocument(context, this.document.documentSource.fileUri!!) } private fun setupInteractionListeners() { @@ -1204,9 +1211,6 @@ class PdfReaderViewModel @Inject constructor( } private fun _select(key: AnnotationKey?, didSelectInDocument: Boolean) { - if (key == viewState.selectedAnnotationKey) { - return - } val existing = viewState.selectedAnnotationKey if (existing != null) { if (viewState.sortedKeys.contains(existing)) { @@ -1557,7 +1561,7 @@ class PdfReaderViewModel @Inject constructor( fun selectAnnotationFromDocument(key: AnnotationKey) { - if (!viewState.sidebarEditingEnabled && key != viewState.selectedAnnotationKey) { + if (!viewState.sidebarEditingEnabled) { _select(key = key, didSelectInDocument = true) } } @@ -1634,6 +1638,7 @@ class PdfReaderViewModel @Inject constructor( .invertColors(isCalculatedThemeDark) .themeMode(themeMode) .showNoteEditorForNewNoteAnnotations(false) + .textSelectionPopupToolbarEnabled(false) // .disableFormEditing() // .disableAnnotationRotation() // .setSelectedAnnotationResizeEnabled(false) @@ -1898,7 +1903,7 @@ class PdfReaderViewModel @Inject constructor( val pdfAnnotation = document.annotation(annotationToReselect.page, annotationToReselect.key) if (pdfAnnotation != null) { - fragment.setSelectedAnnotation(pdfAnnotation) +// fragment.setSelectedAnnotation(pdfAnnotation) } } setupInteractionListeners() diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index d55d1e1c..3bf7db90 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -4,7 +4,7 @@ object BuildConfig { const val compileSdkVersion = 34 const val targetSdk = 33 - val versionCode = 78 // Must be updated on every build + val versionCode = 79 // Must be updated on every build val version = Version( major = 1, minor = 0, diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index 9254f700..cc70b89d 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -2,7 +2,7 @@ object Libs { const val androidJUnitRunner = "androidx.test.runner.AndroidJUnitRunner" - const val pspdfkit = "com.pspdfkit:pspdfkit:8.10.0" + const val pspdfkit = "com.pspdfkit:pspdfkit:2024.3.1" const val googleServices = "com.google.gms:google-services:4.3.13" const val realmGradlePlugin = "io.realm:realm-gradle-plugin:10.15.1" const val materialDesign = "com.google.android.material:material:1.10.0"