mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-31 20:25:38 +00:00
Composer: snackbar on new messages
This commit is contained in:
parent
a22605bf69
commit
b8ba2a84a4
3 changed files with 56 additions and 0 deletions
|
@ -277,6 +277,15 @@ public interface DaoMessage {
|
|||
" AND ui_hide")
|
||||
LiveData<List<Long>> liveHiddenThread(long account, String thread);
|
||||
|
||||
@Query("SELECT * FROM message" +
|
||||
" JOIN folder_view AS folder ON folder.id = message.folder" +
|
||||
" WHERE message.account = :account" +
|
||||
" AND message.thread = :thread" +
|
||||
" AND folder.type <> '" + EntityFolder.ARCHIVE + "'" +
|
||||
" AND NOT ui_seen" +
|
||||
" AND NOT ui_hide")
|
||||
LiveData<List<EntityMessage>> liveUnreadThread(long account, String thread);
|
||||
|
||||
@Query("SELECT SUM(fts) AS fts, COUNT(*) AS total FROM message" +
|
||||
" JOIN folder_view AS folder ON folder.id = message.folder" +
|
||||
" WHERE content" +
|
||||
|
|
|
@ -5197,6 +5197,52 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
db.message().liveUnreadThread(data.draft.account, data.draft.thread).observe(getViewLifecycleOwner(), new Observer<List<EntityMessage>>() {
|
||||
private int lastDiff = 0;
|
||||
private List<EntityMessage> base = null;
|
||||
|
||||
@Override
|
||||
public void onChanged(List<EntityMessage> messages) {
|
||||
if (messages == null)
|
||||
return;
|
||||
|
||||
if (base == null) {
|
||||
base = messages;
|
||||
return;
|
||||
}
|
||||
|
||||
int diff = (messages.size() - base.size());
|
||||
if (diff > lastDiff) {
|
||||
lastDiff = diff;
|
||||
String msg = getResources().getQuantityString(
|
||||
R.plurals.title_notification_unseen, diff, diff);
|
||||
|
||||
Snackbar snackbar = Snackbar.make(view, msg, Snackbar.LENGTH_INDEFINITE)
|
||||
.setGestureInsetBottomIgnored(true);
|
||||
snackbar.setAction(R.string.title_show, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
EntityMessage message = messages.get(0);
|
||||
boolean notify_remove = prefs.getBoolean("notify_remove", true);
|
||||
|
||||
Intent thread = new Intent(v.getContext(), ActivityView.class);
|
||||
thread.setAction("thread:" + message.id);
|
||||
thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
thread.putExtra("account", message.account);
|
||||
thread.putExtra("folder", message.folder);
|
||||
thread.putExtra("thread", message.thread);
|
||||
thread.putExtra("filter_archive", true);
|
||||
thread.putExtra("ignore", notify_remove);
|
||||
|
||||
v.getContext().startActivity(thread);
|
||||
getActivity().finish();
|
||||
}
|
||||
});
|
||||
snackbar.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1642,6 +1642,7 @@
|
|||
<string name="title_download">Download</string>
|
||||
<string name="title_report">Report</string>
|
||||
<string name="title_fix">Fix</string>
|
||||
<string name="title_show">Show</string>
|
||||
<string name="title_enable">Enable</string>
|
||||
<string name="title_enabled">Enabled</string>
|
||||
<string name="title_disable">Disable</string>
|
||||
|
|
Loading…
Reference in a new issue