1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04: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; mNotifyNewMail = true;
mSignature = "Sent from my Android phone with K-9. Please excuse my brevity."; mSignature = "Sent from my Android phone with K-9. Please excuse my brevity.";
mVibrate = false; mVibrate = false;
mFolderDisplayMode = FolderMode.ALL; mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
mFolderSyncMode = FolderMode.ALL; mFolderSyncMode = FolderMode.FIRST_CLASS;
mRingtoneUri = "content://settings/system/notification_sound"; mRingtoneUri = "content://settings/system/notification_sound";
} }
@ -126,7 +126,7 @@ public class Account implements Serializable {
} }
catch (Exception e) catch (Exception e)
{ {
mFolderDisplayMode = FolderMode.ALL; mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
} }
try try
@ -136,7 +136,7 @@ public class Account implements Serializable {
} }
catch (Exception e) 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++) { for (int i = 0, count = remoteFolders.length; i < count; i++) {
LocalFolder localFolder = localStore.getFolder(remoteFolders[i].getName()); LocalFolder localFolder = localStore.getFolder(remoteFolders[i].getName());
if (!localFolder.exists()) { if (!localFolder.exists()) {
// TODO: if the localFolder is inbox, set to 1st Class
localFolder.create(FolderType.HOLDS_MESSAGES, account.getDisplayCount()); localFolder.create(FolderType.HOLDS_MESSAGES, account.getDisplayCount());
localFolder.setDisplayClass(Folder.FolderClass.FIRST_CLASS);
localFolder.save(Preferences.getPreferences(mApplication)); localFolder.save(Preferences.getPreferences(mApplication));
} }
remoteFolderNames.add(remoteFolders[i].getName()); remoteFolderNames.add(remoteFolders[i].getName());

View File

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