Write reply/forward flags on Controller.sendMessage
- also fix some mixups with the actual icon states Bug: 4947145 Change-Id: Iec1bbfc46ac956a6bf050e4fb162b94ea3c6b316
This commit is contained in:
parent
d8ab562d0d
commit
7891106a7d
@ -294,6 +294,12 @@ public abstract class EmailContent {
|
||||
public String mTextContent;
|
||||
public String mHtmlReply;
|
||||
public String mTextReply;
|
||||
|
||||
/**
|
||||
* Points to the ID of the message being replied to or forwarded. Will always be set,
|
||||
* even if {@link #mHtmlReply} and {@link #mTextReply} are null (indicating the user doesn't
|
||||
* want to include quoted text.
|
||||
*/
|
||||
public long mSourceKey;
|
||||
public String mIntroText;
|
||||
|
||||
@ -680,7 +686,7 @@ public abstract class EmailContent {
|
||||
public String mProtocolSearchInfo;
|
||||
|
||||
// The following transient members may be used while building and manipulating messages,
|
||||
// but they are NOT persisted directly by EmailProvider
|
||||
// but they are NOT persisted directly by EmailProvider. See Body for related fields.
|
||||
transient public String mText;
|
||||
transient public String mHtml;
|
||||
transient public String mTextReply;
|
||||
|
@ -93,8 +93,6 @@ public class Controller {
|
||||
/*package*/ static final String SEARCH_MAILBOX_SERVER_ID = "__search_mailbox__";
|
||||
private static final String WHERE_TYPE_ATTACHMENT =
|
||||
MailboxColumns.TYPE + "=" + Mailbox.TYPE_ATTACHMENT;
|
||||
private static final String WHERE_TYPE_SEARCH =
|
||||
MailboxColumns.TYPE + "=" + Mailbox.TYPE_SEARCH;
|
||||
private static final String WHERE_MAILBOX_KEY = MessageColumns.MAILBOX_KEY + "=?";
|
||||
|
||||
private static final String[] MESSAGEID_TO_ACCOUNTID_PROJECTION = new String[] {
|
||||
@ -554,15 +552,19 @@ public class Controller {
|
||||
* Send a message:
|
||||
* - move the message to Outbox (the message is assumed to be in Drafts).
|
||||
* - EAS service will take it from there
|
||||
* - mark reply/forward state in source message (if any)
|
||||
* - trigger send for POP/IMAP
|
||||
* @param messageId the id of the message to send
|
||||
* @param message the fully populated Message (usually retrieved from the Draft box). Note that
|
||||
* all transient fields (e.g. Body related fields) are also expected to be fully loaded
|
||||
*/
|
||||
public void sendMessage(long messageId, long accountId) {
|
||||
public void sendMessage(Message message) {
|
||||
ContentResolver resolver = mProviderContext.getContentResolver();
|
||||
if (accountId == -1) {
|
||||
long accountId = message.mAccountKey;
|
||||
long messageId = message.mId;
|
||||
if (accountId == Account.NO_ACCOUNT) {
|
||||
accountId = lookupAccountForMessage(messageId);
|
||||
}
|
||||
if (accountId == -1) {
|
||||
if (accountId == Account.NO_ACCOUNT) {
|
||||
// probably the message was not found
|
||||
if (Logging.LOGD) {
|
||||
Email.log("no account found for message " + messageId);
|
||||
@ -576,9 +578,25 @@ public class Controller {
|
||||
cv.put(EmailContent.MessageColumns.MAILBOX_KEY, outboxId);
|
||||
|
||||
// does this need to be SYNCED_CONTENT_URI instead?
|
||||
Uri uri = ContentUris.withAppendedId(EmailContent.Message.CONTENT_URI, messageId);
|
||||
Uri uri = ContentUris.withAppendedId(Message.CONTENT_URI, messageId);
|
||||
resolver.update(uri, cv, null, null);
|
||||
|
||||
// If this is a reply/forward, indicate it as such on the source.
|
||||
long sourceKey = message.mSourceKey;
|
||||
if (sourceKey != Message.NO_MESSAGE) {
|
||||
Message source = Message.restoreMessageWithId(mProviderContext, sourceKey);
|
||||
if (source != null) {
|
||||
boolean isReply = (message.mFlags & Message.FLAG_TYPE_REPLY) != 0;
|
||||
int flagUpdate = isReply ? Message.FLAG_REPLIED_TO : Message.FLAG_FORWARDED;
|
||||
uri = ContentUris.withAppendedId(Message.CONTENT_URI, sourceKey);
|
||||
cv.clear();
|
||||
cv.put(MessageColumns.FLAGS, source.mFlags | flagUpdate);
|
||||
resolver.update(uri, cv, null, null);
|
||||
} else {
|
||||
Log.w(Logging.LOG_TAG, "Unable to find source message for a reply/forward");
|
||||
}
|
||||
}
|
||||
|
||||
sendPendingMessages(accountId);
|
||||
}
|
||||
|
||||
|
@ -1162,8 +1162,8 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||
// Use the Intent to set flags saying this message is a reply or a forward and save the
|
||||
// unique id of the source message
|
||||
if (mSource != null && mQuotedTextBar.getVisibility() == View.VISIBLE) {
|
||||
// If the quote bar is visible; this must either be a reply or forward
|
||||
message.mSourceKey = mSource.mId;
|
||||
// If the quote bar is visible; this must either be a reply or forward
|
||||
// Get the body of the source message here
|
||||
message.mHtmlReply = mSource.mHtml;
|
||||
message.mTextReply = mSource.mText;
|
||||
@ -1195,8 +1195,9 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||
mDraft.mIntroText = null;
|
||||
mDraft.mTextReply = null;
|
||||
mDraft.mHtmlReply = null;
|
||||
mDraft.mSourceKey = 0;
|
||||
mDraft.mFlags &= ~Message.FLAG_TYPE_MASK;
|
||||
|
||||
// Note that mSourceKey is not cleared out as this is still considered a
|
||||
// reply/forward.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1282,7 +1283,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||
Utility.showToast(MessageCompose.this,
|
||||
R.string.message_view_attachment_background_load);
|
||||
}
|
||||
mController.sendMessage(mDraft.mId, mDraft.mAccountKey);
|
||||
mController.sendMessage(mDraft);
|
||||
|
||||
ArrayList<CharSequence> addressTexts = new ArrayList<CharSequence>();
|
||||
addressTexts.add(mToView.getText());
|
||||
|
@ -76,9 +76,6 @@ public class MessageListItem extends View {
|
||||
init(context);
|
||||
}
|
||||
|
||||
// Narrow mode shows sender/snippet and time/favorite stacked to save real estate; due to this,
|
||||
// it is also somewhat taller
|
||||
private static final int MODE_NARROW = MessageListItemCoordinates.NARROW_MODE;
|
||||
// Wide mode shows sender, snippet, time, and favorite spread out across the screen
|
||||
private static final int MODE_WIDE = MessageListItemCoordinates.WIDE_MODE;
|
||||
// Sentinel indicating that the view needs layout
|
||||
@ -357,13 +354,13 @@ public class MessageListItem extends View {
|
||||
|
||||
// Draw the reply state. Draw nothing if neither replied nor forwarded.
|
||||
if (mHasBeenRepliedTo && mHasBeenForwarded) {
|
||||
canvas.drawBitmap(sStateReplied,
|
||||
canvas.drawBitmap(sStateRepliedAndForwarded,
|
||||
mCoordinates.stateX, mCoordinates.stateY, sDefaultPaint);
|
||||
} else if (mHasBeenRepliedTo) {
|
||||
canvas.drawBitmap(sStateForwarded,
|
||||
canvas.drawBitmap(sStateReplied,
|
||||
mCoordinates.stateX, mCoordinates.stateY, sDefaultPaint);
|
||||
} else if (mHasBeenForwarded) {
|
||||
canvas.drawBitmap(sStateRepliedAndForwarded,
|
||||
canvas.drawBitmap(sStateForwarded,
|
||||
mCoordinates.stateX, mCoordinates.stateY, sDefaultPaint);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user