| java.lang.Object | |||
| ↳ | android.view.View | ||
| ↳ | android.view.ViewGroup | ||
| ↳ | com.pspdfkit.ui.toolbar.ContextualToolbar<T extends com.pspdfkit.ui.special_mode.controller.base.SpecialModeController> | ||
Known Direct Subclasses
|
Base class of all contextual toolbars.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| interface | ContextualToolbar.OnMenuItemClickListener | Listener for menu items clicks. | |||||||||
| interface | ContextualToolbar.OnMenuItemLongClickListener | Listener for long clicks on menu items with submenu. | |||||||||
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | CONTEXTUAL_TOOLBAR_PADDING_DP | ||||||||||
| int | MIN_TOOLBAR_CAPACITY | Minimal number of spaces left on the toolbar for menu icons. | |||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup
| |||||||||||
From class
android.view.View
| |||||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| protected ContextualToolbarMenuItem | closeButton | A button for closing the contextual toolbar. | |||||||||
| protected ToolbarCoordinatorLayoutController | coordinatorController | Controller for ContextualToolbar -> ToolbarCoordinatorLayout communication. |
|||||||||
| protected ContextualToolbarMenuItem | dragButton | A special button used for dragging the toolbar. | |||||||||
| protected List<ContextualToolbarMenuItem> | originalMenuItems | Items originally set on the toolbar before the grouping rule is applied, see setMenuItems(List). |
|||||||||
|
[Expand]
Inherited Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.View
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ContextualToolbar(Context context) | |||||||||||
| ContextualToolbar(Context context, AttributeSet attrs) | |||||||||||
| ContextualToolbar(Context context, AttributeSet attrs, int defStyleAttr) | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| abstract void |
bindController(T specialModeController)
Binds the special mode controller to this toolbar.
| ||||||||||
| ContextualToolbarMenuItem |
findItemById(int menuItemId)
Finds a menu item with specific ID in a list of currently displayed menu items.
| ||||||||||
| ContextualToolbarMenuItem |
getCloseButton()
Returns the button used to close the toolbar.
| ||||||||||
| ContextualToolbarMenuItem |
getDragButton()
Returns the button used to drag the toolbar (if detachable).
| ||||||||||
| List<ContextualToolbarMenuItem> |
getMenuItems()
Gets the list of originally set menu items.
| ||||||||||
| ToolbarCoordinatorLayout.LayoutParams.Position |
getPosition()
Gets position of the toolbar.
| ||||||||||
| int |
getSubmenuSizePx()
Returns the submenu's size in pixels, or the amount of space needed for the submenu.
| ||||||||||
| boolean |
hasOpenedSubmenu()
Returns true if this contextual toolbar have currently opened submenu.
| ||||||||||
| final boolean |
isAttached()
Indicates whether the toolbar is attached or detached.
| ||||||||||
| boolean | isDraggable() | ||||||||||
| boolean |
onBackPressed()
Called when onBackPressed() to wire up back press with back and close buttons.
| ||||||||||
| void | onClick(View v) | ||||||||||
| boolean |
onLongClick(View v)
Called when a view has been clicked and held.
| ||||||||||
| List<ContextualToolbarMenuItem> |
onMenuItemsGrouped(List<ContextualToolbarMenuItem> menuItems)
A method called once the flat items provided through
setMenuItems(List) have been grouped by the
MenuItemGroupingRule that can be set with setMenuItemGroupingRule(MenuItemGroupingRule) and with
DefaultMenuItemGroupingRule as the default one. | ||||||||||
| boolean | onTouchEvent(MotionEvent event) | ||||||||||
| final void |
setAttached(boolean isAttached)
Sets whether the toolbar is attached or detached from the layout.
| ||||||||||
| void |
setCloseButton(ContextualToolbarMenuItem closeButton)
Sets the button used to close the toolbar.
| ||||||||||
| void |
setDragButton(ContextualToolbarMenuItem dragButton)
Sets the button used to drag the toolbar (if detachable).
| ||||||||||
| void |
setDraggable(boolean draggable)
Sets whether the toolbar is draggable or not.
| ||||||||||
| boolean |
setMenuItemEnabled(int menuItemId, boolean enabled)
Enables or disables a menu item if that menu item currently exists.
| ||||||||||
| void |
setMenuItemGroupingRule(MenuItemGroupingRule groupingRule)
Sets the rule for grouping menu items.
| ||||||||||
| boolean |
setMenuItemVisibility(int menuItemId, int visibility)
Shows or hides a menu item if that menu item currently exists.
| ||||||||||
| void |
setMenuItems(List<ContextualToolbarMenuItem> menuItems)
Set contextual toolbar menu items.
| ||||||||||
| void |
setOnMenuItemClickListener(ContextualToolbar.OnMenuItemClickListener listener)
Sets a listener for menu item clicks on the toolbar.
| ||||||||||
| void |
setOnMenuItemLongClickListener(ContextualToolbar.OnMenuItemLongClickListener listener)
Sets a listener for menu item long clicks.
| ||||||||||
| void |
setPosition(ToolbarCoordinatorLayout.LayoutParams.Position position)
Sets position of the toolbar.
| ||||||||||
| void |
setToolbarCoordinatorController(ToolbarCoordinatorLayoutController coordinatorController)
Sets the toolbar coordinator controller for communication with
ToolbarCoordinatorLayout. | ||||||||||
| void |
setUseBackButtonForCloseWhenHorizontal(boolean useBackButtonForCloseWhenHorizontal)
Sets whether to use back button for closing the toolbar when the toolbar is placed horizontally.
| ||||||||||
| abstract void |
unbindController()
Unbinds the bound controller (if any).
| ||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Completable | closeSubmenuForItem(ContextualToolbarMenuItem menuItem) | ||||||||||
| void | deselectCurrentMenuItem() | ||||||||||
| ContextualToolbarMenuItem | getCurrentlySelectedMenuItem() | ||||||||||
| abstract void | handleMenuItemClick(ContextualToolbarMenuItem item) | ||||||||||
| void |
notifyToolbarChanged()
Notifies
ToolbarCoordinatorLayoutController about toolbar menu items change made by the toolbar implementation. | ||||||||||
| void | onAttachedToWindow() | ||||||||||
| void | onDetachedFromWindow() | ||||||||||
| void | onDraw(Canvas canvas) | ||||||||||
| void | onLayout(boolean changed, int l, int t, int r, int b) | ||||||||||
| void | onMeasure(int widthMeasureSpec, int heightMeasureSpec) | ||||||||||
| boolean |
onMenuItemClick(ContextualToolbarMenuItem clickedMenuItem)
This method handles menu item clicks, in respect to the menu item listener, which can
mark click as handled and suppress further click handling.
| ||||||||||
| boolean | onMenuItemLongClick(ContextualToolbarMenuItem clickedMenuItem) | ||||||||||
| Completable | openSubmenuForItem(ContextualToolbarMenuItem menuItem) | ||||||||||
| boolean | selectMenuItem(ContextualToolbarMenuItem menuItem) | ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup
| |||||||||||
From class
android.view.View
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.graphics.drawable.Drawable.Callback
| |||||||||||
From interface
android.view.KeyEvent.Callback
| |||||||||||
From interface
android.view.View.OnClickListener
| |||||||||||
From interface
android.view.View.OnLongClickListener
| |||||||||||
From interface
android.view.ViewManager
| |||||||||||
From interface
android.view.ViewParent
| |||||||||||
From interface
android.view.accessibility.AccessibilityEventSource
| |||||||||||
Minimal number of spaces left on the toolbar for menu icons.
Controller for ContextualToolbar -> ToolbarCoordinatorLayout communication.
ContextualToolbar needs a way to invoke its own detaching and attaching.
ToolbarCoordinatorLayout is the one that handles movements once ContextualToolbar is detached.
A special button used for dragging the toolbar. Present when the toolbar is draggable.
Items originally set on the toolbar before the grouping rule is applied, see setMenuItems(List).
Binds the special mode controller to this toolbar.
| specialModeController | Controller to bind to a toolbar. |
|---|
Finds a menu item with specific ID in a list of currently displayed menu items.
Returns the button used to close the toolbar.
Returns the button used to drag the toolbar (if detachable).
Gets the list of originally set menu items. Note that the shown menu items in the toolbar could differ from structure because they
could be altered by MenuItemGroupingRule that regroups items depending on the available space.
Gets position of the toolbar.
ToolbarCoordinatorLayout.
Returns the submenu's size in pixels, or the amount of space needed for the submenu. If there are no items with a submenu, it will return 0.
Returns true if this contextual toolbar have currently opened submenu.
Indicates whether the toolbar is attached or detached.
true if the toolbar is attached and can't be dragged around, false otherwise.
true when toolbar is draggable.
Called when onBackPressed() to wire up back press with back and close buttons.
true if the back press was handled, false otherwise.
Called when a view has been clicked and held.
| v | The view that was clicked and held. |
|---|
A method called once the flat items provided through setMenuItems(List) have been grouped by the
MenuItemGroupingRule that can be set with setMenuItemGroupingRule(MenuItemGroupingRule) and with
DefaultMenuItemGroupingRule as the default one.
By overriding this method you can do final editing before items are added to the toolbar.
| menuItems | Grouped menu items. |
|---|
Sets whether the toolbar is attached or detached from the layout. Being detached means that it can be moved around (used for annotation editor toolbar). In the scope of this view, what it affects is coloring of the view - the toolbar is highlighted when detached. This is usually called from the outside (toolbar coordinator layout).
| isAttached | true to set toolbar as attached, false as detached.
|
|---|
Sets the button used to close the toolbar.
| closeButton | Button to be set as a close button. |
|---|
Sets the button used to drag the toolbar (if detachable).
| dragButton | Button to be set as a drag button. |
|---|
Sets whether the toolbar is draggable or not.
| draggable | If true, the toolbar can be dragged. If false, it's pinned to the top.
|
|---|
Enables or disables a menu item if that menu item currently exists.
| menuItemId | ID of the menu item. |
|---|---|
| enabled | true if the item should be enabled, false otherwise. |
true if the menu item exists and it's enabled status was applied.
Sets the rule for grouping menu items. Default one is DefaultMenuItemGroupingRule.
| groupingRule | Menu items grouping rule to be set. |
|---|
Set contextual toolbar menu items.
| menuItems | Menu items to populate the toolbar. |
|---|
Sets a listener for menu item clicks on the toolbar.
Calling this method will replace any previously set listener.
You may provide null to clear the listener.
| listener | ContextualToolbar.OnMenuItemClickListener that should be notified, or null to clear the listener.
|
|---|
Sets a listener for menu item long clicks.
Calling this method will replace any previously set listener.
You may provide null to clear the listener.
| listener | ContextualToolbar.OnMenuItemLongClickListener that should be notified, or null to clear the listener.
|
|---|
Sets position of the toolbar.
| position | Position for the toolbar in the ToolbarCoordinatorLayout.
|
|---|
Sets the toolbar coordinator controller for communication with ToolbarCoordinatorLayout.
Calling this method will replace any previously set controller.
You may provide null to clear the controller.
| coordinatorController | ToolbarCoordinatorLayoutController that should be notified, or null to clear the controller.
|
|---|
Sets whether to use back button for closing the toolbar when the toolbar is placed horizontally. Defaults to true.
If false the 'X' button will be used and it will be placed on the end of the toolbar.
| useBackButtonForCloseWhenHorizontal | true to use back button, false to use 'X' button
|
|---|
Unbinds the bound controller (if any).
Notifies ToolbarCoordinatorLayoutController about toolbar menu items change made by the toolbar implementation.
Coordinator controller is not notified about the change when using public method setMenuItems(List.
This will trigger a call to onPrepareContextualToolbar(ContextualToolbar),
giving users the chance to modify the toolbar - e.g. to apply a custom grouping rule or hide toolbar items.
This method handles menu item clicks, in respect to the menu item listener, which can mark click as handled and suppress further click handling.
| clickedMenuItem | Menu item that was clicked. |
|---|
true if the click was handled, and should not be processed further on.