diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java index 751c5d34e4..642260df5e 100644 --- a/app/src/main/java/eu/faircode/email/EntityRule.java +++ b/app/src/main/java/eu/faircode/email/EntityRule.java @@ -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"); diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java index c471531727..cb5719b4c1 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRule.java +++ b/app/src/main/java/eu/faircode/email/FragmentRule.java @@ -230,11 +230,12 @@ public class FragmentRule extends FragmentBase { spAnswer.setAdapter(adapterAnswer); List 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; diff --git a/app/src/main/res/layout/fragment_rule.xml b/app/src/main/res/layout/fragment_rule.xml index a39bbbf657..9907219508 100644 --- a/app/src/main/res/layout/fragment_rule.xml +++ b/app/src/main/res/layout/fragment_rule.xml @@ -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" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b00ad55adc..c2e6d9c88d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -537,6 +537,14 @@ $name$ will be replaced by the sender full name $email$ will be replaced by the sender email address + Mark read + Mark unread + Add star + Move + Copy (label) + Reply + Automation + Edit rule Rule applies to Name @@ -553,11 +561,10 @@ This action will be applied to new messages arriving in the folder %1$s Folder Identity - Reply template + Reply template Reply to CC addresses Rule name missing Condition missing - Automation This will send the intent \'%1$s\' with the extras \'%2$s\' Synchronize