fix #241, make sure we show the call confirmation on number click

This commit is contained in:
tibbi 2018-09-01 23:44:01 +02:00
parent 63d3702af3
commit 353462e684
3 changed files with 11 additions and 5 deletions

View File

@ -11,6 +11,7 @@ import android.widget.RelativeLayout
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.dialogs.CallConfirmationDialog
import com.simplemobiletools.contacts.extensions.* import com.simplemobiletools.contacts.extensions.*
import com.simplemobiletools.contacts.helpers.* import com.simplemobiletools.contacts.helpers.*
import kotlinx.android.synthetic.main.activity_view_contact.* import kotlinx.android.synthetic.main.activity_view_contact.*
@ -225,8 +226,14 @@ class ViewContactActivity : ContactActivity() {
contact_number_type.setText(getPhoneNumberTextId(phoneNumber.type)) contact_number_type.setText(getPhoneNumberTextId(phoneNumber.type))
setOnClickListener { setOnClickListener {
if (config.showCallConfirmation) {
CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) {
startCallIntent(phoneNumber.value) startCallIntent(phoneNumber.value)
} }
} else {
startCallIntent(phoneNumber.value)
}
}
} }
} }
contact_numbers_image.beVisible() contact_numbers_image.beVisible()

View File

@ -7,10 +7,9 @@ import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.extensions.config import com.simplemobiletools.contacts.extensions.config
import com.simplemobiletools.contacts.models.Contact
import kotlinx.android.synthetic.main.dialog_call_confirmation.view.* import kotlinx.android.synthetic.main.dialog_call_confirmation.view.*
class CallConfirmationDialog(val activity: BaseSimpleActivity, val contact: Contact, private val callback: () -> Unit) { class CallConfirmationDialog(val activity: BaseSimpleActivity, val callee: String, private val callback: () -> Unit) {
private var view = activity.layoutInflater.inflate(R.layout.dialog_call_confirmation, null) private var view = activity.layoutInflater.inflate(R.layout.dialog_call_confirmation, null)
init { init {
@ -18,7 +17,7 @@ class CallConfirmationDialog(val activity: BaseSimpleActivity, val contact: Cont
AlertDialog.Builder(activity) AlertDialog.Builder(activity)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
val title = String.format(activity.getString(R.string.call_person), contact.getFullName()) val title = String.format(activity.getString(R.string.call_person), callee)
activity.setupDialogStuff(view, this, titleText = title) { activity.setupDialogStuff(view, this, titleText = title) {
view.call_confirm_phone.apply { view.call_confirm_phone.apply {
startAnimation(AnimationUtils.loadAnimation(activity, R.anim.pulsing_animation)) startAnimation(AnimationUtils.loadAnimation(activity, R.anim.pulsing_animation))

View File

@ -36,7 +36,7 @@ fun SimpleActivity.startCallIntent(recipient: String) {
fun SimpleActivity.tryStartCall(contact: Contact) { fun SimpleActivity.tryStartCall(contact: Contact) {
if (config.showCallConfirmation) { if (config.showCallConfirmation) {
CallConfirmationDialog(this, contact) { CallConfirmationDialog(this, contact.getFullName()) {
startCall(contact) startCall(contact)
} }
} else { } else {