Importing and Exporting the UI Configuration
Every setting of the messaging UI can be written as JSON, with the same names as in code. The same JSON applies on Android, iOS and Flutter. Uses:
- One file with the look and features of the app, for all platforms.
- Settings sent from the app’s server, to change the UI without a new app release.
- A look chosen in the Customize screen, saved on the app’s server and restored on the user’s other devices.
Format
The JSON has one object per group. Each object has settings of that group, with their names in code (see Messaging UI Settings):
{
"theme": {"accentColor": "#FF00A884"},
"userList": {"title": "Chats", "searchMode": "top", "enableArchive": false},
"messages": {"enableForward": false, "enableKeep": false},
"messageAppearance": {"showBubbleTail": false, "textSize": "large"},
"attachments": {"buttonStyle": "plus"},
"sensitivity": {"tapToViewLevel": 2, "blockScreenshotLevel": 3}
}
Only the settings in the JSON change. The other settings keep their values.
| Setting type | In JSON | Example |
|---|---|---|
| A switch | true or false | "enableForward": false |
| A number | a number | "maxPhotos": 4 |
| A text | a string; null for none where allowed | "title": "Chats" |
| A color | "#AARRGGBB" or "#RRGGBB" (opaque) | "accentColor": "#FF00A884" |
| A choice among constants | a word | "searchMode": "top", "textSize": "large" |
A list of choices (MesiboUiOption) | a list of objects: value, and optionally title and detail | "sizes": [{"value": 1600, "title": "Standard"}] |
| A list of texts or colors | a list | "reactions": ["👍", "❤️"] |
The choices written as words:
| Setting | Words |
|---|---|
userList.searchMode | "button", "top", "system", "none" |
messageAppearance.textSize | "small", "medium", "large", "extra_large" |
attachments.buttonStyle | "clip", "plus" |
mediaPicker.galleryButtonAction | "camera", "more_apps", "folders", "none" |
The values of userList.filters | "all", "unread", "favorites", "groups", "online" |
The values of messageOptions.timerStarts and disappearing.timerStarts | "sent", "delivered", "read" |
A list of choices is replaced as a whole. For example, to offer only two picture sizes:
{
"imageSending": {
"sizes": [{"value": 1280, "title": "Standard"}, {"value": 4096, "title": "HD"}],
"maxDimension": 1280
},
"userList": {
"filters": [{"value": "all", "title": "All"}, {"value": "unread", "title": "Unread"}]
}
}
The built-in attachment tiles are changed by their type: "gallery", "camera", "video",
"document", "audio" or "location". Each can have title, enabled, color, imageColor,
backgroundColor and borderColor:
{"attachments": {"tiles": [{"type": "location", "enabled": false}, {"type": "gallery", "color": "#FF00868B"}]}}
Pictures, drawable resources and click handlers are not in JSON. The app sets them in code. The app’s own attachment tiles are also added in code.
Applying a JSON
applyJson applies the settings in a JSON. It returns a list of problems, for example an unknown
setting or a wrong type. Settings without problems are applied.
List<String> problems = MesiboUI.getConfig().applyJson(json);
for (String problem : problems)
Log.w("ui", problem);
val problems = MesiboUI.getConfig().applyJson(json)
problems.forEach { Log.w("ui", it) }
let problems = MesiboUI.getConfig().applyJson(json)
problems.forEach { print($0) }
NSArray<NSString *> *problems = [[MesiboUI getConfig] applyJson:json];
for (NSString *problem in problems)
NSLog(@"%@", problem);
List<String> problems = await MesiboUI().applyJson(json);
problems.forEach(print);
The open screens are drawn again with the new settings.
mesibo makes a new configuration each time a theme is applied, so settings applied once are lost.
The app applies its JSON in
MesiboUI_onConfig, which mesibo calls for each
new configuration:
@Override
public void MesiboUI_onConfig(MesiboUiConfig config, boolean dark) {
config.applyJson(dark ? myDarkJson : myLightJson);
}
override fun MesiboUI_onConfig(config: MesiboUiConfig, dark: Boolean) {
config.applyJson(if (dark) myDarkJson else myLightJson)
}
func MesiboUI_onConfig(config: MesiboUiConfig, dark: Bool) {
_ = config.applyJson(dark ? myDarkJson : myLightJson)
}
- (void)MesiboUI_onConfig:(MesiboUiConfig *)config dark:(BOOL)dark {
[config applyJson:dark ? myDarkJson : myLightJson];
}
In Flutter, the settings applied with applyJson() or setConfig() are kept, and applied again to
each new configuration.
Exporting the configuration
toJson writes the configuration as JSON. toJson(false) writes every setting. toJson(true)
writes only the settings that differ from the defaults of the light theme.
String all = MesiboUI.getConfig().toJson(false);
String changed = MesiboUI.getConfig().toJson(true);
val all = MesiboUI.getConfig().toJson(false)
val changed = MesiboUI.getConfig().toJson(true)
let all = MesiboUI.getConfig().toJson(false)
let changed = MesiboUI.getConfig().toJson(true)
NSString *all = [[MesiboUI getConfig] toJson:NO];
NSString *changed = [[MesiboUI getConfig] toJson:YES];
String all = await MesiboUI().toJson();
String changed = await MesiboUI().toJson(onlyChanged: true);
Customizations
A JSON saved for the light or the dark theme is a customization. mesibo applies it each time that theme is applied. See Customizations.
JSON Schema
jsonSchema returns a JSON Schema of the configuration: every group and setting, with its type,
its default and its allowed words. Editors such as VS Code use the schema to check a JSON file and
to complete the names.
String schema = MesiboUiConfig.jsonSchema();
val schema = MesiboUiConfig.jsonSchema()
let schema = MesiboUiConfig.jsonSchema()
NSString *schema = [MesiboUiConfig jsonSchema];
The schema is saved next to the JSON file, for example as mesibo-ui.schema.json, and named in
$schema at the top of the JSON file:
{
"$schema": "./mesibo-ui.schema.json",
"userList": {"title": "Chats"}
}
Platform-only settings
A setting of one platform only, for example the location group of Android, is accepted on all
platforms. A platform without the setting skips it and reports no problem.