/** Set message read/unread. */
 public void onMarkMessageAsRead(boolean isRead) {
   if (!isMessageOpen()) return;
   Message message = getMessage();
   if (message.mFlagRead != isRead) {
     message.mFlagRead = isRead;
     getController().setMessageRead(message.mId, isRead);
     if (!isRead) { // Became unread.  We need to close the message.
       mCallback.onMessageSetUnread();
     }
   }
 }
  /** Toggle favorite status and write back to provider */
  private void onClickFavorite() {
    if (!isMessageOpen()) return;
    Message message = getMessage();

    // Update UI
    boolean newFavorite = !message.mFlagFavorite;
    mFavoriteIcon.setImageDrawable(newFavorite ? mFavoriteIconOn : mFavoriteIconOff);

    // Handle accessibility event
    setStarContentDescription(newFavorite);
    mFavoriteIcon.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);

    // Update provider
    message.mFlagFavorite = newFavorite;
    getController().setMessageFavorite(message.mId, newFavorite);
  }
Пример #3
0
 private boolean parseResult(EasEmailSyncParser parser, ArrayList<ContentProviderOperation> ops)
     throws IOException {
   // Get an email sync parser for our incoming message data
   boolean res = false;
   Message msg = new Message();
   while (nextTag(Tags.SEARCH_RESULT) != END) {
     if (tag == Tags.SYNC_CLASS) {
       getValue();
     } else if (tag == Tags.SYNC_COLLECTION_ID) {
       getValue();
     } else if (tag == Tags.SEARCH_LONG_ID) {
       msg.mProtocolSearchInfo = getValue();
     } else if (tag == Tags.SEARCH_PROPERTIES) {
       msg.mAccountKey = mService.mAccount.mId;
       msg.mMailboxKey = mService.mMailbox.mId;
       msg.mFlagLoaded = Message.FLAG_LOADED_COMPLETE;
       parser.pushTag(tag);
       parser.addData(msg, tag);
       if (msg.mHtml != null) {
         msg.mHtml = TextUtilities.highlightTermsInHtml(msg.mHtml, mQuery);
       }
       msg.addSaveOps(ops);
     } else {
       skipTag();
     }
   }
   return res;
 }
Пример #4
0
  /** M: Test the sync function */
  public void testSync() throws IOException {
    ArrayList<Long> ids = setupAccountMailboxAndMessages(4);
    setupSyncParserAndAdapter(mAccount, mMailbox);
    mSyncAdapter.mService = EasSyncService.setupServiceForAccount(mProviderContext, mAccount);
    mSyncAdapter.mService.mMailbox = mMailbox;
    mSyncAdapter.mService.mContentResolver = mResolver;
    MessageMoveRequest req1 = new MessageMoveRequest(ids.get(0), mMailbox.mId);
    FetchMailRequest req2 = new FetchMailRequest(ids.get(1));
    MeetingResponseRequest req3 = new MeetingResponseRequest(ids.get(2), 2);
    Attachment att = new Attachment();
    att.mId = 1;
    att.mLocation = "location1";
    att.mMessageKey = ids.get(3);
    att.mAccountKey = mAccount.mId;
    PartRequest req4 = new PartRequest(att, "dest1", "content1");

    ContentValues cv = new ContentValues();
    cv.put(Message.MAILBOX_KEY, 2);
    mResolver.update(
        ContentUris.withAppendedId(Message.SYNCED_CONTENT_URI, ids.get(0)), cv, null, null);

    Message msg = Message.restoreMessageWithId(mProviderContext, ids.get(2));
    Exchange.sBadSyncKeyMailboxId = mMailbox.mId;
    mSyncAdapter.mService.addRequest(req4);
    mSyncAdapter.mService.sync(mSyncAdapter);
    mSyncAdapter.mService.clearRequests();
    mSyncAdapter.mService.addRequest(req1);
    mSyncAdapter.mService.addRequest(req2);
    mSyncAdapter.mService.addRequest(req3);
    mSyncAdapter.mService.mProtocolVersionDouble = 12.0;
    mSyncAdapter.mService.sync(mSyncAdapter);
    mSyncAdapter.mService.clearRequests();
    mSyncAdapter.mService.addRequest(req4);
    mSyncAdapter.mService.mProtocolVersionDouble = 2.5;
    mSyncAdapter.mService.sync(mSyncAdapter);
    assertEquals(1, mSyncAdapter.mService.getSendStatus());
    assertEquals(Eas.EAS_SYNC_RECOVER, mSyncAdapter.mService.getSnycStatus());
  }
Пример #5
0
  /** M: Create a message for test purposes */
  public static Message setupMessage(
      String name,
      long accountId,
      long mailboxId,
      String msgInfo,
      boolean addBody,
      boolean saveIt,
      Context context,
      boolean starred,
      boolean read) {
    Message message = new Message();

    message.mDisplayName = name;
    message.mMailboxKey = mailboxId;
    message.mAccountKey = accountId;
    message.mFlagRead = read;
    message.mFlagLoaded = Message.FLAG_LOADED_UNLOADED;
    message.mFlagFavorite = starred;
    message.mServerId = "serverid " + name;
    message.mMeetingInfo = msgInfo;
    message.mFlags |= Message.FLAG_TYPE_REPLY;

    if (addBody) {
      message.mText = "body text " + name;
      message.mHtml = "body html " + name;
    }

    if (saveIt) {
      message.save(context);
    }
    return message;
  }
 /** NOTE See the comment on the super method. It's called on a worker thread. */
 @Override
 protected Message openMessageSync(Activity activity) {
   return Message.restoreMessageWithId(activity, getMessageId());
 }