Skip to main content

Fastboard API

This page provides the API reference for the Fastboard SDK.

FastboardView class

getFastboard

public Fastboard getFastboard()
Copy

Gets the Fastboard instance.

The Fastboard SDK does not support initializing a Fastboard instance directly. To get the Fastboard object, you need to add the FastboardView object to the app's layout, and then call the getFastboard method.

Note

You must call this method before calling any other API.

Returnss

The Fastboard instance when the method call succeeds.

Fastboard class

The Fastboard class provides methods to create the FastRoom instance.

public FastRoom createFastRoom(FastRoomOptions roomOptions)
Copy

Creates a FastRoom instance.

Note

Call this method after getting the Fastboard instance.

Parameters

  • roomOptions: Configuration options for a whiteboard room. see FastRoomOptions.

Returns

The FastRoom instance when the method call succeeds.

FastRoomOptions

Configuration options for a whiteboard room.

public class FastRoomOptions {
private final String appId;
private final String uuid;
private final String token;
private final String uid;
private final boolean writable;

private final FastRegion fastRegion;

public FastRoomOptions(String appId, String uuid, String token, String uid, FastRegion fastRegion) {
this(appId, uuid, token, uid, fastRegion, true);
}

public FastRoomOptions(String appId, String uuid, String token, String uid, FastRegion fastRegion, boolean writable) {
this.appId = appId;
this.uuid = uuid;
this.token = token;
this.uid = uid;
this.fastRegion = fastRegion;
this.writable = writable;
}
}
Copy

The FastRoomOptions class contains the following properties:

  • appId: String. The App Identifier of your Interactive Whiteboard project issued by Agora. See Get security credentials for your whiteboard project.
  • uuid: String. The room UUID, that is, the unique identifier of a room. See the value of the uuid parameter in the response body after a successful call of Create a room (POST).
  • token: String. The room token for user authentication, which can be obtained through one of the following methods:
  • uid: String. The unique identifier of a user in string format. The maximum length is 1,024 bytes. Ensure that the uid of each user in the same room is unique.
  • writable: boolean. Whether the user joins the whiteboard room in interactive mode:
    • true: Join the whiteboard room in interactive mode, that is, with read and write permissions.
    • false: Join the whiteboard room in subscription mode, that is, with read-only permission.
  • fastRegion: The data center, which must be the same as the data center you chose when creating the whiteboard room. See FastRegion.

FastRegion

Data centers.

FastRegion has the following enumerators:

  • CN_HZ: Hangzhou, China, which provides services to areas not covered by other data centers.
  • US_SV: Silicon Valley, United States, which provides services to North America and South America.
  • SG: Singapore, which provides services to Singapore, East Asia, and Southeast Asia.
  • IN_MUM: Mumbai, India, which provides services to India.
  • GB_LON: London, United Kingdom, which provides services to Europe.

FastRoom class

The FastRoom class provides methods to manage the whiteboard room.

join [1/2]

public void join()
Copy

Joins the whiteboard room.

Note

Call this method after successfully creating the FastRoom instance.

join [2/2]

public void join(@Nullable OnRoomReadyCallback onRoomReadyCallback)
Copy

Joins the whiteboard room.

Note

Call this method after successfully creating the FastRoom instance.

Parameters

  • onRoomReadyCallback: The OnRoomReadyCallback instance. Passing in null means not registering the interface.

OnRoomReadyCallback

The OnRoomReadyCallback interface provides callbacks that report room events to your application. It has the following member functions:

void onRoomReady(FastRoom fastRoom);
Copy

Occurs when the room is ready.

Parameters

  • fastRoom: The FastRoom instance.

isReady

public boolean isReady()
Copy

Gets whether the room is ready.

After calling the join method, you need to call this method to get whether the room is ready. When the room is ready, you can call other methods in the FastRoom class to operate the whiteboard.

Returns

Whether the room is ready:

  • true: The room is ready.
  • false: The room is not ready.

redo

public void redo()
Copy

Redoes an undone action.

undo

public void undo()
Copy

Undoes an action.

setStrokeColor

public void setStrokeColor(@ColorInt int color)
Copy

Sets the stroke color.

Parameters

  • color: int. The stroke color in RGB format. For example, 0x0000FF represents blue.

setAppliance

public void setAppliance(FastAppliance fastAppliance)
Copy

Sets the whiteboard tool currently in use.

Parameters

FastAppliance

Whiteboard tools.

