1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Use imports for inner classes

This commit is contained in:
cketti 2015-03-06 21:17:49 +01:00
parent 980d799087
commit b826d4e98d
9 changed files with 34 additions and 27 deletions

View File

@ -39,10 +39,10 @@ import com.fsck.k9.provider.EmailProvider;
import com.fsck.k9.provider.EmailProvider.StatsColumns; import com.fsck.k9.provider.EmailProvider.StatsColumns;
import com.fsck.k9.search.ConditionsTreeNode; import com.fsck.k9.search.ConditionsTreeNode;
import com.fsck.k9.search.LocalSearch; import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.search.SqlQueryBuilder; import com.fsck.k9.search.SqlQueryBuilder;
import com.fsck.k9.search.SearchSpecification.Attribute; import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchCondition; import com.fsck.k9.search.SearchSpecification.SearchCondition;
import com.fsck.k9.search.SearchSpecification.SearchField;
import com.fsck.k9.mail.ssl.LocalKeyStore; import com.fsck.k9.mail.ssl.LocalKeyStore;
import com.fsck.k9.view.ColorChip; import com.fsck.k9.view.ColorChip;
import com.larswerkman.colorpicker.ColorPicker; import com.larswerkman.colorpicker.ColorPicker;
@ -1754,17 +1754,17 @@ public class Account implements BaseAccount, StoreConfig {
switch (displayMode) { switch (displayMode) {
case FIRST_CLASS: { case FIRST_CLASS: {
// Count messages in the INBOX and non-special first class folders // Count messages in the INBOX and non-special first class folders
search.and(SearchSpecification.SearchField.DISPLAY_CLASS, FolderClass.FIRST_CLASS.name(), search.and(SearchField.DISPLAY_CLASS, FolderClass.FIRST_CLASS.name(),
Attribute.EQUALS); Attribute.EQUALS);
break; break;
} }
case FIRST_AND_SECOND_CLASS: { case FIRST_AND_SECOND_CLASS: {
// Count messages in the INBOX and non-special first and second class folders // Count messages in the INBOX and non-special first and second class folders
search.and(SearchSpecification.SearchField.DISPLAY_CLASS, FolderClass.FIRST_CLASS.name(), search.and(SearchField.DISPLAY_CLASS, FolderClass.FIRST_CLASS.name(),
Attribute.EQUALS); Attribute.EQUALS);
// TODO: Create a proper interface for creating arbitrary condition trees // TODO: Create a proper interface for creating arbitrary condition trees
SearchCondition searchCondition = new SearchCondition(SearchSpecification.SearchField.DISPLAY_CLASS, SearchCondition searchCondition = new SearchCondition(SearchField.DISPLAY_CLASS,
Attribute.EQUALS, FolderClass.SECOND_CLASS.name()); Attribute.EQUALS, FolderClass.SECOND_CLASS.name());
ConditionsTreeNode root = search.getConditions(); ConditionsTreeNode root = search.getConditions();
if (root.mRight != null) { if (root.mRight != null) {
@ -1776,7 +1776,7 @@ public class Account implements BaseAccount, StoreConfig {
} }
case NOT_SECOND_CLASS: { case NOT_SECOND_CLASS: {
// Count messages in the INBOX and non-special non-second-class folders // Count messages in the INBOX and non-special non-second-class folders
search.and(SearchSpecification.SearchField.DISPLAY_CLASS, FolderClass.SECOND_CLASS.name(), search.and(SearchField.DISPLAY_CLASS, FolderClass.SECOND_CLASS.name(),
Attribute.NOT_EQUALS); Attribute.NOT_EQUALS);
break; break;
} }
@ -1814,7 +1814,7 @@ public class Account implements BaseAccount, StoreConfig {
excludeSpecialFolder(search, getOutboxFolderName()); excludeSpecialFolder(search, getOutboxFolderName());
excludeSpecialFolder(search, getSentFolderName()); excludeSpecialFolder(search, getSentFolderName());
excludeSpecialFolder(search, getErrorFolderName()); excludeSpecialFolder(search, getErrorFolderName());
search.or(new SearchCondition(SearchSpecification.SearchField.FOLDER, Attribute.EQUALS, getInboxFolderName())); search.or(new SearchCondition(SearchField.FOLDER, Attribute.EQUALS, getInboxFolderName()));
} }
/** /**
@ -1838,12 +1838,12 @@ public class Account implements BaseAccount, StoreConfig {
excludeSpecialFolder(search, getTrashFolderName()); excludeSpecialFolder(search, getTrashFolderName());
excludeSpecialFolder(search, getSpamFolderName()); excludeSpecialFolder(search, getSpamFolderName());
excludeSpecialFolder(search, getOutboxFolderName()); excludeSpecialFolder(search, getOutboxFolderName());
search.or(new SearchCondition(SearchSpecification.SearchField.FOLDER, Attribute.EQUALS, getInboxFolderName())); search.or(new SearchCondition(SearchField.FOLDER, Attribute.EQUALS, getInboxFolderName()));
} }
private void excludeSpecialFolder(LocalSearch search, String folderName) { private void excludeSpecialFolder(LocalSearch search, String folderName) {
if (!K9.FOLDER_NONE.equals(folderName)) { if (!K9.FOLDER_NONE.equals(folderName)) {
search.and(SearchSpecification.SearchField.FOLDER, folderName, Attribute.NOT_EQUALS); search.and(SearchField.FOLDER, folderName, Attribute.NOT_EQUALS);
} }
} }

View File

@ -91,8 +91,8 @@ import com.fsck.k9.preferences.SettingsImporter.ImportContents;
import com.fsck.k9.preferences.SettingsImporter.ImportResults; import com.fsck.k9.preferences.SettingsImporter.ImportResults;
import com.fsck.k9.search.LocalSearch; import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SearchAccount; import com.fsck.k9.search.SearchAccount;
import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.search.SearchSpecification.Attribute; import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchField;
import com.fsck.k9.view.ColorChip; import com.fsck.k9.view.ColorChip;
import de.cketti.library.changelog.ChangeLog; import de.cketti.library.changelog.ChangeLog;
@ -366,7 +366,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
realAccount.limitToDisplayableFolders(search); realAccount.limitToDisplayableFolders(search);
} }
search.and(SearchSpecification.SearchField.READ, "1", Attribute.NOT_EQUALS); search.and(SearchField.READ, "1", Attribute.NOT_EQUALS);
return search; return search;
} }
@ -1864,7 +1864,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
realAccount.limitToDisplayableFolders(search); realAccount.limitToDisplayableFolders(search);
} }
search.and(SearchSpecification.SearchField.FLAGGED, "1", Attribute.EQUALS); search.and(SearchField.FLAGGED, "1", Attribute.EQUALS);
return new AccountClickListener(search); return new AccountClickListener(search);
} }

View File

@ -57,8 +57,8 @@ import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message; import com.fsck.k9.mail.Message;
import com.fsck.k9.mailstore.LocalFolder; import com.fsck.k9.mailstore.LocalFolder;
import com.fsck.k9.search.LocalSearch; import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.search.SearchSpecification.Attribute; import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchField;
import com.fsck.k9.service.MailService; import com.fsck.k9.service.MailService;
import de.cketti.library.changelog.ChangeLog; import de.cketti.library.changelog.ChangeLog;
@ -1102,7 +1102,7 @@ public class FolderList extends K9ListActivity {
getString(R.string.flagged_modifier)); getString(R.string.flagged_modifier));
LocalSearch search = new LocalSearch(searchTitle); LocalSearch search = new LocalSearch(searchTitle);
search.and(SearchSpecification.SearchField.FLAGGED, "1", Attribute.EQUALS); search.and(SearchField.FLAGGED, "1", Attribute.EQUALS);
search.addAllowedFolder(folder.name); search.addAllowedFolder(folder.name);
search.addAccountUuid(account.getUuid()); search.addAccountUuid(account.getUuid());
@ -1117,7 +1117,7 @@ public class FolderList extends K9ListActivity {
getString(R.string.unread_modifier)); getString(R.string.unread_modifier));
LocalSearch search = new LocalSearch(searchTitle); LocalSearch search = new LocalSearch(searchTitle);
search.and(SearchSpecification.SearchField.READ, "1", Attribute.NOT_EQUALS); search.and(SearchField.READ, "1", Attribute.NOT_EQUALS);
search.addAllowedFolder(folder.name); search.addAllowedFolder(folder.name);
search.addAccountUuid(account.getUuid()); search.addAccountUuid(account.getUuid());

View File

@ -49,6 +49,7 @@ import com.fsck.k9.search.SearchAccount;
import com.fsck.k9.search.SearchSpecification; import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.search.SearchSpecification.Attribute; import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchCondition; import com.fsck.k9.search.SearchSpecification.SearchCondition;
import com.fsck.k9.search.SearchSpecification.SearchField;
import com.fsck.k9.view.MessageHeader; import com.fsck.k9.view.MessageHeader;
import com.fsck.k9.view.MessageOpenPgpView; import com.fsck.k9.view.MessageOpenPgpView;
import com.fsck.k9.view.MessageTitleView; import com.fsck.k9.view.MessageTitleView;
@ -403,9 +404,9 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
mSearch.setManualSearch(true); mSearch.setManualSearch(true);
mNoThreading = true; mNoThreading = true;
mSearch.or(new SearchCondition(SearchSpecification.SearchField.SENDER, Attribute.CONTAINS, query)); mSearch.or(new SearchCondition(SearchField.SENDER, Attribute.CONTAINS, query));
mSearch.or(new SearchCondition(SearchSpecification.SearchField.SUBJECT, Attribute.CONTAINS, query)); mSearch.or(new SearchCondition(SearchField.SUBJECT, Attribute.CONTAINS, query));
mSearch.or(new SearchCondition(SearchSpecification.SearchField.MESSAGE_CONTENTS, Attribute.CONTAINS, query)); mSearch.or(new SearchCondition(SearchField.MESSAGE_CONTENTS, Attribute.CONTAINS, query));
Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA); Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA);
if (appData != null) { if (appData != null) {
@ -1220,7 +1221,7 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
public void showMoreFromSameSender(String senderAddress) { public void showMoreFromSameSender(String senderAddress) {
LocalSearch tmpSearch = new LocalSearch("From " + senderAddress); LocalSearch tmpSearch = new LocalSearch("From " + senderAddress);
tmpSearch.addAccountUuids(mSearch.getAccountUuids()); tmpSearch.addAccountUuids(mSearch.getAccountUuids());
tmpSearch.and(SearchSpecification.SearchField.SENDER, senderAddress, Attribute.CONTAINS); tmpSearch.and(SearchField.SENDER, senderAddress, Attribute.CONTAINS);
MessageListFragment fragment = MessageListFragment.newInstance(tmpSearch, false, false); MessageListFragment fragment = MessageListFragment.newInstance(tmpSearch, false, false);
@ -1309,7 +1310,7 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
LocalSearch tmpSearch = new LocalSearch(); LocalSearch tmpSearch = new LocalSearch();
tmpSearch.addAccountUuid(account.getUuid()); tmpSearch.addAccountUuid(account.getUuid());
tmpSearch.and(SearchSpecification.SearchField.THREAD_ID, String.valueOf(threadRootId), Attribute.EQUALS); tmpSearch.and(SearchField.THREAD_ID, String.valueOf(threadRootId), Attribute.EQUALS);
MessageListFragment fragment = MessageListFragment.newInstance(tmpSearch, true, false); MessageListFragment fragment = MessageListFragment.newInstance(tmpSearch, true, false);
addMessageListFragment(fragment, true); addMessageListFragment(fragment, true);

View File

@ -99,6 +99,7 @@ import com.fsck.k9.search.ConditionsTreeNode;
import com.fsck.k9.search.LocalSearch; import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SearchSpecification; import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.search.SearchSpecification.SearchCondition; import com.fsck.k9.search.SearchSpecification.SearchCondition;
import com.fsck.k9.search.SearchSpecification.SearchField;
import com.fsck.k9.search.SqlQueryBuilder; import com.fsck.k9.search.SqlQueryBuilder;
import com.handmark.pulltorefresh.library.ILoadingLayout; import com.handmark.pulltorefresh.library.ILoadingLayout;
@ -3359,7 +3360,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
private String getThreadId(LocalSearch search) { private String getThreadId(LocalSearch search) {
for (ConditionsTreeNode node : search.getLeafSet()) { for (ConditionsTreeNode node : search.getLeafSet()) {
SearchCondition condition = node.mCondition; SearchCondition condition = node.mCondition;
if (condition.field == SearchSpecification.SearchField.THREAD_ID) { if (condition.field == SearchField.THREAD_ID) {
return condition.value; return condition.value;
} }
} }

View File

@ -27,8 +27,8 @@ import com.fsck.k9.mailstore.LockableDatabase.WrappedException;
import com.fsck.k9.provider.EmailProvider; import com.fsck.k9.provider.EmailProvider;
import com.fsck.k9.provider.EmailProvider.MessageColumns; import com.fsck.k9.provider.EmailProvider.MessageColumns;
import com.fsck.k9.search.LocalSearch; import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.search.SearchSpecification.Attribute; import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchField;
import com.fsck.k9.search.SqlQueryBuilder; import com.fsck.k9.search.SqlQueryBuilder;
import java.io.File; import java.io.File;
@ -670,7 +670,7 @@ public class LocalStore extends Store implements Serializable {
String rootIdString = Long.toString(rootId); String rootIdString = Long.toString(rootId);
LocalSearch search = new LocalSearch(); LocalSearch search = new LocalSearch();
search.and(SearchSpecification.SearchField.THREAD_ID, rootIdString, Attribute.EQUALS); search.and(SearchField.THREAD_ID, rootIdString, Attribute.EQUALS);
return searchForMessages(null, search); return searchForMessages(null, search);
} }

View File

@ -12,6 +12,8 @@ import android.os.Parcelable;
import com.fsck.k9.search.SearchSpecification.Attribute; import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchCondition; import com.fsck.k9.search.SearchSpecification.SearchCondition;
import com.fsck.k9.search.SearchSpecification.SearchField;
/** /**
* This class stores search conditions. It's basically a boolean expression binary tree. * This class stores search conditions. It's basically a boolean expression binary tree.
@ -95,7 +97,7 @@ public class ConditionsTreeNode implements Parcelable {
Operator tmpValue = ConditionsTreeNode.Operator.valueOf(cursor.getString(5)); Operator tmpValue = ConditionsTreeNode.Operator.valueOf(cursor.getString(5));
if (tmpValue == Operator.CONDITION) { if (tmpValue == Operator.CONDITION) {
condition = new SearchCondition(SearchSpecification.SearchField.valueOf(cursor.getString(0)), condition = new SearchCondition(SearchField.valueOf(cursor.getString(0)),
Attribute.valueOf(cursor.getString(2)), cursor.getString(1)); Attribute.valueOf(cursor.getString(2)), cursor.getString(1));
} }

View File

@ -5,6 +5,8 @@ import android.content.Context;
import com.fsck.k9.BaseAccount; import com.fsck.k9.BaseAccount;
import com.fsck.k9.R; import com.fsck.k9.R;
import com.fsck.k9.search.SearchSpecification.Attribute; import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchField;
/** /**
* This class is basically a wrapper around a LocalSearch. It allows to expose it as * This class is basically a wrapper around a LocalSearch. It allows to expose it as
@ -20,7 +22,7 @@ public class SearchAccount implements BaseAccount {
String name = context.getString(R.string.search_all_messages_title); String name = context.getString(R.string.search_all_messages_title);
LocalSearch tmpSearch = new LocalSearch(name); LocalSearch tmpSearch = new LocalSearch(name);
tmpSearch.and(SearchSpecification.SearchField.SEARCHABLE, "1", Attribute.EQUALS); tmpSearch.and(SearchField.SEARCHABLE, "1", Attribute.EQUALS);
return new SearchAccount(ALL_MESSAGES, tmpSearch, name, return new SearchAccount(ALL_MESSAGES, tmpSearch, name,
context.getString(R.string.search_all_messages_detail)); context.getString(R.string.search_all_messages_detail));
@ -31,7 +33,7 @@ public class SearchAccount implements BaseAccount {
public static SearchAccount createUnifiedInboxAccount(Context context) { public static SearchAccount createUnifiedInboxAccount(Context context) {
String name = context.getString(R.string.integrated_inbox_title); String name = context.getString(R.string.integrated_inbox_title);
LocalSearch tmpSearch = new LocalSearch(name); LocalSearch tmpSearch = new LocalSearch(name);
tmpSearch.and(SearchSpecification.SearchField.INTEGRATE, "1", Attribute.EQUALS); tmpSearch.and(SearchField.INTEGRATE, "1", Attribute.EQUALS);
return new SearchAccount(UNIFIED_INBOX, tmpSearch, name, return new SearchAccount(UNIFIED_INBOX, tmpSearch, name,
context.getString(R.string.integrated_inbox_detail)); context.getString(R.string.integrated_inbox_detail));
} }

View File

@ -9,6 +9,7 @@ import com.fsck.k9.mailstore.LocalFolder;
import com.fsck.k9.mailstore.LocalStore; import com.fsck.k9.mailstore.LocalStore;
import com.fsck.k9.search.SearchSpecification.Attribute; import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchCondition; import com.fsck.k9.search.SearchSpecification.SearchCondition;
import com.fsck.k9.search.SearchSpecification.SearchField;
public class SqlQueryBuilder { public class SqlQueryBuilder {
@ -199,7 +200,7 @@ public class SqlQueryBuilder {
private static void appendExprRight(SearchCondition condition, StringBuilder query, private static void appendExprRight(SearchCondition condition, StringBuilder query,
List<String> selectionArgs) { List<String> selectionArgs) {
String value = condition.value; String value = condition.value;
SearchSpecification.SearchField field = condition.field; SearchField field = condition.field;
query.append(" "); query.append(" ");
String selectionArg = null; String selectionArg = null;
@ -255,7 +256,7 @@ public class SqlQueryBuilder {
selectionArgs.add(selectionArg); selectionArgs.add(selectionArg);
} }
private static boolean isNumberColumn(SearchSpecification.SearchField field) { private static boolean isNumberColumn(SearchField field) {
switch (field) { switch (field) {
case ATTACHMENT_COUNT: case ATTACHMENT_COUNT:
case DATE: case DATE: