Added seen and thread options to move rule

This commit is contained in:
M66B 2019-06-09 21:25:56 +02:00
parent 4578065562
commit 13f3181d08
4 changed files with 55 additions and 6 deletions

View File

@ -240,13 +240,22 @@ public class EntityRule {
private void onActionMove(Context context, EntityMessage message, JSONObject jargs) throws JSONException {
long target = jargs.getLong("target");
boolean seen = jargs.optBoolean("seen");
boolean thread = jargs.optBoolean("thread");
DB db = DB.getInstance(context);
EntityFolder folder = db.folder().getFolder(target);
if (folder == null)
throw new IllegalArgumentException("Rule move to folder not found");
EntityOperation.queue(context, message, EntityOperation.MOVE, target, false);
List<EntityMessage> messages = db.message().getMessageByThread(
message.account, message.thread, thread ? null : message.id, message.folder);
for (EntityMessage threaded : messages) {
if (seen)
onActionSeen(context, threaded, true);
EntityOperation.queue(context, threaded, EntityOperation.MOVE, target, false);
}
}
private void onActionCopy(Context context, EntityMessage message, JSONObject jargs) throws JSONException {

View File

@ -102,6 +102,8 @@ public class FragmentRule extends FragmentBase {
private ImageView ibColorDefault;
private Spinner spTarget;
private CheckBox cbMoveSeen;
private CheckBox cbMoveThread;
private Spinner spIdent;
@ -117,6 +119,7 @@ public class FragmentRule extends FragmentBase {
private Group grpSnooze;
private Group grpFlag;
private Group grpMove;
private Group grpMoveProp;
private Group grpAnswer;
private Group grpAutomation;
@ -186,6 +189,8 @@ public class FragmentRule extends FragmentBase {
ibColorDefault = view.findViewById(R.id.ibColorDefault);
spTarget = view.findViewById(R.id.spTarget);
cbMoveSeen = view.findViewById(R.id.cbMoveSeen);
cbMoveThread = view.findViewById(R.id.cbMoveThread);
spIdent = view.findViewById(R.id.spIdent);
@ -201,6 +206,7 @@ public class FragmentRule extends FragmentBase {
grpSnooze = view.findViewById(R.id.grpSnooze);
grpFlag = view.findViewById(R.id.grpFlag);
grpMove = view.findViewById(R.id.grpMove);
grpMoveProp = view.findViewById(R.id.grpMoveProp);
grpAnswer = view.findViewById(R.id.grpAnswer);
grpAutomation = view.findViewById(R.id.grpAutomation);
@ -342,6 +348,7 @@ public class FragmentRule extends FragmentBase {
grpSnooze.setVisibility(View.GONE);
grpFlag.setVisibility(View.GONE);
grpMove.setVisibility(View.GONE);
grpMoveProp.setVisibility(View.GONE);
grpAnswer.setVisibility(View.GONE);
grpAutomation.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
@ -505,6 +512,10 @@ public class FragmentRule extends FragmentBase {
spTarget.setSelection(pos);
break;
}
if (type == EntityRule.TYPE_MOVE) {
cbMoveSeen.setChecked(jaction.optBoolean("seen"));
cbMoveThread.setChecked(jaction.optBoolean("thread"));
}
break;
case EntityRule.TYPE_ANSWER:
@ -522,8 +533,7 @@ public class FragmentRule extends FragmentBase {
break;
}
boolean cc = (jaction.has("cc") && jaction.getBoolean("cc"));
cbCc.setChecked(cc);
cbCc.setChecked(jaction.optBoolean("cc"));
break;
}
@ -781,6 +791,7 @@ public class FragmentRule extends FragmentBase {
grpSnooze.setVisibility(type == EntityRule.TYPE_SNOOZE ? View.VISIBLE : View.GONE);
grpFlag.setVisibility(type == EntityRule.TYPE_FLAG ? View.VISIBLE : View.GONE);
grpMove.setVisibility(type == EntityRule.TYPE_MOVE || type == EntityRule.TYPE_COPY ? View.VISIBLE : View.GONE);
grpMoveProp.setVisibility(type == EntityRule.TYPE_MOVE ? View.VISIBLE : View.GONE);
grpAnswer.setVisibility(type == EntityRule.TYPE_ANSWER ? View.VISIBLE : View.GONE);
grpAutomation.setVisibility(type == EntityRule.TYPE_AUTOMATION ? View.VISIBLE : View.GONE);
}
@ -854,15 +865,18 @@ public class FragmentRule extends FragmentBase {
case EntityRule.TYPE_COPY:
EntityFolder target = (EntityFolder) spTarget.getSelectedItem();
jaction.put("target", target == null ? -1 : target.id);
if (action.type == EntityRule.TYPE_MOVE) {
jaction.put("seen", cbMoveSeen.isChecked());
jaction.put("thread", cbMoveThread.isChecked());
}
break;
case EntityRule.TYPE_ANSWER:
EntityIdentity identity = (EntityIdentity) spIdent.getSelectedItem();
EntityAnswer answer = (EntityAnswer) spAnswer.getSelectedItem();
boolean cc = cbCc.isChecked();
jaction.put("identity", identity == null ? -1 : identity.id);
jaction.put("answer", answer == null ? -1 : answer.id);
jaction.put("cc", cc);
jaction.put("cc", cbCc.isChecked());
break;
}
}

View File

@ -438,6 +438,24 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMoveTarget" />
<CheckBox
android:id="@+id/cbMoveSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_rule_seen"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spTarget" />
<CheckBox
android:id="@+id/cbMoveThread"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_rule_thread"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbMoveSeen" />
<TextView
android:id="@+id/tvAnswerIdentity"
android:layout_width="wrap_content"
@ -446,7 +464,7 @@
android:text="@string/title_rule_identity"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spTarget" />
app:layout_constraintTop_toBottomOf="@+id/cbMoveThread" />
<Spinner
android:id="@+id/spIdent"
@ -528,6 +546,13 @@
app:constraint_referenced_ids="
tvMoveTarget,spTarget" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpMoveProp"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="
cbMoveSeen,cbMoveThread" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpAnswer"
android:layout_width="0dp"

View File

@ -568,6 +568,7 @@
<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_hours">Hours</string>
<string name="title_rule_folder">Folder</string>
<string name="title_rule_thread">All messages in same conversation and folder</string>
<string name="title_rule_identity">Identity</string>
<string name="title_rule_template">Reply template</string>
<string name="title_rule_cc">Reply to CC addresses</string>