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

Added support for "show in top group" to ChooseFolder

This commit is contained in:
cketti 2012-08-01 23:44:40 +02:00
parent 5ce0e192b5
commit f3e74d5321

View File

@ -296,7 +296,9 @@ public class ChooseFolder extends K9ListActivity {
}
Account.FolderMode aMode = mMode;
Preferences prefs = Preferences.getPreferences(getApplication().getApplicationContext());
ArrayList<String> localFolders = new ArrayList<String>();
List<String> newFolders = new ArrayList<String>();
List<String> topFolders = new ArrayList<String>();
for (Folder folder : folders) {
String name = folder.getName();
@ -325,33 +327,34 @@ public class ChooseFolder extends K9ListActivity {
folder.getName(), me);
}
localFolders.add(folder.getName());
if (folder.isInTopGroup()) {
topFolders.add(name);
} else {
newFolders.add(name);
}
}
final Comparator<String> comparator = new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
int ret = s1.compareToIgnoreCase(s2);
return (ret != 0) ? ret : s1.compareTo(s2);
}
};
Collections.sort(topFolders, comparator);
Collections.sort(newFolders, comparator);
List<String> localFolders = new ArrayList<String>(newFolders.size() +
topFolders.size() + ((mShowOptionNone) ? 1 : 0));
if (mShowOptionNone) {
localFolders.add(K9.FOLDER_NONE);
}
Collections.sort(localFolders, new Comparator<String>() {
@Override
public int compare(String aName, String bName) {
if (K9.FOLDER_NONE.equalsIgnoreCase(aName)) {
return -1;
}
if (K9.FOLDER_NONE.equalsIgnoreCase(bName)) {
return 1;
}
if (mAccount.getInboxFolderName().equalsIgnoreCase(aName)) {
return -1;
}
if (mAccount.getInboxFolderName().equalsIgnoreCase(bName)) {
return 1;
}
localFolders.addAll(topFolders);
localFolders.addAll(newFolders);
return aName.compareToIgnoreCase(bName);
}
});
int selectedFolder = -1;
/*