Multi-IM support, email support
This is a draft to enable multi im support #1660 and mail support #1656 and should be extended in future to allow replacing of default messaging of phone contacts as @Neamar thought of.
This adds some basic functionality so any contact details can be shown as result in KISS. Regardless of whether that is from any messaging app, mail, phone or anywhere else. As default only phone contacts are show, so nothing will change in first place. Also it was a little bit trickier than expected because messaging apps use their own mime types and not the provided ones. So for custom mimetypes this is working pretty well, other ones (CommonDataKinds.SipAddress, CommonDataKinds.Im, CommonDataKinds.Website, ...) may be handled separated if requested.
Following changes are done:
- existing mime types are loaded from contacts (IM, Mail, Phone, ...)
- extended ContactPojo to hold additional data by mime type
- as this may lead to ContactPojo that has no phone but mime type only there were additional null checks added
- added basic settings to select any mime type that should be shown as separated contact (phone only is default)
- ContactsProvider was extended so result also considers mimetype
- LoadContactsPojos was refactored, so basic data is fetched only once and then all ContactsPojo are created dependent on selected mime types (phone contacts are handled separately)
- ContactsResult was changed, it now has the ability to show following contacts: -- contacts with phone only -> phone button + message button -- contacts with mime type data only -> message button only that calls mime type intent -- contacts with phone and mime type data -> phone button + mime type intent that calls mime type intent -- instead of phone number the detail text of contact is show (set by messaging apps)
- added MimeTypeUtils, for basic handling of mime type related data -- methods for handling mime types -- methods for intent handling -- methods for fetching mime type related data from sync adapters, messaging apps, ...
There's also lots of work left:
- general code review needs to be done
- especially for some classes that needs to be renamed/relocated
- performance needs to be checked
- maybe calculation of result needs to be changed
- contacts should have separate messaging icons so it's clear which app will be called, maybe we use app icon or add badge similar to shortcuts. Maybe @TBog can help here, as i'm not sure how this can be handled.
- settings should be refined
- layout needs to be checked, some mail addresses and some telegram infos are a little too long on my screen.
Bur for first version it's working pretty well, i already enabled telegram messages and mail on my daily driver and i have to say:
I love it 😄

Hello! I did not react yet, cause I know this one will take me some time to test and review. I'm building it on my everyday device to test :)
Haven't looked at the code yet, but a couple thoughts:
- we're overdue for a reorg of settings. I think we should have two new "top level" setting categories: "app settings" (icon pack, shortcuts, ...) and "contact settings" (contact behavior on click, contact shape, and this new setting).
- I went in the settings and enabled some MimeTypes, didn't see anything change. Restarted KISS, still no changes :( Do I need to do something more?
* we're overdue for a reorg of settings. I think we should have two new "top level" setting categories: "app settings" (icon pack, shortcuts, ...) and "contact settings" (contact behavior on click, contact shape, and this new setting).
Should this reorganization be done before extension with mime types/IM?
* I went in the settings and enabled some MimeTypes, didn't see anything change. Restarted KISS, still no changes :( Do I need to do something more?
All in all there shouldn't be anything else to do than just enable additional mime types to show them, but:
- i forgot to push some changes, now restart shouldn't be necessary any more
- i also didn't realized i have swapped labels shown related mime types in settings, sorry for this, this came up only when going to settings again.
I just added an app icon to contacts so one can distinct easily between contacts for different messaging apps.
I tried to keep it similar to existing results, so it is shown like the app icon badge for shortcuts for now:

@Neamar Were you able to get it up and running on your device? Else i have to invest some more time here.
As i had no issues in last weeks with running these changes, so currently it feels like a solid base for any upcoming messaging extensions to me. Therefore: ready for review from my side 😁
Sorry, no progress on my side :'(
Hello! Really sorry it took me so long to get back to you.
I checked out the last version, and I'm still only seeing one line per contact :(
I guess I must be missing something, but I'm not sure what.
Here is an example: searching for a contact...

I'm only seeing one result, but I should at least see Signal too (and this contact also uses Telegram and Signal).
From the contacts app, we can see WA:

And from Signal:

