| java.lang.Object | ||||||||
| ↳ | android.content.Context | |||||||
| ↳ | android.content.ContextWrapper | |||||||
| ↳ | android.view.ContextThemeWrapper | |||||||
| ↳ | android.app.Activity | |||||||
| ↳ | androidx.core.app.ComponentActivity | |||||||
| ↳ | androidx.fragment.app.FragmentActivity | |||||||
| ↳ | androidx.appcompat.app.AppCompatActivity | |||||||
| ↳ | com.pspdfkit.ui.PdfActivity | |||||||
Activity with fully integrated views and behaviour. Can be invoked by the simple helper methods showDocument(Context, Uri, PdfActivityConfiguration)
and showDocument(Context, Uri, String, PdfActivityConfiguration). For more advanced customization use PdfActivityIntentBuilder to generate
an Intent with proper parameters.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| long | TIMEOUT_DEFAULT | Parameter for setScreenTimeout(long) used for restoring screen timeout to its default system value. |
|||||||||
| long | TIMEOUT_INFINITE | Parameter for setScreenTimeout(long) used for disabling screen timeout. |
|||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Activity
| |||||||||||
From class
android.content.Context
| |||||||||||
From interface
android.content.ComponentCallbacks2
| |||||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| public static final int | MENU_OPTION_EDIT_ANNOTATIONS | Id of the thumbnail grid menu item. | |||||||||
| public static final int | MENU_OPTION_OUTLINE | Id of the thumbnail grid menu item. | |||||||||
| public static final int | MENU_OPTION_SEARCH | Id of the thumbnail grid menu item. | |||||||||
| public static final int | MENU_OPTION_SETTINGS | Id of the settings menu item. | |||||||||
| public static final int | MENU_OPTION_SHARE | Id of the thumbnail grid menu item. | |||||||||
| public static final int | MENU_OPTION_THUMBNAIL_GRID | Id of the thumbnail grid menu item. | |||||||||
|
[Expand]
Inherited Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Activity
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| PdfActivity() | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void | addPropertyInspectorLifecycleListener(PropertyInspectorCoordinatorLayoutController.PropertyInspectorLifecycleListener lifecycleListener) | ||||||||||
| boolean | dispatchKeyEvent(KeyEvent event) | ||||||||||
| PdfActivityConfiguration |
getConfiguration()
Returns the
PdfActivityConfiguration that was provided while launching this activity. | ||||||||||
| PdfDocument |
getDocument()
Returns the
PdfDocument that is loaded into this activity, or null if no document has been loaded yet. | ||||||||||
| DocumentCoordinator |
getDocumentCoordinator()
Returns the coordinator responsible for displaying documents and switching between multiple loaded documents.
| ||||||||||
| PSPDFKitViews |
getPSPDFKitViews()
Returns object with inflated PSPDFKit views.
| ||||||||||
| int |
getPageIndex()
Returns current page index set on the document.
| ||||||||||
| PdfFragment |
getPdfFragment()
Returns the
PdfFragment that is used to show the document. | ||||||||||
| PropertyInspectorCoordinatorLayout |
getPropertyInspectorCoordinator()
Returns property inspector coordinator layout.
| ||||||||||
| long |
getScreenTimeout()
Gets screen timeout in milliseconds that has been added to the predefined
system timeout,
TIMEOUT_DEFAULT or TIMEOUT_INFINITE. | ||||||||||
| int |
getSiblingPageIndex(int pageIndex)
Get page sibling index (usable in double page mode).
| ||||||||||
| UserInterfaceViewMode |
getUserInterfaceViewMode()
Return current user interface view mode that activity is using.
| ||||||||||
| void |
hideUserInterface()
Animates user interface controls out of view.
| ||||||||||
| boolean |
isDocumentInteractionEnabled()
Indicates whether interaction with the document is enabled right now.
| ||||||||||
| boolean |
isImageDocument()
Indicates whether the displayed document is an image or not.
| ||||||||||
| boolean |
isUserInterfaceEnabled()
Indicates whether UI is enabled right now.
| ||||||||||
| boolean |
isUserInterfaceVisible()
Checks whether user interface controls are currently visible.
| ||||||||||
| void | onActivityResult(int requestCode, int resultCode, Intent data) | ||||||||||
| void | onBackPressed() | ||||||||||
| boolean | onCreateOptionsMenu(Menu menu) | ||||||||||
| boolean |
onDocumentClick()
Called when the user taps / clicks on the document, not the page itself but on the side (if visible).
| ||||||||||
| void |
onDocumentLoadFailed(Throwable exception)
Called if document loading has failed.
| ||||||||||
| void |
onDocumentLoaded(PdfDocument document)
Called when document is successfully loaded and the document view has been laid out.
| ||||||||||
| boolean |
onDocumentSave(PdfDocument document, DocumentSaveOptions saveOptions)
Called before document will be saved.
| ||||||||||
| void |
onDocumentSaveCancelled(PdfDocument document)
Called if document saving has been cancelled.
| ||||||||||
| void |
onDocumentSaveFailed(PdfDocument document, Throwable exception)
Called if document saving has failed.
| ||||||||||
| void |
onDocumentSaved(PdfDocument document)
Called after the document has been saved.
| ||||||||||
| void |
onDocumentZoomed(PdfDocument document, int pageIndex, float scaleFactor)
Called when a user zooms a document.
| ||||||||||
| List<Integer> |
onGenerateMenuItemIds(List<Integer> menuItems)
Called before the main menu items are set to be ordered.
| ||||||||||
| boolean | onOptionsItemSelected(MenuItem item) | ||||||||||
| void |
onPageChanged(PdfDocument document, int pageIndex)
Called when user scrolled to a new page.
| ||||||||||
| boolean |
onPageClick(PdfDocument document, int pageIndex, MotionEvent event, PointF pagePosition, Annotation clickedAnnotation)
Called when user taps / clicks on the page.
| ||||||||||
| void |
onPageUpdated(PdfDocument document, int pageIndex)
Called when content of page with pageIndex has changed (for example due to annotation or form field being
updated).
| ||||||||||
| boolean | onPrepareOptionsMenu(Menu menu) | ||||||||||
| void |
onSetActivityTitle(PdfActivityConfiguration configuration, PdfDocument document)
Called when activity title must be set - before and after document was loaded.
| ||||||||||
| void | onTrimMemory(int level) | ||||||||||
| void | onUserInteraction() | ||||||||||
| void |
onUserInterfaceVisibilityChanged(boolean visible)
Called when user interface visibility have changed.
| ||||||||||
| void | onWindowFocusChanged(boolean hasFocus) | ||||||||||
| void | removePropertyInspectorLifecycleListener(PropertyInspectorCoordinatorLayoutController.PropertyInspectorLifecycleListener lifecycleListener) | ||||||||||
| void |
setAnnotationCreationInspectorController(AnnotationCreationInspectorController annotationCreationInspectorController)
Sets controller of the annotation inspector used when creating annotations.
| ||||||||||
| void |
setAnnotationEditingInspectorController(AnnotationEditingInspectorController annotationEditingInspectorController)
Sets controller of the annotation inspector used when editing annotations.
| ||||||||||
| void |
setConfiguration(PdfActivityConfiguration configuration)
Replaces activity configuration.
| ||||||||||
| void |
setDocumentFromDataProvider(DataProvider dataProvider, String password)
Loads a new document in this activity and replaces the existing one.
| ||||||||||
| void |
setDocumentFromDataProviders(List<DataProvider> dataProviders, List<String> passwords)
Loads a new document in this activity and replaces the existing one.
| ||||||||||
| void |
setDocumentFromUri(Uri documentUri, String password)
Loads a new document in this activity and replaces the existing one.
| ||||||||||
| void |
setDocumentFromUris(List<Uri> documentUris, List<String> passwords)
Loads a new document in this activity and replaces the existing one.
| ||||||||||
| void |
setDocumentInteractionEnabled(boolean documentInteractionEnabled)
Enables or disables interaction with the document.
| ||||||||||
| void |
setDocumentPrintDialogFactory(DocumentPrintDialogFactory factory)
Sets the creator for document print dialogs.
| ||||||||||
| void |
setDocumentSharingDialogFactory(DocumentSharingDialogFactory factory)
Sets the creator for document sharing dialogs.
| ||||||||||
| void | setOnContextualToolbarLifecycleListener(ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener lifecycleListener) | ||||||||||
| void | setOnContextualToolbarMovementListener(ToolbarCoordinatorLayout.OnContextualToolbarMovementListener movementListener) | ||||||||||
| void | setOnContextualToolbarPositionListener(ToolbarCoordinatorLayout.OnContextualToolbarPositionListener positionListener) | ||||||||||
| void |
setPageIndex(int pageIndex)
Set page to be displayed in the current document.
| ||||||||||
| void |
setPageIndex(int pageIndex, boolean animate)
Set page to be displayed in the current document.
| ||||||||||
| void | setPrintOptionsProvider(PrintOptionsProvider provider) | ||||||||||
| void |
setScreenTimeout(long screenTimeoutMillis)
Sets screen timeout in milliseconds that will be added to the predefined
system timeout (that is usually 1 minute).
| ||||||||||
| void |
setSharingActionMenuListener(ActionMenuListener listener)
Sets the listener for sharing menu lifecycle and click events.
| ||||||||||
| void | setSharingOptionsProvider(SharingOptionsProvider provider) | ||||||||||
| void |
setUserInterfaceEnabled(boolean userInterfaceEnabled)
Enables or disables the user interface.
| ||||||||||
| void |
setUserInterfaceViewMode(UserInterfaceViewMode userInterfaceViewMode)
Sets the activity user interface view mode at a runtime.
| ||||||||||
| void |
setUserInterfaceVisible(boolean show, boolean animate)
Show or hide user interface controls.
| ||||||||||
| static void |
showDocument(Context context, Uri documentUri, String password, PdfActivityConfiguration configuration)
Opens a new
PdfActivity displaying a passed document. | ||||||||||
| static void |
showDocument(Context context, Uri documentUri, PdfActivityConfiguration configuration)
Opens a new
PdfActivity displaying a passed document. | ||||||||||
| static void |
showImage(Context context, Uri imageUri, PdfActivityConfiguration configuration)
Opens a new
PdfActivity displaying a passed image document. | ||||||||||
| void |
showUserInterface()
Animates user interface controls into view.
| ||||||||||
| void |
toggleUserInterface()
Toggles the visibility of user interface controls.
| ||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void | onCreate(Bundle savedInstanceState) | ||||||||||
| void | onDestroy() | ||||||||||
| void | onPause() | ||||||||||
| void | onResume() | ||||||||||
| void | onSaveInstanceState(Bundle outState) | ||||||||||
| void | onStart() | ||||||||||
| void | onStop() | ||||||||||
Parameter for setScreenTimeout(long) used for restoring screen timeout to its default system value.
Parameter for setScreenTimeout(long) used for disabling screen timeout.
Id of the thumbnail grid menu item.
Id of the thumbnail grid menu item.
Id of the thumbnail grid menu item.
Id of the settings menu item.
Id of the thumbnail grid menu item.
Id of the thumbnail grid menu item.
Returns the PdfActivityConfiguration that was provided while launching this activity.
Returns the PdfDocument that is loaded into this activity, or null if no document has been loaded yet.
Returns the coordinator responsible for displaying documents and switching between multiple loaded documents.
DocumentCoordinator instance managing documents in this activity.
Returns object with inflated PSPDFKit views. This is meant to be used when extending this class for easier customization.
PSPDFKitViews.PSPDFView instances.
Returns current page index set on the document.
Returns the PdfFragment that is used to show the document.
null if no document is being displayed.
Returns property inspector coordinator layout.
Gets screen timeout in milliseconds that has been added to the predefined
system timeout, TIMEOUT_DEFAULT or TIMEOUT_INFINITE.
TIMEOUT_DEFAULT or TIMEOUT_INFINITE.
Get page sibling index (usable in double page mode).
| pageIndex | Index of the page for which we look for the sibling. |
|---|
-1 if there is none.
Return current user interface view mode that activity is using.
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.
Indicates whether interaction with the document is enabled right now.
true when the user can interact with the document, false otherwise.
Indicates whether the displayed document is an image or not.
true if the displayed document is image, false otherwise.
Indicates whether UI is enabled right now. UI is disabled when document is being saved/loaded, or when manually disabled.
true when UI is enabled right now.
Checks whether user interface controls are currently visible.
true if visible, false otherwise.
Called when the user taps / clicks on the document, not the page itself but on the side (if visible).
true if tap is handled or false if PSPDFKit should execute it's default action.
Called if document loading has failed.
| exception | Cause of the loading failure. |
|---|
Called when document is successfully loaded and the document view has been laid out.
| document | Loaded document instance. |
|---|
Called before document will be saved. This callback allows cancellation of the save process.
| document | Instance of document to be saved. |
|---|---|
| saveOptions | Save options to be applied to the document. You may change parameters on this object to control how document is saved. |
true if the document should be saved, false if saving should be cancelled.
Called if document saving has been cancelled.
| document | Instance of document that was saved. |
|---|
Called if document saving has failed.
| exception | Cause of the saving failure if applicable. |
|---|
Called after the document has been saved.
| document | Instance of document that was saved. |
|---|
Called when a user zooms a document.
| document | Current document. |
|---|---|
| pageIndex | The number of the page that the was zoomed. |
| scaleFactor | The current scale factor. |
Called before the main menu items are set to be ordered. Override this method
to add your custom items to the list. You add just the ids and then in
onCreateOptionsMenu(Menu) and onPrepareOptionsMenu(Menu)
you can find your items by id and edit them accordingly.
| menuItems | A list of menu item ids, ordered by how they're gonna appear in the main toolbar. |
|---|
Called when user scrolled to a new page.
| document | Currently opened document. |
|---|---|
| pageIndex | Page number of new page. |
Called when user taps / clicks on the page.
| document | Currently opened document. |
|---|---|
| pageIndex | Page number of the page being tapped. |
| event | MotionEvent that triggered this page click. May be null if this page click was triggered from keyboard or
accessibility event. |
| pagePosition | Tapped page position (in PDF page coordinates with origin on bottom left). Coordinates passed here may exceed the page size
(which is returned by getPageSize(int)) and can also be negative. If the click was triggered by the
keyboard, pagePosition will be null. |
| clickedAnnotation | Annotation that was tapped, or null if no annotation was tapped. |
true if tap was handled by this DocumentListener and should not be handled by PSPDFKit anymore. If returning
false PSPDFKit will continue executing it's default action.
Called when content of page with pageIndex has changed (for example due to annotation or form field being updated). All views displaying this page need to refresh.
| pageIndex | Page index of the updated page. Page index is 0-based. |
|---|
Called when activity title must be set - before and after document was loaded.
| configuration | Passed activity configuration instance. |
|---|---|
| document | Loaded document. If document hasn't been loaded yet, this parameter will be null.
|
Called when user interface visibility have changed.
| visible | true when UI interface is visible, false when it is hidden.
|
|---|
Sets controller of the annotation inspector used when creating annotations. This replaces default annotation inspector.
| annotationCreationInspectorController | Controller instance to use. |
|---|
Sets controller of the annotation inspector used when editing annotations. This replaces default annotation inspector.
| annotationEditingInspectorController | Controller instance to use. |
|---|
Replaces activity configuration. This method restarts activity to apply new configuration.
Note: This is a no-op when configuration has not changed.
| configuration | The configuration to restart activity with. |
|---|
Loads a new document in this activity and replaces the existing one. This method may only be called if
onSaveInstanceState(Bundle) has not been called or an exception will be thrown, since
after that call state loss could occur.
| dataProvider | Data provider for the document. |
|---|---|
| password | Document password. May be null. |
Loads a new document in this activity and replaces the existing one. This method may only be called if
onSaveInstanceState(Bundle) has not been called or an exception will be thrown, since
after that call state loss could occur.
| dataProviders | List of data providers for compound document. |
|---|---|
| passwords | List of passwords for compound document, may be null. |
Loads a new document in this activity and replaces the existing one. This method may only be called if
onSaveInstanceState(Bundle) has not been called or an exception will be thrown, since
after that call state loss could occur.
| documentUri | Document URI. |
|---|---|
| password | Document password. May be null.
|
| IllegalStateException |
|---|
Loads a new document in this activity and replaces the existing one. This method may only be called if
onSaveInstanceState(Bundle) has not been called or an exception will be thrown, since
after that call state loss could occur.
| documentUris | List of document URIs for compound document. |
|---|---|
| passwords | List of passwords for compound document, may be null. |
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.
| documentInteractionEnabled | true to enable interacting with the document, false to disable it.
|
|---|
Sets the creator for document print dialogs.
| factory | Creator to set or null to clear registered creator.
|
|---|
Sets the creator for document sharing dialogs.
| factory | Creator to set or null to clear registered creator.
|
|---|
Set page to be displayed in the current document.
| pageIndex | Index of the target page (starting at 0). |
|---|
Set page to be displayed in the current document.
| pageIndex | Index of the target page (starting at 0). |
|---|---|
| animate | true if the transition to the specified page should be animated, false otherwise.
|
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.
| screenTimeoutMillis | can be a positive number, TIMEOUT_DEFAULT or TIMEOUT_INFINITE.
|
|---|
Sets the listener for sharing menu lifecycle and click events. Calling this method will replace any previously set listener.
You may provide null to clear the listener.
| listener | ActionMenuListener that should be notified, or null to clear the listener.
|
|---|
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).
| userInterfaceEnabled | true to enable the UI, false to disable the UI.
|
|---|
Sets the activity user interface view mode at a runtime. Overriding PdfActivityConfiguration.
Show or hide user interface controls. This does not respect currently configured UserInterfaceViewMode.
| show | true to show user interface, false to hide it. |
|---|---|
| animate | true to animate the change.
|
Opens a new PdfActivity displaying a passed document. If the document is password
protected PSPDFKit will prompt the user to enter the password.
| context | Calling context. |
|---|---|
| documentUri | Uri pointing to the document file. |
| password | Document password, can be null. |
| configuration | Desired activity configuration generated with PdfActivityConfiguration.Builder.
|
Opens a new PdfActivity displaying a passed document. If the document is password
protected PSPDFKit will prompt the user to enter the password.
| context | Calling context |
|---|---|
| documentUri | Uri pointing to the document file |
| configuration | Desired activity configuration generated with PdfActivityConfiguration.Builder
|
Opens a new PdfActivity displaying a passed image document.
| context | Calling context |
|---|---|
| imageUri | Uri pointing to the image document with a supported format (JPG or PNG). |
| configuration | Desired activity configuration generated with PdfActivityConfiguration.Builder,
ImageDocumentLoader#getDefaultImageDocumentActivityConfiguration(PdfActivityConfiguration.Builder),
or getDefaultImageDocumentActivityConfiguration(Context).
|
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.
Toggles the visibility of user interface controls.