From cc986cf3d75dd80f59e41b829bb41c369f973d7d Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Mon, 3 Sep 2012 14:42:59 -0700 Subject: [PATCH] Clear visible limit when entering mailbox; enable imap load more Bug: 7045530 Change-Id: I013c465dfbe992e9df104039e8576465805c9119 --- src/com/android/email/imap2/Imap2SyncService.java | 9 ++++----- src/com/android/email/provider/EmailProvider.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/com/android/email/imap2/Imap2SyncService.java b/src/com/android/email/imap2/Imap2SyncService.java index 70bbe21bc..c36ac81c3 100644 --- a/src/com/android/email/imap2/Imap2SyncService.java +++ b/src/com/android/email/imap2/Imap2SyncService.java @@ -1523,7 +1523,6 @@ public class Imap2SyncService extends AbstractSyncService { do { uids[offs++] = c.getInt(0); } while (c.moveToNext()); - System.err.println(uids); return uids; } } finally { @@ -2011,7 +2010,7 @@ public class Imap2SyncService extends AbstractSyncService { private int[] handleLoadMore(int[] serverList, int howManyMore) throws IOException { // User has asked for more; find the oldest message Arrays.sort(serverList); - int oldest = serverList[serverList.length - 1]; + int oldest = serverList[0]; // Get its current sequence number String tag = writeCommand(mWriter, "uid fetch " + oldest + " (UID)"); // IMAP_OK if we want it to work @@ -2020,8 +2019,7 @@ public class Imap2SyncService extends AbstractSyncService { Parser lp = new Parser(line.substring(2)); // Last one we want is one before this message int end = lp.parseInteger() - 1; - // First one is end - 9 (we want 10) - int start = end - 9; + int start = end - howManyMore + 1; if (start < 1) { start = 1; } @@ -2029,7 +2027,7 @@ public class Imap2SyncService extends AbstractSyncService { // Get the uid's of the messages to load tag = writeCommand(mWriter, "uid search " + start + ":" + end); // IMAP_OK if we want it to work - if (readResponse(mReader, tag, "SEARCH").equals(IMAP_BAD)) { + if (readResponse(mReader, tag, "SEARCH").equals(IMAP_OK)) { int[] moreServerList; // Parse the list @@ -2041,6 +2039,7 @@ public class Imap2SyncService extends AbstractSyncService { // Length of "* search" Parser p = new Parser(msgs, 8); moreServerList = p.gatherInts(); + userLog("[Load more found " + moreServerList.length + " messages]"); int[] completeList = new int[serverList.length + moreServerList.length]; System.arraycopy(serverList, 0, completeList, 0, serverList.length); System.arraycopy(moreServerList, 0, completeList, serverList.length, diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index a235b39c0..b084d6798 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -2693,7 +2693,7 @@ outer: // "load more" is valid for protocols not supporting "lookback" values.put(UIProvider.FolderColumns.LOAD_MORE_URI, uiUriString("uiloadmore", mailboxId)); - }; + } values.put(UIProvider.FolderColumns.CAPABILITIES, getFolderCapabilities(info, mailbox.mFlags, mailbox.mType, mailboxId)); } @@ -3261,6 +3261,15 @@ outer: if (visible) { NotificationController.getInstance(mContext).cancelNewMessageNotification( mMailboxId); + // Clear the visible limit of the mailbox (if any) + Mailbox mailbox = Mailbox.restoreMailboxWithId(mContext, mMailboxId); + if (mailbox.mVisibleLimit > 0) { + ContentValues values = new ContentValues(); + values.put(MailboxColumns.VISIBLE_LIMIT, 0); + mContext.getContentResolver().update( + ContentUris.withAppendedId(Mailbox.CONTENT_URI, mMailboxId), + values, null, null); + } } } // Return success