Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 172adeee authored by Daniel Applebaum's avatar Daniel Applebaum
Browse files

Add ability to Flag/Unflag messages. Flagged messages are shown with

a red/bold subject.  Can be done in the FolderMessageList using the
hotkey G (toggle) or by long-pressing the message to bring up the
message context menu.  Can be done while viewing an individual message
by using the hotkey G (toggle).  To-do: add a Flag/Unflag option to a
menu in the individual message view.

Add sending the Answered flag to the IMAP server when replying to a
message.  This is currently done as soon as the reply is started.
Perhaps it would be better to wait until the reply is sent, but that
would require keeping additional state with the draft.  Messages to
which the user has replied are indicated with a white arrow next to
the subject.

To-do: In the MessageView, provide visual indication of Flagged and
Answered states.

parent 5b49112a
Loading
Loading
Loading
Loading
+798 B
Loading image diff...
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@
		android:id="@+id/mark_as_read"
		android:title="@string/mark_as_read_action"
	/>
	<item
		android:id="@+id/flag"
		android:title="@string/flag_action"
	/>
	<item
		android:id="@+id/send_alternate"
		android:title="@string/send_alternate_action"
+5 −2
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@
    <string name="send_alternate_action">Forward (alternate)</string>
    <string name="send_alternate_chooser_title">Choose sender</string>
    
    <string name="flag_action">Flag</string>
    <string name="unflag_action">Unflag</string>
 
    <string name="mark_as_unread_action">Mark as unread</string>
    <string name="move_to_action">Move to</string>
    <string name="folders_action">Folders</string>
@@ -353,8 +356,8 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
    <string name="message_help_key">Del (or D) - Delete\u000AR -
    Reply\u000AA - Reply All\u000AF - Forward\u000AJ or P - Previous
    Message\u000AK, N or space - Next Message\u000AZ - Zoom Out\u000AShift-Z -
    Zoom In</string>
    Zoom In\u000aG - Flag</string>
    <string name="message_list_help_key">Del (or D) - Delete\u000AR -
    Reply\u000AA - Reply All\u000AC - Compose\u000AF - Forward\u000AQ
    Reply\u000AA - Reply All\u000AC - Compose\u000AF - Forward\\u000aG - Flagu000AQ
    - Return to Accounts</string>
