1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-02 00:25:10 -04:00

fixed issue with sort not being remembered at all on unified inbox / all messages (still does not save sort to settings).

This commit is contained in:
ashley willis 2012-04-12 21:12:22 -05:00
parent f0c22510e2
commit 93de6cdafe
2 changed files with 36 additions and 0 deletions

View File

@ -4,6 +4,7 @@ package com.fsck.k9;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.SynchronousQueue;
@ -24,6 +25,7 @@ import android.os.Looper;
import android.text.format.Time;
import android.util.Log;
import com.fsck.k9.Account.SortType;
import com.fsck.k9.activity.MessageCompose;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.controller.MessagingListener;
@ -194,6 +196,8 @@ public class K9 extends Application {
private static boolean useGalleryBugWorkaround = false;
private static boolean galleryBuggy;
private static SortType mSortType;
private static HashMap<SortType, Boolean> mSortAscending = new HashMap<SortType, Boolean>();
/**
* The MIME type(s) of attachments we're willing to view.
@ -471,6 +475,8 @@ public class K9 extends Application {
super.onCreate();
app = this;
mSortType = Account.DEFAULT_SORT_TYPE;
mSortAscending.put(Account.DEFAULT_SORT_TYPE, Account.DEFAULT_SORT_ASCENDING);
galleryBuggy = checkForBuggyGallery();
@ -1119,4 +1125,24 @@ public class K9 extends Application {
public static void setAttachmentDefaultPath(String attachmentDefaultPath) {
K9.mAttachmentDefaultPath = attachmentDefaultPath;
}
public static synchronized SortType getSortType() {
return mSortType;
}
public static synchronized void setSortType(SortType sortType) {
mSortType = sortType;
}
public static synchronized boolean isSortAscending(SortType sortType) {
if (mSortAscending.get(sortType) == null) {
mSortAscending.put(sortType, sortType.isDefaultAscending());
}
return mSortAscending.get(sortType);
}
public static synchronized void setSortAscending(SortType sortType, boolean sortAscending) {
mSortAscending.put(sortType, sortAscending);
}
}

View File

@ -831,6 +831,9 @@ public class MessageList
} else {
Preferences preferences = Preferences.getPreferences(this);
accountsWithNotification = preferences.getAccounts();
mSortType = K9.getSortType(); // ASH
mSortAscending = K9.isSortAscending(mSortType);
mSortDateAscending = K9.isSortAscending(SortType.SORT_DATE);
}
for (Account accountWithNotification : accountsWithNotification) {
@ -1215,6 +1218,10 @@ public class MessageList
mSortAscending = mAccount.isSortAscending(mSortType);
mSortDateAscending = mAccount.isSortAscending(SortType.SORT_DATE);
mAccount.save(Preferences.getPreferences(this));
} else {
K9.setSortType(mSortType);
mSortAscending = K9.isSortAscending(mSortType);
mSortDateAscending = K9.isSortAscending(SortType.SORT_DATE);
}
reSort();
}
@ -1255,6 +1262,9 @@ public class MessageList
mAccount.setSortAscending(mSortType, mSortAscending);
mSortDateAscending = mAccount.isSortAscending(SortType.SORT_DATE);
mAccount.save(Preferences.getPreferences(this));
} else {
K9.setSortAscending(mSortType, mSortAscending);
mSortDateAscending = K9.isSortAscending(SortType.SORT_DATE);
}
reSort();
}