mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Fixes Issue 254
Provide for only showing folders that are subscribed on the server (IMAP only) Also: Change default for Notification behavior to the old way. Make going to the search for unread messages off by default. Fix up some hiding of labels, etc. on the incoming server settings. Check for message suppression in search results.
This commit is contained in:
parent
1a66072910
commit
dedfd026be
@ -66,6 +66,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent" />
|
||||
<TextView
|
||||
|
||||
android:id="@+id/account_auth_type_label"
|
||||
android:text="@string/account_setup_incoming_authtype_label"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
@ -132,6 +134,12 @@
|
||||
android:inputType="number"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent" />
|
||||
<CheckBox
|
||||
android:id="@+id/subscribed_folders_only"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/account_setup_incoming_subscribed_folders_only_label"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
@ -183,6 +191,7 @@
|
||||
android:layout_width="fill_parent" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/compression_label"
|
||||
android:text="@string/account_setup_incoming_compression_label"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -364,6 +364,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
<string name="account_setup_incoming_imap_folder_trash">Trash folder name</string>
|
||||
<string name="account_setup_incoming_imap_folder_outbox">Outbox folder name</string>
|
||||
|
||||
<string name="account_setup_incoming_subscribed_folders_only_label">Show only subscribed folders</string>
|
||||
<string name="account_setup_auto_expand_folder">Auto-expand folder</string>
|
||||
|
||||
<string name="account_setup_incoming_webdav_path_prefix_label">WebDAV (Exchange) path</string>
|
||||
|
@ -90,6 +90,7 @@ public class Account implements BaseAccount
|
||||
private boolean goToUnreadMessageSearch;
|
||||
private Map<String, Boolean> compressionMap = new ConcurrentHashMap<String, Boolean>();
|
||||
private Searchable searchableFolders;
|
||||
private boolean subscribedFoldersOnly;
|
||||
// Tracks if we have sent a notification for this account for
|
||||
// current set of fetched messages
|
||||
private boolean mRingNotified;
|
||||
@ -140,6 +141,7 @@ public class Account implements BaseAccount
|
||||
mChipColor = (new Random()).nextInt(0xffffff) + 0xff000000;
|
||||
mLedColor = mChipColor;
|
||||
goToUnreadMessageSearch = false;
|
||||
subscribedFoldersOnly = false;
|
||||
|
||||
searchableFolders = Searchable.ALL;
|
||||
|
||||
@ -200,7 +202,9 @@ public class Account implements BaseAccount
|
||||
|
||||
mMaxPushFolders = preferences.getPreferences().getInt(mUuid + ".maxPushFolders", 10);
|
||||
goToUnreadMessageSearch = preferences.getPreferences().getBoolean(mUuid + ".goToUnreadMessageSearch",
|
||||
true);
|
||||
false);
|
||||
subscribedFoldersOnly = preferences.getPreferences().getBoolean(mUuid + ".subscribedFoldersOnly",
|
||||
false);
|
||||
for (String type : networkTypes)
|
||||
{
|
||||
Boolean useCompression = preferences.getPreferences().getBoolean(mUuid + ".useCompression." + type,
|
||||
@ -370,6 +374,7 @@ public class Account implements BaseAccount
|
||||
editor.remove(mUuid + ".chipColor");
|
||||
editor.remove(mUuid + ".ledColor");
|
||||
editor.remove(mUuid + ".goToUnreadMessageSearch");
|
||||
editor.remove(mUuid + ".subscribedFoldersOnly");
|
||||
for (String type : networkTypes)
|
||||
{
|
||||
editor.remove(mUuid + ".useCompression." + type);
|
||||
@ -453,6 +458,7 @@ public class Account implements BaseAccount
|
||||
editor.putInt(mUuid + ".chipColor", mChipColor);
|
||||
editor.putInt(mUuid + ".ledColor", mLedColor);
|
||||
editor.putBoolean(mUuid + ".goToUnreadMessageSearch", goToUnreadMessageSearch);
|
||||
editor.putBoolean(mUuid + ".subscribedFoldersOnly", subscribedFoldersOnly);
|
||||
|
||||
for (String type : networkTypes)
|
||||
{
|
||||
@ -484,7 +490,7 @@ public class Account implements BaseAccount
|
||||
Account.FolderMode aMode = getFolderDisplayMode();
|
||||
Preferences prefs = Preferences.getPreferences(context);
|
||||
long folderLoadStart = System.currentTimeMillis();
|
||||
List<? extends Folder> folders = localStore.getPersonalNamespaces();
|
||||
List<? extends Folder> folders = localStore.getPersonalNamespaces(false);
|
||||
long folderLoadEnd = System.currentTimeMillis();
|
||||
long folderEvalStart = folderLoadEnd;
|
||||
for (Folder folder : folders)
|
||||
@ -1202,4 +1208,14 @@ public class Account implements BaseAccount
|
||||
{
|
||||
this.goToUnreadMessageSearch = goToUnreadMessageSearch;
|
||||
}
|
||||
|
||||
public boolean subscribedFoldersOnly()
|
||||
{
|
||||
return subscribedFoldersOnly;
|
||||
}
|
||||
|
||||
public void setSubscribedFoldersOnly(boolean subscribedFoldersOnly)
|
||||
{
|
||||
this.subscribedFoldersOnly = subscribedFoldersOnly;
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
private CheckBox pushPollOnConnect;
|
||||
private Spinner idleRefreshPeriod;
|
||||
private Spinner folderPushLimit;
|
||||
private CheckBox subscribedFoldersOnly;
|
||||
|
||||
public static void actionIncomingSettings(Activity context, Account account, boolean makeDefault)
|
||||
{
|
||||
@ -133,6 +134,8 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
compressionOther = (CheckBox)findViewById(R.id.compression_other);
|
||||
saveAllHeaders = (CheckBox)findViewById(R.id.save_all_headers);
|
||||
pushPollOnConnect = (CheckBox)findViewById(R.id.push_poll_on_connect);
|
||||
|
||||
subscribedFoldersOnly = (CheckBox)findViewById(R.id.subscribed_folders_only);
|
||||
idleRefreshPeriod = (Spinner)findViewById(R.id.idle_refresh_period);
|
||||
|
||||
folderPushLimit = (Spinner)findViewById(R.id.folder_push_limit);
|
||||
@ -296,8 +299,10 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
|
||||
findViewById(R.id.webdav_path_prefix_section).setVisibility(View.GONE);
|
||||
findViewById(R.id.webdav_path_debug_section).setVisibility(View.GONE);
|
||||
findViewById(R.id.account_auth_type_label).setVisibility(View.GONE);
|
||||
findViewById(R.id.account_auth_type).setVisibility(View.GONE);
|
||||
findViewById(R.id.compression_section).setVisibility(View.GONE);
|
||||
findViewById(R.id.compression_label).setVisibility(View.GONE);
|
||||
findViewById(R.id.push_poll_on_connect_section).setVisibility(View.GONE);
|
||||
findViewById(R.id.idle_refresh_period_label).setVisibility(View.GONE);
|
||||
findViewById(R.id.idle_refresh_period).setVisibility(View.GONE);
|
||||
@ -335,13 +340,16 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
|
||||
/** Hide the unnecessary fields */
|
||||
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
|
||||
findViewById(R.id.account_auth_type_label).setVisibility(View.GONE);
|
||||
findViewById(R.id.account_auth_type).setVisibility(View.GONE);
|
||||
findViewById(R.id.compression_section).setVisibility(View.GONE);
|
||||
findViewById(R.id.compression_label).setVisibility(View.GONE);
|
||||
findViewById(R.id.push_poll_on_connect_section).setVisibility(View.GONE);
|
||||
findViewById(R.id.idle_refresh_period_label).setVisibility(View.GONE);
|
||||
findViewById(R.id.idle_refresh_period).setVisibility(View.GONE);
|
||||
findViewById(R.id.account_setup_push_limit_label).setVisibility(View.GONE);
|
||||
findViewById(R.id.folder_push_limit).setVisibility(View.GONE);
|
||||
subscribedFoldersOnly.setVisibility(View.GONE);
|
||||
if (uri.getPath() != null && uri.getPath().length() > 0)
|
||||
{
|
||||
String[] pathParts = uri.getPath().split("\\|");
|
||||
@ -408,6 +416,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
|
||||
saveAllHeaders.setChecked(mAccount.isSaveAllHeaders());
|
||||
pushPollOnConnect.setChecked(mAccount.isPushPollOnConnect());
|
||||
subscribedFoldersOnly.setChecked(mAccount.subscribedFoldersOnly());
|
||||
SpinnerHelper.initSpinner(this, idleRefreshPeriod, R.array.idle_refresh_period_entries,
|
||||
R.array.idle_refresh_period_values, String.valueOf(mAccount.getIdleRefreshMinutes()));
|
||||
|
||||
@ -564,6 +573,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
mAccount.setCompression(Account.TYPE_OTHER, compressionOther.isChecked());
|
||||
mAccount.setSaveAllHeaders(saveAllHeaders.isChecked());
|
||||
mAccount.setPushPollOnConnect(pushPollOnConnect.isChecked());
|
||||
mAccount.setSubscribedFoldersOnly(subscribedFoldersOnly.isChecked());
|
||||
String idleRefreshPeriodValue = SpinnerHelper.getSpinnerValue(idleRefreshPeriod);
|
||||
try
|
||||
{
|
||||
|
@ -421,7 +421,7 @@ public class MessagingController implements Runnable
|
||||
try
|
||||
{
|
||||
Store localStore = account.getLocalStore();
|
||||
localFolders = localStore.getPersonalNamespaces();
|
||||
localFolders = localStore.getPersonalNamespaces(false);
|
||||
|
||||
Folder[] folderArray = localFolders.toArray(new Folder[0]);
|
||||
|
||||
@ -489,7 +489,7 @@ public class MessagingController implements Runnable
|
||||
{
|
||||
Store store = account.getRemoteStore();
|
||||
|
||||
List<? extends Folder> remoteFolders = store.getPersonalNamespaces();
|
||||
List<? extends Folder> remoteFolders = store.getPersonalNamespaces(false);
|
||||
|
||||
LocalStore localStore = account.getLocalStore();
|
||||
HashSet<String> remoteFolderNames = new HashSet<String>();
|
||||
@ -503,7 +503,7 @@ public class MessagingController implements Runnable
|
||||
remoteFolderNames.add(remoteFolders.get(i).getName());
|
||||
}
|
||||
|
||||
localFolders = localStore.getPersonalNamespaces();
|
||||
localFolders = localStore.getPersonalNamespaces(false);
|
||||
|
||||
/*
|
||||
* Clear out any folders that are no longer on the remote store.
|
||||
@ -526,7 +526,7 @@ public class MessagingController implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
localFolders = localStore.getPersonalNamespaces();
|
||||
localFolders = localStore.getPersonalNamespaces(false);
|
||||
Folder[] folderArray = localFolders.toArray(new Folder[0]);
|
||||
|
||||
for (MessagingListener l : getListeners())
|
||||
@ -810,7 +810,7 @@ public class MessagingController implements Runnable
|
||||
try
|
||||
{
|
||||
LocalStore store = account.getLocalStore();
|
||||
List<? extends Folder> folders = store.getPersonalNamespaces();
|
||||
List<? extends Folder> folders = store.getPersonalNamespaces(false);
|
||||
Set<String> folderNameSet = null;
|
||||
if (folderNames != null)
|
||||
{
|
||||
@ -879,14 +879,17 @@ public class MessagingController implements Runnable
|
||||
public void messageStarted(String message, int number, int ofTotal) {}
|
||||
public void messageFinished(Message message, int number, int ofTotal)
|
||||
{
|
||||
List<Message> messages = new ArrayList<Message>();
|
||||
|
||||
messages.add(message);
|
||||
stats.unreadMessageCount += (message.isSet(Flag.SEEN) == false) ? 1 : 0;
|
||||
stats.flaggedMessageCount += (message.isSet(Flag.FLAGGED)) ? 1 : 0;
|
||||
if (listener != null)
|
||||
if (isMessageSuppressed(message.getFolder().getAccount(), message.getFolder().getName(), message) == false)
|
||||
{
|
||||
listener.listLocalMessagesAddMessages(account, null, messages);
|
||||
List<Message> messages = new ArrayList<Message>();
|
||||
|
||||
messages.add(message);
|
||||
stats.unreadMessageCount += (message.isSet(Flag.SEEN) == false) ? 1 : 0;
|
||||
stats.flaggedMessageCount += (message.isSet(Flag.FLAGGED)) ? 1 : 0;
|
||||
if (listener != null)
|
||||
{
|
||||
listener.listLocalMessagesAddMessages(account, null, messages);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -4195,7 +4198,7 @@ public class MessagingController implements Runnable
|
||||
Account.FolderMode aSyncMode = account.getFolderSyncMode();
|
||||
|
||||
Store localStore = account.getLocalStore();
|
||||
for (final Folder folder : localStore.getPersonalNamespaces())
|
||||
for (final Folder folder : localStore.getPersonalNamespaces(false))
|
||||
{
|
||||
|
||||
folder.open(Folder.OpenMode.READ_WRITE);
|
||||
@ -4764,7 +4767,7 @@ public class MessagingController implements Runnable
|
||||
List<String> names = new ArrayList<String>();
|
||||
|
||||
Store localStore = account.getLocalStore();
|
||||
for (final Folder folder : localStore.getPersonalNamespaces())
|
||||
for (final Folder folder : localStore.getPersonalNamespaces(false))
|
||||
{
|
||||
if (folder.getName().equals(account.getErrorFolderName())
|
||||
|| folder.getName().equals(account.getOutboxFolderName()))
|
||||
|
@ -116,7 +116,7 @@ public abstract class Store
|
||||
|
||||
public abstract Folder getFolder(String name) throws MessagingException;
|
||||
|
||||
public abstract List<? extends Folder> getPersonalNamespaces() throws MessagingException;
|
||||
public abstract List<? extends Folder> getPersonalNamespaces(boolean forceListAll) throws MessagingException;
|
||||
|
||||
public abstract void checkSettings() throws MessagingException;
|
||||
|
||||
|
@ -251,20 +251,65 @@ public class ImapStore extends Store
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Folder> getPersonalNamespaces() throws MessagingException
|
||||
public List<? extends Folder> getPersonalNamespaces(boolean forceListAll) throws MessagingException
|
||||
{
|
||||
ImapConnection connection = getConnection();
|
||||
try
|
||||
{
|
||||
List<? extends Folder> allFolders = listFolders(connection, false);
|
||||
if (forceListAll || mAccount.subscribedFoldersOnly() == false)
|
||||
{
|
||||
return allFolders;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Folder> resultFolders = new LinkedList<Folder>();
|
||||
HashSet<String> subscribedFolderNames = new HashSet<String>();
|
||||
List<? extends Folder> subscribedFolders = listFolders(connection, true);
|
||||
for (Folder subscribedFolder : subscribedFolders)
|
||||
{
|
||||
subscribedFolderNames.add(subscribedFolder.getName());
|
||||
}
|
||||
for (Folder folder : allFolders)
|
||||
{
|
||||
if (subscribedFolderNames.contains(folder.getName()))
|
||||
{
|
||||
resultFolders.add(folder);
|
||||
}
|
||||
}
|
||||
return resultFolders;
|
||||
}
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
connection.close();
|
||||
throw new MessagingException("Unable to get folder list.", ioe);
|
||||
}
|
||||
catch (MessagingException me)
|
||||
{
|
||||
connection.close();
|
||||
throw new MessagingException("Unable to get folder list.", me);
|
||||
}
|
||||
finally
|
||||
{
|
||||
releaseConnection(connection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<? extends Folder> listFolders(ImapConnection connection, boolean LSUB) throws IOException, MessagingException
|
||||
{
|
||||
String commandResponse = LSUB ? "LSUB" : "LIST";
|
||||
|
||||
LinkedList<Folder> folders = new LinkedList<Folder>();
|
||||
|
||||
List<ImapResponse> responses =
|
||||
connection.executeSimpleCommand(String.format("LIST \"\" \"%s*\"",
|
||||
connection.executeSimpleCommand(String.format(commandResponse + " \"\" \"%s*\"",
|
||||
getCombinedPrefix()));
|
||||
|
||||
for (ImapResponse response : responses)
|
||||
{
|
||||
if (ImapResponseParser.equalsIgnoreCase(response.get(0), "LIST"))
|
||||
if (ImapResponseParser.equalsIgnoreCase(response.get(0), commandResponse))
|
||||
{
|
||||
boolean includeFolder = true;
|
||||
String folder = decodeFolderName(response.getString(3));
|
||||
@ -312,16 +357,7 @@ public class ImapStore extends Store
|
||||
}
|
||||
folders.add(getFolder("INBOX"));
|
||||
return folders;
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
connection.close();
|
||||
throw new MessagingException("Unable to get folder list.", ioe);
|
||||
}
|
||||
finally
|
||||
{
|
||||
releaseConnection(connection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -373,7 +373,7 @@ public class LocalStore extends Store implements Serializable
|
||||
|
||||
// TODO this takes about 260-300ms, seems slow.
|
||||
@Override
|
||||
public List<? extends Folder> getPersonalNamespaces() throws MessagingException
|
||||
public List<? extends Folder> getPersonalNamespaces(boolean forceListAll) throws MessagingException
|
||||
{
|
||||
LinkedList<LocalFolder> folders = new LinkedList<LocalFolder>();
|
||||
Cursor cursor = null;
|
||||
|
@ -159,7 +159,7 @@ public class Pop3Store extends Store
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Folder> getPersonalNamespaces() throws MessagingException
|
||||
public List<? extends Folder> getPersonalNamespaces(boolean forceListAll) throws MessagingException
|
||||
{
|
||||
List<Folder> folders = new LinkedList<Folder>();
|
||||
folders.add(getFolder("INBOX"));
|
||||
|
@ -263,7 +263,7 @@ public class WebDavStore extends Store
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Folder> getPersonalNamespaces() throws MessagingException
|
||||
public List<? extends Folder> getPersonalNamespaces(boolean forceListAll) throws MessagingException
|
||||
{
|
||||
LinkedList<Folder> folderList = new LinkedList<Folder>();
|
||||
HashMap<String, String> headers = new HashMap<String, String>();
|
||||
|
Loading…
Reference in New Issue
Block a user