mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-27 11:16:51 +02:00
Added option to mark messages seen for hide rule action
This commit is contained in:
@@ -658,7 +658,7 @@ public class EntityRule {
|
||||
case TYPE_UNSEEN:
|
||||
return onActionSeen(context, message, false);
|
||||
case TYPE_HIDE:
|
||||
return onActionHide(context, message);
|
||||
return onActionHide(context, message, jaction);
|
||||
case TYPE_IGNORE:
|
||||
return onActionIgnore(context, message, jaction);
|
||||
case TYPE_SNOOZE:
|
||||
@@ -811,7 +811,9 @@ public class EntityRule {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean onActionHide(Context context, EntityMessage message) {
|
||||
private boolean onActionHide(Context context, EntityMessage message, JSONObject jargs) {
|
||||
boolean seen = jargs.optBoolean("seen");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
EntityFolder folder = db.folder().getFolder(message.folder);
|
||||
@@ -824,7 +826,8 @@ public class EntityRule {
|
||||
|
||||
message.ui_snoozed = Long.MAX_VALUE;
|
||||
message.ui_ignored = true;
|
||||
return true;
|
||||
|
||||
return (!seen || onActionSeen(context, message, true));
|
||||
}
|
||||
|
||||
private boolean onActionIgnore(Context context, EntityMessage message, JSONObject jargs) {
|
||||
|
||||
@@ -139,6 +139,8 @@ public class FragmentRule extends FragmentBase {
|
||||
private Spinner spAction;
|
||||
private TextView tvActionRemark;
|
||||
|
||||
private CheckBox cbHideSeen;
|
||||
|
||||
private NumberPicker npDuration;
|
||||
private CheckBox cbScheduleEnd;
|
||||
private CheckBox cbSnoozeSeen;
|
||||
@@ -191,6 +193,7 @@ public class FragmentRule extends FragmentBase {
|
||||
|
||||
private Group grpReady;
|
||||
private Group grpAge;
|
||||
private Group grpHide;
|
||||
private Group grpSnooze;
|
||||
private Group grpFlag;
|
||||
private Group grpImportance;
|
||||
@@ -348,6 +351,8 @@ public class FragmentRule extends FragmentBase {
|
||||
spAction = view.findViewById(R.id.spAction);
|
||||
tvActionRemark = view.findViewById(R.id.tvActionRemark);
|
||||
|
||||
cbHideSeen = view.findViewById(R.id.cbHideSeen);
|
||||
|
||||
npDuration = view.findViewById(R.id.npDuration);
|
||||
cbScheduleEnd = view.findViewById(R.id.cbScheduleEnd);
|
||||
cbSnoozeSeen = view.findViewById(R.id.cbSnoozeSeen);
|
||||
@@ -401,6 +406,7 @@ public class FragmentRule extends FragmentBase {
|
||||
|
||||
grpReady = view.findViewById(R.id.grpReady);
|
||||
grpAge = view.findViewById(R.id.grpAge);
|
||||
grpHide = view.findViewById(R.id.grpHide);
|
||||
grpSnooze = view.findViewById(R.id.grpSnooze);
|
||||
grpFlag = view.findViewById(R.id.grpFlag);
|
||||
grpImportance = view.findViewById(R.id.grpImportance);
|
||||
@@ -951,6 +957,7 @@ public class FragmentRule extends FragmentBase {
|
||||
bottom_navigation.setVisibility(View.GONE);
|
||||
grpReady.setVisibility(View.GONE);
|
||||
grpAge.setVisibility(View.GONE);
|
||||
grpHide.setVisibility(View.GONE);
|
||||
grpSnooze.setVisibility(View.GONE);
|
||||
grpFlag.setVisibility(View.GONE);
|
||||
grpImportance.setVisibility(View.GONE);
|
||||
@@ -1417,6 +1424,10 @@ public class FragmentRule extends FragmentBase {
|
||||
} else {
|
||||
int type = jaction.getInt("type");
|
||||
switch (type) {
|
||||
case EntityRule.TYPE_HIDE:
|
||||
cbHideSeen.setChecked(jaction.optBoolean("seen", false));
|
||||
break;
|
||||
|
||||
case EntityRule.TYPE_SNOOZE:
|
||||
npDuration.setValue(jaction.optInt("duration", 0));
|
||||
cbScheduleEnd.setChecked(jaction.optBoolean("schedule_end", false));
|
||||
@@ -1554,6 +1565,7 @@ public class FragmentRule extends FragmentBase {
|
||||
}
|
||||
|
||||
private void showActionParameters(int type) {
|
||||
grpHide.setVisibility(type == EntityRule.TYPE_HIDE ? View.VISIBLE : View.GONE);
|
||||
grpSnooze.setVisibility(type == EntityRule.TYPE_SNOOZE ? View.VISIBLE : View.GONE);
|
||||
grpFlag.setVisibility(type == EntityRule.TYPE_FLAG ? View.VISIBLE : View.GONE);
|
||||
grpImportance.setVisibility(type == EntityRule.TYPE_IMPORTANCE ? View.VISIBLE : View.GONE);
|
||||
@@ -1863,6 +1875,10 @@ public class FragmentRule extends FragmentBase {
|
||||
if (action != null) {
|
||||
jaction.put("type", action.type);
|
||||
switch (action.type) {
|
||||
case EntityRule.TYPE_HIDE:
|
||||
jaction.put("seen", cbHideSeen.isChecked());
|
||||
break;
|
||||
|
||||
case EntityRule.TYPE_SNOOZE:
|
||||
jaction.put("duration", npDuration.getValue());
|
||||
jaction.put("schedule_end", cbScheduleEnd.isChecked());
|
||||
|
||||
Reference in New Issue
Block a user