mirror of https://github.com/M66B/FairEmail.git
Added hiding messages
This commit is contained in:
parent
04adcaf221
commit
5d2a1c4266
|
@ -793,6 +793,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ivType.setImageResource(icon);
|
||||
}
|
||||
|
||||
ibSnoozed.setImageResource(
|
||||
message.ui_snoozed != null && message.ui_snoozed == Long.MAX_VALUE
|
||||
? R.drawable.baseline_visibility_off_24 : R.drawable.baseline_timelapse_24);
|
||||
|
||||
ivPriority.setVisibility(EntityMessage.PRIORITIY_HIGH.equals(message.priority) ? View.VISIBLE : View.GONE);
|
||||
ibAuth.setVisibility(authentication && !authenticated ? View.VISIBLE : View.GONE);
|
||||
ibSnoozed.setVisibility(message.ui_snoozed == null ? View.GONE : View.VISIBLE);
|
||||
|
@ -2126,7 +2130,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
private void onShowSnoozed(TupleMessageEx message) {
|
||||
if (message.ui_snoozed != null) {
|
||||
if (message.ui_snoozed != null && message.ui_snoozed != Long.MAX_VALUE) {
|
||||
DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);
|
||||
DateFormat D = new SimpleDateFormat("E");
|
||||
ToastEx.makeText(
|
||||
|
@ -2866,6 +2870,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
popupMenu.getMenu().findItem(R.id.menu_unseen).setEnabled(
|
||||
(message.uid != null && !message.folderReadOnly) || message.accountPop);
|
||||
|
||||
popupMenu.getMenu().findItem(R.id.menu_hide).setTitle(message.ui_snoozed == null ? R.string.title_hide : R.string.title_unhide);
|
||||
|
||||
popupMenu.getMenu().findItem(R.id.menu_flag_color).setEnabled(
|
||||
(message.uid != null && !message.folderReadOnly) || message.accountPop);
|
||||
|
||||
|
@ -2914,6 +2920,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
case R.id.menu_unseen:
|
||||
onMenuUnseen(message);
|
||||
return true;
|
||||
case R.id.menu_hide:
|
||||
onMenuHide(message);
|
||||
return true;
|
||||
case R.id.menu_flag_color:
|
||||
onMenuColoredStar(message);
|
||||
return true;
|
||||
|
@ -3124,6 +3133,43 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}.execute(context, owner, args, "message:unseen");
|
||||
}
|
||||
|
||||
private void onMenuHide(final TupleMessageEx message) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", message.id);
|
||||
args.putBoolean("hide", message.ui_snoozed == null);
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
boolean hide = args.getBoolean("hide");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
||||
EntityMessage message = db.message().getMessage(id);
|
||||
if (message == null)
|
||||
return null;
|
||||
|
||||
db.message().setMessageSnoozed(message.id, hide ? Long.MAX_VALUE : null);
|
||||
EntityMessage.snooze(context, message.id, hide ? Long.MAX_VALUE : null);
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.unexpectedError(parentFragment.getFragmentManager(), ex);
|
||||
}
|
||||
}.execute(context, owner, args, "message:hide");
|
||||
}
|
||||
|
||||
private void onMenuColoredStar(final TupleMessageEx message) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", message.id);
|
||||
|
|
|
@ -130,6 +130,9 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
case EntityRule.TYPE_UNSEEN:
|
||||
tvAction.setText(R.string.title_rule_unseen);
|
||||
break;
|
||||
case EntityRule.TYPE_HIDE:
|
||||
tvAction.setText(R.string.title_rule_hide);
|
||||
break;
|
||||
case EntityRule.TYPE_IGNORE:
|
||||
tvAction.setText(R.string.title_rule_ignore);
|
||||
break;
|
||||
|
|
|
@ -238,7 +238,7 @@ public class EntityMessage implements Serializable {
|
|||
PendingIntent pi = PendingIntent.getService(context, ServiceUI.PI_WAKEUP, snoozed, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
if (wakeup == null) {
|
||||
if (wakeup == null || wakeup == Long.MAX_VALUE) {
|
||||
Log.i("Cancel snooze id=" + id);
|
||||
am.cancel(pi);
|
||||
} else {
|
||||
|
|
|
@ -97,6 +97,7 @@ public class EntityRule {
|
|||
static final int TYPE_IGNORE = 9;
|
||||
static final int TYPE_NOOP = 10;
|
||||
static final int TYPE_KEYWORD = 11;
|
||||
static final int TYPE_HIDE = 12;
|
||||
|
||||
static final String ACTION_AUTOMATION = BuildConfig.APPLICATION_ID + ".AUTOMATION";
|
||||
static final String EXTRA_RULE = "rule";
|
||||
|
@ -274,6 +275,8 @@ public class EntityRule {
|
|||
return onActionSeen(context, message, true);
|
||||
case TYPE_UNSEEN:
|
||||
return onActionSeen(context, message, false);
|
||||
case TYPE_HIDE:
|
||||
return onActionHide(context, message);
|
||||
case TYPE_IGNORE:
|
||||
return onActionIgnore(context, message, jaction);
|
||||
case TYPE_SNOOZE:
|
||||
|
@ -304,6 +307,17 @@ public class EntityRule {
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean onActionHide(Context context, EntityMessage message) {
|
||||
DB db = DB.getInstance(context);
|
||||
db.message().setMessageSnoozed(message.id, Long.MAX_VALUE);
|
||||
db.message().setMessageUiIgnored(message.id, true);
|
||||
EntityMessage.snooze(context, message.id, Long.MAX_VALUE);
|
||||
|
||||
message.ui_snoozed = Long.MAX_VALUE;
|
||||
message.ui_ignored = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean onActionIgnore(Context context, EntityMessage message, JSONObject jargs) {
|
||||
DB db = DB.getInstance(context);
|
||||
db.message().setMessageUiIgnored(message.id, true);
|
||||
|
|
|
@ -147,6 +147,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
static final Long SWIPE_ACTION_ASK = -1L;
|
||||
static final Long SWIPE_ACTION_SEEN = -2L;
|
||||
static final Long SWIPE_ACTION_SNOOZE = -3L;
|
||||
static final Long SWIPE_ACTION_HIDE = -4L;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -1441,6 +1442,11 @@ public class FragmentAccount extends FragmentBase {
|
|||
snooze.name = getString(R.string.title_snooze_now);
|
||||
folders.add(snooze);
|
||||
|
||||
EntityFolder hide = new EntityFolder();
|
||||
hide.id = SWIPE_ACTION_HIDE;
|
||||
hide.name = getString(R.string.title_hide);
|
||||
folders.add(hide);
|
||||
|
||||
folders.addAll(_folders);
|
||||
|
||||
adapterSwipe.clear();
|
||||
|
|
|
@ -1434,6 +1434,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
icon = (message.ui_seen ? R.drawable.baseline_visibility_off_24 : R.drawable.baseline_visibility_24);
|
||||
else if (FragmentAccount.SWIPE_ACTION_SNOOZE.equals(action))
|
||||
icon = (message.ui_snoozed == null ? R.drawable.baseline_timelapse_24 : R.drawable.baseline_timer_off_24);
|
||||
else if (FragmentAccount.SWIPE_ACTION_HIDE.equals(action))
|
||||
icon = (message.ui_snoozed == null ? R.drawable.baseline_visibility_off_24 : R.drawable.baseline_visibility_24);
|
||||
else
|
||||
icon = EntityFolder.getIcon(dX > 0 ? swipes.right_type : swipes.left_type);
|
||||
Drawable d = getResources().getDrawable(icon, getContext().getTheme()).mutate();
|
||||
|
@ -1496,6 +1498,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
onActionSeenSelection(!message.ui_seen, message.id);
|
||||
else if (FragmentAccount.SWIPE_ACTION_SNOOZE.equals(action))
|
||||
onActionSnooze(message);
|
||||
else if (FragmentAccount.SWIPE_ACTION_HIDE.equals(action))
|
||||
onActionHide(message);
|
||||
else
|
||||
swipeFolder(message, action);
|
||||
}
|
||||
|
@ -1928,6 +1932,17 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
onSnooze(args);
|
||||
}
|
||||
|
||||
private void onActionHide(TupleMessageEx message) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("account", message.account);
|
||||
args.putString("thread", message.thread);
|
||||
args.putLong("id", message.id);
|
||||
args.putLong("duration", message.ui_snoozed == null ? Long.MAX_VALUE : 0);
|
||||
args.putLong("time", message.ui_snoozed == null ? Long.MAX_VALUE : 0);
|
||||
|
||||
onSnooze(args);
|
||||
}
|
||||
|
||||
private void onActionSnoozeSelection() {
|
||||
Bundle args = new Bundle();
|
||||
args.putString("title", getString(R.string.title_snooze));
|
||||
|
@ -2648,7 +2663,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
ibSeen.setImageResource(filter_seen ? R.drawable.baseline_drafts_24 : R.drawable.baseline_mail_24);
|
||||
ibUnflagged.setImageResource(filter_unflagged ? R.drawable.baseline_star_border_24 : R.drawable.baseline_star_24);
|
||||
ibSnoozed.setImageResource(filter_snoozed ? R.drawable.baseline_timelapse_24 : R.drawable.baseline_timer_off_24);
|
||||
ibSnoozed.setImageResource(filter_snoozed ? R.drawable.baseline_visibility_off_24 : R.drawable.baseline_visibility_24);
|
||||
|
||||
ibSeen.setVisibility(experiments && folder ? View.VISIBLE : View.GONE);
|
||||
ibUnflagged.setVisibility(experiments && folder ? View.VISIBLE : View.GONE);
|
||||
|
@ -4235,8 +4250,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
account, thread, threading ? null : id, null);
|
||||
for (EntityMessage threaded : messages) {
|
||||
db.message().setMessageSnoozed(threaded.id, wakeup);
|
||||
EntityMessage.snooze(context, threaded.id, wakeup);
|
||||
EntityOperation.queue(context, threaded, EntityOperation.SEEN, true);
|
||||
EntityMessage.snooze(context, threaded.id, wakeup);
|
||||
}
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
|
|
|
@ -329,6 +329,7 @@ public class FragmentRule extends FragmentBase {
|
|||
actions.add(new Action(EntityRule.TYPE_NOOP, getString(R.string.title_rule_noop)));
|
||||
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_HIDE, getString(R.string.title_rule_hide)));
|
||||
actions.add(new Action(EntityRule.TYPE_IGNORE, getString(R.string.title_rule_ignore)));
|
||||
actions.add(new Action(EntityRule.TYPE_SNOOZE, getString(R.string.title_rule_snooze)));
|
||||
actions.add(new Action(EntityRule.TYPE_FLAG, getString(R.string.title_rule_flag)));
|
||||
|
|
|
@ -716,17 +716,6 @@
|
|||
app:layout_constraintStart_toEndOf="@id/barrier_folders"
|
||||
app:layout_constraintTop_toBottomOf="@id/spLeft" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHideRemark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/title_hide_remark"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/spRight" />
|
||||
|
||||
<!-- save -->
|
||||
|
||||
<Button
|
||||
|
@ -737,7 +726,7 @@
|
|||
android:tag="disable"
|
||||
android:text="@string/title_save"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHideRemark" />
|
||||
app:layout_constraintTop_toBottomOf="@id/spRight" />
|
||||
|
||||
<eu.faircode.email.ContentLoadingProgressBar
|
||||
android:id="@+id/pbSave"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
android:title="@string/title_sort_on_size" />
|
||||
<item
|
||||
android:id="@+id/menu_sort_on_snoozed"
|
||||
android:title="@string/title_sort_on_snoozed" />
|
||||
android:title="@string/title_sort_on_hidden" />
|
||||
</group>
|
||||
<item
|
||||
android:id="@+id/menu_ascending"
|
||||
|
@ -71,7 +71,7 @@
|
|||
<item
|
||||
android:id="@+id/menu_filter_snoozed"
|
||||
android:checkable="true"
|
||||
android:title="@string/title_filter_snoozed" />
|
||||
android:title="@string/title_filter_hidden" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_filter_duplicates"
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
android:id="@+id/menu_unseen"
|
||||
android:title="@string/title_unseen" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_hide"
|
||||
android:title="@string/title_hide" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_flag_color"
|
||||
android:title="@string/title_flag_color" />
|
||||
|
|
|
@ -430,7 +430,6 @@
|
|||
<string name="title_no_sync">Synchronization errors since %1$s</string>
|
||||
<string name="title_identity_required">An identity is required to send messages</string>
|
||||
<string name="title_drafts_required">A drafts folder is required to send messages</string>
|
||||
<string name="title_hide_remark">Messages can be hidden by snoozing messages</string>
|
||||
<string name="title_account_delete">Delete this account permanently?</string>
|
||||
<string name="title_identity_delete">Delete this identity permanently?</string>
|
||||
<string name="title_edit_html">Edit as HTML</string>
|
||||
|
@ -507,6 +506,8 @@
|
|||
|
||||
<string name="title_seen">Mark read</string>
|
||||
<string name="title_unseen">Mark unread</string>
|
||||
<string name="title_hide">Hide</string>
|
||||
<string name="title_unhide">Show</string>
|
||||
<string name="title_flag">Add star</string>
|
||||
<string name="title_flag_color">Colored star …</string>
|
||||
<string name="title_unflag">Remove star</string>
|
||||
|
@ -661,13 +662,13 @@
|
|||
<string name="title_sort_on_sender">Sender</string>
|
||||
<string name="title_sort_on_subject">Subject</string>
|
||||
<string name="title_sort_on_size">Size</string>
|
||||
<string name="title_sort_on_snoozed">Snoozed</string>
|
||||
<string name="title_sort_on_hidden">Hidden</string>
|
||||
<string name="title_sort_ascending">Oldest first</string>
|
||||
|
||||
<string name="title_filter">Filter out</string>
|
||||
<string name="title_filter_seen">Read</string>
|
||||
<string name="title_filter_unflagged">Unstarred</string>
|
||||
<string name="title_filter_snoozed">Snoozed</string>
|
||||
<string name="title_filter_hidden">Hidden</string>
|
||||
<string name="title_filter_duplicates">Duplicates</string>
|
||||
|
||||
<string name="title_compact">Compact view</string>
|
||||
|
@ -689,6 +690,7 @@
|
|||
<string name="title_rule_noop">No action</string>
|
||||
<string name="title_rule_seen">Mark read</string>
|
||||
<string name="title_rule_unseen">Mark unread</string>
|
||||
<string name="title_rule_hide">Hide</string>
|
||||
<string name="title_rule_ignore">Suppress notification</string>
|
||||
<string name="title_rule_snooze">Snooze</string>
|
||||
<string name="title_rule_flag">Add star</string>
|
||||
|
|
Loading…
Reference in New Issue