Skip to content

Implement #86 include call history in dialpad#332

Closed
miapuffia wants to merge 11 commits into
FossifyOrg:mainfrom
miapuffia:implement-history-in-dialpad
Closed

Implement #86 include call history in dialpad#332
miapuffia wants to merge 11 commits into
FossifyOrg:mainfrom
miapuffia:implement-history-in-dialpad

Conversation

@miapuffia
Copy link
Copy Markdown
Contributor

@miapuffia miapuffia commented Mar 20, 2025

What is it?

  • Bugfix
  • Feature
  • Codebase improvement

Description of the changes in your PR

  • Added call history to dialpad

Before/After Screenshots/Screen Record

  • Before:
image - After: image

Fixes the following issue(s)

@miapuffia
Copy link
Copy Markdown
Contributor Author

Android development and Kotlin are not my forte, so I'm sure there's much to be desired with my solution. I think ideally there would be an entirely new adapter that could, for example, have a horizontal line between contacts and history to better differentiate them.

Other ideas I have for improvement:

  • Only showing history once a number has started to be entered, to prevent a potentially very large list
  • A setting to toggle the addition of history
  • Putting the call history icon at the end of the letter fast scroller to jump straight to history without adding a bunch of numbers

@naveensingh
Copy link
Copy Markdown
Member

Thanks for your contribution! I presume you are still working on this PR since it's marked as draft? If not:

  • The original request is exactly about "completion results" so yes, call history items shouldn't be displayed until we have something to search for.
  • The way it is implemented now (fetching history + contacts), it'll be too slow for someone with a large call history. We have (basic) lazy-loading on the call history tab for this reason.
  • Yes, there should be at least some indication regarding call history items. I think we can divide the list into two categories e.g. "Contacts" and "Recents"/"Recently called". Adding an adapter that handles contacts as well as recent calls will solve and help with #150.
  • Regarding turning off history, we could add a "Filter" button in top right corner to allow users to choose what they want to include in the search results. This would, again, help with #150.

@miapuffia
Copy link
Copy Markdown
Contributor Author

I submitted it as a draft in anticipation of these changes being necessary.
I'll start working on them, although making a new adapter may be beyond my knowledge.

@naveensingh
Copy link
Copy Markdown
Member

I'll start working on them, although making a new adapter may be beyond my knowledge.

I'm sure you can do it, don't give up so soon ;)

The RecentCallAdapter might help you with it, there's also https://github.com/FossifyOrg/Messages/blob/master/app/src/main/kotlin/org/fossify/messages/adapters/ThreadAdapter.kt

@miapuffia
Copy link
Copy Markdown
Contributor Author

miapuffia commented Mar 23, 2025

I was able to get a stripped down adapter almost working. The header and recent call items work but I can't seem to set the contact items to populate data. I think it's because the contact binding works differently. Can you take a look at what I'm missing?
image

@miapuffia miapuffia marked this pull request as ready for review March 31, 2025 14:49
@miapuffia
Copy link
Copy Markdown
Contributor Author

I was able to fix all the issues I found except one: the fast scroller no longer works. It was getting an index out of bounds error and when I added a length check that fixed the error but caused it to no longer display.

@naveensingh
Copy link
Copy Markdown
Member

Hey, I'll check this soon. What's up with the commit history? :)

@miapuffia
Copy link
Copy Markdown
Contributor Author

Hey, I'll check this soon. What's up with the commit history? :)

Rebase + additional changes. I'm not a git expert; is there a better way to reduce commit clutter?

@naveensingh
Copy link
Copy Markdown
Member

naveensingh commented Apr 2, 2025

The following are your new commits, am I right?

  1. 3493b2b Implement call history in dialpad
  2. 4c83ab4 Fixed formatting
  3. e86fdd9 Added dialpad adapter
  4. efa607c Fixed contact display issues
  5. b43e56c Added back action buttons to dialpad items
  6. eadd6f2 Fixed bugs with dialpad actions
  7. 5f95e08 Remove recents delete action in dialpad
  8. fa98f31 Fixed dialpad item selected visual bug
  9. 5871ca1 Added lazy loading

You might be able to fix it by cherry-picking but I'll do it (if you can't).

@Aga-C
Copy link
Copy Markdown
Contributor

Aga-C commented Apr 2, 2025

