Phone icon indicating copy to clipboard operation
Phone copied to clipboard

Add dynamic shortcuts for starred contacts

Open Grafcube opened this issue 1 year ago • 11 comments

What is it?

  • [ ] Bugfix
  • [x] Feature
  • [ ] Codebase improvement

Description of the changes in your PR

  • It uses the custom sorting if set.
  • It uses ACTION_DIAL instead of ACTION_CALL if calling permission is denied.

Fixes the following issue(s)

  • Fixes #248

Acknowledgement

Grafcube avatar Sep 28 '24 12:09 Grafcube

I think that visible shortcuts should always be the first ones according to current sorting of Favorites tab. For example, if I sort descending by name, I want to see in shortcuts three first items by that sorting, not by the default one; if I use custom sorting, I want to have specific contacts visible at the top, so also in shortcuts.

Aga-C avatar Sep 28 '24 13:09 Aga-C

Done! I recall sorting the list at first but I must have accidentally removed it while refactoring.

Grafcube avatar Sep 28 '24 13:09 Grafcube

I've downloaded your latest changes and sorting is still not applied. See screenshots:

obraz

obraz

Also, there are two other bugs:

  • Changing sorting doesn't invoke refreshing shortcuts.
  • After fresh installation of the app, there are no shortcuts at all. I have to add/remove any contact from favorites first.

Aga-C avatar Sep 28 '24 13:09 Aga-C

The changes aren't applied immediately. It's called onResume so it'll apply if you close the app and reopen it (you don't have to fully close it, you can open it through recents as well).

I have to add/remove any contact from favorites first.

I didn't need to add/remove anything when I was testing it so I'm not sure why that's happening.

Grafcube avatar Sep 28 '24 13:09 Grafcube

I did it, and sorting is still not applied.

Aga-C avatar Sep 28 '24 13:09 Aga-C

I just tested it again with a fresh install and it seems to work fine. It only shows up after the second or third time I open the app after a fresh install, but after that it reflects sorting changes relatively quickly.

I'm not sure where the issue is happening.

Edit: Just to clarify, I'm talking about the sorting in the Favourites tab.

Grafcube avatar Sep 28 '24 13:09 Grafcube

@Aga-C can you test out the latest commit? It should work now.

Grafcube avatar Oct 01 '24 10:10 Grafcube

But you still haven't solved a problem, which is in your code:

                if (order.isEmpty()) {
                    starred.sorted()
                } else {
                    val orderList = Converters().jsonToStringList(order).withIndex().associate { it.value to it.index }
                    starred.sortedBy { orderList[it.contactId.toString()] }
                }

You always assume, that if order is set, that's the only way to sort, while you should check config.isCustomOrderSelected. That's why I haven't seen changes - I had order set, but I was changing sorting to different from custom.

Aga-C avatar Oct 01 '24 10:10 Aga-C

I see. Sorry about that, it seems like I fundamentally misunderstood the issue. It should be fixed now.

Grafcube avatar Oct 01 '24 10:10 Grafcube

It still doesn't show the first three items from the current sorting. Check the recording below:

https://github.com/user-attachments/assets/947fd237-eec3-4480-8c3f-e269ffc2a9c9

Also, one of these contacts (Test Hmm) is created as a private contact. It should still display it.

Aga-C avatar Oct 01 '24 11:10 Aga-C

At this point, I genuinely have no idea where the problem is. I'm just not encountering that issue so I have no way to debug it.

Grafcube avatar Oct 01 '24 11:10 Grafcube

I can reproduce the sorting issue as well. Sometimes, I get shortcuts that are not even on my favorite list. Restarting the app doesn't help. It's probably because you are relying on cachedContacts, which is not even initialized when pushStarredShortcuts() is called on resume.

Also, it should directly initiate a call instead of asking for a phone app.

naveensingh avatar Jun 05 '25 09:06 naveensingh

This pull request was automatically closed due to inactivity and/or lack of response from the author. If you have further updates or additional information, please comment or reopen the PR to continue.

fossifybot[bot] avatar Jun 19 '25 12:06 fossifybot[bot]