Skip to content

Commit e9a19cc

Browse files
authored
fix: improve speed dial UX (#546)
* Show the contact name in the confirmation dialog after speed dialing #543 * Improved speed dial management UX for contacts with multiple numbers Refs: #543
1 parent 329bfe1 commit e9a19cc

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Changed
1212
- Tapping a contact now starts a call; tap the photo for details ([#80])
13+
- Improved speed dial management UX for contacts with multiple numbers
14+
15+
### Fixed
16+
- Fixed speed dial not showing contact name ([#543])
1317

1418
## [1.6.2] - 2025-08-23
1519
### Changed
@@ -179,6 +183,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
179183
[#378]: https://github.com/FossifyOrg/Phone/issues/378
180184
[#526]: https://github.com/FossifyOrg/Phone/issues/526
181185
[#535]: https://github.com/FossifyOrg/Phone/issues/535
186+
[#543]: https://github.com/FossifyOrg/Phone/issues/543
182187

183188
[Unreleased]: https://github.com/FossifyOrg/Phone/compare/1.6.2...HEAD
184189
[1.6.2]: https://github.com/FossifyOrg/Phone/compare/1.6.1...1.6.2

app/src/main/kotlin/org/fossify/phone/activities/DialpadActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ class DialpadActivity : SimpleActivity() {
376376
}
377377
}
378378

379-
private fun initCall(number: String = binding.dialpadInput.value) {
379+
private fun initCall(number: String = binding.dialpadInput.value, name: String? = null) {
380380
if (number.isNotEmpty()) {
381-
startCallWithConfirmationCheck(number, number)
381+
startCallWithConfirmationCheck(number, name ?: number)
382382
clearInputWithDelay()
383383
} else {
384384
RecentsHelper(this).getRecentCalls(queryLimit = 1) {
@@ -410,7 +410,7 @@ class DialpadActivity : SimpleActivity() {
410410
if (binding.dialpadInput.value.length == 1) {
411411
val speedDial = speedDialValues.firstOrNull { it.id == id }
412412
if (speedDial?.isValid() == true) {
413-
initCall(speedDial.number)
413+
initCall(speedDial.number, speedDial.getName(this))
414414
return true
415415
}
416416
}

app/src/main/kotlin/org/fossify/phone/activities/ManageSpeedDialActivity.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.os.Bundle
44
import com.google.gson.Gson
55
import org.fossify.commons.dialogs.RadioGroupDialog
66
import org.fossify.commons.extensions.getMyContactsCursor
7+
import org.fossify.commons.extensions.getPhoneNumberTypeText
78
import org.fossify.commons.extensions.updateTextColors
89
import org.fossify.commons.extensions.viewBinding
910
import org.fossify.commons.helpers.ContactsHelper
@@ -71,7 +72,7 @@ class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
7172
SelectContactDialog(this, allContacts) { selectedContact ->
7273
if (selectedContact.phoneNumbers.size > 1) {
7374
val radioItems = selectedContact.phoneNumbers.mapIndexed { index, item ->
74-
RadioItem(index, item.normalizedNumber, item)
75+
RadioItem(index, "${item.value} (${getPhoneNumberTypeText(item.type, item.label)})", item)
7576
}
7677
val userPhoneNumbersList = selectedContact.phoneNumbers.map { it.value }
7778
val checkedItemId = userPhoneNumbersList.indexOf(clickedContact.number)
@@ -80,6 +81,8 @@ class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
8081
speedDialValues.first { it.id == clickedContact.id }.apply {
8182
displayName = selectedContact.getNameToDisplay()
8283
number = selectedNumber.normalizedNumber
84+
type = selectedNumber.type
85+
label = selectedNumber.label
8386
}
8487
updateAdapter()
8588
}
@@ -102,6 +105,8 @@ class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
102105
speedDialValues.first { it.id == dialId }.apply {
103106
displayName = ""
104107
number = ""
108+
type = null
109+
label = null
105110
}
106111
}
107112
updateAdapter()

app/src/main/kotlin/org/fossify/phone/adapters/SpeedDialAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SpeedDialAdapter(
7070
private fun setupView(binding: ItemSpeedDialBinding, speedDial: SpeedDial) {
7171
binding.apply {
7272
var displayName = "${speedDial.id}. "
73-
displayName += if (speedDial.isValid()) speedDial.displayName else ""
73+
displayName += if (speedDial.isValid()) speedDial.getName(activity) else ""
7474

7575
speedDialLabel.apply {
7676
text = displayName
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
package org.fossify.phone.models
22

3-
data class SpeedDial(val id: Int, var number: String, var displayName: String) {
3+
import android.content.Context
4+
import org.fossify.commons.extensions.getPhoneNumberTypeText
5+
6+
data class SpeedDial(
7+
val id: Int,
8+
var number: String,
9+
var displayName: String,
10+
var type: Int? = null,
11+
var label: String? = null
12+
) {
413
fun isValid() = number.trim().isNotEmpty()
14+
15+
fun getName(context: Context) = if (type != null && label != null) {
16+
"$displayName - ${context.getPhoneNumberTypeText(type!!, label!!)}"
17+
} else {
18+
displayName
19+
}
520
}

0 commit comments

Comments
 (0)