Dimple Plugin SDK

Dimple Plugin SDK is set of files that can be included in your application to ease creation of plugins. It's available for download here. JavaDoc is available here

What's included

  • DimpleConst - Constants used for Dimple plugin intents.
  • DimplePluginActivity - abstract activity that can be extended for setup of plugins and execution of simple plugin.
  • DimplePluginBroadcastReceiver - abstract receiver that can be extended to receive long-press plugin events.

Usage

Copy all 3 java files into your project

Files can be found in src folder.

Package of files is not important - files can be placed anywhere in project source directory.

Create activity that will be used to setup plugin.

In AndroidManifest.xml file you need to include

<activity android:name="ActivityName">
    <intent-filter>
        <action android:name="io.dimple.action.PLUGIN"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

to list this activity as simple plugin or

<activity android:name="ActivityName">
    <intent-filter>
        <action android:name="io.dimple.action.PLUGIN_LONGPRESS"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

to list this activity as long-press plugin in Dimple (replacing ActivityName with your activity).

In code your activity should extend DimplePluginActivity and implement createPlugin method:

public class ActivityName extends extends DimplePluginActivity
{
    @Override
    public void createPlugin(boolean longPress, int memorySize)
    {
    }
}

Send data back to Dimple

When you have prepared plugin data (it can be in createPlugin method or from user interaction) - you need to send data back to Dimple to add plugin to Dimple button. To do it, you can use method finishCreatingPlugin. If you want to cancel plugin creation, call cancelCreatingPlugin.

Sending back data does not guarantee that plugin will be written to Dimple as user can cancel writing later or remove configured plugin from button list.

Execute

Simple plugin

Simple plugin execution happens in same activity as setup. Override execute method to react on plugin execution.

@Override
public void execute(byte[] data)
{
}

Long-press plugin

For long-press plugin you need to implement DimplePluginBroadcastReceiver class and make broadcast receiver.

In AndroidManifest.xml file you need to include

<receiver android:name="ReceiverName">
    <intent-filter>
        <action android:name="io.dimple.action.PLUGIN_LONGPRESS"/>
    </intent-filter>
</receiver>

(replacing ReceiverName with your receiver) and in code

public class ReceiverName extends DimplePluginBroadcastReceiver
{
    @Override
    public void onDimpleDown(Context context, byte[] data)
    {
    }

    @Override
    public void onDimpleHold(Context context, long holdLength, byte[] data, long timeSinceLastHoldEvent)
    {
    }

    @Override
    public void onDimpleUp(Context context, long holdLength, byte[] data)
    {
    }
}

Tags: plugins, SDK