[Android Software/Hacking General [Developers Only]] Muzikant:
Prerequisite

Don't know what is AutomateIt ? Read more on this thread.

What is AutomateIt Plugin ?

Plugins are applications that by installing them, you add new actions and triggers that you can use within AutomateIt. Sounds easy, right ?

Each plugin can provide additional triggers and actions that extend the capabilities of AutomateIt, so you can focus on the functionality and take advantage of the AutomateIt platform to connect each trigger or action with existing capabilities of AutomateIt or with other plugins.

More details and a list of available plugins are available on the app website.

Getting started

Although developing a plugin is super-easy and requires only several simple steps, you are deeply encouraged to read the full documentation on the app website.

To summarize it for you, here are the steps you need to follow when developing a new plugin:

Download AutomateIt Plugin SDK

Setup your environment

Develop your plugin

Test your plugin

Setting up your environment after downloading the plugin SDK is done by adding a single dependency needs to be added to your build.gradle file:

compile 'com.automateitapp:automateit.plugin.sdk:1.0.3'

Creating a new plugin action or trigger is done by implementing a class that extends either PluginAction or PluginTrigger in your plugin project that references the AutomateItPluginLibrary.

Each of these abstract classes requires a set of simple functions to be implemented that provide metadata for the action or trigger (such as title, description, icons and parameters) and the functionality of the action or trigger. See sample code below for an action that shows a Toast message.

a complete sample app is available as a git repo that can be cloned from here.

When the plugin app is installed on a user device, it communicates with AutomateIt so that the plugin actions and triggers become available within AutomateIt.

Additional Documentation

AutomateIt Plugin Developer Guide

AutomateIt Plugin SDK Reference

Looking forward to seeing some awesome plugins !

Sample Action Code

package com.smarterapps.demoplugin.actions;

import java.util.List;

import android.content.Context;
import android.widget.Toast;

import com.smarterapps.automateitplugin.sdk.PluginDataFieldCollection;
import com.smarterapps.automateitplugin.sdk.PluginValidationResult;
import com.smarterapps.automateitplugin.sdk.RequiredApp;
import com.smarterapps.automateitplugin.sdk.fields.PluginDataFieldBoolean;
import com.smarterapps.automateitplugin.sdk.fields.PluginDataFieldString;
import com.smarterapps.demoplugin.R;

public class Action1 extends com.smarterapps.automateitplugin.sdk.PluginAction
{
private static final int FIELD_ID_TEXT_TO_SHOW = 1;
private static final int FIELD_ID_DURATION_LONG = 2;

@Override
public String getActionTitle(Context context)
{
return context.getString(R.string.action1_title);
}

@Override
public String getActionDescription(Context context)
{
return context.getString(R.string.action1_default_description);
}

@Override
public String getActionDescription(Context context, PluginDataFieldCollection data)
{
if (null != data)
{
String msgText = (String) data.getFieldById(FIELD_ID_TEXT_TO_SHOW).getValue();
boolean durationLong = (Boolean) data.getFieldById(FIELD_ID_DURATION_LONG).getValue();

int toastDurationStringId = durationLong ? R.string.duration_long: R.string.duration_short;

return context.getString(R.string.action1_description,
context.getString(toastDurationStringId),
msgText);
}

return getActionDescription(context);
}

@Override
public int getActionIconResourceId()
{
return R.drawable.ic_action1;
}

@Override
public int getActionSmallIconResourceId()
{
return R.drawable.ic_action1_small;
}

@Override
public PluginDataFieldCollection getActionFields(Context context)
{
PluginDataFieldCollection retval = new PluginDataFieldCollection();

retval.add(new PluginDataFieldBoolean(
FIELD_ID_DURATION_LONG,
context.getString(R.string.action1_field_duration_title),
context.getString(R.string.action1_field_duration_description),
true));

retval.add(new PluginDataFieldString(
FIELD_ID_TEXT_TO_SHOW,
context.getString(R.string.action1_field_msg_title),
context.getString(R.string.action1_field_msg_description),
""));

return retval;
}

@Override
public void doAction(Context context, PluginDataFieldCollection data)
{
boolean durationLong = (Boolean) data.getFieldById(FIELD_ID_DURATION_LONG).getValue();
int toastDuration = durationLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;

String toastMsg = (String) data.getFieldById(FIELD_ID_TEXT_TO_SHOW).getValue();
Toast.makeText(context, toastMsg, toastDuration).show();
}

@Override
public PluginValidationResult validateData(Context context, PluginDataFieldCollection data)
{
// Validate action1
String toastMsg = (String) data.getFieldById(FIELD_ID_TEXT_TO_SHOW).getValue();

if (null == toastMsg || toastMsg.trim().length() == 0)
{
return new PluginValidationResult(false, "Toast message can't be empty");
}

return PluginValidationResult.getValidResult();
}

@Override
public List<RequiredApp> getRequiredApps()
{
return null;
}
}