mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
Merge pull request #588 from ismailnurudeen/fix/dialer-issues
Fix/dialer shortcut & call confirmation dialog
This commit is contained in:
@@ -20,6 +20,7 @@ import android.view.ViewConfiguration
|
|||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
|
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.contacts.Contact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
@@ -287,7 +288,14 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ContactsAdapter(this, filtered, dialpad_list, null, text) {
|
ContactsAdapter(this, filtered, dialpad_list, null, text) {
|
||||||
startCallIntent((it as Contact).phoneNumbers.first().normalizedNumber)
|
val contact = it as Contact
|
||||||
|
if (config.showCallConfirmation) {
|
||||||
|
CallConfirmationDialog(this@DialpadActivity, contact.getNameToDisplay()) {
|
||||||
|
startCallIntent(contact.getPrimaryNumber() ?: return@CallConfirmationDialog)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
startCallIntent(contact.getPrimaryNumber() ?: return@ContactsAdapter)
|
||||||
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
dialpad_list.adapter = this
|
dialpad_list.adapter = this
|
||||||
}
|
}
|
||||||
@@ -306,10 +314,22 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
private fun initCall(number: String = dialpad_input.value, handleIndex: Int) {
|
private fun initCall(number: String = dialpad_input.value, handleIndex: Int) {
|
||||||
if (number.isNotEmpty()) {
|
if (number.isNotEmpty()) {
|
||||||
if (handleIndex != -1 && areMultipleSIMsAvailable()) {
|
if (handleIndex != -1 && areMultipleSIMsAvailable()) {
|
||||||
|
if (config.showCallConfirmation) {
|
||||||
|
CallConfirmationDialog(this, number) {
|
||||||
callContactWithSim(number, handleIndex == 0)
|
callContactWithSim(number, handleIndex == 0)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
callContactWithSim(number, handleIndex == 0)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (config.showCallConfirmation) {
|
||||||
|
CallConfirmationDialog(this, number) {
|
||||||
startCallIntent(number)
|
startCallIntent(number)
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
startCallIntent(number)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -224,9 +224,7 @@ class ContactsAdapter(
|
|||||||
private fun getSelectedItems() = contacts.filter { selectedKeys.contains(it.rawId) } as ArrayList<Contact>
|
private fun getSelectedItems() = contacts.filter { selectedKeys.contains(it.rawId) } as ArrayList<Contact>
|
||||||
|
|
||||||
private fun getSelectedPhoneNumber(): String? {
|
private fun getSelectedPhoneNumber(): String? {
|
||||||
val numbers = getSelectedItems().firstOrNull()?.phoneNumbers
|
return getSelectedItems().firstOrNull()?.getPrimaryNumber()
|
||||||
val primaryNumber = numbers?.firstOrNull { it.isPrimary }
|
|
||||||
return primaryNumber?.normalizedNumber ?: numbers?.firstOrNull()?.normalizedNumber
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryCreateShortcut() {
|
private fun tryCreateShortcut() {
|
||||||
@@ -247,7 +245,7 @@ class ContactsAdapter(
|
|||||||
activity.handlePermission(PERMISSION_CALL_PHONE) { hasPermission ->
|
activity.handlePermission(PERMISSION_CALL_PHONE) { hasPermission ->
|
||||||
val action = if (hasPermission) Intent.ACTION_CALL else Intent.ACTION_DIAL
|
val action = if (hasPermission) Intent.ACTION_CALL else Intent.ACTION_DIAL
|
||||||
val intent = Intent(action).apply {
|
val intent = Intent(action).apply {
|
||||||
data = Uri.fromParts("tel", contact.phoneNumbers.first().normalizedNumber, null)
|
data = Uri.fromParts("tel", getSelectedPhoneNumber(), null)
|
||||||
}
|
}
|
||||||
|
|
||||||
val shortcut = ShortcutInfo.Builder(activity, contact.hashCode().toString())
|
val shortcut = ShortcutInfo.Builder(activity, contact.hashCode().toString())
|
||||||
|
Reference in New Issue
Block a user