Skip to content

Latest commit

 

History

History
103 lines (72 loc) · 3.2 KB

4_settings.md

File metadata and controls

103 lines (72 loc) · 3.2 KB

Settings

Every plugin has access to a SettingsAPI instance, made available as this.settings inside your plugin class, which can be used to persist settings. You can store any data structure here: Strings, Integers, Booleans or even Objects (json stringified).

Setting keys are automatically prefixed with your plugin name to prevent collisions.

Settings are stored per-plugin inside /Aliucord/settings/[PluginName].json.

If this is undesired, you may manually write to the Aliucord Path or whichever you deem appropriate. Avoid storing huge data structures or raw bytes here. Write those to the cache folder or something similar.

SettingsTab

You may want to add a SettingsTab to your plugin, which can be opened by clicking the settings button on your plugin's card in Aliucord's plugins tab

To do so, you must simply set this.settingsTab to a SettingsTab. This can either be a dedicated page or a bottomsheet

Passing arguments to your SettingsTab

It may be desired to pass arguments to your SettingsTab, e.g. your plugin's SettingsAPI. To do so, simply make use of SettingsTab.withArgs:

Java
public class MyPlugin extends Plugin {
    public MyPlugin() {
        settingsTab = new SettingsTab(MySettingsPage.class).withArgs(settings);
    }
}
Kotlin
class MyPlugin : Plugin() {
    init {
        settingsTab = SettingsTab(MySettingsPage::class.java).withArgs(settings)
    }
}

Then inside your SettingsPage fragment:

Java
public class MySettingsPage extends SettingsPage {
    private final SettingsAPI mSettings;
    
    public MySettingsPage(SettingsAPI settings) {
        mSettings = settings;
    }
}
Kotlin
class MySettingsPage(val mSettings: SettingsAPI) : SettingsPage() {
    
}

Dedicated Settings Page

This is a dedicated page that takes up the entire screen.

To use it, you must extend com.aliucord.fragments.SettingsPage and override onViewBound(View).

You can then create and add Views to the page using addView(View)

Settings Bottomsheet

This is a sheet that takes up the bottom portion of the screen (e.g. the actions sheet when long pressing a message or user profiles).

To use it, you must extend com.aliucord.widgets.BottomSheet and override onViewCreated(view: View, bundle: Bundle).

You can then create and add Views to the bottomsheet using addView(View)