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:

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.

CallbackCalledThe app can
MesiboUI_onConfigwhen a new configuration is made, each time a theme is appliedchange any option
MesiboUI_onInitScreenwhen a screen is createdadd buttons and menu items to the screen
MesiboUI_onUpdateScreenfor every open screen, when the app calls MesiboUI.updateScreens()change the buttons and menu items it added
MesiboUI_onActionbefore mesibo does what the user asked: open a chat, show attachments, send a message, …let mesibo do it, or do it itself
MesiboUI_onGetCustomRowbefore a row of a list is createdreturn its own row, or none for mesibo’s row
MesiboUI_onUpdateRowafter mesibo fills one of its rowschange 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: