rename firstClassAttachment to inlineAttachment (with reversed logic)

This commit is contained in:
Vincent Breitmoser 2016-07-24 20:24:59 +02:00
parent a3ce1adf6e
commit b7bcaf8deb
6 changed files with 19 additions and 19 deletions

View file

@ -165,7 +165,7 @@ public class AttachmentPresenter {
}
for (AttachmentViewInfo attachmentViewInfo : messageViewInfo.attachments) {
if (attachmentViewInfo.firstClassAttachment) {
if (!attachmentViewInfo.inlineAttachment) {
addAttachment(attachmentViewInfo);
}
}

View file

@ -21,16 +21,16 @@ public class AttachmentViewInfo {
* @see com.fsck.k9.ui.messageview.AttachmentController#getAttachmentUriForMimeType(AttachmentViewInfo, String)
*/
public final Uri uri;
public final boolean firstClassAttachment;
public final boolean inlineAttachment;
public final Part part;
public AttachmentViewInfo(String mimeType, String displayName, long size, Uri uri, boolean firstClassAttachment,
public AttachmentViewInfo(String mimeType, String displayName, long size, Uri uri, boolean inlineAttachment,
Part part) {
this.mimeType = mimeType;
this.displayName = displayName;
this.size = size;
this.uri = uri;
this.firstClassAttachment = firstClassAttachment;
this.inlineAttachment = inlineAttachment;
this.part = part;
}
}

View file

@ -720,7 +720,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
// TODO might want to do that at a later point?
// String displayName = cursor.getString(5);
// int type = cursor.getInt(1);
// boolean firstClassAttachment = (type != MessagePartType.HIDDEN_ATTACHMENT);
// boolean inlineAttachment = (type == MessagePartType.HIDDEN_ATTACHMENT);
final Part part;
if (id == message.getMessagePartId()) {

View file

@ -48,7 +48,7 @@ public class AttachmentInfoExtractor {
List<AttachmentViewInfo> attachments = new ArrayList<>();
for (Part part : attachmentParts) {
AttachmentViewInfo attachmentViewInfo = extractAttachmentInfo(part);
if (attachmentViewInfo.firstClassAttachment) {
if (!attachmentViewInfo.inlineAttachment) {
attachments.add(attachmentViewInfo);
}
}
@ -102,7 +102,7 @@ public class AttachmentInfoExtractor {
@WorkerThread
private AttachmentViewInfo extractAttachmentInfo(Part part, Uri uri, long size) throws MessagingException {
boolean firstClassAttachment = true;
boolean inlineAttachment = false;
String mimeType = part.getMimeType();
String contentTypeHeader = MimeUtility.unfoldAndDecode(part.getContentType());
@ -127,12 +127,12 @@ public class AttachmentInfoExtractor {
if (contentDisposition != null &&
MimeUtility.getHeaderParameter(contentDisposition, null).matches("^(?i:inline)") &&
part.getHeader(MimeHeader.HEADER_CONTENT_ID).length > 0) {
firstClassAttachment = false;
inlineAttachment = true;
}
long attachmentSize = extractAttachmentSize(contentDisposition, size);
return new AttachmentViewInfo(mimeType, name, attachmentSize, uri, firstClassAttachment, part);
return new AttachmentViewInfo(mimeType, name, attachmentSize, uri, inlineAttachment, part);
}
@WorkerThread

View file

@ -85,9 +85,9 @@ public class AttachmentResolverTest {
when(subPart2.getContentId()).thenReturn("cid-2");
when(attachmentInfoExtractor.extractAttachmentInfo(subPart1)).thenReturn(
new AttachmentViewInfo(null, null, AttachmentViewInfo.UNKNOWN_SIZE, ATTACHMENT_TEST_URI_1, true, subPart1));
new AttachmentViewInfo(null, null, AttachmentViewInfo.UNKNOWN_SIZE, ATTACHMENT_TEST_URI_1, false, subPart1));
when(attachmentInfoExtractor.extractAttachmentInfo(subPart2)).thenReturn(
new AttachmentViewInfo(null, null, AttachmentViewInfo.UNKNOWN_SIZE, ATTACHMENT_TEST_URI_2, true, subPart2));
new AttachmentViewInfo(null, null, AttachmentViewInfo.UNKNOWN_SIZE, ATTACHMENT_TEST_URI_2, false, subPart2));
Map<String,Uri> result = AttachmentResolver.buildCidToAttachmentUriMap(attachmentInfoExtractor, multipartPart);

View file

@ -79,7 +79,7 @@ public class AttachmentInfoExtractorTest {
assertEquals(AttachmentViewInfo.UNKNOWN_SIZE, attachmentViewInfo.size);
assertEquals("noname", attachmentViewInfo.displayName);
assertNull(attachmentViewInfo.mimeType);
assertTrue(attachmentViewInfo.firstClassAttachment);
assertFalse(attachmentViewInfo.inlineAttachment);
}
@Test
@ -95,7 +95,7 @@ public class AttachmentInfoExtractorTest {
}
@Test
public void extractInfoForDb__withContentTypeAndName__shouldReturnNamedFirstClassAttachment() throws Exception {
public void extractInfoForDb__withContentTypeAndName__shouldReturnNamedAttachment() throws Exception {
Part part = mock(Part.class);
when(part.getMimeType()).thenReturn(TEST_MIME_TYPE);
when(part.getContentType()).thenReturn(TEST_MIME_TYPE + "; name=\"filename.ext\"");
@ -105,7 +105,7 @@ public class AttachmentInfoExtractorTest {
assertEquals(Uri.EMPTY, attachmentViewInfo.uri);
assertEquals(TEST_MIME_TYPE, attachmentViewInfo.mimeType);
assertEquals("filename.ext", attachmentViewInfo.displayName);
assertTrue(attachmentViewInfo.firstClassAttachment);
assertFalse(attachmentViewInfo.inlineAttachment);
}
@Test
@ -119,7 +119,7 @@ public class AttachmentInfoExtractorTest {
}
@Test
public void extractInfoForDb__withDispositionAttach__shouldReturnNamedFirstClassAttachment() throws Exception {
public void extractInfoForDb__withDispositionAttach__shouldReturnNamedAttachment() throws Exception {
Part part = mock(Part.class);
when(part.getDisposition()).thenReturn("attachment" + "; filename=\"filename.ext\"; meaningless=\"dummy\"");
@ -127,11 +127,11 @@ public class AttachmentInfoExtractorTest {
assertEquals(Uri.EMPTY, attachmentViewInfo.uri);
assertEquals("filename.ext", attachmentViewInfo.displayName);
assertTrue(attachmentViewInfo.firstClassAttachment);
assertFalse(attachmentViewInfo.inlineAttachment);
}
@Test
public void extractInfoForDb__withDispositionInlineAndContentId__shouldReturnNotFirstClassAttachment()
public void extractInfoForDb__withDispositionInlineAndContentId__shouldReturnInlineAttachment()
throws Exception {
Part part = mock(Part.class);
when(part.getHeader(MimeHeader.HEADER_CONTENT_ID)).thenReturn(TEST_CONTENT_ID);
@ -139,7 +139,7 @@ public class AttachmentInfoExtractorTest {
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertFalse(attachmentViewInfo.firstClassAttachment);
assertTrue(attachmentViewInfo.inlineAttachment);
}
@Test
@ -186,6 +186,6 @@ public class AttachmentInfoExtractorTest {
assertEquals(TEST_URI, attachmentViewInfo.uri);
assertEquals(TEST_SIZE, attachmentViewInfo.size);
assertEquals(TEST_MIME_TYPE, attachmentViewInfo.mimeType);
assertTrue(attachmentViewInfo.firstClassAttachment);
assertFalse(attachmentViewInfo.inlineAttachment);
}
}