</resources>
+11 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public class Account implements Serializable {
    int mAccountNumber;
    boolean mVibrate;
    String mRingtoneUri;
    boolean showOngoing = true;
    
    public enum FolderMode {
    	ALL, FIRST_CLASS, FIRST_AND_SECOND_CLASS, NOT_SECOND_CLASS;
@@ -505,4 +506,14 @@ public class Account implements Serializable {
			mFolderSyncMode = syncMode;
		}

    public boolean isShowOngoing()
    {
      return showOngoing;
    }

    public void setShowOngoing(boolean showOngoing)
    {
      this.showOngoing = showOngoing;
    }

}
+85 −51
Original line number Diff line number Diff line
@@ -87,8 +87,8 @@ public class MessagingController implements Runnable {

    private static final String PENDING_COMMAND_TRASH =
        "com.android.email.MessagingController.trash";
    private static final String PENDING_COMMAND_MARK_READ =
        "com.android.email.MessagingController.markRead";
    private static final String PENDING_COMMAND_SET_FLAG =
        "com.android.email.MessagingController.setFlag";
    private static final String PENDING_COMMAND_APPEND =
        "com.android.email.MessagingController.append";
    private static final String PENDING_COMMAND_MARK_ALL_AS_READ =
@@ -735,12 +735,19 @@ s * critical data as fast as possible, and then we'll fill in the de
              fp.add(FetchProfile.Item.FLAGS);
              remoteFolder.fetch(remoteMessages.toArray(new Message[0]), fp, null);
              for (Message remoteMessage : remoteMessages) {
                boolean messageChanged = false;
                  Message localMessage = localFolder.getMessage(remoteMessage.getUid());
                  if (localMessage == null) {
                      continue;
                  }
                  if (!remoteMessage.isSet(Flag.X_NO_SEEN_INFO) && remoteMessage.isSet(Flag.SEEN) != localMessage.isSet(Flag.SEEN)) {
                      localMessage.setFlag(Flag.SEEN, remoteMessage.isSet(Flag.SEEN));
                  for (Flag flag : new Flag[] { Flag.SEEN, Flag.FLAGGED, Flag.ANSWERED } )
                  {
                    if (remoteMessage.isSet(flag) != localMessage.isSet(flag)) {
                      localMessage.setFlag(flag, remoteMessage.isSet(flag));
                      
                    }
                  }
                  if (messageChanged) {
                    for (MessagingListener l : getListeners()) {
                      l.synchronizeMailboxNewMessage(account, folder, localMessage);
                    }
@@ -1071,8 +1078,8 @@ s * critical data as fast as possible, and then we'll fill in the de
	            if (PENDING_COMMAND_APPEND.equals(command.command)) {
	                processPendingAppend(command, account);
	            }
	            else if (PENDING_COMMAND_MARK_READ.equals(command.command)) {
	                processPendingMarkRead(command, account);
	            else if (PENDING_COMMAND_SET_FLAG.equals(command.command)) {
	                processPendingSetFlag(command, account);
	            }
	            else if (PENDING_COMMAND_MARK_ALL_AS_READ.equals(command.command)) {
                processPendingMarkAllAsRead(command, account);
@@ -1286,7 +1293,7 @@ s * critical data as fast as possible, and then we'll fill in the de
     * @param command arguments = (String folder, String uid, boolean read)
     * @param account
     */
    private void processPendingMarkRead(PendingCommand command, Account account)
    private void processPendingSetFlag(PendingCommand command, Account account)
            throws MessagingException {
        String folder = command.arguments[0];
        String uid = command.arguments[1];
@@ -1296,7 +1303,9 @@ s * critical data as fast as possible, and then we'll fill in the de
    			return;
    		}
        
        boolean read = Boolean.parseBoolean(command.arguments[2]);
        boolean newState = Boolean.parseBoolean(command.arguments[2]);
        
        Flag flag = Flag.valueOf(command.arguments[3]);

        Store remoteStore = Store.getInstance(account.getStoreUri(), mApplication);
        Folder remoteFolder = remoteStore.getFolder(folder);
@@ -1315,7 +1324,7 @@ s * critical data as fast as possible, and then we'll fill in the de
        if (remoteMessage == null) {
            return;
        }
        remoteMessage.setFlag(Flag.SEEN, read);
        remoteMessage.setFlag(flag, newState);
    }
    
    private void processPendingMarkAllAsRead(PendingCommand command, Account account) throws MessagingException {
@@ -1437,6 +1446,9 @@ s * critical data as fast as possible, and then we'll fill in the de
      processPendingCommands(account);
    }

    
    
    
    /**
     * Mark the message with the given account, folder and uid either Seen or not Seen.
     * @param account
@@ -1449,13 +1461,27 @@ s * critical data as fast as possible, and then we'll fill in the de
            final String folder,
            final String uid,
            final boolean seen) {
      setMessageFlag(account, folder, uid, Flag.SEEN, seen);
    }
    
    
    public void setMessageFlag(
        final Account account,
        final String folder,
        final String uid,
        final Flag flag,
        boolean newState) {
        try {
            Store localStore = Store.getInstance(account.getLocalStoreUri(), mApplication);
            Folder localFolder = localStore.getFolder(folder);
            localFolder.open(OpenMode.READ_WRITE);

            Message message = localFolder.getMessage(uid);
            message.setFlag(Flag.SEEN, seen);
            message.setFlag(flag, newState);
            
            for (MessagingListener l : getListeners()) {
              l.folderStatusChanged(account, folder);
          }
            
            if (account.getErrorFolderName().equals(folder))
        		{
@@ -1463,8 +1489,8 @@ s * critical data as fast as possible, and then we'll fill in the de
        		}
            
            PendingCommand command = new PendingCommand();
            command.command = PENDING_COMMAND_MARK_READ;
            command.arguments = new String[] { folder, uid, Boolean.toString(seen) };
            command.command = PENDING_COMMAND_SET_FLAG;
            command.arguments = new String[] { folder, uid, Boolean.toString(newState), flag.toString() };
            queuePendingCommand(account, command);
            processPendingCommands(account);
        }
@@ -1951,8 +1977,8 @@ s * critical data as fast as possible, and then we'll fill in the de
            else if (account.getDeletePolicy() == Account.DELETE_POLICY_MARK_AS_READ)
            {
              PendingCommand command = new PendingCommand();
              command.command = PENDING_COMMAND_MARK_READ;
              command.arguments = new String[] { folder, message.getUid(), Boolean.toString(true) };
              command.command = PENDING_COMMAND_SET_FLAG;
              command.arguments = new String[] { folder, message.getUid(), Boolean.toString(true), Flag.SEEN.toString() };
              queuePendingCommand(account, command);
              processPendingCommands(account);
            }
@@ -2108,6 +2134,7 @@ s * critical data as fast as possible, and then we'll fill in the de
	                  	}
                    	putBackground("sendPending " + account.getDescription(), null, new Runnable() {
                        public void run() {
                          if (account.isShowOngoing()) {
                            Notification notif = new Notification(R.drawable.ic_menu_refresh, 
                                context.getString(R.string.notification_bg_send_ticker, account.getDescription()), System.currentTimeMillis());                         
                            Intent intent = FolderMessageList.actionHandleAccountIntent(context, account, Email.INBOX);
@@ -2124,15 +2151,18 @@ s * critical data as fast as possible, and then we'll fill in the de
                              }
                              
                              notifMgr.notify(Email.FETCHING_EMAIL_NOTIFICATION_ID, notif);
                          }
                          try
                          {
                            sendPendingMessagesSynchronous(account);
                          }
                        	finally {
                        	  if (account.showOngoing) {
                        	    notifMgr.cancel(Email.FETCHING_EMAIL_NOTIFICATION_ID);
                        	  }
                          }
                        }
                    	}
                    	);
	                    try
	                    {
@@ -2221,6 +2251,7 @@ s * critical data as fast as possible, and then we'll fill in the de
				                    			}
				                    			return;
				                    		}
				                    		if (account.isShowOngoing()) {
  				                    		Notification notif = new Notification(R.drawable.ic_menu_refresh, 
  				                    		    context.getString(R.string.notification_bg_sync_ticker, account.getDescription(), folder.getName()), 
  				                    		    System.currentTimeMillis());                         
@@ -2237,13 +2268,16 @@ s * critical data as fast as possible, and then we'll fill in the de
  			                            }
  
  			                            notifMgr.notify(Email.FETCHING_EMAIL_NOTIFICATION_ID, notif);
				                    		}
			                          try
			                          {
			                            synchronizeMailboxSynchronous(account, folder.getName());
			                          }
				                    	  
		                            finally {
		                              if (account.isShowOngoing()) {
		                                notifMgr.cancel(Email.FETCHING_EMAIL_NOTIFICATION_ID);
		                              }
		                            }
				                    	}
				                    	catch (Exception e)
Loading