Add totalCount to Mailbox; send to UIProvider
Change-Id: If01868eb27a97540683f25148f32b8c41ae59c17
This commit is contained in:
parent
9e266d12fb
commit
e2166f7548
|
@ -1466,6 +1466,8 @@ public abstract class EmailContent {
|
|||
public static final String LAST_NOTIFIED_MESSAGE_KEY = "lastNotifiedMessageKey";
|
||||
// The UIProvider last sync result
|
||||
public static final String LAST_NOTIFIED_MESSAGE_COUNT = "lastNotifiedMessageCount";
|
||||
// The total number of messages in the remote mailbox
|
||||
public static final String TOTAL_COUNT = "totalCount";
|
||||
}
|
||||
|
||||
public interface HostAuthColumns {
|
||||
|
|
|
@ -60,6 +60,7 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||
public int mUiLastSyncResult;
|
||||
public long mLastNotifiedMessageKey;
|
||||
public int mLastNotifiedMessageCount;
|
||||
public int mTotalCount;
|
||||
|
||||
public static final int CONTENT_ID_COLUMN = 0;
|
||||
public static final int CONTENT_DISPLAY_NAME_COLUMN = 1;
|
||||
|
@ -82,6 +83,7 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||
public static final int CONTENT_UI_LAST_SYNC_RESULT_COLUMN = 18;
|
||||
public static final int CONTENT_LAST_NOTIFIED_MESSAGE_KEY_COLUMN = 19;
|
||||
public static final int CONTENT_LAST_NOTIFIED_MESSAGE_COUNT_COLUMN = 20;
|
||||
public static final int CONTENT_TOTAL_COUNT_COLUMN = 21;
|
||||
|
||||
/**
|
||||
* <em>NOTE</em>: If fields are added or removed, the method {@link #getHashes()}
|
||||
|
@ -95,7 +97,8 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||
MailboxColumns.FLAG_VISIBLE, MailboxColumns.FLAGS, MailboxColumns.VISIBLE_LIMIT,
|
||||
MailboxColumns.SYNC_STATUS, MailboxColumns.PARENT_KEY, MailboxColumns.LAST_TOUCHED_TIME,
|
||||
MailboxColumns.UI_SYNC_STATUS, MailboxColumns.UI_LAST_SYNC_RESULT,
|
||||
MailboxColumns.LAST_NOTIFIED_MESSAGE_KEY, MailboxColumns.LAST_NOTIFIED_MESSAGE_COUNT
|
||||
MailboxColumns.LAST_NOTIFIED_MESSAGE_KEY, MailboxColumns.LAST_NOTIFIED_MESSAGE_COUNT,
|
||||
MailboxColumns.TOTAL_COUNT
|
||||
};
|
||||
|
||||
private static final String ACCOUNT_AND_MAILBOX_TYPE_SELECTION =
|
||||
|
@ -322,6 +325,7 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||
mUiLastSyncResult = cursor.getInt(CONTENT_UI_LAST_SYNC_RESULT_COLUMN);
|
||||
mLastNotifiedMessageKey = cursor.getLong(CONTENT_LAST_NOTIFIED_MESSAGE_KEY_COLUMN);
|
||||
mLastNotifiedMessageCount = cursor.getInt(CONTENT_LAST_NOTIFIED_MESSAGE_COUNT_COLUMN);
|
||||
mTotalCount = cursor.getInt(CONTENT_TOTAL_COUNT_COLUMN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -347,6 +351,7 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||
values.put(MailboxColumns.UI_LAST_SYNC_RESULT, mUiLastSyncResult);
|
||||
values.put(MailboxColumns.LAST_NOTIFIED_MESSAGE_KEY, mLastNotifiedMessageKey);
|
||||
values.put(MailboxColumns.LAST_NOTIFIED_MESSAGE_COUNT, mLastNotifiedMessageCount);
|
||||
values.put(MailboxColumns.TOTAL_COUNT, mTotalCount);
|
||||
return values;
|
||||
}
|
||||
|
||||
|
@ -565,6 +570,8 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||
= mLastNotifiedMessageKey;
|
||||
hash[CONTENT_LAST_NOTIFIED_MESSAGE_COUNT_COLUMN]
|
||||
= mLastNotifiedMessageCount;
|
||||
hash[CONTENT_TOTAL_COUNT_COLUMN]
|
||||
= mTotalCount;
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
@ -599,6 +606,7 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||
dest.writeInt(mUiLastSyncResult);
|
||||
dest.writeLong(mLastNotifiedMessageKey);
|
||||
dest.writeInt(mLastNotifiedMessageCount);
|
||||
dest.writeInt(mTotalCount);
|
||||
}
|
||||
|
||||
public Mailbox(Parcel in) {
|
||||
|
@ -624,6 +632,7 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||
mUiLastSyncResult = in.readInt();
|
||||
mLastNotifiedMessageKey = in.readLong();
|
||||
mLastNotifiedMessageCount = in.readInt();
|
||||
mTotalCount = in.readInt();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<Mailbox> CREATOR = new Parcelable.Creator<Mailbox>() {
|
||||
|
|
|
@ -117,8 +117,9 @@ public final class DBHelper {
|
|||
// Version 32: Add columns to mailbox for last notified message key/count; insure not null
|
||||
// for "notified" columns
|
||||
// Version 33: Add columns to attachment for ui provider columns
|
||||
// Version 34: Add total count to mailbox
|
||||
|
||||
public static final int DATABASE_VERSION = 33;
|
||||
public static final int DATABASE_VERSION = 34;
|
||||
|
||||
// Any changes to the database format *must* include update-in-place code.
|
||||
// Original version: 2
|
||||
|
@ -395,7 +396,8 @@ public final class DBHelper {
|
|||
+ MailboxColumns.UI_SYNC_STATUS + " integer default 0, "
|
||||
+ MailboxColumns.UI_LAST_SYNC_RESULT + " integer default 0, "
|
||||
+ MailboxColumns.LAST_NOTIFIED_MESSAGE_KEY + " integer not null default 0, "
|
||||
+ MailboxColumns.LAST_NOTIFIED_MESSAGE_COUNT + " integer not null default 0"
|
||||
+ MailboxColumns.LAST_NOTIFIED_MESSAGE_COUNT + " integer not null default 0, "
|
||||
+ MailboxColumns.TOTAL_COUNT + " integer"
|
||||
+ ");";
|
||||
db.execSQL("create table " + Mailbox.TABLE_NAME + s);
|
||||
db.execSQL("create index mailbox_" + MailboxColumns.SERVER_ID
|
||||
|
@ -852,6 +854,16 @@ public final class DBHelper {
|
|||
}
|
||||
oldVersion = 33;
|
||||
}
|
||||
if (oldVersion == 33) {
|
||||
try {
|
||||
db.execSQL("alter table " + Mailbox.TABLE_NAME
|
||||
+ " add column " + MailboxColumns.TOTAL_COUNT + " integer;");
|
||||
} catch (SQLException e) {
|
||||
// Shouldn't be needed unless we're debugging and interrupt the process
|
||||
Log.w(TAG, "Exception upgrading EmailProvider.db from 33 to 34 " + e);
|
||||
}
|
||||
oldVersion = 34;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2000,6 +2000,7 @@ outer:
|
|||
.add(UIProvider.FolderColumns.REFRESH_URI, uriWithId("uirefresh"))
|
||||
.add(UIProvider.FolderColumns.SYNC_STATUS, MailboxColumns.UI_SYNC_STATUS)
|
||||
.add(UIProvider.FolderColumns.LAST_SYNC_RESULT, MailboxColumns.UI_LAST_SYNC_RESULT)
|
||||
.add(UIProvider.FolderColumns.TOTAL_COUNT, MailboxColumns.TOTAL_COUNT)
|
||||
.build();
|
||||
|
||||
private static final ProjectionMap sAccountListMap = ProjectionMap.builder()
|
||||
|
|
|
@ -552,6 +552,9 @@ public class ImapService extends Service {
|
|||
|
||||
// 5. Get the remote message count.
|
||||
int remoteMessageCount = remoteFolder.getMessageCount();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MailboxColumns.TOTAL_COUNT, remoteMessageCount);
|
||||
mailbox.update(context, values);
|
||||
|
||||
// 6. Determine the limit # of messages to download
|
||||
int visibleLimit = mailbox.mVisibleLimit;
|
||||
|
|
|
@ -52,6 +52,7 @@ import com.android.emailcommon.mail.MessagingException;
|
|||
import com.android.emailcommon.mail.Part;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.MessageColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.SyncColumns;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
|
@ -536,6 +537,9 @@ public class Pop3Service extends Service {
|
|||
|
||||
// 5. Get the remote message count.
|
||||
int remoteMessageCount = remoteFolder.getMessageCount();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MailboxColumns.TOTAL_COUNT, remoteMessageCount);
|
||||
mailbox.update(context, values);
|
||||
|
||||
// 6. Determine the limit # of messages to download
|
||||
int visibleLimit = mailbox.mVisibleLimit;
|
||||
|
|
Loading…
Reference in New Issue