You can also squash commits into one. It's easy in GUI clients - just select commits, right-click on them and select Squash. Then you only have to force push and history gets cleaner.

@naveensingh
Copy link
Copy Markdown
Member

Yeah, that also works.

@miapuffia
Copy link
Copy Markdown
Contributor Author

The following are your new commits, am I right?

Looks right.

You can also squash commits into one. It's easy in GUI clients - just select commits, right-click on them and select Squash. Then you only have to force push and history gets cleaner.

Git desktop won't let me squash anything without complaining about merge commits.

@naveensingh naveensingh force-pushed the implement-history-in-dialpad branch from 5871ca1 to df90376 Compare April 12, 2025 16:52
@naveensingh
Copy link
Copy Markdown
Member

Fixed the commits. I have the original history backed up locally just in case.

Will review the code later.

@naveensingh naveensingh self-assigned this May 26, 2025
Copy link
Copy Markdown
Member

@naveensingh naveensingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this works, there is a lot of duplication now. Any change in original adapters will have to be copy-pasted to the new adapter and vice versa. It'll be hard to maintain.

At the moment, I don't have any ideas on how to handle this cleanly. Maybe we can use two RecyclerViews with static text views as headers? That way, we would be able to reuse the existing adapters for contacts and recents, but it's unclear how action mode will work with two adapters in play.

}
}

allCallItems = newItems
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since getContacts and getRecents are async, allCallItems = newItems will execute before the code finishes fetching the items. The current code will work, but it relies on an implicit behavior.

Also, the callback is never being called.

Comment on lines +275 to +279

val privateContacts = MyContactsContentProvider.getContacts(this, privateCursor)
if (privateContacts.isNotEmpty()) {
allCallItems.addAll(privateContacts.map { DialpadItem(it) })
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's happening here.

If the goal is to add private contacts to allCallItems, this should be handled by getContacts, not getRecents.

allCallItems should only be updated in one place. Otherwise, subtle bugs and crashes are possible.

Comment on lines +5 to +61
class DialpadItem {
val id: Int
val header: String?
val isHeaderForContacts: Boolean
val contact: Contact?
val recentCall: RecentCall?
val itemType: DialpadItemType

constructor(header: String, isHeaderForContacts: Boolean) {
this.id = increment()
this.header = header
this.isHeaderForContacts = isHeaderForContacts
this.contact = null
this.recentCall = null
this.itemType = DialpadItemType.HEADER
}

constructor(contact: Contact) {
this.id = increment()
this.header = null
isHeaderForContacts = false
this.contact = contact
this.recentCall = null
this.itemType = DialpadItemType.CONTACT
}

constructor(recentCall: RecentCall) {
this.id = increment()
this.header = null
isHeaderForContacts = false
this.contact = null
this.recentCall = recentCall
this.itemType = DialpadItemType.RECENTCALL
}

fun isHeader(): Boolean = header != null

fun isContact(): Boolean = contact != null

fun isRecentCall(): Boolean = recentCall != null

fun getItemId(): Int = this.id

enum class DialpadItemType {
HEADER,
CONTACT,
RECENTCALL
}

companion object {
private var idCount = 0

fun increment(): Int {
return ++idCount
}
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a sealed class instead? Example:

fun increment(): Int

It's better to use a stable ID than a counter. hashCode() has been used throughout the project for this.

Note: RecentCall already has a getItemId() function.

Comment on lines +245 to +251
newItems.add(DialpadItem("Contacts", true))
newItems.addAll(contacts.map { DialpadItem(it) })
}

getRecents(contacts, loadAllRecents) { recentCalls ->
if (recentCalls.isNotEmpty()) {
newItems.add(DialpadItem("Call History", false))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded strings here. There's already string resources available for both of these.

@naveensingh naveensingh added the waiting for author If the author does not respond, the issue will be closed. Otherwise, the label will be removed. label Jun 6, 2025
@naveensingh naveensingh removed their assignment Jun 9, 2025
@fossifybot
Copy link
Copy Markdown
Contributor

fossifybot Bot commented Jun 20, 2025

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 fossifybot Bot removed the waiting for author If the author does not respond, the issue will be closed. Otherwise, the label will be removed. label Jun 20, 2025
@fossifybot fossifybot Bot closed this Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include numbers from history in dial pad's completion results

3 participants