-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IMAP Keywords (rebased) #558
Conversation
…x to allow all flags to be retrieved by valueOfByRealName() just in case.
Changes: * Current codebase has a new "FORWARDED" flag * Since Flag is no longer an enum, use another container (HashSet instead of EnumSet) * Direct (dumb) translation of ImapStore.search(). Don't quite like it right now. * Remove MessagingController.SYNC_FLAGS so that all flags are sync'd (not entirely sure this works the way I think it does, though).
Also, fix wrong translation of switch statement (must not break when encountering default flags).
Adds a label+field after "Cc:" listing all user-defined imap keywords in the message.
public static Flag valueOf(String internalName) throws IllegalArgumentException { | ||
try { | ||
// the argument being 'null' implies we look for a static field | ||
return (Flag)(Flag.class.getField(internalName).get(null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than reflection here, I would extract the internal flags listed in valueOfByRealName into a method returning a set of Strings and see if it contains internalName.
You can ensure the new method is kept in sync with the actual fields in a unit test.The unit test can use reflection to enumerate Flag's fields without concern about performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like k9mail/src/androidTest/java/com/fsck/k9/mailstore/LocalMessageTest.java ?
How would it account for new flags showing up during the imap session, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@igoralmeida I've added an example of how you could do it here
https://github.com/artbristol/k-9/tree/art/keywords-swap-reflection-to-unit-test
Guys, thanks for the feedback. Could you also give me some pointers regarding the tag<->keyword mapping I mentioned? This is how alpine does, for example. |
another important thing (IMHO) is naming. this PR mentions |
Here's my take: "flags" are hard-coded IMAP message attributes (SEEN, ANSWERED, RECENT, etc.) "[user-defined] keywords" live on the IMAP server as well, but can be created by the IMAP client "tags" are user-facing text that relate to IMAP keywords. I'm thinking a dictionary-like mapping {'$label1':'TODO', 'some_keyw':'Some Keyword'} "labels" should be avoided here due to Gmail's implementation and UI, which uses IMAP folders instead of keywords. Also, Thunderbird will unfortunately use '$label1...5' for some keywords, but I believe that's understandable given the context. Thus, the UI should use Tags consistently, while showing the term keyword only on some account configuration activity that maps Keyword to Tag + (possibly) Color. |
One of the last features that I miss personally. A feature like this is mostly about the UI and how to present tags to the user in a useful way. Does anyone know of mobile mail clients that already support this? I like the way Thunderbird handles this (color and GUI "labels"), but I'm not sure whether this is applicable on mobile devices. |
per artbristol's recommendation in issue 558
…it-test' into keywords
Latest push: merged @artbristol 's consistency/test code + answer comments here. |
I could not reproduce the problem fully, but I'm almost sure it was due to removing some X_.... flags. If I understand correctly, those are supposed to be local to k-9 only. Anyway, I believe it's fixed now. Whenever messages have user-defined keywords, they will show up in the header in the message view activity. |
Some ramblings... I've been looking into the keyword->tag mapping functionality and how things would look like in StoreSchemaDefinition and the fetching code. The next idea would be a single Regardless of the design, And, finally, another approach that occurred to me was adding the tags to LocalMessage directly, probably in LocalMessage.populateFromGetMessageCursor. In this case, I think I need to create some kind of "TagStore" similar to LocalStore so I can discover the tags as the keywords appear. If anyone can explain the current architecture and/or comment on the approaches above, I'd be happy to read. |
This maps name->Flag, to avoid duplication of objects, and adds a "tag name" attribute to the Flag class. The UI now uses this field instead of the name. The memory mapping is updated at every call to MessagingController.checkMailForAccount(). Probably not the right place.
This creates a very simple activity (shamelessly copying from FolderList) to present a listing of imap keywords and their corresponding tags from the memory map. Read-only, for now. To access the activity, click the Tags label (or any of the items) in the message header. Also, change Flag.REMEMBERED_KEYWORDS to LinkedHashMap to maintain iteration order.
This "works" (read-only). Kind of ugly. Contributions, especially to the UI, are very welcome. |
User can edit the tag names for imap keywords that k-9 picks up when reading/syncing local messages. Usability still sucks and the UI has too many quirks (lost focus, cursor not updated, saving to memory only when leaving the activity...)
Tag names survive resets. Still barely usable: need somebody with actual android UI skills.
I think adventurous people can start poking now, despite the annoying usability problems:
I'm trying to get the most basic functionality working (reading keywords from the server and customizing the tags locally) first. I'd love ideas and patches to fix the most pressing usability problems, but I'm much more interested in making the internals good enough for a merge, possibly with a big "EXPERIMENTAL" sign next to some preference to enable the UI bits. |
Coming from Thunderbird, I would say you need:
|
Please take care to not make the implementation so Thunderbird-specific as to conflict with other MUAs' interfaces. Also, there are a number of registered keywords whose treatment should be special-cased: http://www.iana.org/assignments/imap-keywords/imap-keywords.xhtml (There are also a lot of non-registered $keywords used by various servers and clients; I'd think special-casing them would not be advised, as their use is not standardized.) Furthermore: not all IMAP servers support arbitrary keywords (Exchange...), so giving people the option of setting them there must be disabled. |
On 11/13/2015 08:04 AM, Erik Quaeghebeur wrote:
Igor Almeida |
Would it be appreciated if we start a BountySource reward on this bug and bug 769? |
@PanderMusubi Yes. |
I noticed that bounties are not often collected even though there are a lot out there, see https://www.bountysource.com/teams/k9mail By the way, since this issue is closed, I cannot add to a bounty on this issue... |
Closing - needs further work, rebase and discussion. See #2260 |
This is a rebase of #146 on top of current master, also adding the ability to list the tags in the message view.
I have no intention of merging this as-is, but hopefully this is a good starting point to discuss the functionality.
For example: the actual listing should use a mapping so that the user sees tags, not the IMAP keywords themselves ($label1, $label2, some_keyword, ...), but I don't have enough android experience to do this yet.
Please comment.