FastAppliance has the following enumerators:

  • CLICKER(Appliance.CLICKER): Clicker, which can be used for clicking and selecting content on an HTML5 file.
  • SELECTOR(Appliance.SELECTOR): Selector.
  • PENCIL (Appliance.PENCIL): Pencil.
  • RECTANGLE(Appliance.RECTANGLE): Rectangle.
  • ELLIPSE(Appliance.ELLIPSE): Ellipse.
  • TEXT(Appliance.TEXT): Text.
  • ERASER(Appliance.ERASER): Eraser.
  • LASER_POINTER(Appliance.LASER_POINTER): Laser pointer.
  • ARROW(Appliance.ARROW): Arrow.
  • STRAIGHT (Appliance.STRAIGHT): Straight line.
  • PENTAGRAM(Appliance.SHAPE, ShapeType.Pentagram): Pentagram.
  • RHOMBUS(Appliance.SHAPE, ShapeType.Rhombus): Rhombus.
  • TRIANGLE(Appliance.SHAPE, ShapeType.Triangle): Triangle.
  • BUBBLE(Appliance.SHAPE, ShapeType.SpeechBalloon): Speech balloon.
  • OTHER_CLEAR(): Clears all contents on the current whiteboard page.

setStokeWidth

public void setStokeWidth(int width)
Copy

Sets the stroke width.

Parameters

  • strokeWidth: int. The stroke width (px).

cleanScene

public void cleanScene()
Copy

Clears all contents on the current whiteboard page.

setWritable

public void setWritable(boolean writable)
Copy

Sets whether the user is in interactive mode in the room.

Parameters

  • writable: boolean. Whether the user is in interactive mode:
    • true: Interactive mode, that is, with read and write permissions.
    • false: Subscription mode, that is, with read-only permission.

insertImage

public void insertImage(String url, int width, int height)
Copy

Inserts an image.

This method inserts and displays a specified online image on the current whiteboard page.

Parameters

  • url: String. The URL address of the image. Ensure your app clients can access the URL; otherwise, the image cannot be displayed.
  • width: int. The width (px) of the image.
  • height: int. The height (px) of the image.

insertVideo

public void insertVideo(String url, String title)
Copy

Inserts and plays audio and video in the whiteboard sub-window.

Parameters

  • url: The URL address of the audio or video file. Make sure your app clients can access the URL; otherwise, the audio or video file cannot be loaded properly.
  • title: The title of the sub-window.

insertDocs

public void insertDocs(FastInsertDocParams params, FastResult<String> result)
Copy

Inserts and displays a document in the whiteboard sub-window.

After successfully launching a file conversion task, you can call this method and pass in the parameters of the converted file. After a successful call, the SDK automatically creates a sub-window to insert and display the converted file per page.

Parameters

  • params: Parameters of the converted file. See FastInsertDocParams.
  • result: The call result of insertDocs. See FastResult. After you pass in a FastResult instance, the SDK triggers the callbacks implemented in the FastResult instance to report the call result of insertDocs. Passing in null means not monitoring the callbacks.

FastInsertDocParams

Parameters of the converted file.

public class FastInsertDocParams {

private String taskUUID;

private String taskToken;

private String fileType;

private String title;

}
Copy

The FastInsertDocParams class has the following properties:

  • taskUUID: String. The UUID of the file conversion task. You can get uuid from the response body when the Start file conversion API call succeeds.
  • taskToken: String. The task token of the file conversion task, which must be the same as the task token that you use to start the file conversion task.
  • fileType: String. The document type:
    • pdf: A static document.
    • pptx: A dynamic document.
  • title: String. The title of the sub-window.

FastResult

The result of calling insertDocs.

public interface FastResult<T> {
void onSuccess(T value);
void onError(Exception exception);
}
Copy

The FastResult interface provides callbacks that report the result of calling insertDocs. The interface provides the following callbacks:

  • onSuccess: Occurs when the insertDocs call succeeds.
  • onError: Occurs when the insertDocs call fails.

setFastStyle

public void setFastStyle(FastStyle style)
Copy

Sets the style of the whiteboard user interface.

Parameters

  • style: The style of the whiteboard user interface. See FastStyle.

FastStyle

The style of the whiteboard user interface.

public class FastStyle {
private int mainColor;
private boolean darkMode;

public FastStyle() {
}

public int getMainColor() {
return mainColor;
}

public void setMainColor(@ColorInt int color) {
this.mainColor = color;
}

public boolean isDarkMode() {
return darkMode;
}

public void setDarkMode(boolean darkMode) {
this.darkMode = darkMode;
}

public FastStyle copy() {
FastStyle style = new FastStyle();
style.mainColor = mainColor;
style.darkMode = darkMode;
return style;
}
}
Copy

The FastStyle class contains the following member methods:

getMainColor

Gets the theme color of the whiteboard user interface.

Returns

The theme color of the whiteboard user interface.

setMainColor

Sets the theme color of the whiteboard user interface.

This method sets the color of the following user interface elements:

  • The borders of some buttons.
  • The prompt text when the whiteboard is loaded.

Parameters

  • color: The theme color in RGB format of the whiteboard user interface. For example, 0x0000FF represents blue.
isDarkMode

Gets whether the whiteboard user interface is in dark mode.

Returns

  • true: The whiteboard user interface is in dark mode.
  • false: The whiteboard user interface is in light mode.
setDarkMode

Sets whether to use dark mode for the whiteboard user interface.

