Added rule type copy

This commit is contained in:
M66B
2019-05-18 08:34:26 +02:00
parent fcf5192ad8
commit 386f9cca17
4 changed files with 28 additions and 9 deletions

View File

@@ -84,6 +84,7 @@ public class EntityRule {
static final int TYPE_ANSWER = 4;
static final int TYPE_AUTOMATION = 5;
static final int TYPE_FLAG = 6;
static final int TYPE_COPY = 7;
static final String ACTION_AUTOMATION = BuildConfig.APPLICATION_ID + ".AUTOMATION";
static final String EXTRA_RULE = "rule";
@@ -213,6 +214,9 @@ public class EntityRule {
case TYPE_MOVE:
onActionMove(context, db, message, jaction);
break;
case TYPE_COPY:
onActionCopy(context, db, message, jaction);
break;
case TYPE_ANSWER:
onActionAnswer(context, db, message, jaction);
break;
@@ -235,6 +239,11 @@ public class EntityRule {
EntityOperation.queue(context, db, message, EntityOperation.MOVE, target, false);
}
private void onActionCopy(Context context, DB db, EntityMessage message, JSONObject jargs) throws JSONException {
long target = jargs.getLong("target");
EntityOperation.queue(context, db, message, EntityOperation.COPY, target, false);
}
private void onActionAnswer(Context context, DB db, EntityMessage message, JSONObject jargs) throws JSONException, IOException {
long iid = jargs.getLong("identity");
long aid = jargs.getLong("answer");

View File

@@ -230,11 +230,12 @@ public class FragmentRule extends FragmentBase {
spAnswer.setAdapter(adapterAnswer);
List<Action> actions = new ArrayList<>();
actions.add(new Action(EntityRule.TYPE_SEEN, getString(R.string.title_seen)));
actions.add(new Action(EntityRule.TYPE_UNSEEN, getString(R.string.title_unseen)));
actions.add(new Action(EntityRule.TYPE_FLAG, getString(R.string.title_flag)));
actions.add(new Action(EntityRule.TYPE_MOVE, getString(R.string.title_move)));
actions.add(new Action(EntityRule.TYPE_ANSWER, getString(R.string.title_answer_reply)));
actions.add(new Action(EntityRule.TYPE_SEEN, getString(R.string.title_rule_seen)));
actions.add(new Action(EntityRule.TYPE_UNSEEN, getString(R.string.title_rule_unseen)));
actions.add(new Action(EntityRule.TYPE_FLAG, getString(R.string.title_rule_flag)));
actions.add(new Action(EntityRule.TYPE_MOVE, getString(R.string.title_rule_move)));
actions.add(new Action(EntityRule.TYPE_COPY, getString(R.string.title_rule_copy)));
actions.add(new Action(EntityRule.TYPE_ANSWER, getString(R.string.title_rule_answer)));
actions.add(new Action(EntityRule.TYPE_AUTOMATION, getString(R.string.title_rule_automation)));
adapterAction.addAll(actions);
@@ -478,6 +479,7 @@ public class FragmentRule extends FragmentBase {
break;
case EntityRule.TYPE_MOVE:
case EntityRule.TYPE_COPY:
long target = jaction.getLong("target");
for (int pos = 0; pos < adapterTarget.getCount(); pos++)
if (adapterTarget.getItem(pos).id.equals(target)) {
@@ -679,7 +681,7 @@ public class FragmentRule extends FragmentBase {
private void showActionParameters(int type) {
grpFlag.setVisibility(type == EntityRule.TYPE_FLAG ? View.VISIBLE : View.GONE);
grpMove.setVisibility(type == EntityRule.TYPE_MOVE ? View.VISIBLE : View.GONE);
grpMove.setVisibility(type == EntityRule.TYPE_MOVE || type == EntityRule.TYPE_COPY ? View.VISIBLE : View.GONE);
grpAnswer.setVisibility(type == EntityRule.TYPE_ANSWER ? View.VISIBLE : View.GONE);
grpAutomation.setVisibility(type == EntityRule.TYPE_AUTOMATION ? View.VISIBLE : View.GONE);
}
@@ -746,6 +748,7 @@ public class FragmentRule extends FragmentBase {
break;
case EntityRule.TYPE_MOVE:
case EntityRule.TYPE_COPY:
EntityFolder target = (EntityFolder) spTarget.getSelectedItem();
jaction.put("target", target.id);
break;