Ok, there may be some things to check
- First off all settings: there is now "Select contacts to be shown" where you should see a list of all mimetypes of your contacts for which an app can handle intents.
- This must not be empty, there should be phone and some more. In my case it looks like this, i have contacts for mail, phone and telegram shown:

-
There you can enable/disable contacts, phone is the onyl one that is selected by default, all others are not.
-
ff some mimetype isn't there, there are no contacts that uses them, this may be e.g. if sync is disabled.
-
If there are multiple mime types per app these are shown with dedicated mimetype in brackets (ugly in my opinion, but there is no possibility to distinct)
-
Handling of these mime types is partially logged too, so you should see how many there are, how long it took to load contacts, ...
2021-04-28 13:21:32.928 31998-32061/fr.neamar.kiss.debug I/time: 98 milliseconds to load 7 supported mime types -> all mimetypes
2021-04-28 13:21:32.929 31998-32061/fr.neamar.kiss.debug I/time: 100 milliseconds to load 3 active mime types -> all mimetypes that can be handled by apps
2021-04-28 13:21:33.222 31998-32061/fr.neamar.kiss.debug I/time: 189 milliseconds to list contacts for vnd.android.cursor.item/phone_v2
2021-04-28 13:21:33.488 31998-32061/fr.neamar.kiss.debug I/time: 265 milliseconds to list contacts for vnd.android.cursor.item/email_v2
2021-04-28 13:21:33.529 31998-32061/fr.neamar.kiss.debug I/time: 40 milliseconds to list contacts for vnd.android.cursor.item/vnd.org.telegram.messenger.android.profile
2021-04-28 13:21:33.529 31998-32061/fr.neamar.kiss.debug I/time: 702 milliseconds to list all contacts
- if you can debug it, there are some methods where i would put breakpoints:
MimeTypeUtils.getSupportedMimeTypes: must return all mime types from your contacts, for signal contacts there has to be one containing "vnd.org.thoughtcrime.securesms.contact"MimeTypeUtils.getActiveMimeTypes: if you enable signal contact in settings there also must be something containing "vnd.org.thoughtcrime.securesms.contact"LoadContactsPojos.createGenericContactsthis must be called for "vnd.org.thoughtcrime.securesms.contact" too
Thanks for your help! I... did not enable the setting ;)
I'm now seeing whatsapp contact, which is already amazing! For some reason, Telegram did not appear in the mimetype list. Signal does appear, but I'm not seeing any contact for them. I'll check if there is an option to sync with the address book or similar.
Will keep you posted!
Currently it's only possible to show data that is synced to contacts in any way.
But it shouldn't be that much effort to add some predefined mimetypes, e.g for telegram or whatsapp, in a future change. These could also be used to build messaging intents with phone numbers and if there is any app that can handle the intent, it will be shown 😁
That makes sense! I've investigated a little more, and I'm seeing the flag added to some contacts, not the bulk of them.
I guess that could be a good first step, understanding the limitation from each provider first. Whatsapp seems to be doing a good job (at least on my phone), Signal a mixed one (I'd say 60% of my contacts are missing) and Telegram is just crap (but that might be because I use Telegram X)
Curious about other experiences
How's progress looking on this one? Are there by chance @marunjar builds available somewhere to check them out? I'm curious to see if it works with Element (matrix) contacts.
How's progress looking on this one? Are there by chance @marunjar builds available somewhere to check them out? I'm curious to see if it works with Element (matrix) contacts.
Sorry for the delay. I'm not sure if there are any CI builds for pull requests that produce an app to download and test. But here is the (zipped 🙁) debug build i'm currently running if you really want to give it a try: app-debug.zip
Good morning gentlemen I'm wondering why generate other search result for IM contact... Is it not possible to add button on the original contact result? So it would be like: Guillaume Besson {signal} {video call} {sms} {call} Thanx for your work
I have (for example) multiple chat applications. It would be impossible to fit all icons on one result.
Another benefit is that when you use a result it will get recorded in history and will have higher score on the next search.
This PR is inactive because it has been open 60 days with no activity.
Remove inactive label or comment or this will be closed in 14 days.'