Skip to content

Commit

Permalink
Limiting the options available in PSPDFKIT's Text Selection Popup Too…
Browse files Browse the repository at this point in the history
…lbar to Copy, Text Highlight, Share.

Upping versionCode to 80
  • Loading branch information
Dima-Android committed Jun 28, 2024
1 parent 1ba5e4e commit 62192f7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,23 +357,35 @@ class PdfReaderViewModel @Inject constructor(
})

this@PdfReaderViewModel.fragment.addDocumentListener(pdfThumbnailBar.documentListener)
this.fragment.addOnAnnotationCreationModeChangeListener(object:
AnnotationManager.OnAnnotationCreationModeChangeListener {
override fun onEnterAnnotationCreationMode(p0: AnnotationCreationController) {
set(true)
}

override fun onChangeAnnotationCreationMode(p0: AnnotationCreationController) {
set(true)
}
addOnAnnotationCreationModeChangeListener()
setOnPreparePopupToolbarListener()
fragmentManager.commit {
add(containerId, this@PdfReaderViewModel.fragment)
}
}

override fun onExitAnnotationCreationMode(p0: AnnotationCreationController) {
set(false)
private fun setOnPreparePopupToolbarListener() {
this.fragment.setOnPreparePopupToolbarListener { toolbar ->
val sourceItems = toolbar.menuItems
val menuItems = sourceItems.listIterator()

while (menuItems.hasNext()) {
val item = menuItems.next()
when (item.id) {
com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_underline,
com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_strikeout,
com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_speak,
com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_search,
com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_redact,
com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_paste_annotation,
com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_link,
-> {
menuItems.remove()
}
}
}

})
fragmentManager.commit {
add(containerId, this@PdfReaderViewModel.fragment)
toolbar.menuItems = sourceItems
}
}

Expand Down Expand Up @@ -1638,7 +1650,6 @@ class PdfReaderViewModel @Inject constructor(
.invertColors(isCalculatedThemeDark)
.themeMode(themeMode)
.showNoteEditorForNewNoteAnnotations(false)
.textSelectionPopupToolbarEnabled(false)
// .disableFormEditing()
// .disableAnnotationRotation()
// .setSelectedAnnotationResizeEnabled(false)
Expand Down Expand Up @@ -1931,7 +1942,17 @@ class PdfReaderViewModel @Inject constructor(
}
})
this@PdfReaderViewModel.fragment.addDocumentListener(pdfThumbnailBar.documentListener)
this.fragment.addOnAnnotationCreationModeChangeListener(object:
setOnPreparePopupToolbarListener()
addOnAnnotationCreationModeChangeListener()

fragmentManager.commit {
replace(containerId, this@PdfReaderViewModel.fragment)
}
updateVisibilityOfAnnotations()
}

private fun addOnAnnotationCreationModeChangeListener() {
this.fragment.addOnAnnotationCreationModeChangeListener(object :
AnnotationManager.OnAnnotationCreationModeChangeListener {
override fun onEnterAnnotationCreationMode(p0: AnnotationCreationController) {
set(true)
Expand All @@ -1946,11 +1967,6 @@ class PdfReaderViewModel @Inject constructor(
}

})

fragmentManager.commit {
replace(containerId, this@PdfReaderViewModel.fragment)
}
updateVisibilityOfAnnotations()
}

private fun toggleTopAndBottomBarVisibility() {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object BuildConfig {
const val compileSdkVersion = 34
const val targetSdk = 33

val versionCode = 79 // Must be updated on every build
val versionCode = 80 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit 62192f7

Please sign in to comment.