TRichView 20.4 – FireMonkey Android platform

We’ve uploaded new versions of our components: TRichView 20.4, ScaleRichView 11.3.1, ReportWorkshop 4.1.1

Trial versions are available here: https://www.trichview.com/download/

The new feature of this update is Android (32-bit and 64-bit) in FireMonkey (supported by TRichView, RvHtmlImporter, RichViewXML components).

The full list of supported FireMonkey platforms: Windows (32-bit and 64-bit), macOS (64-bit Intel and ARM), Android (32-bit and 64-bit).
Next in plans: Linux.

This update is free for customers who ordered TRichView in 2020, 2021, and 2022.

FireMonkey Android platforms

Starting from this update, TRichView supports 32-bit and 64-bit Android platforms in Delphi 10.4 and 11.x.
You can implement a rich text interface and create DocX, RTF, Markdown, HTML and text files on mobile phones and tablets using our components.

Supported touch screen gestures:

  • tap: moving the caret, executing a hypertext link (in TRichView or read-only TRichViewEdit)
  • long tap: selecting word
  • panning: scrolling. You can also resize images and controls, and make selection using special selecton handles.

Note: to make selection, TRichView can use both old selection handles (the same as in VCL) and selection handles specified in its FireMonkey style.
By default, ‘memostyle’ for Android contains selection handles, and they are used. They are better than VCL selection handles, because they can be drawn outside table cells and even outside the editor window.

Selecting text

Known issues

Text menu

FireMonkey for Android does not support TPopupMenu. Instead, FireMonkey system can display a special Android menu containing Clipboard and sharing commands. TRichViewEdit implements all necessary interfaces, so this menu is shown after making selection.
Unfortunately, this menu was designed for TMemo and TEdit and expects that an editor copies and pastes in a plain text format.
Because of this:
– “Paste” is shown only if the Clipboard contains a plain text (while TRichViewEdit can paste in other formats, such as its native “RVF” format).
– “Copy” and “Cut” are shown only if a selection contains some text (and are not shown when a picture is selected).
You can promote the request to modify this menu in future versions of Delphi by voting at Embarcadero Quality portal: https://quality.embarcadero.com/browse/RSP-39007
In any case, I’ll find a workaround (either by finding a way of replacing this menu or by displaying a customizable popup)

Tables

On desktop systems, the user can select multiple table cells, resize rows and columns using mouse. But it is not convenient to do it using a finger.
In future updates, I plan to add a special popup widget simplifying table selection and resizing on touch screens.

Other changes

Default popup menu [FireMonkey]

Starting from this version, if PopupMenu property is not assigned to TRichView or TRichViewEdit, they display a standard popup menu, like TMemo.
TRIchView menu contains Copy and Select All commands. TRichViewEdit adds Undo, Paste, Cut and Delete commands.
The menu is localized.
For Windows and macOS platforms.

Image size parameters [All frameworks]

New optional parameters (ImageWidth and ImageHeight) are added to methods for adding or inserting pictures (AddPicture, AddHotPicture, InsertPicture, InsertHotPicture). If non-zero values are specified, the image is displayed stretched to the specified size.

FireMonkey demo projects

Demo projects for Android

In this update, we’ve ported to Android the following TRichView demo projects:

  • all Tutorial projects
  • Editors\Editor 1\
  • Editors\Editor 2\

All other demos will be ported in the next update.
The demos can be found in <TRichView Dir>\TRichView\Demos\Delphi.FMX\

While changes in Tutorial projects are minimal (layouts are changed to fit screens of mobile devices), the editor demos have many changes.

For all ported projects, there are two DPROJ files, PROJECTNAME.DPROJ and PROJECTNAME_D10_4.DPROJ.
For non-Android platform, any project can be used in any supported Delphi version.
For Android platform, PROJECTNAME_D10_4.DPROJ must be used in Delphi 10.4, and PROJECTNAME.DPROJ must be used in Delphi 11.

File save and open dialogs

TOpenDialog and TSaveDialog components do not work on Android, so I had to find a substitution.
There are two options possible: to implement a form for selecting files, or using a native Android solution (intents).
In this version of demo projects, I decided to use the second approach.
I created a helper class TRVFileChooser allowing to choose a file on Android (the unit fmxRVFileOpenAndroidFM.pas, included in TRichView).
When requesting to open or to save a file, an external application (file manager) is opened where the user can choose a file.

This solution has a drawback: file names are returned as Uri. TRVFileChooser has methods allowing to read and write files by Uri. But the problem is in HTML and Markdown files: the component cannot read and write external images (referred by relative paths) because it does not know a file folder (because Uri are not file names).
This problem will be solved in one of future updates of demo projects.

Modal dialogs

Modal dialogs are not supported in Android, so I had to modify the editor demos.
The changes are related to:

  • file opening and saving dialogs,
  • dialog windows (properties and options) in Editor 1
  • request to save a modified file in Editor 2

Text files

Previously, the editor demos supported RVF, DocX, RTF, Markdown formats (and HTML for export).
In this update, a support for text files is added.
File encoding is detected by content using TEncoding.GetBufferEncoding.
This method can detect UTF-8, UTF-16 LE and UTF-16 BE with signatures. For Windows, the demo does additional tests to distinguish ANSI and UTF-16 encodings.

Editor 1 Demo

This demo shows how to work with non-text items (images, images from image lists, controls, tables).

Rich text editor for Android developed in Delphi

In addition to the changes mentioned above, this demo implements:

  1. A substitution for TMainMenu implemented as TListBox inside TPopup. This menu can be opened by the button at the top left corner.
    This button is hidden for non-Android platforms, so when compiling for Windows and macOS, the application uses the standard TMainMenu.
Table operations in Delphi Android application

  1. This demo contains several dialog windows (for options, document object properties, checkpoints (bookmarks)).
    Since this update, these dialogs have top toolbars shown only on Android, and classic buttons shown on desktop OS.
Dialog in Delphi Android application

Editor 2

This demo shows how to implement commands for modifying text and paragraph attributes, and how to implement New/Open/Save/SaveAs commands to edit RVF, DocX, RTF, Markdown and text files.

This demo uses a toolbar that can wrap to fit window width.

Editing RTF file in Delphi Android application
Editing DocX file in Delphi Android application
Share this article