Fixes Issue 1291
Provides for the user to elect to have certain folders displayed first in the FolderList. Folders so elected are displayed in alphabetical order first, then folders not so elected are displayed alphabetical order. No special handling is done for Inbox any more, except that it is in "top group" by default, to preserve current behavior until the user changes the settings.
This commit is contained in:
parent
df4c768fea
commit
f0808fb3e0
6 changed files with 61 additions and 24 deletions
|
@ -485,6 +485,10 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
|||
<string name="account_settings_folder_target_mode_not_second_class">All except 2nd Class folders</string>
|
||||
|
||||
<string name="folder_settings_title">Folder settings</string>
|
||||
|
||||
<string name="folder_settings_in_top_group_label">Show in top group</string>
|
||||
<string name="folder_settings_in_top_group_summary">Show near the top of the folder list</string>
|
||||
|
||||
<string name="folder_settings_folder_display_mode_label">Folder display class</string>
|
||||
<string name="folder_settings_folder_display_mode_normal">None</string>
|
||||
<string name="folder_settings_folder_display_mode_first_class">1st Class</string>
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
<PreferenceCategory
|
||||
android:key="folder_settings">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="folder_settings_in_top_group"
|
||||
android:title="@string/folder_settings_in_top_group_label"
|
||||
android:summary="@string/folder_settings_in_top_group_summary" />
|
||||
|
||||
<ListPreference
|
||||
android:key="folder_settings_folder_display_mode"
|
||||
android:title="@string/folder_settings_folder_display_mode_label"
|
||||
|
|
|
@ -29,6 +29,8 @@ import com.fsck.k9.service.MailService;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* FolderList is the primary user interface for the program. This
|
||||
|
@ -80,7 +82,7 @@ public class FolderList extends K9ListActivity
|
|||
}
|
||||
|
||||
|
||||
public void newFolders(final ArrayList<FolderInfoHolder> newFolders)
|
||||
public void newFolders(final List<FolderInfoHolder> newFolders)
|
||||
{
|
||||
runOnUiThread(new Runnable()
|
||||
{
|
||||
|
@ -806,7 +808,8 @@ public class FolderList extends K9ListActivity
|
|||
return;
|
||||
}
|
||||
|
||||
ArrayList<FolderInfoHolder> newFolders = new ArrayList<FolderInfoHolder>();
|
||||
List<FolderInfoHolder> newFolders = new LinkedList<FolderInfoHolder>();
|
||||
List<FolderInfoHolder> topFolders = new LinkedList<FolderInfoHolder>();
|
||||
|
||||
Account.FolderMode aMode = account.getFolderDisplayMode();
|
||||
|
||||
|
@ -859,11 +862,19 @@ public class FolderList extends K9ListActivity
|
|||
holder.populate(folder, unreadMessageCount);
|
||||
|
||||
}
|
||||
|
||||
newFolders.add(holder);
|
||||
if (folder.isInTopGroup())
|
||||
{
|
||||
topFolders.add(holder);
|
||||
}
|
||||
else
|
||||
{
|
||||
newFolders.add(holder);
|
||||
}
|
||||
}
|
||||
Collections.sort(newFolders);
|
||||
mHandler.newFolders(newFolders);
|
||||
Collections.sort(topFolders);
|
||||
topFolders.addAll(newFolders);
|
||||
mHandler.newFolders(topFolders);
|
||||
mHandler.refreshTitle();
|
||||
|
||||
}
|
||||
|
@ -1279,29 +1290,14 @@ public class FolderList extends K9ListActivity
|
|||
String s1 = this.name;
|
||||
String s2 = o.name;
|
||||
|
||||
if (K9.INBOX.equalsIgnoreCase(s1) && K9.INBOX.equalsIgnoreCase(s2))
|
||||
int ret = s1.compareToIgnoreCase(s2);
|
||||
if (ret != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (K9.INBOX.equalsIgnoreCase(s1))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (K9.INBOX.equalsIgnoreCase(s2))
|
||||
{
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
int ret = s1.compareToIgnoreCase(s2);
|
||||
if (ret != 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return s1.compareTo(s2);
|
||||
}
|
||||
return s1.compareTo(s2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package com.fsck.k9.activity.setup;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.util.Log;
|
||||
|
@ -26,9 +27,11 @@ public class FolderSettings extends K9PreferenceActivity
|
|||
private static final String PREFERENCE_DISPLAY_CLASS = "folder_settings_folder_display_mode";
|
||||
private static final String PREFERENCE_SYNC_CLASS = "folder_settings_folder_sync_mode";
|
||||
private static final String PREFERENCE_PUSH_CLASS = "folder_settings_folder_push_mode";
|
||||
private static final String PREFERENCE_IN_TOP_GROUP = "folder_settings_in_top_group";
|
||||
|
||||
private LocalFolder mFolder;
|
||||
|
||||
private CheckBoxPreference mInTopGroup;
|
||||
private ListPreference mDisplayClass;
|
||||
private ListPreference mSyncClass;
|
||||
private ListPreference mPushClass;
|
||||
|
@ -79,6 +82,10 @@ public class FolderSettings extends K9PreferenceActivity
|
|||
Preference category = findPreference(PREFERENCE_TOP_CATERGORY);
|
||||
category.setTitle(folderName);
|
||||
|
||||
|
||||
mInTopGroup = (CheckBoxPreference)findPreference(PREFERENCE_IN_TOP_GROUP);
|
||||
mInTopGroup.setChecked(mFolder.isInTopGroup());
|
||||
|
||||
mDisplayClass = (ListPreference) findPreference(PREFERENCE_DISPLAY_CLASS);
|
||||
mDisplayClass.setValue(mFolder.getDisplayClass().name());
|
||||
mDisplayClass.setSummary(mDisplayClass.getEntry());
|
||||
|
@ -142,6 +149,7 @@ public class FolderSettings extends K9PreferenceActivity
|
|||
|
||||
private void saveSettings()
|
||||
{
|
||||
mFolder.setInTopGroup(mInTopGroup.isChecked());
|
||||
// We call getPushClass() because display class changes can affect push class when push class is set to inherit
|
||||
FolderClass oldPushClass = mFolder.getPushClass();
|
||||
FolderClass oldDisplayClass = mFolder.getDisplayClass();
|
||||
|
|
|
@ -202,6 +202,11 @@ public abstract class Folder
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean isInTopGroup()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
|
|
|
@ -671,6 +671,7 @@ public class LocalStore extends Store implements Serializable
|
|||
private FolderClass displayClass = FolderClass.NO_CLASS;
|
||||
private FolderClass syncClass = FolderClass.INHERITED;
|
||||
private FolderClass pushClass = FolderClass.SECOND_CLASS;
|
||||
private boolean inTopGroup = false;
|
||||
private String prefId = null;
|
||||
private String mPushState = null;
|
||||
|
||||
|
@ -684,6 +685,7 @@ public class LocalStore extends Store implements Serializable
|
|||
{
|
||||
syncClass = FolderClass.FIRST_CLASS;
|
||||
pushClass = FolderClass.FIRST_CLASS;
|
||||
inTopGroup = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1024,6 +1026,8 @@ public class LocalStore extends Store implements Serializable
|
|||
|
||||
editor.remove(id + ".displayMode");
|
||||
editor.remove(id + ".syncMode");
|
||||
editor.remove(id + ".pushMode");
|
||||
editor.remove(id + ".inTopGroup");
|
||||
|
||||
editor.commit();
|
||||
}
|
||||
|
@ -1060,6 +1064,7 @@ public class LocalStore extends Store implements Serializable
|
|||
{
|
||||
editor.putString(id + ".pushMode", pushClass.name());
|
||||
}
|
||||
editor.putBoolean(id + ".inTopGroup", inTopGroup);
|
||||
|
||||
editor.commit();
|
||||
}
|
||||
|
@ -1108,9 +1113,11 @@ public class LocalStore extends Store implements Serializable
|
|||
}
|
||||
|
||||
FolderClass defPushClass = FolderClass.SECOND_CLASS;
|
||||
boolean defInTopGroup = false;
|
||||
if (K9.INBOX.equals(getName()))
|
||||
{
|
||||
defPushClass = FolderClass.FIRST_CLASS;
|
||||
defInTopGroup = true;
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -1128,6 +1135,7 @@ public class LocalStore extends Store implements Serializable
|
|||
{
|
||||
pushClass = FolderClass.INHERITED;
|
||||
}
|
||||
inTopGroup = preferences.getPreferences().getBoolean(id + ".inTopGroup", defInTopGroup);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2102,6 +2110,17 @@ public class LocalStore extends Store implements Serializable
|
|||
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInTopGroup()
|
||||
{
|
||||
return inTopGroup;
|
||||
}
|
||||
|
||||
public void setInTopGroup(boolean inTopGroup)
|
||||
{
|
||||
this.inTopGroup = inTopGroup;
|
||||
}
|
||||
}
|
||||
|
||||
public class LocalTextBody extends TextBody
|
||||
|
|
Loading…
Reference in a new issue