Relnote: Added new API for custom link handling - Introduced protected API in PdfViewerFragment to allow subclasses to customize link click behaviour. Detailed API design doc : go/jetpack-customlinkhandling-apidesign Bug: 407666002 Test: build and run on test device Change-Id: I275fe809e6be028c15674bd51c18602a99f8e047
diff --git a/pdf/pdf-viewer-fragment/api/current.txt b/pdf/pdf-viewer-fragment/api/current.txt index b9ca43d..3bff8c6 100644 --- a/pdf/pdf-viewer-fragment/api/current.txt +++ b/pdf/pdf-viewer-fragment/api/current.txt
@@ -14,6 +14,7 @@ method public final boolean isTextSearchActive(); method public final boolean isToolboxVisible(); method public static final androidx.pdf.viewer.fragment.PdfViewerFragment newInstance(androidx.pdf.viewer.fragment.PdfStylingOptions pdfStylingOptions); + method protected boolean onLinkClicked(androidx.pdf.content.ExternalLink externalLink); method public void onLoadDocumentError(Throwable error); method public void onLoadDocumentSuccess(); method public void onRequestImmersiveMode(boolean enterImmersive);
diff --git a/pdf/pdf-viewer-fragment/api/restricted_current.txt b/pdf/pdf-viewer-fragment/api/restricted_current.txt index b9ca43d..3bff8c6 100644 --- a/pdf/pdf-viewer-fragment/api/restricted_current.txt +++ b/pdf/pdf-viewer-fragment/api/restricted_current.txt
@@ -14,6 +14,7 @@ method public final boolean isTextSearchActive(); method public final boolean isToolboxVisible(); method public static final androidx.pdf.viewer.fragment.PdfViewerFragment newInstance(androidx.pdf.viewer.fragment.PdfStylingOptions pdfStylingOptions); + method protected boolean onLinkClicked(androidx.pdf.content.ExternalLink externalLink); method public void onLoadDocumentError(Throwable error); method public void onLoadDocumentSuccess(); method public void onRequestImmersiveMode(boolean enterImmersive);
diff --git a/pdf/pdf-viewer-fragment/src/main/kotlin/androidx/pdf/viewer/fragment/PdfViewerFragment.kt b/pdf/pdf-viewer-fragment/src/main/kotlin/androidx/pdf/viewer/fragment/PdfViewerFragment.kt index 192347b..5ab25fa 100644 --- a/pdf/pdf-viewer-fragment/src/main/kotlin/androidx/pdf/viewer/fragment/PdfViewerFragment.kt +++ b/pdf/pdf-viewer-fragment/src/main/kotlin/androidx/pdf/viewer/fragment/PdfViewerFragment.kt
@@ -477,14 +477,11 @@ /** * Called when an external link in the PDF is clicked. Override this method to provide custom - * handling for external links (e.g., URLs), as opposed to internal document navigation like - * `goTo` links, which are handled separately. + * handling for external links (e.g., URLs). * - * @param externalLink The [ExternalLink] model representing the clicked link. It contains - * metadata such as the link's URL, bounds, and the page it was found on. + * @param externalLink The [ExternalLink] model representing the clicked link. * @return `true` if the link click was handled; `false` to fall back to the default behaviour. */ - @RestrictTo(RestrictTo.Scope.LIBRARY) protected open fun onLinkClicked(externalLink: ExternalLink): Boolean { return false }