mirror of https://github.com/M66B/FairEmail.git
Auto close conversations
This commit is contained in:
parent
94421c1e9a
commit
ec4e1d2400
|
@ -89,6 +89,7 @@ public class FragmentMessages extends FragmentEx {
|
||||||
private AdapterMessage.ViewType viewType;
|
private AdapterMessage.ViewType viewType;
|
||||||
private LiveData<PagedList<TupleMessageEx>> messages = null;
|
private LiveData<PagedList<TupleMessageEx>> messages = null;
|
||||||
|
|
||||||
|
private int autoCount = 0;
|
||||||
private boolean autoExpand = true;
|
private boolean autoExpand = true;
|
||||||
private List<Long> expanded = new ArrayList<>();
|
private List<Long> expanded = new ArrayList<>();
|
||||||
private List<Long> headers = new ArrayList<>();
|
private List<Long> headers = new ArrayList<>();
|
||||||
|
@ -827,37 +828,58 @@ public class FragmentMessages extends FragmentEx {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewType == AdapterMessage.ViewType.THREAD && autoExpand) {
|
if (viewType == AdapterMessage.ViewType.THREAD)
|
||||||
autoExpand = false;
|
if (autoExpand) {
|
||||||
|
autoExpand = false;
|
||||||
|
|
||||||
int count = 0;
|
int unseen = 0;
|
||||||
int unseen = 0;
|
TupleMessageEx single = null;
|
||||||
TupleMessageEx single = null;
|
TupleMessageEx see = null;
|
||||||
TupleMessageEx see = null;
|
for (int i = 0; i < messages.size(); i++) {
|
||||||
for (int i = 0; i < messages.size(); i++) {
|
TupleMessageEx message = messages.get(i);
|
||||||
TupleMessageEx message = messages.get(i);
|
if (!EntityFolder.ARCHIVE.equals(message.folderType) &&
|
||||||
if (!EntityFolder.ARCHIVE.equals(message.folderType) &&
|
!EntityFolder.SENT.equals(message.folderType)) {
|
||||||
!EntityFolder.SENT.equals(message.folderType)) {
|
autoCount++;
|
||||||
count++;
|
single = message;
|
||||||
single = message;
|
if (!message.ui_seen) {
|
||||||
if (!message.ui_seen) {
|
unseen++;
|
||||||
unseen++;
|
see = message;
|
||||||
see = message;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
TupleMessageEx expand = null;
|
// Auto expand when:
|
||||||
if (count == 1)
|
// - single, non archived/sent message
|
||||||
expand = single;
|
// - one unread, non archived/sent message in conversation
|
||||||
else if (unseen == 1)
|
|
||||||
expand = see;
|
|
||||||
|
|
||||||
if (expand != null) {
|
TupleMessageEx expand = null;
|
||||||
expanded.add(expand.id);
|
if (autoCount == 1)
|
||||||
handleExpand(expand.id);
|
expand = single;
|
||||||
|
else if (unseen == 1)
|
||||||
|
expand = see;
|
||||||
|
|
||||||
|
if (expand != null) {
|
||||||
|
expanded.add(expand.id);
|
||||||
|
handleExpand(expand.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (autoCount > 0) {
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < messages.size(); i++) {
|
||||||
|
TupleMessageEx message = messages.get(i);
|
||||||
|
if (!EntityFolder.ARCHIVE.equals(message.folderType) &&
|
||||||
|
!EntityFolder.SENT.equals(message.folderType)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Auto close when:
|
||||||
|
// - no more non archived/sent messages
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Log.i(Helper.TAG, "Submit messages=" + messages.size());
|
Log.i(Helper.TAG, "Submit messages=" + messages.size());
|
||||||
adapter.submitList(messages);
|
adapter.submitList(messages);
|
||||||
|
|
Loading…
Reference in New Issue