UI Listener - Action Handlers
mesibo handles every user action in its screens: opening a chat, showing the attachments, sending a message, and so on. An app can take over any of them, or check them first, with an action handler. For example, the app can check every message before it is sent, open its own profile screen, or show its own location picker.
When the user does something, mesibo calls MesiboUI_onAction() before doing it. The app returns:
true(YES): mesibo does it as usual,false(NO): the app handled it, and mesibo does nothing.
action.type tells what the user did. Only the fields of action that apply to that type are set:
| Type | The user | Fields |
|---|---|---|
ACTION_ROW | tapped a row: a chat in a list, or a message in a chat (screen.type tells which) | row, profile or message |
ACTION_PROFILE | tapped something that shows a user profile or group profile: the chat title, a group sender’s name, the popup’s Info or picture | profile |
ACTION_ATTACHMENTS | tapped the attach button | profile |
ACTION_CAMERA | tapped the camera button, or the Camera tile | profile |
ACTION_GALLERY, ACTION_VIDEO, ACTION_DOCUMENT, ACTION_AUDIO | tapped a tile of the attachment sheet | profile |
ACTION_LOCATION | tapped the Location tile | profile |
ACTION_VOICE | started recording a voice message | profile |
ACTION_MESSAGE | tapped an action of the long press bar (messageAction: MESSAGEACTION_REPLY, _FORWARD, _COPY, _KEEP, …) | message, the first selected |
ACTION_SEND | sent a message, or saved an edited one | message, about to be sent |
On Android the constants are in MesiboUI (MesiboUI.ACTION_SEND); on iOS they are
MESIBO_ACTION_SEND and MESIBO_MESSAGEACTION_REPLY.
For example, the app can check every message before it is sent: change its text, or stop it. When
the app returns false, the message is not sent, and its text stays in the message input
(screen.controls.editText) for the user to change.
@Override
public boolean MesiboUI_onAction(MesiboUI.MesiboScreen screen, MesiboUiAction action) {
if (MesiboUI.ACTION_SEND == action.type) {
if (containsBlockedWords(action.message.message))
return false; // not sent
action.message.message = cleanUp(action.message.message);
}
return true;
}
override fun MesiboUI_onAction(screen: MesiboUI.MesiboScreen, action: MesiboUiAction): Boolean {
if (MesiboUI.ACTION_SEND == action.type) {
if (containsBlockedWords(action.message.message))
return false // not sent
action.message.message = cleanUp(action.message.message)
}
return true
}
func MesiboUI_onAction(screen: MesiboScreen, action: MesiboUiAction) -> Bool {
if Int32(action.type) == MESIBO_ACTION_SEND, let message = action.message {
if containsBlockedWords(message.message) {
return false // not sent
}
message.message = cleanUp(message.message)
}
return true
}
- (BOOL)MesiboUI_onAction:(MesiboScreen *)screen action:(MesiboUiAction *)action {
if (MESIBO_ACTION_SEND == action.type) {
if ([self containsBlockedWords:action.message.message])
return NO; // not sent
action.message.message = [self cleanUp:action.message.message];
}
return YES;
}
Other examples:
ACTION_PROFILE: the app opens its own profile screen instead of mesibo’s.ACTION_LOCATION: the app shows its own location picker.ACTION_ATTACHMENTS: the app shows its own attachment sheet. To change only the tiles of mesibo’s sheet, the app changesattachments.tilesinstead.ACTION_ROWon the chat list: the app opens its own screen for a chat.
An attachment tile can also have its own handler (listener on Android), which runs instead of
mesibo’s action for that tile. mesibo calls MesiboUI_onAction() first.