1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Set to use new folder display and sync class defaults.

Accounts are now set:
Folder display mode = All except 2nd Class
Folder sync mode = Only 1st Class

Only the Inbox is set for:
Folder sync class = 1st Class
All other folders have class set to None for sync and display

Also restored an optimization on opening local folders that I
removed.  It is now optimistic, and in the normal case does not have
to make an explicit existence check
This commit is contained in:
Daniel Applebaum 2009-01-03 01:47:24 +00:00
parent 41d6598e22
commit 828ceba503
3 changed files with 38 additions and 29 deletions

View File

@ -75,8 +75,8 @@ public class Account implements Serializable {
mNotifyNewMail = true;
mSignature = "Sent from my Android phone with K-9. Please excuse my brevity.";
mVibrate = false;
mFolderDisplayMode = FolderMode.ALL;
mFolderSyncMode = FolderMode.ALL;
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
mFolderSyncMode = FolderMode.FIRST_CLASS;
mRingtoneUri = "content://settings/system/notification_sound";
}
@ -126,7 +126,7 @@ public class Account implements Serializable {
}
catch (Exception e)
{
mFolderDisplayMode = FolderMode.ALL;
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
}
try
@ -136,7 +136,7 @@ public class Account implements Serializable {
}
catch (Exception e)
{
mFolderSyncMode = FolderMode.ALL;
mFolderSyncMode = FolderMode.FIRST_CLASS;
}
}

View File

@ -304,9 +304,7 @@ public class MessagingController implements Runnable {
for (int i = 0, count = remoteFolders.length; i < count; i++) {
LocalFolder localFolder = localStore.getFolder(remoteFolders[i].getName());
if (!localFolder.exists()) {
// TODO: if the localFolder is inbox, set to 1st Class
localFolder.create(FolderType.HOLDS_MESSAGES, account.getDisplayCount());
localFolder.setDisplayClass(Folder.FolderClass.FIRST_CLASS);
localFolder.save(Preferences.getPreferences(mApplication));
}
remoteFolderNames.add(remoteFolders[i].getName());

View File

@ -348,6 +348,12 @@ public class LocalStore extends Store implements Serializable {
public LocalFolder(String name) {
this.mName = name;
if (Email.INBOX.equals(getName()))
{
syncClass = FolderClass.FIRST_CLASS;
}
}
public long getId() {
@ -356,28 +362,33 @@ public class LocalStore extends Store implements Serializable {
@Override
public void open(OpenMode mode) throws MessagingException {
if (isOpen()) {
return;
}
if (!exists()) {
create(FolderType.HOLDS_MESSAGES);
}
Cursor cursor = null;
try {
cursor = mDb.rawQuery("SELECT id, unread_count, visible_limit, last_updated, status FROM folders "
+ "where folders.name = ?",
new String[] {
mName
});
cursor.moveToFirst();
open(cursor.getInt(0), cursor.getInt(1), cursor.getInt(2), cursor.getLong(3), cursor.getString(4));
if (isOpen()) {
return;
}
Cursor cursor = null;
try {
cursor = mDb.rawQuery("SELECT id, unread_count, visible_limit, last_updated, status FROM folders "
+ "where folders.name = ?",
new String[] {
mName
});
if (cursor.moveToFirst()) {
int folderId = cursor.getInt(0);
if (folderId > 0)
{
open(cursor.getInt(0), cursor.getInt(1), cursor.getInt(2), cursor.getLong(3), cursor.getString(4));
}
} else {
create(FolderType.HOLDS_MESSAGES);
open(mode);
}
finally {
if (cursor != null) {
cursor.close();
}
}
finally {
if (cursor != null) {
cursor.close();
}
}
}
private void open(int id, int unreadCount, int visibleLimit, long lastChecked, String status) throws MessagingException
@ -581,8 +592,8 @@ public class LocalStore extends Store implements Serializable {
String id = getPrefId();
SharedPreferences.Editor editor = preferences.mSharedPreferences.edit();
// there can be a lot of folders. For the defaults, let's not save prefs, saving space
if (displayClass == FolderClass.NONE)
// there can be a lot of folders. For the defaults, let's not save prefs, saving space, except for INBOX
if (displayClass == FolderClass.NONE && !Email.INBOX.equals(getName()))
{
editor.remove(id + ".displayMode");
}
@ -591,7 +602,7 @@ public class LocalStore extends Store implements Serializable {
editor.putString(id + ".displayMode", displayClass.name());
}
if (syncClass == FolderClass.NONE)
if (syncClass == FolderClass.NONE && !Email.INBOX.equals(getName()))
{
editor.remove(id + ".syncMode");
}