View mode dialog

In this document

ViewModePickerDialogFragment allows users to pick PDF page presentation mode, select page color mode, rotate pages, and crop pages.

Showing view mode dialog

To show view mode dialog in your activity, create a new instance of ViewModePickerDialogFragment by using newInstance(PDFViewCtrl.PagePresentationMode, boolean, boolean, int), and call show(FragmentManager, String):

ViewModePickerDialogFragment dialog = ViewModePickerDialogFragment.newInstance(pdfViewCtrl.getPagePresentationMode(), false, false, 0);
// set dialog style
dialog.setStyle(DialogFragment.STYLE_NORMAL, com.pdftron.pdf.tools.R.style.CustomAppTheme);   
// show dialog
dialog.show(activity.getSupportFragmentManager(), "view_mode_picker");

where activity is an instance of Activity.

Setting view mode dialog listener

In order to let users to pick PDF page presentation mode, color mode, etc. You need to set view mode dialog listener. To set view mode dialog listener, call: ViewModePickerDialogFragment.setViewModePickerDialogFragmentListener(ViewModePickerDialogFragment.ViewModePickerDialogFragmentListener). Override each method in the listener to change page presentation mode, colr mode, reflow, etc.

dialog.setViewModePickerDialogFragmentListener(new ViewModePickerDialogFragment.ViewModePickerDialogFragmentListener() {
   /**
    * Called when a view mode has been selected.
    *
    * @param viewMode The selected view mode
    */
    @Override
    public void onViewModeSelected(String viewMode) {
        // do something
    }

    /**
      * Called when a color mode has been selected.
      *
      * @param colorMode The color mode
      * @return True if the dialog should be dismissed
      */
    @Override
    public boolean onViewModeColorSelected(int colorMode) {
        return false;
    }

    /**
      * Called when a custom color mode is selected
      *
      * @param bgColor  The selected background color
      * @param txtColor The selected text color
      * @return True if the dialog should be dismissed
      */
    @Override
    public boolean onCustomColorModeSelected(int bgColor, int txtColor) {
        return false;
    }

    /**
      * Called when the dialog has been dismissed.
      */
    @Override
    public void onViewModePickerDialogFragmentDismiss() {
        // do something
    }

    /**
      * The implementation should zoom in/out reflow
      *
      * @param flagZoomIn True if zoom in; False if zoom out
      * @return The text size raging from 0 to 100
      */
    @Override
    public int onReflowZoomInOut(boolean flagZoomIn) {
        return 0;
    }

    /**
      * The implementation should check tab conversion and shows the alert if needed.
      *
      * @param messageID      The message ID
      * @param allowConverted True if conversion is allowed
      * @return True if handled
      */
    @Override
    public boolean checkTabConversionAndAlert(int messageID, boolean allowConverted) {
        return false;
    }
});

In function onViewModeSelected(String), the selected view mode values include fowllowing:

To learn about setting page presentation mode, see PDFViewCtrl page presentation mode.
To learn about setting page color mode, see PDFViewCtrl color modes.
To learn about reflow, see reflow.
To learn about cropping pages, see crop page dialog.