Class PSPDFKitPreferences
-
- All Implemented Interfaces:
public class PSPDFKitPreferences
Allows you to read and write global preferences.
-
-
Field Summary
Fields Modifier and Type Field Description public final static String
PREFERENCES_NAME
-
Method Summary
Modifier and Type Method Description static PSPDFKitPreferences
get(@NonNull() Context context)
Gets global singleton preferences instance. List<Pair<AnnotationTool, AnnotationToolVariant>>
getLastAnnotationTools()
Gets the list of annotation tools as they were last used/selected. void
setLastAnnotationTool(@NonNull() AnnotationTool tool)
Sets the last used annotation tool. void
setLastAnnotationTool(@NonNull() AnnotationTool tool, @NonNull() AnnotationToolVariant toolVariant)
Sets the last used annotation tool. String
getAnnotationCreator(@Nullable() String defaultCreator)
Retrieves the annotation creator boolean
isAnnotationCreatorSet()
Checks if the annotation creator has been set void
resetAnnotationCreator()
Resets the annotation creator by nullifying the value. void
setAnnotationCreator(@Nullable() String creator)
Sets the annotation creator. ToolbarCoordinatorLayout.LayoutParams.Position
getLastToolbarPosition(@NonNull() ContextualToolbar contextualToolbar, @NonNull() ToolbarCoordinatorLayout.LayoutParams.Position defaultPosition)
Gets the last position of the given toolbar. void
setLastToolbarPosition(@NonNull() ContextualToolbar contextualToolbar, @NonNull() ToolbarCoordinatorLayout.LayoutParams.Position position)
Saves the last position of the given toolbar. List<Integer>
getRecentlyUsedColors()
Gets the recently used colors. void
setRecentlyUsedColors(@NonNull() List<Integer> recentlyUsedColors)
Replaces the list of recently used colors with the new list. void
setIsComparisonFirstLaunch(boolean isComparisonFirstLaunch)
Sets if comparison alignment dialog has been launched before Boolean
isComparisonFirstLaunch()
Returns True if it's the first time launching comparison alignment dialog and false when it has been launched before. void
setMeasurementSnappingEnabled(boolean enabled)
Enables snapping to page graphics for measurement tools. Boolean
isMeasurementSnappingEnabled()
Returns true
if snapping to page graphics for measurement tools is enabled.void
setSnapToSelfEnabled(boolean enabled)
Enables snapping to itself at the end of shape Boolean
isSnapToSelfEnabled()
Returns true
if snapping to self is enabled.void
setSmartGuidesEnabled(boolean enabled)
Enables smart guides for predefined angles. void
setUseStylusForAnnotating(boolean useStylusForAnnotating)
Enables or disables the usage of stylus during drawing Boolean
isSmartGuidesEnabled()
Returns true
if smart guides for various angles is enabled.Boolean
useStylusForAnnotating()
Returns true
if we should only use the stylus during drawing.void
clearPreferences()
Wipes all user preferences, handle with care. void
setStylusSettingChangeListener(@Nullable() StylusSettingChangeListener stylusSettingChangeListener)
A listener for when the stylus setting changes for real time updates to the toolbar. -
-
Method Detail
-
get
@NonNull() static PSPDFKitPreferences get(@NonNull() Context context)
Gets global singleton preferences instance.
-
getLastAnnotationTools
@NonNull() List<Pair<AnnotationTool, AnnotationToolVariant>> getLastAnnotationTools()
Gets the list of annotation tools as they were last used/selected. Items that were not yet selected are not in the list, so this means that list will be empty at the beginning so that needs to be handled as well.
-
setLastAnnotationTool
void setLastAnnotationTool(@NonNull() AnnotationTool tool)
Sets the last used annotation tool. This method will add the tool to the beginning of the last selected tools list. If it already exists there, it will be just moved to the first place.
- Parameters:
tool
- Tool to be set as the last used one.
-
setLastAnnotationTool
void setLastAnnotationTool(@NonNull() AnnotationTool tool, @NonNull() AnnotationToolVariant toolVariant)
Sets the last used annotation tool. This method will add the tool to the beginning of the last selected tools list. If it already exists there, it will be just moved to the first place.
- Parameters:
tool
- Tool to be set as the last used one.toolVariant
- Variant of the annotation tool for which to set the value.
-
getAnnotationCreator
@Nullable() String getAnnotationCreator(@Nullable() String defaultCreator)
Retrieves the annotation creator
- Parameters:
defaultCreator
- the default creator that will be returned if no creator has been previously stored.- Returns:
the annotation creator
-
isAnnotationCreatorSet
boolean isAnnotationCreatorSet()
Checks if the annotation creator has been set
- Returns:
return
false
if the annotation creator has not been set,true
otherwise.
-
resetAnnotationCreator
void resetAnnotationCreator()
Resets the annotation creator by nullifying the value.
-
setAnnotationCreator
void setAnnotationCreator(@Nullable() String creator)
Sets the annotation creator.
- Parameters:
creator
- the creator to set
-
getLastToolbarPosition
@NonNull() ToolbarCoordinatorLayout.LayoutParams.Position getLastToolbarPosition(@NonNull() ContextualToolbar contextualToolbar, @NonNull() ToolbarCoordinatorLayout.LayoutParams.Position defaultPosition)
Gets the last position of the given toolbar.
- Parameters:
contextualToolbar
- Toolbar for which to get the position.defaultPosition
- Default toolbar position.- Returns:
Last position of the toolbar.
-
setLastToolbarPosition
void setLastToolbarPosition(@NonNull() ContextualToolbar contextualToolbar, @NonNull() ToolbarCoordinatorLayout.LayoutParams.Position position)
Saves the last position of the given toolbar.
- Parameters:
contextualToolbar
- Toolbar for which to save the position.position
- Position to be saved.
-
getRecentlyUsedColors
@NonNull() List<Integer> getRecentlyUsedColors()
Gets the recently used colors.
- Returns:
The recently used colors, this might be empty.
-
setRecentlyUsedColors
void setRecentlyUsedColors(@NonNull() List<Integer> recentlyUsedColors)
Replaces the list of recently used colors with the new list.
- Parameters:
recentlyUsedColors
- The new colors to set as recently used colors.
-
setIsComparisonFirstLaunch
void setIsComparisonFirstLaunch(boolean isComparisonFirstLaunch)
Sets if comparison alignment dialog has been launched before
-
isComparisonFirstLaunch
Boolean isComparisonFirstLaunch()
Returns True if it's the first time launching comparison alignment dialog and false when it has been launched before. .
-
setMeasurementSnappingEnabled
void setMeasurementSnappingEnabled(boolean enabled)
Enables snapping to page graphics for measurement tools.
-
isMeasurementSnappingEnabled
Boolean isMeasurementSnappingEnabled()
Returns
true
if snapping to page graphics for measurement tools is enabled. Default value istrue
.
-
setSnapToSelfEnabled
void setSnapToSelfEnabled(boolean enabled)
Enables snapping to itself at the end of shape
-
isSnapToSelfEnabled
Boolean isSnapToSelfEnabled()
Returns
true
if snapping to self is enabled. Default value istrue
.
-
setSmartGuidesEnabled
void setSmartGuidesEnabled(boolean enabled)
Enables smart guides for predefined angles.
-
setUseStylusForAnnotating
void setUseStylusForAnnotating(boolean useStylusForAnnotating)
Enables or disables the usage of stylus during drawing
-
isSmartGuidesEnabled
Boolean isSmartGuidesEnabled()
Returns
true
if smart guides for various angles is enabled. Default value istrue
.
-
useStylusForAnnotating
Boolean useStylusForAnnotating()
Returns
true
if we should only use the stylus during drawing. Default value isfalse
.
-
clearPreferences
void clearPreferences()
Wipes all user preferences, handle with care.
-
setStylusSettingChangeListener
@RestrictTo(value = RestrictTo.Scope.LIBRARY) void setStylusSettingChangeListener(@Nullable() StylusSettingChangeListener stylusSettingChangeListener)
A listener for when the stylus setting changes for real time updates to the toolbar. Only for internal use
-
-
-
-