mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 09:52:16 -05:00
commit
80fa468ec2
@ -36,27 +36,27 @@ public class MessageReferenceTest {
|
|||||||
public void parseIdentityStringWithoutFlag() throws MessagingException {
|
public void parseIdentityStringWithoutFlag() throws MessagingException {
|
||||||
MessageReference messageReference = new MessageReference("!:byBoYWkh:Zm9sZGVy:MTAxMDEwMTA=");
|
MessageReference messageReference = new MessageReference("!:byBoYWkh:Zm9sZGVy:MTAxMDEwMTA=");
|
||||||
|
|
||||||
assertEquals("o hai!", messageReference.accountUuid);
|
assertEquals("o hai!", messageReference.getAccountUuid());
|
||||||
assertEquals("folder", messageReference.folderName);
|
assertEquals("folder", messageReference.getFolderName());
|
||||||
assertEquals("10101010", messageReference.uid);
|
assertEquals("10101010", messageReference.getUid());
|
||||||
assertNull(messageReference.flag);
|
assertNull(messageReference.getFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseIdentityStringWithFlag() throws MessagingException {
|
public void parseIdentityStringWithFlag() throws MessagingException {
|
||||||
MessageReference messageReference = new MessageReference("!:byBoYWkh:Zm9sZGVy:MTAxMDEwMTA=:ANSWERED");
|
MessageReference messageReference = new MessageReference("!:byBoYWkh:Zm9sZGVy:MTAxMDEwMTA=:ANSWERED");
|
||||||
|
|
||||||
assertEquals("o hai!", messageReference.accountUuid);
|
assertEquals("o hai!", messageReference.getAccountUuid());
|
||||||
assertEquals("folder", messageReference.folderName);
|
assertEquals("folder", messageReference.getFolderName());
|
||||||
assertEquals("10101010", messageReference.uid);
|
assertEquals("10101010", messageReference.getUid());
|
||||||
assertEquals(Flag.ANSWERED, messageReference.flag);
|
assertEquals(Flag.ANSWERED, messageReference.getFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseIdentityStringContainingBadVersionNumber() throws MessagingException {
|
public void parseIdentityStringContainingBadVersionNumber() throws MessagingException {
|
||||||
MessageReference messageReference = new MessageReference("@:byBoYWkh:Zm9sZGVy:MTAxMDEwMTA=:ANSWERED");
|
MessageReference messageReference = new MessageReference("@:byBoYWkh:Zm9sZGVy:MTAxMDEwMTA=:ANSWERED");
|
||||||
|
|
||||||
assertNull(messageReference.accountUuid);
|
assertNull(messageReference.getAccountUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = MessagingException.class)
|
@Test(expected = MessagingException.class)
|
||||||
@ -71,7 +71,7 @@ public class MessageReferenceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void equalsWithAnObjectShouldReturnFalse() {
|
public void equalsWithAnObjectShouldReturnFalse() {
|
||||||
MessageReference messageReference = new MessageReference();
|
MessageReference messageReference = new MessageReference(null, null, null, null);
|
||||||
Object object = new Object();
|
Object object = new Object();
|
||||||
|
|
||||||
assertFalse(messageReference.equals(object));
|
assertFalse(messageReference.equals(object));
|
||||||
@ -125,21 +125,14 @@ public class MessageReferenceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MessageReference createMessageReference(String accountUuid, String folderName, String uid) {
|
private MessageReference createMessageReference(String accountUuid, String folderName, String uid) {
|
||||||
MessageReference messageReference = new MessageReference();
|
MessageReference messageReference = new MessageReference(accountUuid, folderName, uid, null);
|
||||||
messageReference.accountUuid = accountUuid;
|
|
||||||
messageReference.folderName = folderName;
|
|
||||||
messageReference.uid = uid;
|
|
||||||
|
|
||||||
return messageReference;
|
return messageReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MessageReference createMessageReferenceWithFlag(String accountUuid, String folderName, String uid,
|
private MessageReference createMessageReferenceWithFlag(String accountUuid, String folderName, String uid,
|
||||||
Flag flag) {
|
Flag flag) {
|
||||||
MessageReference messageReference = new MessageReference();
|
MessageReference messageReference = new MessageReference(accountUuid, folderName, uid, flag);
|
||||||
messageReference.accountUuid = accountUuid;
|
|
||||||
messageReference.folderName = folderName;
|
|
||||||
messageReference.uid = uid;
|
|
||||||
messageReference.flag = flag;
|
|
||||||
|
|
||||||
return messageReference;
|
return messageReference;
|
||||||
}
|
}
|
||||||
|
@ -519,7 +519,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String accountUuid = (mMessageReference != null) ?
|
final String accountUuid = (mMessageReference != null) ?
|
||||||
mMessageReference.accountUuid :
|
mMessageReference.getAccountUuid() :
|
||||||
intent.getStringExtra(EXTRA_ACCOUNT);
|
intent.getStringExtra(EXTRA_ACCOUNT);
|
||||||
|
|
||||||
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
||||||
@ -715,9 +715,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
*/
|
*/
|
||||||
MessagingController.getInstance(getApplication()).addListener(mListener);
|
MessagingController.getInstance(getApplication()).addListener(mListener);
|
||||||
|
|
||||||
final Account account = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
|
final Account account = Preferences.getPreferences(this).getAccount(mMessageReference.getAccountUuid());
|
||||||
final String folderName = mMessageReference.folderName;
|
final String folderName = mMessageReference.getFolderName();
|
||||||
final String sourceMessageUid = mMessageReference.uid;
|
final String sourceMessageUid = mMessageReference.getUid();
|
||||||
MessagingController.getInstance(getApplication()).loadMessageForView(account, folderName, sourceMessageUid, null);
|
MessagingController.getInstance(getApplication()).loadMessageForView(account, folderName, sourceMessageUid, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,7 +727,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mAction == Action.REPLY || mAction == Action.REPLY_ALL) {
|
if (mAction == Action.REPLY || mAction == Action.REPLY_ALL) {
|
||||||
mMessageReference.flag = Flag.ANSWERED;
|
mMessageReference = mMessageReference.withModifiedFlag(Flag.ANSWERED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAction == Action.REPLY || mAction == Action.REPLY_ALL ||
|
if (mAction == Action.REPLY || mAction == Action.REPLY_ALL ||
|
||||||
@ -740,7 +740,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mAction == Action.FORWARD) {
|
if (mAction == Action.FORWARD) {
|
||||||
mMessageReference.flag = Flag.FORWARDED;
|
mMessageReference = mMessageReference.withModifiedFlag(Flag.FORWARDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
final View mEncryptLayout = findViewById(R.id.layout_encrypt);
|
final View mEncryptLayout = findViewById(R.id.layout_encrypt);
|
||||||
@ -1317,15 +1317,15 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
}
|
}
|
||||||
sendMessage();
|
sendMessage();
|
||||||
|
|
||||||
if (mMessageReference != null && mMessageReference.flag != null) {
|
if (mMessageReference != null && mMessageReference.getFlag() != null) {
|
||||||
if (K9.DEBUG) {
|
if (K9.DEBUG) {
|
||||||
Log.d(K9.LOG_TAG, "Setting referenced message (" + mMessageReference.folderName + ", " + mMessageReference.uid + ") flag to " + mMessageReference.flag);
|
Log.d(K9.LOG_TAG, "Setting referenced message (" + mMessageReference.getFolderName() + ", " + mMessageReference.getUid() + ") flag to " + mMessageReference.getFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
final Account account = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
|
final Account account = Preferences.getPreferences(this).getAccount(mMessageReference.getAccountUuid());
|
||||||
final String folderName = mMessageReference.folderName;
|
final String folderName = mMessageReference.getFolderName();
|
||||||
final String sourceMessageUid = mMessageReference.uid;
|
final String sourceMessageUid = mMessageReference.getUid();
|
||||||
MessagingController.getInstance(getApplication()).setFlag(account, folderName, sourceMessageUid, mMessageReference.flag, true);
|
MessagingController.getInstance(getApplication()).setFlag(account, folderName, sourceMessageUid, mMessageReference.getFlag(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDraftNeedsSaving = false;
|
mDraftNeedsSaving = false;
|
||||||
@ -1888,9 +1888,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
if (mMessageReference != null) { // shouldn't happen...
|
if (mMessageReference != null) { // shouldn't happen...
|
||||||
// TODO - Should we check if mSourceMessageBody is already present and bypass the MessagingController call?
|
// TODO - Should we check if mSourceMessageBody is already present and bypass the MessagingController call?
|
||||||
MessagingController.getInstance(getApplication()).addListener(mListener);
|
MessagingController.getInstance(getApplication()).addListener(mListener);
|
||||||
final Account account = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
|
final Account account = Preferences.getPreferences(this).getAccount(mMessageReference.getAccountUuid());
|
||||||
final String folderName = mMessageReference.folderName;
|
final String folderName = mMessageReference.getFolderName();
|
||||||
final String sourceMessageUid = mMessageReference.uid;
|
final String sourceMessageUid = mMessageReference.getUid();
|
||||||
MessagingController.getInstance(getApplication()).loadMessageForView(account, folderName, sourceMessageUid, null);
|
MessagingController.getInstance(getApplication()).loadMessageForView(account, folderName, sourceMessageUid, null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2415,7 +2415,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
|
|
||||||
// Check if this is a valid account in our database
|
// Check if this is a valid account in our database
|
||||||
Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
||||||
Account account = prefs.getAccount(messageReference.accountUuid);
|
Account account = prefs.getAccount(messageReference.getAccountUuid());
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
mMessageReference = messageReference;
|
mMessageReference = messageReference;
|
||||||
}
|
}
|
||||||
@ -2931,7 +2931,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
class Listener extends MessagingListener {
|
class Listener extends MessagingListener {
|
||||||
@Override
|
@Override
|
||||||
public void loadMessageForViewStarted(Account account, String folder, String uid) {
|
public void loadMessageForViewStarted(Account account, String folder, String uid) {
|
||||||
if ((mMessageReference == null) || !mMessageReference.uid.equals(uid)) {
|
if ((mMessageReference == null) || !mMessageReference.getUid().equals(uid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2940,7 +2940,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadMessageForViewFinished(Account account, String folder, String uid, LocalMessage message) {
|
public void loadMessageForViewFinished(Account account, String folder, String uid, LocalMessage message) {
|
||||||
if ((mMessageReference == null) || !mMessageReference.uid.equals(uid)) {
|
if ((mMessageReference == null) || !mMessageReference.getUid().equals(uid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2949,7 +2949,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadMessageForViewBodyAvailable(Account account, String folder, String uid, final Message message) {
|
public void loadMessageForViewBodyAvailable(Account account, String folder, String uid, final Message message) {
|
||||||
if ((mMessageReference == null) || !mMessageReference.uid.equals(uid)) {
|
if ((mMessageReference == null) || !mMessageReference.getUid().equals(uid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2980,7 +2980,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadMessageForViewFailed(Account account, String folder, String uid, Throwable t) {
|
public void loadMessageForViewFailed(Account account, String folder, String uid, Throwable t) {
|
||||||
if ((mMessageReference == null) || !mMessageReference.uid.equals(uid)) {
|
if ((mMessageReference == null) || !mMessageReference.getUid().equals(uid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mHandler.sendEmptyMessage(MSG_PROGRESS_OFF);
|
mHandler.sendEmptyMessage(MSG_PROGRESS_OFF);
|
||||||
@ -2991,13 +2991,13 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
public void messageUidChanged(Account account, String folder, String oldUid, String newUid) {
|
public void messageUidChanged(Account account, String folder, String oldUid, String newUid) {
|
||||||
// Track UID changes of the source message
|
// Track UID changes of the source message
|
||||||
if (mMessageReference != null) {
|
if (mMessageReference != null) {
|
||||||
final Account sourceAccount = Preferences.getPreferences(MessageCompose.this).getAccount(mMessageReference.accountUuid);
|
final Account sourceAccount = Preferences.getPreferences(MessageCompose.this).getAccount(mMessageReference.getAccountUuid());
|
||||||
final String sourceFolder = mMessageReference.folderName;
|
final String sourceFolder = mMessageReference.getFolderName();
|
||||||
final String sourceMessageUid = mMessageReference.uid;
|
final String sourceMessageUid = mMessageReference.getUid();
|
||||||
|
|
||||||
if (account.equals(sourceAccount) && (folder.equals(sourceFolder))) {
|
if (account.equals(sourceAccount) && (folder.equals(sourceFolder))) {
|
||||||
if (oldUid.equals(sourceMessageUid)) {
|
if (oldUid.equals(sourceMessageUid)) {
|
||||||
mMessageReference.uid = newUid;
|
mMessageReference = mMessageReference.withModifiedUid(newUid);
|
||||||
}
|
}
|
||||||
if ((mSourceMessage != null) && (oldUid.equals(mSourceMessage.getUid()))) {
|
if ((mSourceMessage != null) && (oldUid.equals(mSourceMessage.getUid()))) {
|
||||||
mSourceMessage.setUid(newUid);
|
mSourceMessage.setUid(newUid);
|
||||||
@ -3141,7 +3141,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
* to the old message's uid.
|
* to the old message's uid.
|
||||||
*/
|
*/
|
||||||
if (mMessageReference != null) {
|
if (mMessageReference != null) {
|
||||||
message.setUid(mMessageReference.uid);
|
message.setUid(mMessageReference.getUid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,10 +379,9 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
|||||||
Collection<Account> accounts = Preferences.getPreferences(this).getAvailableAccounts();
|
Collection<Account> accounts = Preferences.getPreferences(this).getAvailableAccounts();
|
||||||
for (Account account : accounts) {
|
for (Account account : accounts) {
|
||||||
if (String.valueOf(account.getAccountNumber()).equals(accountId)) {
|
if (String.valueOf(account.getAccountNumber()).equals(accountId)) {
|
||||||
mMessageReference = new MessageReference();
|
String folderName = segmentList.get(1);
|
||||||
mMessageReference.accountUuid = account.getUuid();
|
String messageUid = segmentList.get(2);
|
||||||
mMessageReference.folderName = segmentList.get(1);
|
mMessageReference = new MessageReference(account.getUuid(), folderName, messageUid, null);
|
||||||
mMessageReference.uid = segmentList.get(2);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,8 +430,8 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
|||||||
|
|
||||||
if (mMessageReference != null) {
|
if (mMessageReference != null) {
|
||||||
mSearch = new LocalSearch();
|
mSearch = new LocalSearch();
|
||||||
mSearch.addAccountUuid(mMessageReference.accountUuid);
|
mSearch.addAccountUuid(mMessageReference.getAccountUuid());
|
||||||
mSearch.addAllowedFolder(mMessageReference.folderName);
|
mSearch.addAllowedFolder(mMessageReference.getFolderName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSearch == null) {
|
if (mSearch == null) {
|
||||||
@ -1168,8 +1167,8 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
|||||||
@Override
|
@Override
|
||||||
public void openMessage(MessageReference messageReference) {
|
public void openMessage(MessageReference messageReference) {
|
||||||
Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
||||||
Account account = prefs.getAccount(messageReference.accountUuid);
|
Account account = prefs.getAccount(messageReference.getAccountUuid());
|
||||||
String folderName = messageReference.folderName;
|
String folderName = messageReference.getFolderName();
|
||||||
|
|
||||||
if (folderName.equals(account.getDraftsFolderName())) {
|
if (folderName.equals(account.getDraftsFolderName())) {
|
||||||
MessageCompose.actionEditDraft(this, messageReference);
|
MessageCompose.actionEditDraft(this, messageReference);
|
||||||
|
@ -17,15 +17,20 @@ import com.fsck.k9.mail.filter.Base64;
|
|||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
public class MessageReference implements Parcelable {
|
public class MessageReference implements Parcelable {
|
||||||
public String accountUuid;
|
private final String accountUuid;
|
||||||
public String folderName;
|
private final String folderName;
|
||||||
public String uid;
|
private final String uid;
|
||||||
public Flag flag = null;
|
private final Flag flag;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize an empty MessageReference.
|
* Initialize a new MessageReference.
|
||||||
*/
|
*/
|
||||||
public MessageReference() {
|
public MessageReference(String accountUuid, String folderName, String uid, Flag flag) {
|
||||||
|
this.accountUuid = accountUuid;
|
||||||
|
this.folderName = folderName;
|
||||||
|
this.uid = uid;
|
||||||
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version identifier for use when serializing. This will allow us to introduce future versions
|
// Version identifier for use when serializing. This will allow us to introduce future versions
|
||||||
@ -34,7 +39,7 @@ public class MessageReference implements Parcelable {
|
|||||||
private static final String IDENTITY_SEPARATOR = ":";
|
private static final String IDENTITY_SEPARATOR = ":";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a MessageReference from a seraialized identity.
|
* Initialize a MessageReference from a serialized identity.
|
||||||
* @param identity Serialized identity.
|
* @param identity Serialized identity.
|
||||||
* @throws MessagingException On missing or corrupted identity.
|
* @throws MessagingException On missing or corrupted identity.
|
||||||
*/
|
*/
|
||||||
@ -44,6 +49,10 @@ public class MessageReference implements Parcelable {
|
|||||||
throw new MessagingException("Null or truncated MessageReference identity.");
|
throw new MessagingException("Null or truncated MessageReference identity.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String accountUuid = null;
|
||||||
|
String folderName = null;
|
||||||
|
String uid = null;
|
||||||
|
Flag flag = null;
|
||||||
// Version check.
|
// Version check.
|
||||||
if (identity.charAt(0) == IDENTITY_VERSION_1.charAt(0)) {
|
if (identity.charAt(0) == IDENTITY_VERSION_1.charAt(0)) {
|
||||||
// Split the identity, stripping away the first two characters representing the version and delimiter.
|
// Split the identity, stripping away the first two characters representing the version and delimiter.
|
||||||
@ -62,12 +71,17 @@ public class MessageReference implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (K9.DEBUG)
|
if (K9.DEBUG) {
|
||||||
Log.d(K9.LOG_TAG, "Thawed " + toString());
|
Log.d(K9.LOG_TAG, "Thawed " + toString());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new MessagingException("Invalid MessageReference in " + identity + " identity.");
|
throw new MessagingException("Invalid MessageReference in " + identity + " identity.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.accountUuid = accountUuid;
|
||||||
|
this.folderName = folderName;
|
||||||
|
this.uid = uid;
|
||||||
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,7 +112,7 @@ public class MessageReference implements Parcelable {
|
|||||||
if (o instanceof MessageReference == false) {
|
if (o instanceof MessageReference == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MessageReference other = (MessageReference)o;
|
MessageReference other = (MessageReference) o;
|
||||||
if ((accountUuid == other.accountUuid || (accountUuid != null && accountUuid.equals(other.accountUuid)))
|
if ((accountUuid == other.accountUuid || (accountUuid != null && accountUuid.equals(other.accountUuid)))
|
||||||
&& (folderName == other.folderName || (folderName != null && folderName.equals(other.folderName)))
|
&& (folderName == other.folderName || (folderName != null && folderName.equals(other.folderName)))
|
||||||
&& (uid == other.uid || (uid != null && uid.equals(other.uid)))) {
|
&& (uid == other.uid || (uid != null && uid.equals(other.uid)))) {
|
||||||
@ -156,12 +170,16 @@ public class MessageReference implements Parcelable {
|
|||||||
public static final Creator<MessageReference> CREATOR = new Creator<MessageReference>() {
|
public static final Creator<MessageReference> CREATOR = new Creator<MessageReference>() {
|
||||||
@Override
|
@Override
|
||||||
public MessageReference createFromParcel(Parcel source) {
|
public MessageReference createFromParcel(Parcel source) {
|
||||||
MessageReference ref = new MessageReference();
|
MessageReference ref;
|
||||||
ref.uid = source.readString();
|
String uid = source.readString();
|
||||||
ref.accountUuid = source.readString();
|
String accountUuid = source.readString();
|
||||||
ref.folderName = source.readString();
|
String folderName = source.readString();
|
||||||
String flag = source.readString();
|
String flag = source.readString();
|
||||||
if (flag != null) ref.flag = Flag.valueOf(flag);
|
if (flag != null) {
|
||||||
|
ref = new MessageReference(uid, accountUuid, folderName, Flag.valueOf(flag));
|
||||||
|
} else {
|
||||||
|
ref = new MessageReference(uid, accountUuid, folderName, null);
|
||||||
|
}
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,4 +201,28 @@ public class MessageReference implements Parcelable {
|
|||||||
dest.writeString(folderName);
|
dest.writeString(folderName);
|
||||||
dest.writeString(flag == null ? null : flag.name());
|
dest.writeString(flag == null ? null : flag.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAccountUuid() {
|
||||||
|
return accountUuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFolderName() {
|
||||||
|
return folderName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUid() {
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flag getFlag() {
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageReference withModifiedUid(String newUid) {
|
||||||
|
return new MessageReference(accountUuid, folderName, newUid, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageReference withModifiedFlag(Flag newFlag) {
|
||||||
|
return new MessageReference(accountUuid, folderName, uid, newFlag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4908,7 +4908,7 @@ public class MessagingController implements Runnable {
|
|||||||
String initialFolder = message.getFolder().getName();
|
String initialFolder = message.getFolder().getName();
|
||||||
/* only go to folder if all messages are in the same folder, else go to folder list */
|
/* only go to folder if all messages are in the same folder, else go to folder list */
|
||||||
for (MessageReference ref : allRefs) {
|
for (MessageReference ref : allRefs) {
|
||||||
if (!TextUtils.equals(initialFolder, ref.folderName)) {
|
if (!TextUtils.equals(initialFolder, ref.getFolderName())) {
|
||||||
initialFolder = null;
|
initialFolder = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4980,8 +4980,8 @@ public class MessagingController implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TaskStackBuilder buildMessageViewBackStack(Context context, MessageReference message) {
|
private TaskStackBuilder buildMessageViewBackStack(Context context, MessageReference message) {
|
||||||
Account account = Preferences.getPreferences(context).getAccount(message.accountUuid);
|
Account account = Preferences.getPreferences(context).getAccount(message.getAccountUuid());
|
||||||
TaskStackBuilder stack = buildMessageListBackStack(context, account, message.folderName);
|
TaskStackBuilder stack = buildMessageListBackStack(context, account, message.getFolderName());
|
||||||
stack.addNextIntent(MessageList.actionDisplayMessageIntent(context, message));
|
stack.addNextIntent(MessageList.actionDisplayMessageIntent(context, message));
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
@ -2007,9 +2007,9 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
|||||||
String uid = cursor.getString(UID_COLUMN);
|
String uid = cursor.getString(UID_COLUMN);
|
||||||
String folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
String folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
||||||
|
|
||||||
if (account.getUuid().equals(mActiveMessage.accountUuid) &&
|
if (account.getUuid().equals(mActiveMessage.getAccountUuid()) &&
|
||||||
folderName.equals(mActiveMessage.folderName) &&
|
folderName.equals(mActiveMessage.getFolderName()) &&
|
||||||
uid.equals(mActiveMessage.uid)) {
|
uid.equals(mActiveMessage.getUid())) {
|
||||||
int res = R.attr.messageListActiveItemBackgroundColor;
|
int res = R.attr.messageListActiveItemBackgroundColor;
|
||||||
|
|
||||||
TypedValue outValue = new TypedValue();
|
TypedValue outValue = new TypedValue();
|
||||||
@ -2992,10 +2992,10 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
|||||||
for (int i = 0, len = mAdapter.getCount(); i < len; i++) {
|
for (int i = 0, len = mAdapter.getCount(); i < len; i++) {
|
||||||
Cursor cursor = (Cursor) mAdapter.getItem(i);
|
Cursor cursor = (Cursor) mAdapter.getItem(i);
|
||||||
|
|
||||||
MessageReference ref = new MessageReference();
|
String accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
|
||||||
ref.accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
|
String folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
||||||
ref.folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
String messageUid = cursor.getString(UID_COLUMN);
|
||||||
ref.uid = cursor.getString(UID_COLUMN);
|
MessageReference ref = new MessageReference(accountUuid, folderName, messageUid, null);
|
||||||
|
|
||||||
messageRefs.add(ref);
|
messageRefs.add(ref);
|
||||||
}
|
}
|
||||||
@ -3058,12 +3058,11 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
|||||||
|
|
||||||
private MessageReference getReferenceForPosition(int position) {
|
private MessageReference getReferenceForPosition(int position) {
|
||||||
Cursor cursor = (Cursor) mAdapter.getItem(position);
|
Cursor cursor = (Cursor) mAdapter.getItem(position);
|
||||||
MessageReference ref = new MessageReference();
|
|
||||||
ref.accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
|
|
||||||
ref.folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
|
||||||
ref.uid = cursor.getString(UID_COLUMN);
|
|
||||||
|
|
||||||
return ref;
|
String accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
|
||||||
|
String folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
||||||
|
String messageUid = cursor.getString(UID_COLUMN);
|
||||||
|
return new MessageReference(accountUuid, folderName, messageUid, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openMessageAtPosition(int position) {
|
private void openMessageAtPosition(int position) {
|
||||||
@ -3091,9 +3090,9 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
|||||||
String folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
String folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
||||||
String uid = cursor.getString(UID_COLUMN);
|
String uid = cursor.getString(UID_COLUMN);
|
||||||
|
|
||||||
if (accountUuid.equals(messageReference.accountUuid) &&
|
if (accountUuid.equals(messageReference.getAccountUuid()) &&
|
||||||
folderName.equals(messageReference.folderName) &&
|
folderName.equals(messageReference.getFolderName()) &&
|
||||||
uid.equals(messageReference.uid)) {
|
uid.equals(messageReference.getUid())) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3330,12 +3329,12 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
|||||||
StringBuilder query = new StringBuilder();
|
StringBuilder query = new StringBuilder();
|
||||||
List<String> queryArgs = new ArrayList<String>();
|
List<String> queryArgs = new ArrayList<String>();
|
||||||
if (needConditions) {
|
if (needConditions) {
|
||||||
boolean selectActive = mActiveMessage != null && mActiveMessage.accountUuid.equals(accountUuid);
|
boolean selectActive = mActiveMessage != null && mActiveMessage.getAccountUuid().equals(accountUuid);
|
||||||
|
|
||||||
if (selectActive) {
|
if (selectActive) {
|
||||||
query.append("(" + MessageColumns.UID + " = ? AND " + SpecialColumns.FOLDER_NAME + " = ?) OR (");
|
query.append("(" + MessageColumns.UID + " = ? AND " + SpecialColumns.FOLDER_NAME + " = ?) OR (");
|
||||||
queryArgs.add(mActiveMessage.uid);
|
queryArgs.add(mActiveMessage.getUid());
|
||||||
queryArgs.add(mActiveMessage.folderName);
|
queryArgs.add(mActiveMessage.getFolderName());
|
||||||
}
|
}
|
||||||
|
|
||||||
SqlQueryBuilder.buildWhereClause(account, mSearch.getConditions(), query, queryArgs);
|
SqlQueryBuilder.buildWhereClause(account, mSearch.getConditions(), query, queryArgs);
|
||||||
|
@ -509,10 +509,7 @@ public class LocalMessage extends MimeMessage {
|
|||||||
|
|
||||||
public MessageReference makeMessageReference() {
|
public MessageReference makeMessageReference() {
|
||||||
if (mReference == null) {
|
if (mReference == null) {
|
||||||
mReference = new MessageReference();
|
mReference = new MessageReference(getFolder().getAccountUuid(), getFolder().getName(), mUid, null);
|
||||||
mReference.folderName = getFolder().getName();
|
|
||||||
mReference.uid = mUid;
|
|
||||||
mReference.accountUuid = getFolder().getAccountUuid();
|
|
||||||
}
|
}
|
||||||
return mReference;
|
return mReference;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class NotificationActionService extends CoreService {
|
|||||||
List<MessageReference> refs =
|
List<MessageReference> refs =
|
||||||
intent.getParcelableArrayListExtra(EXTRA_MESSAGE_LIST);
|
intent.getParcelableArrayListExtra(EXTRA_MESSAGE_LIST);
|
||||||
for (MessageReference ref : refs) {
|
for (MessageReference ref : refs) {
|
||||||
controller.setFlag(account, ref.folderName, ref.uid, Flag.SEEN, true);
|
controller.setFlag(account, ref.getFolderName(), ref.getUid(), Flag.SEEN, true);
|
||||||
}
|
}
|
||||||
} else if (DELETE_ALL_ACTION.equals(action)) {
|
} else if (DELETE_ALL_ACTION.equals(action)) {
|
||||||
if (K9.DEBUG)
|
if (K9.DEBUG)
|
||||||
|
@ -55,6 +55,6 @@ public class LocalMessageLoader extends AsyncTaskLoader<LocalMessage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LocalMessage loadMessageFromDatabase() throws MessagingException {
|
private LocalMessage loadMessageFromDatabase() throws MessagingException {
|
||||||
return controller.loadMessage(account, messageReference.folderName, messageReference.uid);
|
return controller.loadMessage(account, messageReference.getFolderName(), messageReference.getUid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,9 +197,8 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
Context appContext = getActivity().getApplicationContext();
|
Context appContext = getActivity().getApplicationContext();
|
||||||
mAccount = Preferences.getPreferences(appContext).getAccount(mMessageReference.accountUuid);
|
mAccount = Preferences.getPreferences(appContext).getAccount(mMessageReference.getAccountUuid());
|
||||||
messageCryptoHelper = new MessageCryptoHelper(getActivity(), mAccount, this);
|
messageCryptoHelper = new MessageCryptoHelper(getActivity(), mAccount, this);
|
||||||
|
|
||||||
if (resetPgpData) {
|
if (resetPgpData) {
|
||||||
// start with fresh, empty PGP data
|
// start with fresh, empty PGP data
|
||||||
mPgpData = new PgpData();
|
mPgpData = new PgpData();
|
||||||
@ -346,7 +345,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refileMessage(String dstFolder) {
|
private void refileMessage(String dstFolder) {
|
||||||
String srcFolder = mMessageReference.folderName;
|
String srcFolder = mMessageReference.getFolderName();
|
||||||
LocalMessage messageToMove = mMessage;
|
LocalMessage messageToMove = mMessage;
|
||||||
mFragmentListener.showNextMessageOrReturn();
|
mFragmentListener.showNextMessageOrReturn();
|
||||||
mController.moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null);
|
mController.moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null);
|
||||||
@ -424,7 +423,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
private void startRefileActivity(int activity) {
|
private void startRefileActivity(int activity) {
|
||||||
Intent intent = new Intent(getActivity(), ChooseFolder.class);
|
Intent intent = new Intent(getActivity(), ChooseFolder.class);
|
||||||
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount.getUuid());
|
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount.getUuid());
|
||||||
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, mMessageReference.folderName);
|
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, mMessageReference.getFolderName());
|
||||||
intent.putExtra(ChooseFolder.EXTRA_SEL_FOLDER, mAccount.getLastSelectedFolderName());
|
intent.putExtra(ChooseFolder.EXTRA_SEL_FOLDER, mAccount.getLastSelectedFolderName());
|
||||||
intent.putExtra(ChooseFolder.EXTRA_MESSAGE, mMessageReference);
|
intent.putExtra(ChooseFolder.EXTRA_MESSAGE, mMessageReference);
|
||||||
startActivityForResult(intent, activity);
|
startActivityForResult(intent, activity);
|
||||||
@ -499,8 +498,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mMessageView.disableDownloadButton();
|
mMessageView.disableDownloadButton();
|
||||||
|
mController.loadMessageForViewRemote(mAccount, mMessageReference.getFolderName(), mMessageReference.getUid(),
|
||||||
mController.loadMessageForViewRemote(mAccount, mMessageReference.folderName, mMessageReference.uid,
|
|
||||||
downloadMessageListener);
|
downloadMessageListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,12 +524,12 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void moveMessage(MessageReference reference, String destFolderName) {
|
public void moveMessage(MessageReference reference, String destFolderName) {
|
||||||
mController.moveMessage(mAccount, mMessageReference.folderName, mMessage,
|
mController.moveMessage(mAccount, mMessageReference.getFolderName(), mMessage,
|
||||||
destFolderName, null);
|
destFolderName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyMessage(MessageReference reference, String destFolderName) {
|
public void copyMessage(MessageReference reference, String destFolderName) {
|
||||||
mController.copyMessage(mAccount, mMessageReference.folderName, mMessage,
|
mController.copyMessage(mAccount, mMessageReference.getFolderName(), mMessage,
|
||||||
destFolderName, null);
|
destFolderName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,12 +642,12 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canMessageBeArchived() {
|
public boolean canMessageBeArchived() {
|
||||||
return (!mMessageReference.folderName.equals(mAccount.getArchiveFolderName())
|
return (!mMessageReference.getFolderName().equals(mAccount.getArchiveFolderName())
|
||||||
&& mAccount.hasArchiveFolder());
|
&& mAccount.hasArchiveFolder());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canMessageBeMovedToSpam() {
|
public boolean canMessageBeMovedToSpam() {
|
||||||
return (!mMessageReference.folderName.equals(mAccount.getSpamFolderName())
|
return (!mMessageReference.getFolderName().equals(mAccount.getSpamFolderName())
|
||||||
&& mAccount.hasSpamFolder());
|
&& mAccount.hasSpamFolder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user