From 353462e684e41c933fec7174b9f1acedd5662267 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 1 Sep 2018 23:44:01 +0200 Subject: [PATCH] fix #241, make sure we show the call confirmation on number click --- .../contacts/activities/ViewContactActivity.kt | 9 ++++++++- .../contacts/dialogs/CallConfirmationDialog.kt | 5 ++--- .../simplemobiletools/contacts/extensions/Activity.kt | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt index 3b41f777..f4af0e7e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt @@ -11,6 +11,7 @@ import android.widget.RelativeLayout import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS import com.simplemobiletools.contacts.R +import com.simplemobiletools.contacts.dialogs.CallConfirmationDialog import com.simplemobiletools.contacts.extensions.* import com.simplemobiletools.contacts.helpers.* import kotlinx.android.synthetic.main.activity_view_contact.* @@ -225,7 +226,13 @@ class ViewContactActivity : ContactActivity() { contact_number_type.setText(getPhoneNumberTextId(phoneNumber.type)) setOnClickListener { - startCallIntent(phoneNumber.value) + if (config.showCallConfirmation) { + CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) { + startCallIntent(phoneNumber.value) + } + } else { + startCallIntent(phoneNumber.value) + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/CallConfirmationDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/CallConfirmationDialog.kt index 40f3ef89..66575647 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/CallConfirmationDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/CallConfirmationDialog.kt @@ -7,10 +7,9 @@ import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.extensions.config -import com.simplemobiletools.contacts.models.Contact 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) init { @@ -18,7 +17,7 @@ class CallConfirmationDialog(val activity: BaseSimpleActivity, val contact: Cont AlertDialog.Builder(activity) .setNegativeButton(R.string.cancel, null) .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) { view.call_confirm_phone.apply { startAnimation(AnimationUtils.loadAnimation(activity, R.anim.pulsing_animation)) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Activity.kt index a63eb96d..41397cfc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Activity.kt @@ -36,7 +36,7 @@ fun SimpleActivity.startCallIntent(recipient: String) { fun SimpleActivity.tryStartCall(contact: Contact) { if (config.showCallConfirmation) { - CallConfirmationDialog(this, contact) { + CallConfirmationDialog(this, contact.getFullName()) { startCall(contact) } } else {