mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -05:00
Aggregate some more thread columns properly.
- show thread as starred if at least one message in it is starred - use arrival date of last message as thread arrival date - use sum of message attachment counts in thread as thread attachment count - show thread as answered/forwarded if all messages in thread were answered/forwarded
This commit is contained in:
parent
1ab04587a9
commit
74c79cc365
@ -89,6 +89,16 @@ public class EmailProvider extends ContentProvider {
|
|||||||
InternalMessageColumns.MIME_TYPE
|
InternalMessageColumns.MIME_TYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final Map<String, String> THREAD_AGGREGATION_FUNCS = new HashMap<String, String>();
|
||||||
|
static {
|
||||||
|
THREAD_AGGREGATION_FUNCS.put(MessageColumns.DATE, "MAX");
|
||||||
|
THREAD_AGGREGATION_FUNCS.put(MessageColumns.INTERNAL_DATE, "MAX");
|
||||||
|
THREAD_AGGREGATION_FUNCS.put(MessageColumns.ATTACHMENT_COUNT, "SUM");
|
||||||
|
THREAD_AGGREGATION_FUNCS.put(MessageColumns.READ, "MIN");
|
||||||
|
THREAD_AGGREGATION_FUNCS.put(MessageColumns.FLAGGED, "MAX");
|
||||||
|
THREAD_AGGREGATION_FUNCS.put(MessageColumns.ANSWERED, "MIN");
|
||||||
|
THREAD_AGGREGATION_FUNCS.put(MessageColumns.FORWARDED, "MIN");
|
||||||
|
}
|
||||||
private static final String[] FIXUP_MESSAGES_COLUMNS = {
|
private static final String[] FIXUP_MESSAGES_COLUMNS = {
|
||||||
MessageColumns.ID
|
MessageColumns.ID
|
||||||
};
|
};
|
||||||
@ -395,12 +405,12 @@ public class EmailProvider extends ContentProvider {
|
|||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String aggregationFunc = THREAD_AGGREGATION_FUNCS.get(columnName);
|
||||||
|
|
||||||
if (MessageColumns.ID.equals(columnName)) {
|
if (MessageColumns.ID.equals(columnName)) {
|
||||||
query.append("u." + MessageColumns.ID + " AS " + MessageColumns.ID);
|
query.append("u." + MessageColumns.ID + " AS " + MessageColumns.ID);
|
||||||
} else if (MessageColumns.READ.equals(columnName)) {
|
} else if (aggregationFunc != null) {
|
||||||
query.append("MIN(read) AS " + MessageColumns.READ);
|
query.append(aggregationFunc + "(" + columnName + ") AS " + columnName);
|
||||||
} else if (MessageColumns.DATE.equals(columnName)) {
|
|
||||||
query.append("MAX(date) AS " + MessageColumns.DATE);
|
|
||||||
} else if (SpecialColumns.THREAD_COUNT.equals(columnName)) {
|
} else if (SpecialColumns.THREAD_COUNT.equals(columnName)) {
|
||||||
query.append("COUNT(g) AS " + SpecialColumns.THREAD_COUNT);
|
query.append("COUNT(g) AS " + SpecialColumns.THREAD_COUNT);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user