-
Notifications
You must be signed in to change notification settings - Fork 6
PluginData
Mars edited this page Aug 8, 2017
·
7 revisions
For every MessageOnTap plugin, there are two kinds of data which are very important: trigger and custom tags. Developers should pass give these two data to PluginManagerService to achieve its own function.
@Override
protected PluginData iPluginData() {
Log.e(TAG, "getting plugin data");
ArrayList<Trigger> triggerArrayList = new ArrayList<>();
Set<Tag> tagList = new HashSet<>(Arrays.asList(tag_I, tag_doc, tag_me, tag_send,
tag_time, tag_time, tag_you));
HashSet<String> mMandatory = new HashSet<>();
HashSet<String> mOptional = new HashSet<>();
// Category one: with file name
// trigger 1: Can you send me XXX (a file)?
COMPLETE = 0;
mOptional.add("TAG_You");
mMandatory.add("TAG_SEND");
mOptional.add("TAG_ME");
mOptional.add("TAG_TIME");
DIRECTION = 0;
HashSet<Trigger.Constraint> constraints = new HashSet<>();
Trigger trigger1 = new Trigger("doc_trigger_one", mMandatory, mOptional, constraints,
Mood.UNKNOWN, Direction.INCOMING);
triggerArrayList.add(trigger1);
clearLists(mMandatory, mOptional);
//trigger 2: I can send you XXX
mMandatory.add("TAG_I");
mMandatory.add("TAG_SEND");
mOptional.add("TAG_You");
mOptional.add("TAG_TIME");
MOOD = 0;
DIRECTION = 1;
HashSet<Trigger.Constraint> constraints2 = new HashSet<>();
Trigger trigger2 = new Trigger("calendar_trigger_two", mMandatory, mOptional, constraints2,
Mood.IMPERATIVE, Direction.OUTGOING);
triggerArrayList.add(trigger2);
// Category two: without file name
// trigger 3: Can you send me the file on this topic
// second example: send me the file please
mMandatory.add("TAG_SEND");
mOptional.add("TAG_ME");
mMandatory.add("TAG_DOC");
mOptional.add("TAG_TIME");
DIRECTION = 0;
HashSet<Trigger.Constraint> constraints3 = new HashSet<>();
Trigger trigger3 = new Trigger("calendar_trigger_three", mMandatory, mOptional,
constraints3, Mood.UNKNOWN, Direction.INCOMING);
triggerArrayList.add(trigger3);
clearLists(mMandatory, mOptional);
// trigger 4: I want to send you the doc we talked about earlier
// second example: I'll share my document
mOptional.add("TAG_I");
mMandatory.add("TAG_SEND");
mOptional.add("TAG_You");
mMandatory.add("TAG_DOC");
mOptional.add("TAG_TIME");
DIRECTION = 1;
MOOD = 0;
HashSet<Trigger.Constraint> constraints4 = new HashSet<>();
Trigger trigger4 = new Trigger("calendar_trigger_four", mMandatory, mOptional, constraints4,
Mood.IMPERATIVE, Direction.OUTGOING);
triggerArrayList.add(trigger4);
triggerListHasName.add(trigger1);
triggerListHasName.add(trigger2);
clearLists(mMandatory, mOptional);
Log.e(TAG, "returning plugin data");
//Todo:taglist
return new PluginData().tagSet(JSONUtils.simpleObjectToJson(tagList, Globals.TYPE_TAG_SET))
.triggerSet(JSONUtils.simpleObjectToJson(triggerArrayList, Globals.TYPE_TRIGGER_SET));
}
DataType | Name |
---|---|
2017 MessageOnTap