Interface PdfUi
-
- All Implemented Interfaces:
-
com.pspdfkit.internal.ui.menu.PdfActivityMenu.OnPrepareDefaultMenuItemListener
,com.pspdfkit.listeners.DocumentListener
,com.pspdfkit.listeners.OnMenuItemsGenerateListener
,com.pspdfkit.listeners.PdfActivityListener
,com.pspdfkit.ui.PdfActivityComponentsApi
public interface PdfUi implements PdfActivityListener, OnMenuItemsGenerateListener, PdfActivityMenu.OnPrepareDefaultMenuItemListener, PdfActivityComponentsApi
The API that is shared between PdfActivity and PdfUiFragment.
-
-
Method Summary
Modifier and Type Method Description abstract PdfUiImpl
getImplementation()
Simply gets the current PdfUiImpl PdfFragment
getPdfFragment()
Returns the PdfFragment that is used to show the document. PdfFragment
requirePdfFragment()
Returns the PdfFragment that is used to show the document. void
setDocumentInteractionEnabled(boolean documentInteractionEnabled)
Enables or disables interaction with the document. boolean
isDocumentInteractionEnabled()
Indicates whether interaction with the document is enabled right now. void
onConfigurationChanged(@NonNull() Configuration newConfiguration)
void
setUserInterfaceEnabled(boolean userInterfaceEnabled)
Enables or disables the user interface. boolean
isUserInterfaceEnabled()
Indicates whether UI is enabled right now. boolean
isImageDocument()
Indicates whether the displayed document is an image or not. DocumentCoordinator
getDocumentCoordinator()
Returns the coordinator responsible for displaying documents and switching between multiple loaded documents. int
getPageIndex()
Returns current page index set on the document. void
setPageIndex(@IntRange(from = 0) int pageIndex)
Sets page to be displayed in the current document. void
setPageIndex(@IntRange(from = 0) int pageIndex, boolean animate)
Sets page to be displayed in the current document. abstract PdfActivityConfiguration
getConfiguration()
Returns the PdfActivityConfiguration that was provided while launching this pdf UI. abstract void
setConfiguration(@NonNull() PdfActivityConfiguration configuration)
Replaces activity configuration. PSPDFKitViews
getPSPDFKitViews()
Returns object with inflated PSPDFKit views. long
getScreenTimeout()
Gets screen timeout in milliseconds that has been added to the predefined system timeout, TIMEOUT_DEFAULT or TIMEOUT_INFINITE. void
setScreenTimeout(long screenTimeoutMillis)
Sets screen timeout in milliseconds that will be added to the predefined system timeout (that is usually 1 minute). void
showUserInterface()
Animates user interface controls into view. void
hideUserInterface()
Animates user interface controls out of view. void
setUserInterfaceVisible(boolean show, boolean animate)
Show or hide user interface controls. boolean
isUserInterfaceVisible()
Checks whether user interface controls are currently visible. UserInterfaceViewMode
getUserInterfaceViewMode()
Return current user interface view mode that activity is using. void
setUserInterfaceViewMode(@NonNull() UserInterfaceViewMode userInterfaceViewMode)
Sets the activity user interface view mode at a runtime. void
toggleUserInterface()
Toggles the visibility of user interface controls. void
setDocumentFromUri(@NonNull() Uri documentUri, @Nullable() String password)
Loads a new document in this activity and replaces the existing one. void
setDocumentFromUris(@NonNull() List<Uri> documentUris, @Nullable() List<String> passwords)
Loads a new document in this activity and replaces the existing one. void
setDocumentFromDataProvider(@NonNull() DataProvider dataProvider, @Nullable() String password)
Loads a new document in this activity and replaces the existing one. void
setDocumentFromDataProviders(@NonNull() List<DataProvider> dataProviders, @Nullable() List<String> passwords)
Loads a new document in this pdf UI and replaces the existing one. PdfDocument
getDocument()
Returns the PdfDocument that is loaded into this pdf UI, or null
if no document has been loaded yet.int
getSiblingPageIndex(@IntRange(from = 0) int pageIndex)
Gets page sibling index (usable in double page mode). void
setOnContextualToolbarLifecycleListener(@Nullable() ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener lifecycleListener)
Sets the listener for lifecycle changes of the ContextualToolbar as it goes through the ToolbarCoordinatorLayout - preparing, displaying, removing. void
setOnContextualToolbarMovementListener(@Nullable() ToolbarCoordinatorLayout.OnContextualToolbarMovementListener movementListener)
Sets the listener for ContextualToolbar movements within the layout. void
setOnContextualToolbarPositionListener(@Nullable() ToolbarCoordinatorLayout.OnContextualToolbarPositionListener positionListener)
Sets the listener for ContextualToolbar position changes within the layout. void
addPropertyInspectorLifecycleListener(@NonNull() PropertyInspectorCoordinatorLayoutController.PropertyInspectorLifecycleListener lifecycleListener)
Adds the listener for lifecycle changes of the PropertyInspector as it goes through the PropertyInspectorCoordinatorLayout - preparing, displaying, removing. void
removePropertyInspectorLifecycleListener(@NonNull() PropertyInspectorCoordinatorLayoutController.PropertyInspectorLifecycleListener lifecycleListener)
Removes previously registered listener for lifecycle changes of the PropertyInspector as it goes through the PropertyInspectorCoordinatorLayout - preparing, displaying, removing. void
setAnnotationEditingInspectorController(@NonNull() AnnotationEditingInspectorController annotationEditingInspectorController)
Sets controller of the annotation inspector used when editing annotations. void
setAnnotationCreationInspectorController(@NonNull() AnnotationCreationInspectorController annotationCreationInspectorController)
Sets controller of the annotation inspector used when creating annotations. void
setSharingActionMenuListener(@Nullable() ActionMenuListener listener)
Sets the listener for sharing menu lifecycle and click events. void
setDocumentSharingDialogFactory(@Nullable() DocumentSharingDialogFactory factory)
Sets the creator for document sharing dialogs. void
setDocumentPrintDialogFactory(@Nullable() DocumentPrintDialogFactory factory)
Sets the creator for document print dialogs. void
setSharingOptionsProvider(@Nullable() SharingOptionsProvider provider)
Sets the provider for sharing options. void
setPrintOptionsProvider(@Nullable() PrintOptionsProvider provider)
Sets the provider for print options. PropertyInspectorCoordinatorLayout
getPropertyInspectorCoordinator()
Returns property inspector coordinator layout. -
-
Method Detail
-
getImplementation
@NonNull()@RestrictTo(value = RestrictTo.Scope.LIBRARY) abstract PdfUiImpl getImplementation()
Simply gets the current PdfUiImpl
-
getPdfFragment
@Nullable() PdfFragment getPdfFragment()
Returns the PdfFragment that is used to show the document.
- Returns:
Current fragment for displaying the document, or
null
if no document is being displayed.
-
requirePdfFragment
@NonNull() PdfFragment requirePdfFragment()
Returns the PdfFragment that is used to show the document. Throws an exception when PdfFragment is not yet initialized.
- Returns:
Current fragment for displaying the document.
-
setDocumentInteractionEnabled
void setDocumentInteractionEnabled(boolean documentInteractionEnabled)
Enables or disables interaction with the document. When the interaction is disabled you can no longer scroll or zoom the document in any way, any other UI like the thumbnail bar is still enabled.
- Parameters:
documentInteractionEnabled
-true
to enable interacting with the document,false
to disable it.
-
isDocumentInteractionEnabled
boolean isDocumentInteractionEnabled()
Indicates whether interaction with the document is enabled right now.
- Returns:
true
when the user can interact with the document,false
otherwise.
-
onConfigurationChanged
void onConfigurationChanged(@NonNull() Configuration newConfiguration)
-
setUserInterfaceEnabled
void setUserInterfaceEnabled(boolean userInterfaceEnabled)
Enables or disables the user interface. When the user interface is disabled all temporary UI elements (navigation buttons, redaction UI) are hidden, and all user interaction is disabled (no scrolling, no clicking on the thumbnail bar, no annotation editing).
- Parameters:
userInterfaceEnabled
-true
to enable the UI,false
to disable the UI.
-
isUserInterfaceEnabled
boolean isUserInterfaceEnabled()
Indicates whether UI is enabled right now. UI is disabled when document is being saved/loaded, or when manually disabled.
- Returns:
true
when UI is enabled right now.
-
isImageDocument
boolean isImageDocument()
Indicates whether the displayed document is an image or not.
- Returns:
true
if the displayed document is image,false
otherwise.
-
getDocumentCoordinator
@NonNull() DocumentCoordinator getDocumentCoordinator()
Returns the coordinator responsible for displaying documents and switching between multiple loaded documents.
- Returns:
DocumentCoordinator instance managing documents in this PdfUi.
-
getPageIndex
@IntRange(from = "-1") int getPageIndex()
Returns current page index set on the document.
- Returns:
Index of the page currently displayed in the document (-1 if document is null).
-
setPageIndex
void setPageIndex(@IntRange(from = 0) int pageIndex)
Sets page to be displayed in the current document.
- Parameters:
pageIndex
- Index of the target page (starting at 0).
-
setPageIndex
void setPageIndex(@IntRange(from = 0) int pageIndex, boolean animate)
Sets page to be displayed in the current document.
- Parameters:
pageIndex
- Index of the target page (starting at 0).animate
-true
if the transition to the specified page should be animated,false
otherwise.
-
getConfiguration
@NonNull() abstract PdfActivityConfiguration getConfiguration()
Returns the PdfActivityConfiguration that was provided while launching this pdf UI.
- Returns:
Currently set activity configuration.
-
setConfiguration
abstract void setConfiguration(@NonNull() PdfActivityConfiguration configuration)
Replaces activity configuration. This method restarts the pdf UI to apply new configuration.
Note: This is a no-op when configuration has not changed.
- Parameters:
configuration
- The configuration to restart pdf UI with.
-
getPSPDFKitViews
@NonNull() PSPDFKitViews getPSPDFKitViews()
Returns object with inflated PSPDFKit views. This is meant to be used when extending this class for easier customization.
- Returns:
Object holding inflated PSPDFKitViews.PSPDFView instances.
-
getScreenTimeout
long getScreenTimeout()
Gets screen timeout in milliseconds that has been added to the predefined system timeout, TIMEOUT_DEFAULT or TIMEOUT_INFINITE.
- Returns:
a positive number, TIMEOUT_DEFAULT or TIMEOUT_INFINITE.
-
setScreenTimeout
void setScreenTimeout(long screenTimeoutMillis)
Sets screen timeout in milliseconds that will be added to the predefined system timeout (that is usually 1 minute). I.e. setScreenTimeout(30 * 1000) will turn off the device screen in 90 seconds.
- Parameters:
screenTimeoutMillis
- can be a positive number, TIMEOUT_DEFAULT or TIMEOUT_INFINITE.
-
showUserInterface
void showUserInterface()
Animates user interface controls into view. Does nothing if already showing, USER_INTERFACE_VIEW_MODE_HIDDEN is set or when user interface is forced to be hidden - for example when creating annotations and using vertical toolbar.
-
hideUserInterface
void hideUserInterface()
Animates user interface controls out of view. Does nothing if already hidden, USER_INTERFACE_VIEW_MODE_VISIBLE is set or when user interface is sticky - inline search is active, toolbar forces user interface to be visible etc.
-
setUserInterfaceVisible
void setUserInterfaceVisible(boolean show, boolean animate)
Show or hide user interface controls. This does not respect currently configured .
- Parameters:
show
-true
to show user interface,false
to hide it.animate
-true
to animate the change.
-
isUserInterfaceVisible
boolean isUserInterfaceVisible()
Checks whether user interface controls are currently visible.
- Returns:
true
if visible,false
otherwise.
-
getUserInterfaceViewMode
@NonNull() UserInterfaceViewMode getUserInterfaceViewMode()
Return current user interface view mode that activity is using.
-
setUserInterfaceViewMode
void setUserInterfaceViewMode(@NonNull() UserInterfaceViewMode userInterfaceViewMode)
Sets the activity user interface view mode at a runtime. Overriding .
-
toggleUserInterface
void toggleUserInterface()
Toggles the visibility of user interface controls.
-
setDocumentFromUri
void setDocumentFromUri(@NonNull() Uri documentUri, @Nullable() String password)
Loads a new document in this activity and replaces the existing one. This method may only be called if onSaveInstanceState has not been called or an exception will be thrown, since after that call state loss could occur.
- Parameters:
documentUri
- Document URI.password
- Document password.
-
setDocumentFromUris
void setDocumentFromUris(@NonNull() List<Uri> documentUris, @Nullable() List<String> passwords)
Loads a new document in this activity and replaces the existing one. This method may only be called if onSaveInstanceState has not been called or an exception will be thrown, since after that call state loss could occur.
- Parameters:
documentUris
- List of document URIs for compound document.passwords
- List of passwords for compound document, may be null.
-
setDocumentFromDataProvider
void setDocumentFromDataProvider(@NonNull() DataProvider dataProvider, @Nullable() String password)
Loads a new document in this activity and replaces the existing one. This method may only be called if onSaveInstanceState has not been called or an exception will be thrown, since after that call state loss could occur.
- Parameters:
dataProvider
- Data provider for the document.password
- Document password.
-
setDocumentFromDataProviders
void setDocumentFromDataProviders(@NonNull() List<DataProvider> dataProviders, @Nullable() List<String> passwords)
Loads a new document in this pdf UI and replaces the existing one. This method may only be called if onSaveInstanceState has not been called or an exception will be thrown, since after that call state loss could occur.
- Parameters:
dataProviders
- List of data providers for compound document.passwords
- List of passwords for compound document, may be null.
-
getDocument
@Nullable() PdfDocument getDocument()
Returns the PdfDocument that is loaded into this pdf UI, or
null
if no document has been loaded yet.- Returns:
Document loaded into the pdf UI.
-
getSiblingPageIndex
@IntRange(from = "-1") int getSiblingPageIndex(@IntRange(from = 0) int pageIndex)
Gets page sibling index (usable in double page mode).
- Parameters:
pageIndex
- Index of the page for which we look for the sibling.- Returns:
Provided page sibling, or
-1
if there is none.
-
setOnContextualToolbarLifecycleListener
void setOnContextualToolbarLifecycleListener(@Nullable() ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener lifecycleListener)
Sets the listener for lifecycle changes of the ContextualToolbar as it goes through the ToolbarCoordinatorLayout - preparing, displaying, removing. Calling this method will replace any previously set listener. You may provide
null
to clear the listener.- Parameters:
lifecycleListener
- OnContextualToolbarLifecycleListener that should be notified, ornull
to clear the listener.
-
setOnContextualToolbarMovementListener
void setOnContextualToolbarMovementListener(@Nullable() ToolbarCoordinatorLayout.OnContextualToolbarMovementListener movementListener)
Sets the listener for ContextualToolbar movements within the layout. Calling this method will replace any previously set listener. You may provide
null
to clear the listener.- Parameters:
movementListener
- OnContextualToolbarMovementListener that should be notified, ornull
to clear the listener.
-
setOnContextualToolbarPositionListener
void setOnContextualToolbarPositionListener(@Nullable() ToolbarCoordinatorLayout.OnContextualToolbarPositionListener positionListener)
Sets the listener for ContextualToolbar position changes within the layout. Calling this method will replace any previously set listener. You may provide
null
to clear the listener.- Parameters:
positionListener
- OnContextualToolbarPositionListener that should be notified, ornull
to clear the listener.
-
addPropertyInspectorLifecycleListener
void addPropertyInspectorLifecycleListener(@NonNull() PropertyInspectorCoordinatorLayoutController.PropertyInspectorLifecycleListener lifecycleListener)
Adds the listener for lifecycle changes of the PropertyInspector as it goes through the PropertyInspectorCoordinatorLayout - preparing, displaying, removing. If the listener has already been added previously, this method will be a no-op. Adding
null
is not allowed, and will result in an exception.- Parameters:
lifecycleListener
- PropertyInspectorLifecycleListener that should be notified.
-
removePropertyInspectorLifecycleListener
void removePropertyInspectorLifecycleListener(@NonNull() PropertyInspectorCoordinatorLayoutController.PropertyInspectorLifecycleListener lifecycleListener)
Removes previously registered listener for lifecycle changes of the PropertyInspector as it goes through the PropertyInspectorCoordinatorLayout - preparing, displaying, removing. Upon calling this method the
listener
will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Addingnull
is not allowed,and will result in an exception.- Parameters:
lifecycleListener
- PropertyInspectorLifecycleListener that should be removed.
-
setAnnotationEditingInspectorController
void setAnnotationEditingInspectorController(@NonNull() AnnotationEditingInspectorController annotationEditingInspectorController)
Sets controller of the annotation inspector used when editing annotations. This replaces default annotation inspector.
- Parameters:
annotationEditingInspectorController
- Controller instance to use.
-
setAnnotationCreationInspectorController
void setAnnotationCreationInspectorController(@NonNull() AnnotationCreationInspectorController annotationCreationInspectorController)
Sets controller of the annotation inspector used when creating annotations. This replaces default annotation inspector.
- Parameters:
annotationCreationInspectorController
- Controller instance to use.
-
setSharingActionMenuListener
void setSharingActionMenuListener(@Nullable() ActionMenuListener listener)
Sets the listener for sharing menu lifecycle and click events.
- Parameters:
listener
- Listener to set ornull
to clear registered listener.
-
setDocumentSharingDialogFactory
void setDocumentSharingDialogFactory(@Nullable() DocumentSharingDialogFactory factory)
Sets the creator for document sharing dialogs.
- Parameters:
factory
- Creator to set ornull
to clear registered creator.
-
setDocumentPrintDialogFactory
void setDocumentPrintDialogFactory(@Nullable() DocumentPrintDialogFactory factory)
Sets the creator for document print dialogs.
- Parameters:
factory
- Creator to set ornull
to clear registered creator.
-
setSharingOptionsProvider
void setSharingOptionsProvider(@Nullable() SharingOptionsProvider provider)
Sets the provider for sharing options.
- Parameters:
provider
- Provider to set ornull
to clear registered provider.
-
setPrintOptionsProvider
void setPrintOptionsProvider(@Nullable() PrintOptionsProvider provider)
Sets the provider for print options.
- Parameters:
provider
- Provider to set ornull
to clear registered provider.
-
getPropertyInspectorCoordinator
@NonNull() PropertyInspectorCoordinatorLayout getPropertyInspectorCoordinator()
Returns property inspector coordinator layout.
- Returns:
Property inspector coordinator.
-
-
-
-