Product: PDFTron Android
Product Version: 9.3.1
Please give a brief summary of your issue:
show PRESET area in a ToolBar
with PdfViewCtrl
and AnnotationToolbarComponent
Please describe your issue and provide steps to reproduce it:
Hi! I want to show the preset options in a ToolBar
created with AnnotationToolbarComponent
in an Activity that shows the document with a PdfCtrlView
controller. I would like to get this:
My code is:
// First find our container view group
FrameLayout mToolbarContainer = new FrameLayout(mContext);
mToolbarContainer.setId(ANNOT_TOOLBAR_ID);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ABOVE, BOTTOM_BAR_ID);
addView(mToolbarContainer, params);
// Then setup ToolManager and related ViewModels with AnnotationToolbarComponent
// Remember to initialize your ToolManager before calling below
FragmentActivity activity = (FragmentActivity) getActivity(mContext);
ViewModelProvider vmProvider = new ViewModelProvider(activity);
ToolManagerViewModel toolManagerVm = vmProvider.get(ToolManagerViewModel.class);
toolManagerVm.setToolManager(toolManager);
PresetBarViewModel presetVm = vmProvider.get(PresetBarViewModel.class);
AnnotationToolbarViewModel annotToolbarVm = vmProvider.get(AnnotationToolbarViewModel.class);
// Create our UI component for the annotation toolbar
mAnnotationToolbarComponent = new AnnotationToolbarComponent(
activity,
annotToolbarVm,
presetVm,
toolManagerVm,
mToolbarContainer
);
mAnnotationToolbarComponent.inflateWithBuilder(
//DefaultToolbars.defaultDrawToolbar
AnnotationToolbarBuilder.withTag("Custom Toolbar")
// Add some pre-defined tools that will be handled internally using ToolManager
.addToolButton(ToolbarButtonType.SQUARE, 100)
.addToolButton(ToolbarButtonType.INK, 102)
.addToolButton(ToolbarButtonType.FREE_HIGHLIGHT, 103)
.addToolButton(ToolbarButtonType.ERASER, 104)
// We can also add a custom button to handle ourselves, for example here
// we have added a "favorites" button that contains a star icon
// .addCustomButton(R.string.favorites, R.drawable.annotation_note_icon_star_fill, 105)
.addToolStickyButton(ToolbarButtonType.UNDO, 106)
.addToolStickyButton(ToolbarButtonType.REDO, 107)
);
mAnnotationToolbarComponent.show(true);
Thanks!