Simplified logic (#2911)

This commit is contained in:
Joshua Nelson 2017-11-10 12:05:57 -05:00 committed by cketti
parent 231cab3f36
commit 3fdb5f532f
8 changed files with 13 additions and 45 deletions

View file

@ -452,19 +452,8 @@ public class MessageExtractor {
return false;
}
if (part.isMimeType("text/html")) {
return true;
}
return part.isMimeType("text/html") || part.isMimeType("text/plain") || part.isMimeType("application/pgp");
if (part.isMimeType("text/plain")) {
return true;
}
if (part.isMimeType("application/pgp")) {
return true;
}
return false;
}
private static String getContentDisposition(Part part) {

View file

@ -3,6 +3,7 @@ package com.fsck.k9.mail.store.webdav;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -51,11 +52,8 @@ class DataSet {
* Returns a hashmap of special folder name => special folder url
*/
public Map<String, String> getSpecialFolderToUrl() {
// We return the first (and only) map
for (Map<String, String> folderMap : mData.values()) {
return folderMap;
}
return new HashMap<String, String>();
// We return the first (and only) map, creating one if not present
return mData.isEmpty() ? Collections.<String, String>emptyMap() : mData.values().iterator().next();
}
/**

View file

@ -1690,7 +1690,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
ListView listView = ((AlertDialog) dialog).getListView();
SparseBooleanArray pos = listView.getCheckedItemPositions();
boolean includeGlobals = mImportContents.globalSettings ? pos.get(0) : false;
boolean includeGlobals = mImportContents.globalSettings && pos.get(0);
List<String> accountUuids = new ArrayList<String>();
int start = mImportContents.globalSettings ? 1 : 0;
for (int i = start, end = listView.getCount(); i < end; i++) {

View file

@ -1070,12 +1070,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
if (subjectView.getText().length() != 0) {
return true;
}
if (!recipientPresenter.getToAddresses().isEmpty() ||
return !recipientPresenter.getToAddresses().isEmpty() ||
!recipientPresenter.getCcAddresses().isEmpty() ||
!recipientPresenter.getBccAddresses().isEmpty()) {
return true;
}
return false;
!recipientPresenter.getBccAddresses().isEmpty();
}
@Override

View file

@ -100,20 +100,8 @@ class AutocryptHeader {
AutocryptHeader that = (AutocryptHeader) o;
if (isPreferEncryptMutual != that.isPreferEncryptMutual) {
return false;
}
if (!Arrays.equals(keyData, that.keyData)) {
return false;
}
if (!addr.equals(that.addr)) {
return false;
}
if (!parameters.equals(that.parameters)) {
return false;
}
return true;
return isPreferEncryptMutual == that.isPreferEncryptMutual && Arrays.equals(keyData, that.keyData)
&& addr.equals(that.addr) && parameters.equals(that.parameters);
}
@Override

View file

@ -3838,18 +3838,14 @@ public class MessagingController {
}
private boolean modeMismatch(Account.FolderMode aMode, Folder.FolderClass fMode) {
if (aMode == Account.FolderMode.NONE
return aMode == Account.FolderMode.NONE
|| (aMode == Account.FolderMode.FIRST_CLASS &&
fMode != Folder.FolderClass.FIRST_CLASS)
|| (aMode == Account.FolderMode.FIRST_AND_SECOND_CLASS &&
fMode != Folder.FolderClass.FIRST_CLASS &&
fMode != Folder.FolderClass.SECOND_CLASS)
|| (aMode == Account.FolderMode.NOT_SECOND_CLASS &&
fMode == Folder.FolderClass.SECOND_CLASS)) {
return true;
} else {
return false;
}
fMode == Folder.FolderClass.SECOND_CLASS);
}
private static AtomicInteger sequencing = new AtomicInteger(0);

View file

@ -111,7 +111,7 @@ class IdentitySettings {
@Override
public String toString(String value) {
return (value != null) ? value : null;
return value;
}
@Override

View file

@ -611,7 +611,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
}
public boolean isMessageRead() {
return (mMessage != null) ? mMessage.isSet(Flag.SEEN) : false;
return (mMessage != null) && mMessage.isSet(Flag.SEEN);
}
public boolean isCopyCapable() {