Parameters

  • darkMode: Whether to use dark mode for the whiteboard user interface:
    • true: Use dark mode.
    • false: Use light mode.

FastUiSettings class

The FastUiSettings class provides methods to configure the whiteboard user interface.

showRoomController

public void showRoomController(ControllerId... ids)
Copy

Shows the controls on the whiteboard user interface.

Parameters

  • ids: Identifiers of the user interface controls. See ControllerId.

hideRoomController

public void hideRoomController(ControllerId... ids)
Copy

Hides the controls on the whiteboard user interface.

Parameters

  • ids: Identifiers of the user interface controls. See ControllerId.

ControllerId

Identifiers of whiteboard user interface controls.

ControllerId contains the following enumerators:

  • RedoUndo: The redo and undo buttons
  • ToolBox: The toolbar.
  • PageIndicator: The page indicator.

setToolsExpandAppliances

public static void setToolsExpandAppliances(List<List<FastAppliance>> toolsExpandAppliances)
Copy

Sets the toolset contained in the toolbar in expanded mode.

If the default toolbar provided by UI Kit does not meet your needs, you can call this method to customize the tools contained in the toolbar and set the toolbar to expanded mode. You can pass a two-level list of tools in this method. The elements in the first-level list are expanded and displayed on the toolbar, while the elements in the second-level list are collapsed.

If you want to switch the toolbar to collapsed mode after successfully calling this methods, you can call setToolboxExpand.

Note

Call this method before joining the whiteboard room.

Parameters

  • toolsExpandAppliances: Tools contained in the toolbar in expanded mode. See FastAppliance.

Example

ArrayList<List<FastAppliance>> config = new ArrayList<>();
config.add(Arrays.asList(
FastAppliance.CLICKER,
FastAppliance.PENCIL,
FastAppliance.TEXT,
FastAppliance.SELECTOR,
FastAppliance.ERASER
));
config.add(Arrays.asList(FastAppliance.SELECTOR));
config.add(Arrays.asList(FastAppliance.PENCIL));
config.add(Arrays.asList(FastAppliance.TEXT));
config.add(Arrays.asList(FastAppliance.ERASER));
config.add(Arrays.asList(
FastAppliance.STRAIGHT,
FastAppliance.ARROW,
FastAppliance.RECTANGLE,
FastAppliance.ELLIPSE,
FastAppliance.PENTAGRAM,
FastAppliance.RHOMBUS,
FastAppliance.BUBBLE,
FastAppliance.TRIANGLE
));
config.add(Arrays.asList(FastAppliance.OTHER_CLEAR));

FastUiSettings.setToolsExpandAppliances(config);
Copy

setToolsCollapseAppliances

public static void setToolsCollapseAppliances(List<FastAppliance> toolsCollapseAppliances)
Copy

Sets the toolset contained in the toolbar in collapsed mode.

If the default toolbar provided by UI Kit does not meet your needs, you can call this method to customize the tools contained in the toolbar and set the toolbar to collapsed mode. You can pass a one-level list of tools in this method. The elements in the list are collapsed.

If you want to switch the toolbar to expanded mode after successfully calling this method, you can call setToolboxExpand.

Note

Call this method before joining the whiteboard room.

Parameters

  • toolsCollapseAppliances: Tools contained in the toolbar in collapsed mode. See FastAppliance.

Example

ArrayList<FastAppliance> collapseAppliances = new ArrayList<>();
collapseAppliances.add(FastAppliance.PENCIL);
collapseAppliances.add(FastAppliance.ERASER);
collapseAppliances.add(FastAppliance.ARROW);
collapseAppliances.add(FastAppliance.SELECTOR);
collapseAppliances.add(FastAppliance.TEXT);
collapseAppliances.add(FastAppliance.OTHER_CLEAR);

FastUiSettings.setToolsCollapseAppliances(collapseAppliances);
Copy

setToolsColors

public static void setToolsColors(List<Integer> toolsColors)
Copy

Sets the color set of the palette.

The palette applies to the pencil, text editor, and shape tools. When a user uses these tools to draw and write on the whiteboard, they can select a color from the palette.

Note

Call this method before joining the whiteboard room.

Parameters

  • toolsColors: Colors in RGB format. For example, 0x0000FF represents blue.

setToolboxGravity

public void setToolboxGravity(int gravity)
Copy

Sets the position of the toolbar on the whiteboard.

Parameters

  • Gravity: The position of the toolbar on the whiteboard:
    • Gravity.LEFT: The toolbar is on the left side.
    • Gravity.RIGHT: The toolbar is on the left side.

setToolboxExpand

public void setToolboxExpand(boolean expand)
Copy

Sets whether to expand the toolbar.

The default display state of the toolbar varies by device. The toolbar is expanded by default on tablets and collapsed by default on phones. You can call this method to modify the display state of the toolbar.

Parameters

  • expand: Whether to expand the toolbar:
    • true: Expand the toolbar.
    • false: Collapse the toolbar.