1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -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:
Danny Baumann 2013-01-31 10:56:31 +01:00
parent 1ab04587a9
commit 74c79cc365

View File

@ -89,6 +89,16 @@ public class EmailProvider extends ContentProvider {
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 = {
MessageColumns.ID
};
@ -395,12 +405,12 @@ public class EmailProvider extends ContentProvider {
first = false;
}
final String aggregationFunc = THREAD_AGGREGATION_FUNCS.get(columnName);
if (MessageColumns.ID.equals(columnName)) {
query.append("u." + MessageColumns.ID + " AS " + MessageColumns.ID);
} else if (MessageColumns.READ.equals(columnName)) {
query.append("MIN(read) AS " + MessageColumns.READ);
} else if (MessageColumns.DATE.equals(columnName)) {
query.append("MAX(date) AS " + MessageColumns.DATE);
} else if (aggregationFunc != null) {
query.append(aggregationFunc + "(" + columnName + ") AS " + columnName);
} else if (SpecialColumns.THREAD_COUNT.equals(columnName)) {
query.append("COUNT(g) AS " + SpecialColumns.THREAD_COUNT);
} else {