diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java index 14cec2a311d..f80e58c0587 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java @@ -41,6 +41,7 @@ class ImapFolder extends Folder { + static final String INBOX = "INBOX"; private static final ThreadLocal RFC3501_DATE = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { @@ -78,7 +79,7 @@ public ImapFolder(ImapStore store, String name) { private String getPrefixedName() throws MessagingException { String prefixedName = ""; - if (!store.getStoreConfig().getInboxFolderName().equalsIgnoreCase(name)) { + if (!INBOX.equalsIgnoreCase(name)) { ImapConnection connection; synchronized (this) { if (this.connection == null) { @@ -391,7 +392,7 @@ public void delete(List messages, String trashFolderName) thr return; } - if (trashFolderName == null || getName().equalsIgnoreCase(trashFolderName)) { + if (trashFolderName == null || getName().equals(trashFolderName)) { setFlags(messages, Collections.singleton(Flag.DELETED), true); } else { ImapFolder remoteTrashFolder = getStore().getFolder(trashFolderName); @@ -1369,7 +1370,7 @@ private MessagingException ioExceptionHandler(ImapConnection connection, IOExcep public boolean equals(Object other) { if (other instanceof ImapFolder) { ImapFolder otherFolder = (ImapFolder) other; - return otherFolder.getName().equalsIgnoreCase(getName()); + return otherFolder.getName().equals(getName()); } return super.equals(other); diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapStore.java b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapStore.java index 9888dff0049..966c8e515bd 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapStore.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapStore.java @@ -197,7 +197,7 @@ private Set listFolders(ImapConnection connection, boolean subscribedOnl combinedPrefix = null; } - if (folder.equalsIgnoreCase(mStoreConfig.getInboxFolderName())) { + if (ImapFolder.INBOX.equalsIgnoreCase(folder)) { continue; } else if (folder.equals(mStoreConfig.getOutboxFolderName())) { /* @@ -216,12 +216,14 @@ private Set listFolders(ImapConnection connection, boolean subscribedOnl } } - folderNames.add(mStoreConfig.getInboxFolderName()); + folderNames.add(ImapFolder.INBOX); return folderNames; } void autoconfigureFolders(final ImapConnection connection) throws IOException, MessagingException { + mStoreConfig.setInboxFolderName(ImapFolder.INBOX); + if (!connection.hasCapability(Capabilities.SPECIAL_USE)) { if (K9MailLib.isDebug()) { Timber.d("No detected folder auto-configuration methods."); diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/store/pop3/Pop3Folder.java b/k9mail-library/src/main/java/com/fsck/k9/mail/store/pop3/Pop3Folder.java index f7ae94be29b..20eb7cebc5d 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/store/pop3/Pop3Folder.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/store/pop3/Pop3Folder.java @@ -31,6 +31,9 @@ * POP3 only supports one folder, "Inbox". So the folder name is the ID here. */ class Pop3Folder extends Folder { + static final String INBOX = "INBOX"; + + private Pop3Store pop3Store; private Map uidToMsgMap = new HashMap<>(); @SuppressLint("UseSparseArrays") @@ -44,10 +47,6 @@ class Pop3Folder extends Folder { super(); this.pop3Store = pop3Store; this.name = name; - - if (this.name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderName())) { - this.name = pop3Store.getConfig().getInboxFolderName(); - } } @Override @@ -56,7 +55,7 @@ public synchronized void open(int mode) throws MessagingException { return; } - if (!name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderName())) { + if (!INBOX.equals(name)) { throw new MessagingException("Folder does not exist"); } @@ -113,7 +112,7 @@ public boolean create(FolderType type) throws MessagingException { @Override public boolean exists() throws MessagingException { - return name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderName()); + return INBOX.equals(name); } @Override diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/store/pop3/Pop3Store.java b/k9mail-library/src/main/java/com/fsck/k9/mail/store/pop3/Pop3Store.java index 2b3dde34b85..ed07707e199 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/store/pop3/Pop3Store.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/store/pop3/Pop3Store.java @@ -201,13 +201,15 @@ public Pop3Folder getFolder(String name) { @Override public List getPersonalNamespaces(boolean forceListAll) throws MessagingException { List folders = new LinkedList<>(); - folders.add(getFolder(mStoreConfig.getInboxFolderName())); + folders.add(getFolder(Pop3Folder.INBOX)); return folders; } @Override public void checkSettings() throws MessagingException { - Pop3Folder folder = new Pop3Folder(this, mStoreConfig.getInboxFolderName()); + mStoreConfig.setInboxFolderName(Pop3Folder.INBOX); + + Pop3Folder folder = new Pop3Folder(this, Pop3Folder.INBOX); try { folder.open(Folder.OPEN_MODE_RW); folder.requestUidl(); diff --git a/k9mail-library/src/test/java/com/fsck/k9/mail/store/pop3/Pop3FolderTest.java b/k9mail-library/src/test/java/com/fsck/k9/mail/store/pop3/Pop3FolderTest.java index 56f31b60a63..fc00ab566a4 100644 --- a/k9mail-library/src/test/java/com/fsck/k9/mail/store/pop3/Pop3FolderTest.java +++ b/k9mail-library/src/test/java/com/fsck/k9/mail/store/pop3/Pop3FolderTest.java @@ -6,8 +6,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.List; import com.fsck.k9.mail.FetchProfile; @@ -49,10 +47,10 @@ public void before() throws MessagingException { mockStoreConfig = mock(StoreConfig.class); mockListener = mock(MessageRetrievalListener.class); when(mockStore.getConfig()).thenReturn(mockStoreConfig); - when(mockStoreConfig.getInboxFolderName()).thenReturn("Inbox"); + when(mockStoreConfig.getInboxFolderName()).thenReturn(Pop3Folder.INBOX); when(mockStore.createConnection()).thenReturn(mockConnection); when(mockConnection.executeSimpleCommand(Pop3Commands.STAT_COMMAND)).thenReturn("+OK 10 0"); - folder = new Pop3Folder(mockStore, "Inbox"); + folder = new Pop3Folder(mockStore, Pop3Folder.INBOX); BinaryTempFileBody.setTempDirectory(new File(System.getProperty("java.io.tmpdir"))); } diff --git a/k9mail-library/src/test/java/com/fsck/k9/mail/store/pop3/Pop3StoreTest.java b/k9mail-library/src/test/java/com/fsck/k9/mail/store/pop3/Pop3StoreTest.java index 4a9c2601e1a..f17d739f5b2 100644 --- a/k9mail-library/src/test/java/com/fsck/k9/mail/store/pop3/Pop3StoreTest.java +++ b/k9mail-library/src/test/java/com/fsck/k9/mail/store/pop3/Pop3StoreTest.java @@ -66,7 +66,7 @@ public class Pop3StoreTest { public void setUp() throws Exception { //Using a SSL socket allows us to mock it when(mockStoreConfig.getStoreUri()).thenReturn("pop3+ssl+://PLAIN:user:password@server:12345"); - when(mockStoreConfig.getInboxFolderName()).thenReturn("Inbox"); + when(mockStoreConfig.getInboxFolderName()).thenReturn(Pop3Folder.INBOX); when(mockTrustedSocketFactory.createSocket(null, "server", 12345, null)).thenReturn(mockSocket); when(mockSocket.isConnected()).thenReturn(true); when(mockSocket.isClosed()).thenReturn(false); @@ -187,7 +187,7 @@ public void getPersonalNamespace_shouldReturnListConsistingOfInbox() throws Exce List folders = store.getPersonalNamespaces(true); assertEquals(1, folders.size()); - assertEquals("Inbox", folders.get(0).getName()); + assertEquals("INBOX", folders.get(0).getName()); } @Test @@ -247,7 +247,7 @@ public void open_withAuthResponseUsingAuthPlain_shouldRetrieveMessageCountOnAuth when(mockSocket.getInputStream()).thenReturn(new ByteArrayInputStream(response.getBytes("UTF-8"))); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); when(mockSocket.getOutputStream()).thenReturn(byteArrayOutputStream); - Pop3Folder folder = store.getFolder("Inbox"); + Pop3Folder folder = store.getFolder(Pop3Folder.INBOX); folder.open(Folder.OPEN_MODE_RW); @@ -262,7 +262,7 @@ public void open_withFailedAuth_shouldThrow() throws Exception { CAPA_RESPONSE + AUTH_PLAIN_FAILED_RESPONSE; when(mockSocket.getInputStream()).thenReturn(new ByteArrayInputStream(response.getBytes("UTF-8"))); - Pop3Folder folder = store.getFolder("Inbox"); + Pop3Folder folder = store.getFolder(Pop3Folder.INBOX); folder.open(Folder.OPEN_MODE_RW); } diff --git a/k9mail/src/main/java/com/fsck/k9/Account.java b/k9mail/src/main/java/com/fsck/k9/Account.java index 2282ba7e507..809690c0f81 100644 --- a/k9mail/src/main/java/com/fsck/k9/Account.java +++ b/k9mail/src/main/java/com/fsck/k9/Account.java @@ -1074,7 +1074,7 @@ public synchronized void setDeletePolicy(DeletePolicy deletePolicy) { } public boolean isSpecialFolder(String folderName) { - return (folderName != null && (folderName.equalsIgnoreCase(getInboxFolderName()) || + return (folderName != null && (folderName.equals(getInboxFolderName()) || folderName.equals(getTrashFolderName()) || folderName.equals(getDraftsFolderName()) || folderName.equals(getArchiveFolderName()) || @@ -1096,7 +1096,7 @@ public synchronized void setDraftsFolderName(String name) { * @return true if account has a drafts folder set. */ public synchronized boolean hasDraftsFolder() { - return !K9.FOLDER_NONE.equalsIgnoreCase(draftsFolderName); + return !K9.FOLDER_NONE.equals(draftsFolderName); } public synchronized String getSentFolderName() { @@ -1112,7 +1112,7 @@ public synchronized void setSentFolderName(String name) { * @return true if account has a sent folder set. */ public synchronized boolean hasSentFolder() { - return !K9.FOLDER_NONE.equalsIgnoreCase(sentFolderName); + return !K9.FOLDER_NONE.equals(sentFolderName); } @@ -1129,7 +1129,7 @@ public synchronized void setTrashFolderName(String name) { * @return true if account has a trash folder set. */ public synchronized boolean hasTrashFolder() { - return !K9.FOLDER_NONE.equalsIgnoreCase(trashFolderName); + return !K9.FOLDER_NONE.equals(trashFolderName); } public synchronized String getArchiveFolderName() { @@ -1145,7 +1145,7 @@ public synchronized void setArchiveFolderName(String archiveFolderName) { * @return true if account has an archive folder set. */ public synchronized boolean hasArchiveFolder() { - return !K9.FOLDER_NONE.equalsIgnoreCase(archiveFolderName); + return !K9.FOLDER_NONE.equals(archiveFolderName); } public synchronized String getSpamFolderName() { @@ -1161,7 +1161,7 @@ public synchronized void setSpamFolderName(String name) { * @return true if account has a spam folder set. */ public synchronized boolean hasSpamFolder() { - return !K9.FOLDER_NONE.equalsIgnoreCase(spamFolderName); + return !K9.FOLDER_NONE.equals(spamFolderName); } public synchronized String getOutboxFolderName() { diff --git a/k9mail/src/main/java/com/fsck/k9/activity/ActivityListener.java b/k9mail/src/main/java/com/fsck/k9/activity/ActivityListener.java index 93631085d31..2990d731abe 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/ActivityListener.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/ActivityListener.java @@ -85,9 +85,9 @@ private String getActionInProgressOperation(Context context) { } if (account != null) { - if (displayName.equalsIgnoreCase(account.getInboxFolderName())) { + if (displayName.equals(account.getInboxFolderName())) { displayName = context.getString(R.string.special_mailbox_name_inbox); - } else if (displayName.equalsIgnoreCase(account.getOutboxFolderName())) { + } else if (displayName.equals(account.getOutboxFolderName())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java b/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java index 1a408214562..efb75340062 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java @@ -279,10 +279,7 @@ public void listFolders(Account account, List folders) { for (Folder folder : folders) { String name = folder.getName(); - // Inbox needs to be compared case-insensitively - if (mHideCurrentFolder && (name.equals(mFolder) || ( - mAccount.getInboxFolderName().equalsIgnoreCase(mFolder) && - mAccount.getInboxFolderName().equalsIgnoreCase(name)))) { + if (mHideCurrentFolder && name.equals(mFolder)) { continue; } Folder.FolderClass fMode = folder.getDisplayClass(); @@ -335,7 +332,7 @@ public int compare(String s1, String s2) { try { int position = 0; for (String name : localFolders) { - if (mAccount.getInboxFolderName().equalsIgnoreCase(name)) { + if (mAccount.getInboxFolderName().equals(name)) { folderList.add(getString(R.string.special_mailbox_name_inbox)); mHeldInbox = name; } else if (!account.getOutboxFolderName().equals(name)) { @@ -351,9 +348,7 @@ public int compare(String s1, String s2) { if (name.equals(mSelectFolder)) { selectedFolder = position; } - } else if (name.equals(mFolder) || ( - mAccount.getInboxFolderName().equalsIgnoreCase(mFolder) && - mAccount.getInboxFolderName().equalsIgnoreCase(name))) { + } else if (name.equals(mFolder)) { selectedFolder = position; } position++; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/FolderInfoHolder.java b/k9mail/src/main/java/com/fsck/k9/activity/FolderInfoHolder.java index ef52d8b28fc..b7c63d4346c 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/FolderInfoHolder.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/FolderInfoHolder.java @@ -121,8 +121,7 @@ public static String getDisplayName(Context context, Account account, String nam context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (name.equals(account.getOutboxFolderName())) { displayName = context.getString(R.string.special_mailbox_name_outbox); - // FIXME: We really shouldn't do a case-insensitive comparison here - } else if (name.equalsIgnoreCase(account.getInboxFolderName())) { + } else if (name.equals(account.getInboxFolderName())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else { displayName = name; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java index b6e48cf94cf..ab5c26b821c 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java @@ -986,7 +986,7 @@ public void onChooseAutoExpandFolder() { } private String translateFolder(String in) { - if (account.getInboxFolderName().equalsIgnoreCase(in)) { + if (account.getInboxFolderName().equals(in)) { return getString(R.string.special_mailbox_name_inbox); } else { return in; diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalStore.java b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalStore.java index f0f39f692cc..7196663a58e 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalStore.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalStore.java @@ -918,7 +918,7 @@ public Void doDbWork(final SQLiteDatabase db) throws WrappedException { if (account.isSpecialFolder(name)) { prefHolder.inTopGroup = true; prefHolder.displayClass = LocalFolder.FolderClass.FIRST_CLASS; - if (name.equalsIgnoreCase(account.getInboxFolderName())) { + if (name.equals(account.getInboxFolderName())) { prefHolder.integrate = true; prefHolder.notifyClass = LocalFolder.FolderClass.FIRST_CLASS; prefHolder.pushClass = LocalFolder.FolderClass.FIRST_CLASS; @@ -926,8 +926,7 @@ public Void doDbWork(final SQLiteDatabase db) throws WrappedException { prefHolder.pushClass = LocalFolder.FolderClass.INHERITED; } - if (name.equalsIgnoreCase(account.getInboxFolderName()) || - name.equalsIgnoreCase(account.getDraftsFolderName())) { + if (name.equals(account.getInboxFolderName()) || name.equals(account.getDraftsFolderName())) { prefHolder.syncClass = LocalFolder.FolderClass.FIRST_CLASS; } else { prefHolder.syncClass = LocalFolder.FolderClass.NO_CLASS; diff --git a/k9mail/src/main/java/com/fsck/k9/notification/NotificationActionService.java b/k9mail/src/main/java/com/fsck/k9/notification/NotificationActionService.java index ea446b4e79c..5def5fc8c35 100644 --- a/k9mail/src/main/java/com/fsck/k9/notification/NotificationActionService.java +++ b/k9mail/src/main/java/com/fsck/k9/notification/NotificationActionService.java @@ -233,7 +233,7 @@ private void cancelNotifications(Intent intent, Account account, MessagingContro private boolean isMovePossible(MessagingController controller, Account account, String destinationFolderName) { - boolean isSpecialFolderConfigured = !K9.FOLDER_NONE.equalsIgnoreCase(destinationFolderName); + boolean isSpecialFolderConfigured = !K9.FOLDER_NONE.equals(destinationFolderName); return isSpecialFolderConfigured && controller.isMoveCapable(account); } diff --git a/k9mail/src/main/java/com/fsck/k9/notification/WearNotifications.java b/k9mail/src/main/java/com/fsck/k9/notification/WearNotifications.java index 107cf8abd0f..f0b449b275d 100644 --- a/k9mail/src/main/java/com/fsck/k9/notification/WearNotifications.java +++ b/k9mail/src/main/java/com/fsck/k9/notification/WearNotifications.java @@ -240,7 +240,7 @@ private boolean isSpamActionAvailableForWear(Account account) { } private boolean isMovePossible(Account account, String destinationFolderName) { - if (K9.FOLDER_NONE.equalsIgnoreCase(destinationFolderName)) { + if (K9.FOLDER_NONE.equals(destinationFolderName)) { return false; } diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java index da52ab50789..8732a1c6592 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java @@ -301,7 +301,7 @@ public void onRefile(String dstFolder) { return; } - if (K9.FOLDER_NONE.equalsIgnoreCase(dstFolder)) { + if (K9.FOLDER_NONE.equals(dstFolder)) { return; }