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:
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());

@ -964,7 +964,7 @@
app:layout_constraintTop_toBottomOf="@id/npDuration" />
<CheckBox
android:id="@+id/cbSnoozeSeen"
android:id="@+id/cbHideSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
@ -972,6 +972,15 @@
app:layout_constraintStart_toStartOf="parent"
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
android:id="@+id/tvColor"
android:layout_width="wrap_content"
@ -1525,6 +1534,12 @@
android:layout_height="0dp"
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
android:id="@+id/grpSnooze"
android:layout_width="0dp"

Loading…
Cancel
Save