rename LocalMessage id field to databaseId
This commit is contained in:
parent
52d76cad71
commit
2fbd6f61a8
16 changed files with 40 additions and 50 deletions
|
@ -144,8 +144,6 @@ public abstract class Message implements Part, Body {
|
|||
@Override
|
||||
public abstract void setBody(Body body);
|
||||
|
||||
public abstract long getId();
|
||||
|
||||
public abstract boolean hasAttachments();
|
||||
|
||||
public abstract long getSize();
|
||||
|
|
|
@ -688,11 +688,6 @@ public class MimeMessage extends Message {
|
|||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return Long.parseLong(mUid); //or maybe .mMessageId?
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttachments() {
|
||||
return false;
|
||||
|
|
|
@ -126,7 +126,7 @@ public class EmailProviderCache {
|
|||
public void hideMessages(List<LocalMessage> messages) {
|
||||
synchronized (mHiddenMessageCache) {
|
||||
for (LocalMessage message : messages) {
|
||||
long messageId = message.getId();
|
||||
long messageId = message.getDatabaseId();
|
||||
mHiddenMessageCache.put(messageId, message.getFolder().getId());
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class EmailProviderCache {
|
|||
synchronized (mHiddenMessageCache) {
|
||||
for (Message message : messages) {
|
||||
LocalMessage localMessage = (LocalMessage) message;
|
||||
long messageId = localMessage.getId();
|
||||
long messageId = localMessage.getDatabaseId();
|
||||
long folderId = ((LocalFolder) localMessage.getFolder()).getId();
|
||||
Long hiddenInFolder = mHiddenMessageCache.get(messageId);
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ public class MessagingController {
|
|||
}
|
||||
|
||||
private boolean isMessageSuppressed(LocalMessage message) {
|
||||
long messageId = message.getId();
|
||||
long messageId = message.getDatabaseId();
|
||||
long folderId = message.getFolder().getId();
|
||||
|
||||
EmailProviderCache cache = EmailProviderCache.getCache(message.getFolder().getAccountUuid(), context);
|
||||
|
@ -2511,7 +2511,7 @@ public class MessagingController {
|
|||
localFolder.open(Folder.OPEN_MODE_RW);
|
||||
|
||||
LocalMessage message = localFolder.getMessage(uid);
|
||||
if (message == null || message.getId() == 0) {
|
||||
if (message == null || message.getDatabaseId() == 0) {
|
||||
throw new IllegalArgumentException("Message not found: folder=" + folderName + ", uid=" + uid);
|
||||
}
|
||||
|
||||
|
@ -2530,7 +2530,7 @@ public class MessagingController {
|
|||
throws MessagingException {
|
||||
|
||||
if (account.isMarkMessageAsReadOnView() && !message.isSet(Flag.SEEN)) {
|
||||
List<Long> messageIds = Collections.singletonList(message.getId());
|
||||
List<Long> messageIds = Collections.singletonList(message.getDatabaseId());
|
||||
setFlag(account, messageIds, Flag.SEEN, true);
|
||||
|
||||
message.setFlagInternal(Flag.SEEN, true);
|
||||
|
@ -3996,7 +3996,7 @@ public class MessagingController {
|
|||
public long getId(Message message) {
|
||||
long id;
|
||||
if (message instanceof LocalMessage) {
|
||||
id = message.getId();
|
||||
id = ((LocalMessage) message).getDatabaseId();
|
||||
} else {
|
||||
Timber.w("MessagingController.getId() called without a LocalMessage");
|
||||
id = INVALID_MESSAGE_ID;
|
||||
|
|
|
@ -26,7 +26,7 @@ public class LocalBodyPart extends MimeBodyPart implements LocalPart {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
public long getPartId() {
|
||||
return messagePartId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1046,7 +1046,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
"id %d currently in folder %s",
|
||||
lDestFolder.getId(),
|
||||
message.getUid(),
|
||||
lMessage.getId(),
|
||||
lMessage.getDatabaseId(),
|
||||
getName());
|
||||
|
||||
String newUid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString();
|
||||
|
@ -1060,7 +1060,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
/*
|
||||
* "Move" the message into the new folder
|
||||
*/
|
||||
long msgId = lMessage.getId();
|
||||
long msgId = lMessage.getDatabaseId();
|
||||
String[] idArg = new String[] { Long.toString(msgId) };
|
||||
|
||||
ContentValues cv = new ContentValues();
|
||||
|
@ -1309,7 +1309,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
LocalMessage oldMessage = getMessage(uid);
|
||||
|
||||
if (oldMessage != null) {
|
||||
oldMessageId = oldMessage.getId();
|
||||
oldMessageId = oldMessage.getDatabaseId();
|
||||
|
||||
long oldRootMessagePartId = oldMessage.getMessagePartId();
|
||||
deleteMessagePartsAndDataFromDisk(oldRootMessagePartId);
|
||||
|
@ -1689,7 +1689,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
db.update("messages", cv, "id = ?", new String[]
|
||||
{ Long.toString(message.getId()) });
|
||||
{ Long.toString(message.getDatabaseId()) });
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -1844,7 +1844,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
|
||||
void destroyMessage(LocalMessage localMessage) throws MessagingException {
|
||||
destroyMessage(localMessage.getId(), localMessage.getMessagePartId(), localMessage.getMessageId());
|
||||
destroyMessage(localMessage.getDatabaseId(), localMessage.getMessagePartId(), localMessage.getMessageId());
|
||||
}
|
||||
|
||||
private void destroyMessage(final long messageId, final long messagePartId, final String messageIdHeader)
|
||||
|
|
|
@ -29,7 +29,7 @@ import timber.log.Timber;
|
|||
public class LocalMessage extends MimeMessage {
|
||||
private final LocalStore localStore;
|
||||
|
||||
private long id;
|
||||
private long databaseId;
|
||||
private long rootId;
|
||||
private long threadId;
|
||||
private long messagePartId;
|
||||
|
@ -79,7 +79,7 @@ public class LocalMessage extends MimeMessage {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.id = cursor.getLong(5);
|
||||
this.databaseId = cursor.getLong(5);
|
||||
this.setRecipients(RecipientType.TO, Address.unpack(cursor.getString(6)));
|
||||
this.setRecipients(RecipientType.CC, Address.unpack(cursor.getString(7)));
|
||||
this.setRecipients(RecipientType.BCC, Address.unpack(cursor.getString(8)));
|
||||
|
@ -246,9 +246,8 @@ public class LocalMessage extends MimeMessage {
|
|||
super.setFlag(flag, set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
public long getDatabaseId() {
|
||||
return databaseId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -277,7 +276,7 @@ public class LocalMessage extends MimeMessage {
|
|||
cv.put("answered", isSet(Flag.ANSWERED) ? 1 : 0);
|
||||
cv.put("forwarded", isSet(Flag.FORWARDED) ? 1 : 0);
|
||||
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(id) });
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(databaseId) });
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -311,7 +310,7 @@ public class LocalMessage extends MimeMessage {
|
|||
cv.putNull("reply_to_list");
|
||||
cv.putNull("message_part_id");
|
||||
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(id) });
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(databaseId) });
|
||||
|
||||
try {
|
||||
((LocalFolder) mFolder).deleteMessagePartsAndDataFromDisk(messagePartId);
|
||||
|
@ -319,7 +318,7 @@ public class LocalMessage extends MimeMessage {
|
|||
throw new WrappedException(e);
|
||||
}
|
||||
|
||||
getFolder().deleteFulltextIndexEntry(db, id);
|
||||
getFolder().deleteFulltextIndexEntry(db, databaseId);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -343,7 +342,7 @@ public class LocalMessage extends MimeMessage {
|
|||
ContentValues cv = new ContentValues();
|
||||
cv.putNull("message_part_id");
|
||||
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(id) });
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(databaseId) });
|
||||
|
||||
try {
|
||||
((LocalFolder) mFolder).deleteMessagePartsAndDataFromDisk(messagePartId);
|
||||
|
@ -380,7 +379,7 @@ public class LocalMessage extends MimeMessage {
|
|||
super.copy(message);
|
||||
|
||||
message.messageReference = messageReference;
|
||||
message.id = id;
|
||||
message.databaseId = databaseId;
|
||||
message.attachmentCount = attachmentCount;
|
||||
message.subject = subject;
|
||||
message.preview = preview;
|
||||
|
|
|
@ -24,7 +24,7 @@ public class LocalMimeMessage extends MimeMessage implements LocalPart {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
public long getPartId() {
|
||||
return messagePartId;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.fsck.k9.mailstore;
|
|||
|
||||
public interface LocalPart {
|
||||
String getAccountUuid();
|
||||
long getId();
|
||||
long getPartId();
|
||||
long getSize();
|
||||
LocalMessage getMessage();
|
||||
}
|
||||
|
|
|
@ -756,7 +756,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
|
||||
if (part instanceof LocalPart) {
|
||||
LocalPart localBodyPart = (LocalPart) part;
|
||||
if (localBodyPart.getId() == partId) {
|
||||
if (localBodyPart.getPartId() == partId) {
|
||||
return part;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
import android.text.TextUtils;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.mail.FetchProfile;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mailstore.LocalFolder;
|
||||
|
@ -38,13 +37,13 @@ class MigrationTo55 {
|
|||
|
||||
String fulltext = fulltextCreator.createFulltext(localMessage);
|
||||
if (!TextUtils.isEmpty(fulltext)) {
|
||||
Timber.d("fulltext for msg id %d is %d chars long", localMessage.getId(), fulltext.length());
|
||||
Timber.d("fulltext for msg id %d is %d chars long", localMessage.getDatabaseId(), fulltext.length());
|
||||
cv.clear();
|
||||
cv.put("docid", localMessage.getId());
|
||||
cv.put("docid", localMessage.getDatabaseId());
|
||||
cv.put("fulltext", fulltext);
|
||||
db.insert("messages_fulltext", null, cv);
|
||||
} else {
|
||||
Timber.d("no fulltext for msg id %d :(", localMessage.getId());
|
||||
Timber.d("no fulltext for msg id %d :(", localMessage.getDatabaseId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import timber.log.Timber;
|
|||
import android.support.annotation.WorkerThread;
|
||||
|
||||
import com.fsck.k9.Globals;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.mail.Body;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.Part;
|
||||
|
@ -64,7 +63,7 @@ public class AttachmentInfoExtractor {
|
|||
if (part instanceof LocalPart) {
|
||||
LocalPart localPart = (LocalPart) part;
|
||||
String accountUuid = localPart.getAccountUuid();
|
||||
long messagePartId = localPart.getId();
|
||||
long messagePartId = localPart.getPartId();
|
||||
size = localPart.getSize();
|
||||
isContentAvailable = part.getBody() != null;
|
||||
uri = AttachmentProvider.getAttachmentUri(accountUuid, messagePartId);
|
||||
|
|
|
@ -358,13 +358,13 @@ public class MessageProvider extends ContentProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* Extracts the {@link LocalMessage#getId() ID} from the given {@link MessageInfoHolder}. The underlying
|
||||
* Extracts the {@link LocalMessage#getDatabaseId() ID} from the given {@link MessageInfoHolder}. The underlying
|
||||
* {@link Message} is expected to be a {@link LocalMessage}.
|
||||
*/
|
||||
public static class IdExtractor implements FieldExtractor<MessageInfoHolder, Long> {
|
||||
@Override
|
||||
public Long getField(MessageInfoHolder source) {
|
||||
return source.message.getId();
|
||||
return source.message.getDatabaseId();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
|
|||
|
||||
/* We hide the subject by default for each new message, and MessageTitleView might show
|
||||
* it later by calling showSubjectLine(). */
|
||||
boolean newMessageShown = mMessage == null || mMessage.getId() != message.getId();
|
||||
boolean newMessageShown = mMessage == null || !mMessage.getUid().equals(message.getUid());
|
||||
if (newMessageShown) {
|
||||
mSubjectView.setVisibility(GONE);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class EmailProviderCacheTest {
|
|||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
cache = EmailProviderCache.getCache(UUID.randomUUID().toString(), RuntimeEnvironment.application);
|
||||
when(mockLocalMessage.getId()).thenReturn(localMessageId);
|
||||
when(mockLocalMessage.getDatabaseId()).thenReturn(localMessageId);
|
||||
when(mockLocalMessage.getFolder()).thenReturn(mockLocalMessageFolder);
|
||||
when(mockLocalMessageFolder.getId()).thenReturn(localMessageFolderId);
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ public class MigrationTest {
|
|||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals("text/plain", msg.getMimeType());
|
||||
Assert.assertEquals(2, msg.getId());
|
||||
Assert.assertEquals(2, msg.getDatabaseId());
|
||||
Assert.assertEquals(13, msg.getHeaderNames().size());
|
||||
Assert.assertEquals(0, msg.getAttachmentCount());
|
||||
|
||||
|
@ -229,7 +229,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(3, msg.getId());
|
||||
Assert.assertEquals(3, msg.getDatabaseId());
|
||||
Assert.assertEquals(8, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/mixed", msg.getMimeType());
|
||||
Assert.assertEquals(1, msg.getHeader(MimeHeader.HEADER_CONTENT_TYPE).length);
|
||||
|
@ -301,7 +301,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(4, msg.getId());
|
||||
Assert.assertEquals(4, msg.getDatabaseId());
|
||||
Assert.assertEquals(8, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/mixed", msg.getMimeType());
|
||||
Assert.assertEquals(2, msg.getAttachmentCount());
|
||||
|
@ -360,7 +360,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(5, msg.getId());
|
||||
Assert.assertEquals(5, msg.getDatabaseId());
|
||||
Assert.assertEquals(13, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/encrypted", msg.getMimeType());
|
||||
Assert.assertEquals(2, msg.getAttachmentCount());
|
||||
|
@ -478,7 +478,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(6, msg.getId());
|
||||
Assert.assertEquals(6, msg.getDatabaseId());
|
||||
Assert.assertEquals(12, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("text/plain", msg.getMimeType());
|
||||
Assert.assertEquals(0, msg.getAttachmentCount());
|
||||
|
@ -565,7 +565,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(7, msg.getId());
|
||||
Assert.assertEquals(7, msg.getDatabaseId());
|
||||
Assert.assertEquals(12, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("text/plain", msg.getMimeType());
|
||||
Assert.assertEquals(0, msg.getAttachmentCount());
|
||||
|
@ -623,7 +623,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(8, msg.getId());
|
||||
Assert.assertEquals(8, msg.getDatabaseId());
|
||||
Assert.assertEquals(9, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/alternative", msg.getMimeType());
|
||||
Assert.assertEquals(0, msg.getAttachmentCount());
|
||||
|
@ -688,7 +688,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(9, msg.getId());
|
||||
Assert.assertEquals(9, msg.getDatabaseId());
|
||||
Assert.assertEquals(11, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/mixed", msg.getMimeType());
|
||||
Assert.assertEquals(1, msg.getAttachmentCount());
|
||||
|
|
Loading…
Reference in a new issue