mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-31 15:20:09 -05:00
Restore show next/previous message functionality in MessageView
This is just a temporary fix. In the future we want to get rid of passing the serialized message list from MessageList to MessageView.
This commit is contained in:
parent
303c1ee85d
commit
968d948dd0
@ -111,6 +111,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
MessageColumns.THREAD_ROOT,
|
||||
MessageColumns.THREAD_PARENT,
|
||||
SpecialColumns.ACCOUNT_UUID,
|
||||
SpecialColumns.FOLDER_NAME,
|
||||
|
||||
MessageColumns.THREAD_COUNT,
|
||||
};
|
||||
@ -130,7 +131,8 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
private static final int THREAD_ROOT_COLUMN = 12;
|
||||
private static final int THREAD_PARENT_COLUMN = 13;
|
||||
private static final int ACCOUNT_UUID_COLUMN = 14;
|
||||
private static final int THREAD_COUNT_COLUMN = 15;
|
||||
private static final int FOLDER_NAME_COLUMN = 15;
|
||||
private static final int THREAD_COUNT_COLUMN = 16;
|
||||
|
||||
private static final String[] PROJECTION = Utility.copyOf(THREADED_PROJECTION,
|
||||
THREAD_COUNT_COLUMN);
|
||||
@ -2440,13 +2442,16 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
public ArrayList<MessageReference> getMessageReferences() {
|
||||
ArrayList<MessageReference> messageRefs = new ArrayList<MessageReference>();
|
||||
|
||||
/*
|
||||
for (MessageInfoHolder holder : mAdapter.getMessages()) {
|
||||
MessageReference ref = holder.message.makeMessageReference();
|
||||
for (int i = 0, len = mAdapter.getCount(); i < len; i++) {
|
||||
Cursor cursor = (Cursor) mAdapter.getItem(i);
|
||||
|
||||
MessageReference ref = new MessageReference();
|
||||
ref.accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
|
||||
ref.folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
||||
ref.uid = cursor.getString(UID_COLUMN);
|
||||
|
||||
messageRefs.add(ref);
|
||||
}
|
||||
*/
|
||||
//TODO: implement
|
||||
|
||||
return messageRefs;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.helper.StringUtils;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.store.LocalStore;
|
||||
import com.fsck.k9.mail.store.LockableDatabase;
|
||||
@ -36,8 +37,6 @@ import android.net.Uri;
|
||||
*/
|
||||
/*
|
||||
* TODO:
|
||||
* - modify MessagingController (or LocalStore?) to call ContentResolver.notifyChange() to trigger
|
||||
* notifications when the underlying data changes.
|
||||
* - add support for account list and folder list
|
||||
*/
|
||||
public class EmailProvider extends ContentProvider {
|
||||
@ -94,6 +93,8 @@ public class EmailProvider extends ContentProvider {
|
||||
|
||||
public interface SpecialColumns {
|
||||
public static final String ACCOUNT_UUID = "account_uuid";
|
||||
|
||||
public static final String FOLDER_NAME = "name";
|
||||
}
|
||||
|
||||
public interface MessageColumns {
|
||||
@ -229,8 +230,42 @@ public class EmailProvider extends ContentProvider {
|
||||
InternalMessageColumns.EMPTY + "!=1)";
|
||||
}
|
||||
|
||||
return db.query(MESSAGES_TABLE, projection, where, selectionArgs, null, null,
|
||||
sortOrder);
|
||||
final Cursor cursor;
|
||||
if (Utility.arrayContains(projection, SpecialColumns.FOLDER_NAME)) {
|
||||
StringBuilder query = new StringBuilder();
|
||||
query.append("SELECT ");
|
||||
boolean first = true;
|
||||
for (String columnName : projection) {
|
||||
if (!first) {
|
||||
query.append(",");
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (MessageColumns.ID.equals(columnName)) {
|
||||
query.append("m.");
|
||||
query.append(MessageColumns.ID);
|
||||
query.append(" AS ");
|
||||
query.append(MessageColumns.ID);
|
||||
} else {
|
||||
query.append(columnName);
|
||||
}
|
||||
}
|
||||
|
||||
query.append(" FROM messages m " +
|
||||
"LEFT JOIN folders f ON (m.folder_id = f.id) " +
|
||||
"WHERE ");
|
||||
query.append(addPrefixToSelection(MESSAGES_COLUMNS, "m.", where));
|
||||
query.append(" ORDER BY ");
|
||||
query.append(addPrefixToSelection(MESSAGES_COLUMNS, "m.", sortOrder));
|
||||
|
||||
cursor = db.rawQuery(query.toString(), selectionArgs);
|
||||
} else {
|
||||
cursor = db.query(MESSAGES_TABLE, projection, where, selectionArgs, null,
|
||||
null, sortOrder);
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
});
|
||||
} catch (UnavailableStorageException e) {
|
||||
@ -264,6 +299,9 @@ public class EmailProvider extends ContentProvider {
|
||||
query.append("MAX(m.date) AS " + MessageColumns.DATE);
|
||||
} else if (MessageColumns.THREAD_COUNT.equals(columnName)) {
|
||||
query.append("COUNT(h.id) AS " + MessageColumns.THREAD_COUNT);
|
||||
} else if (SpecialColumns.FOLDER_NAME.equals(columnName)) {
|
||||
query.append("f." + SpecialColumns.FOLDER_NAME + " AS " +
|
||||
SpecialColumns.FOLDER_NAME);
|
||||
} else {
|
||||
query.append("m.");
|
||||
query.append(columnName);
|
||||
@ -274,7 +312,13 @@ public class EmailProvider extends ContentProvider {
|
||||
|
||||
query.append(
|
||||
" FROM messages h JOIN messages m " +
|
||||
"ON (h.id = m.thread_root OR h.id = m.id) " +
|
||||
"ON (h.id = m.thread_root OR h.id = m.id) ");
|
||||
|
||||
if (Utility.arrayContains(projection, SpecialColumns.FOLDER_NAME)) {
|
||||
query.append("LEFT JOIN folders f ON (m.folder_id = f.id) ");
|
||||
}
|
||||
|
||||
query.append(
|
||||
"WHERE " +
|
||||
"(h.deleted = 0 AND m.deleted = 0 AND " +
|
||||
"(m.empty IS NULL OR m.empty != 1) AND " +
|
||||
|
Loading…
Reference in New Issue
Block a user