UI Listener
The configuration changes the texts, colors and features of the messaging UI. The UI listener goes further: it lets the app take part in how the screens work, without replacing them. mesibo calls the app’s listener at each step, for example when it opens a screen, when the user taps something, or when it shows a message, and the app decides what to add or change.
With the UI listener, an app can:
- Add its own buttons and menu items to the chat list, the chats and the profile screens, and update them later, for example when a call starts.
- Handle what the user does, before mesibo does it. For example, check or change a message before it is sent, or open its own profile screen instead of mesibo’s.
- Set the configuration each time mesibo applies a theme.
- Change how the rows of the chat list and of the chats look, or show its own rows.
These are described on the following pages:
- Screen Setup: the screens, their buttons and menu items, and updating them.
- Action Handlers: handling what the user does.
- Configuration Callback: setting the configuration for each theme.
- Message Rendering: changing the rows of the chat list and of the chats, or showing the app’s own rows.
Registering the UI Listener
The app registers a listener with MesiboUI.setListener(), before it shows any screen.
The listener has six callbacks. Every callback is optional: the app implements only the ones it needs, and mesibo keeps its default behavior for the others.
| Callback | Called | The app can |
|---|---|---|
MesiboUI_onConfig | when a new configuration is made, each time a theme is applied | change any option |
MesiboUI_onInitScreen | when a screen is created | add buttons and menu items to the screen |
MesiboUI_onUpdateScreen | for every open screen, when the app calls MesiboUI.updateScreens() | change the buttons and menu items it added |
MesiboUI_onAction | before mesibo does what the user asked: open a chat, show attachments, send a message, … | let mesibo do it, or do it itself |
MesiboUI_onGetCustomRow | before a row of a list is created | return its own row, or none for mesibo’s row |
MesiboUI_onUpdateRow | after mesibo fills one of its rows | change the views of the row |
public class UIListener implements MesiboUIListener {
public UIListener() {
MesiboUI.setListener(this);
}
@Override
public boolean MesiboUI_onInitScreen(MesiboUI.MesiboScreen screen) {
return true;
}
}
class UIListener : MesiboUIListener {
init {
MesiboUI.setListener(this)
}
override fun MesiboUI_onInitScreen(screen: MesiboUI.MesiboScreen): Boolean {
return true
}
}
class UIListener: NSObject, MesiboUIListener {
override init() {
super.init()
MesiboUI.setListener(self)
}
func MesiboUI_onInitScreen(screen: MesiboScreen) -> Bool {
return true
}
}
@interface UIListener : NSObject <MesiboUIListener>
@end
@implementation UIListener
- (instancetype)init {
if ((self = [super init]))
[MesiboUI setListener:self];
return self;
}
- (BOOL)MesiboUI_onInitScreen:(MesiboScreen *)screen {
return YES;
}
@end
Flutter has no listener: the app adds menu items with MesiboUI().setMenu() (see
Flutter), and sets the configuration with MesiboUI().setConfig().
For complete examples, see the UIListener of the sample Messenger apps: