Class DocumentState
-
- All Implemented Interfaces:
-
com.pspdfkit.listeners.OnVisibilityChangedListener
public abstract class DocumentState implements OnVisibilityChangedListener
A state object that can be hoisted to control and observe properties of the com.pspdfkit.jetpack.compose.views.DocumentView. Create instances of this object using rememberDocumentState.
-
-
Field Summary
Fields Modifier and Type Field Description private final StateFlow<Boolean>
viewWithOverlappingToolbarShown
private DocumentConnection
documentConnection
-
Method Summary
Modifier and Type Method Description final StateFlow<Boolean>
getViewWithOverlappingToolbarShown()
Keep track of whether a full screen view is shown that is not the document view so we can handle the main toolbar clipping final DocumentConnection
getDocumentConnection()
Provides ability to perform specific tasks in Document. final Unit
setDocumentConnection(DocumentConnection documentConnection)
Provides ability to perform specific tasks in Document. final Boolean
isDefaultViewerActive()
Checks if viewer is visible or not. final Unit
exitCurrentState()
Reverts back to viewer from any other State. final Unit
setOnContextualToolbarLifecycleListener(ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener listener)
Set the ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener to listen to the lifecycle of the contextual toolbar. final Unit
updateConfiguration(PdfActivityConfiguration configuration)
Updated the configuration of the document. abstract String
getTitle()
Provides the title of the document. final Unit
toggleView(Integer option)
Toggles the view based on the provided MENU_OPTIONS in com.pspdfkit.ui.PdfActivity. Unit
onShow(View view)
Called whenever a PSPDFKit view has become visible. Unit
onHide(View view)
Called whenever a PSPDFKit view has been hidden. final PdfActivityConfiguration
getCurrentConfiguration()
Provides the current configuration of the document. final Bundle
getViewState()
Provides the SavedData bundle from the document. final Unit
setViewState(Bundle bundle)
Set the SavedData bundle to the document. final Unit
setCustomPdfSource(DocumentSource source)
Sets the custom source for the PDF file. final DocumentSource
getDocumentSource()
Provides the document source of the PDF file. -
-
Method Detail
-
getViewWithOverlappingToolbarShown
final StateFlow<Boolean> getViewWithOverlappingToolbarShown()
Keep track of whether a full screen view is shown that is not the document view so we can handle the main toolbar clipping
-
getDocumentConnection
final DocumentConnection getDocumentConnection()
Provides ability to perform specific tasks in Document.
-
setDocumentConnection
final Unit setDocumentConnection(DocumentConnection documentConnection)
Provides ability to perform specific tasks in Document.
-
isDefaultViewerActive
final Boolean isDefaultViewerActive()
Checks if viewer is visible or not. Default value is true
-
exitCurrentState
final Unit exitCurrentState()
Reverts back to viewer from any other State.
-
setOnContextualToolbarLifecycleListener
final Unit setOnContextualToolbarLifecycleListener(ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener listener)
Set the ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener to listen to the lifecycle of the contextual toolbar. Can be implemented in a LaunchedScope to handle the lifecycle of the contextual toolbar, i.e. LaunchedEffect(Unit) { documentState.setOnContextualToolbarLifecycleListener(object : ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener { override fun onPrepareContextualToolbar(toolbar: ContextualToolbar<*>) { if (toolbar is AnnotationCreationToolbar) { // Register grouping rule to tell toolbar how to group menu items. toolbar.setMenuItemGroupingRule(object : PresetMenuItemGroupingRule(context) { override fun getGroupPreset(capacity: Int, itemsCount: Int) = AnnotationCreationToolbarItemPresets.FOUR_ITEMS_GROUPING; }) } } }) }
-
updateConfiguration
final Unit updateConfiguration(PdfActivityConfiguration configuration)
Updated the configuration of the document.
- Parameters:
configuration
- The new configuration to set.
-
toggleView
final Unit toggleView(Integer option)
Toggles the view based on the provided MENU_OPTIONS in com.pspdfkit.ui.PdfActivity.
- Parameters:
option
- The menu id of view to toggle.
-
getCurrentConfiguration
final PdfActivityConfiguration getCurrentConfiguration()
Provides the current configuration of the document.
- Returns:
PdfActivityConfiguration object.
-
getViewState
final Bundle getViewState()
Provides the SavedData bundle from the document.
- Returns:
Bundle object.
-
setViewState
final Unit setViewState(Bundle bundle)
Set the SavedData bundle to the document.
- Parameters:
bundle
- The SavedData bundle to set.
-
setCustomPdfSource
final Unit setCustomPdfSource(DocumentSource source)
Sets the custom source for the PDF file. if you pass null in the source param, it will refresh the document by using same source.
- Parameters:
source
- PDF document source.
-
getDocumentSource
final DocumentSource getDocumentSource()
Provides the document source of the PDF file.
- Returns:
DocumentSource object.
-
-
-
-