Configuration hook
It's possible to set or alter the Plot Plugin configuration programmatically by specifying a configuration hook. By default, the configuration for the Plot Plugin is set by adding a plotconfig.json
to your project, as explained on the integration guides. A use cases for this functionality is to load the config using your own configuration mechanism, instead of specifying it in the plotconfig.json
file.
Plot calls the loadConfig(PlotConfiguration originalConfig, LoadConfigCallback loadConfigCallback)
method after your code calls Plot.init()
. The values of originalConfig are loaded from the plotconfig.json
file, if present.
Otherwise, it uses the default values. This means when specifying a property in both the plotconfig.json
file and the configuration hook, the configuration hook will override the configurations set in the plotconfig.json
. The callback function must be called exactly once.
A configuration hook could like this:
public class MyConfigHook extends ConfigHookBroadcastReceiver {
@Override
public void loadConfig(PlotConfiguration originalConfig, LoadConfigCallback loadConfigCallback) {
PlotConfiguration newConfig = originalConfig;
newConfig.setPublicToken("NewToken");
loadConfigCallback.loadWithConfig(newConfig);
}
}
Another use case for config hook would be changing the notificationSmallIcon
. You can set the notification small icon using newConfig.setNotificationSmallIcon(int notificationSmallIcon)
.