Added rule type copy

pull/156/head
M66B 6 years ago
parent fcf5192ad8
commit 386f9cca17

@ -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");

@ -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;

@ -444,7 +444,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_rule_answer"
android:text="@string/title_rule_template"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spIdent" />

@ -537,6 +537,14 @@
<string name="title_answer_template_name">$name$ will be replaced by the sender full name</string>
<string name="title_answer_template_email">$email$ will be replaced by the sender email address</string>
<string name="title_rule_seen">Mark read</string>
<string name="title_rule_unseen">Mark unread</string>
<string name="title_rule_flag">Add star</string>
<string name="title_rule_move">Move</string>
<string name="title_rule_copy">Copy (label)</string>
<string name="title_rule_answer">Reply</string>
<string name="title_rule_automation">Automation</string>
<string name="title_rule_caption">Edit rule</string>
<string name="title_rule_title">Rule applies to</string>
<string name="title_rule_name">Name</string>
@ -553,11 +561,10 @@
<string name="title_rule_action_remark">This action will be applied to new messages arriving in the folder %1$s</string>
<string name="title_rule_folder">Folder</string>
<string name="title_rule_identity">Identity</string>
<string name="title_rule_answer">Reply template</string>
<string name="title_rule_template">Reply template</string>
<string name="title_rule_cc">Reply to CC addresses</string>
<string name="title_rule_name_missing">Rule name missing</string>
<string name="title_rule_condition_missing">Condition missing</string>
<string name="title_rule_automation">Automation</string>
<string name="title_rule_automation_hint">This will send the intent \'%1$s\' with the extras \'%2$s\'</string>
<string name="title_legend_section_synchronize">Synchronize</string>

Loading…
Cancel
Save