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"