Added option to mark messages seen for hide rule action

pull/217/head
M66B 7 months ago
parent a49ea25fdc
commit 7112d93d47

@ -658,7 +658,7 @@ public class EntityRule {
case TYPE_UNSEEN: case TYPE_UNSEEN:
return onActionSeen(context, message, false); return onActionSeen(context, message, false);
case TYPE_HIDE: case TYPE_HIDE:
return onActionHide(context, message); return onActionHide(context, message, jaction);
case TYPE_IGNORE: case TYPE_IGNORE:
return onActionIgnore(context, message, jaction); return onActionIgnore(context, message, jaction);
case TYPE_SNOOZE: case TYPE_SNOOZE:
@ -811,7 +811,9 @@ public class EntityRule {
return true; 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); DB db = DB.getInstance(context);
EntityFolder folder = db.folder().getFolder(message.folder); EntityFolder folder = db.folder().getFolder(message.folder);
@ -824,7 +826,8 @@ public class EntityRule {
message.ui_snoozed = Long.MAX_VALUE; message.ui_snoozed = Long.MAX_VALUE;
message.ui_ignored = true; message.ui_ignored = true;
return true;
return (!seen || onActionSeen(context, message, true));
} }
private boolean onActionIgnore(Context context, EntityMessage message, JSONObject jargs) { private boolean onActionIgnore(Context context, EntityMessage message, JSONObject jargs) {

@ -139,6 +139,8 @@ public class FragmentRule extends FragmentBase {
private Spinner spAction; private Spinner spAction;
private TextView tvActionRemark; private TextView tvActionRemark;
private CheckBox cbHideSeen;
private NumberPicker npDuration; private NumberPicker npDuration;
private CheckBox cbScheduleEnd; private CheckBox cbScheduleEnd;
private CheckBox cbSnoozeSeen; private CheckBox cbSnoozeSeen;
@ -191,6 +193,7 @@ public class FragmentRule extends FragmentBase {
private Group grpReady; private Group grpReady;
private Group grpAge; private Group grpAge;
private Group grpHide;
private Group grpSnooze; private Group grpSnooze;
private Group grpFlag; private Group grpFlag;
private Group grpImportance; private Group grpImportance;
@ -348,6 +351,8 @@ public class FragmentRule extends FragmentBase {
spAction = view.findViewById(R.id.spAction); spAction = view.findViewById(R.id.spAction);
tvActionRemark = view.findViewById(R.id.tvActionRemark); tvActionRemark = view.findViewById(R.id.tvActionRemark);
cbHideSeen = view.findViewById(R.id.cbHideSeen);
npDuration = view.findViewById(R.id.npDuration); npDuration = view.findViewById(R.id.npDuration);
cbScheduleEnd = view.findViewById(R.id.cbScheduleEnd); cbScheduleEnd = view.findViewById(R.id.cbScheduleEnd);
cbSnoozeSeen = view.findViewById(R.id.cbSnoozeSeen); cbSnoozeSeen = view.findViewById(R.id.cbSnoozeSeen);
@ -401,6 +406,7 @@ public class FragmentRule extends FragmentBase {
grpReady = view.findViewById(R.id.grpReady); grpReady = view.findViewById(R.id.grpReady);
grpAge = view.findViewById(R.id.grpAge); grpAge = view.findViewById(R.id.grpAge);
grpHide = view.findViewById(R.id.grpHide);
grpSnooze = view.findViewById(R.id.grpSnooze); grpSnooze = view.findViewById(R.id.grpSnooze);
grpFlag = view.findViewById(R.id.grpFlag); grpFlag = view.findViewById(R.id.grpFlag);
grpImportance = view.findViewById(R.id.grpImportance); grpImportance = view.findViewById(R.id.grpImportance);
@ -951,6 +957,7 @@ public class FragmentRule extends FragmentBase {
bottom_navigation.setVisibility(View.GONE); bottom_navigation.setVisibility(View.GONE);
grpReady.setVisibility(View.GONE); grpReady.setVisibility(View.GONE);
grpAge.setVisibility(View.GONE); grpAge.setVisibility(View.GONE);
grpHide.setVisibility(View.GONE);
grpSnooze.setVisibility(View.GONE); grpSnooze.setVisibility(View.GONE);
grpFlag.setVisibility(View.GONE); grpFlag.setVisibility(View.GONE);
grpImportance.setVisibility(View.GONE); grpImportance.setVisibility(View.GONE);
@ -1417,6 +1424,10 @@ public class FragmentRule extends FragmentBase {
} else { } else {
int type = jaction.getInt("type"); int type = jaction.getInt("type");
switch (type) { switch (type) {
case EntityRule.TYPE_HIDE:
cbHideSeen.setChecked(jaction.optBoolean("seen", false));
break;
case EntityRule.TYPE_SNOOZE: case EntityRule.TYPE_SNOOZE:
npDuration.setValue(jaction.optInt("duration", 0)); npDuration.setValue(jaction.optInt("duration", 0));
cbScheduleEnd.setChecked(jaction.optBoolean("schedule_end", false)); cbScheduleEnd.setChecked(jaction.optBoolean("schedule_end", false));
@ -1554,6 +1565,7 @@ public class FragmentRule extends FragmentBase {
} }
private void showActionParameters(int type) { 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); grpSnooze.setVisibility(type == EntityRule.TYPE_SNOOZE ? View.VISIBLE : View.GONE);
grpFlag.setVisibility(type == EntityRule.TYPE_FLAG ? View.VISIBLE : View.GONE); grpFlag.setVisibility(type == EntityRule.TYPE_FLAG ? View.VISIBLE : View.GONE);
grpImportance.setVisibility(type == EntityRule.TYPE_IMPORTANCE ? 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) { if (action != null) {
jaction.put("type", action.type); jaction.put("type", action.type);
switch (action.type) { switch (action.type) {
case EntityRule.TYPE_HIDE:
jaction.put("seen", cbHideSeen.isChecked());
break;
case EntityRule.TYPE_SNOOZE: case EntityRule.TYPE_SNOOZE:
jaction.put("duration", npDuration.getValue()); jaction.put("duration", npDuration.getValue());
jaction.put("schedule_end", cbScheduleEnd.isChecked()); jaction.put("schedule_end", cbScheduleEnd.isChecked());

@ -964,7 +964,7 @@
app:layout_constraintTop_toBottomOf="@id/npDuration" /> app:layout_constraintTop_toBottomOf="@id/npDuration" />
<CheckBox <CheckBox
android:id="@+id/cbSnoozeSeen" android:id="@+id/cbHideSeen"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
@ -972,6 +972,15 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbScheduleEnd" /> app:layout_constraintTop_toBottomOf="@id/cbScheduleEnd" />
<CheckBox
android:id="@+id/cbSnoozeSeen"
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/cbHideSeen" />
<TextView <TextView
android:id="@+id/tvColor" android:id="@+id/tvColor"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -1525,6 +1534,12 @@
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="tvAge,etAge" /> app:constraint_referenced_ids="tvAge,etAge" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpHide"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="cbHideSeen" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
android:id="@+id/grpSnooze" android:id="@+id/grpSnooze"
android:layout_width="0dp" android:layout_width="0dp"

Loading…
Cancel
Save