mirror of
https://github.com/FossifyOrg/Phone.git
synced 2026-04-19 23:07:10 -04:00
Merge pull request #241 from Aga-C/add-call-confirmation
Added call confirmation to three dots menu in Call History (#240)
This commit is contained in:
@@ -20,7 +20,6 @@ import android.view.ViewConfiguration
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.view.isVisible
|
||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||
import org.fossify.commons.dialogs.CallConfirmationDialog
|
||||
import org.fossify.commons.extensions.*
|
||||
import org.fossify.commons.helpers.*
|
||||
import org.fossify.commons.models.contacts.Contact
|
||||
@@ -306,13 +305,7 @@ class DialpadActivity : SimpleActivity() {
|
||||
highlightText = text
|
||||
) {
|
||||
val contact = it as Contact
|
||||
if (config.showCallConfirmation) {
|
||||
CallConfirmationDialog(this@DialpadActivity, contact.getNameToDisplay()) {
|
||||
startCallIntent(contact.getPrimaryNumber() ?: return@CallConfirmationDialog)
|
||||
}
|
||||
} else {
|
||||
startCallIntent(contact.getPrimaryNumber() ?: return@ContactsAdapter)
|
||||
}
|
||||
startCallWithConfirmationCheck(contact.getPrimaryNumber() ?: return@ContactsAdapter, contact.getNameToDisplay())
|
||||
Handler().postDelayed({
|
||||
binding.dialpadInput.setText("")
|
||||
}, 1000)
|
||||
@@ -334,21 +327,9 @@ class DialpadActivity : SimpleActivity() {
|
||||
private fun initCall(number: String = binding.dialpadInput.value, handleIndex: Int) {
|
||||
if (number.isNotEmpty()) {
|
||||
if (handleIndex != -1 && areMultipleSIMsAvailable()) {
|
||||
if (config.showCallConfirmation) {
|
||||
CallConfirmationDialog(this, number) {
|
||||
callContactWithSim(number, handleIndex == 0)
|
||||
}
|
||||
} else {
|
||||
callContactWithSim(number, handleIndex == 0)
|
||||
}
|
||||
callContactWithSimWithConfirmationCheck(number, number, handleIndex == 0)
|
||||
} else {
|
||||
if (config.showCallConfirmation) {
|
||||
CallConfirmationDialog(this, number) {
|
||||
startCallIntent(number)
|
||||
}
|
||||
} else {
|
||||
startCallIntent(number)
|
||||
}
|
||||
startCallWithConfirmationCheck(number, number)
|
||||
}
|
||||
|
||||
Handler().postDelayed({
|
||||
|
||||
@@ -177,12 +177,16 @@ class RecentCallsAdapter(
|
||||
|
||||
private fun callContact(useSimOne: Boolean) {
|
||||
val phoneNumber = getSelectedPhoneNumber() ?: return
|
||||
activity.callContactWithSim(phoneNumber, useSimOne)
|
||||
val name = getSelectedName() ?: return
|
||||
|
||||
activity.callContactWithSimWithConfirmationCheck(phoneNumber, name, useSimOne)
|
||||
}
|
||||
|
||||
private fun callContact() {
|
||||
val phoneNumber = getSelectedPhoneNumber() ?: return
|
||||
(activity as SimpleActivity).startCallIntent(phoneNumber)
|
||||
val name = getSelectedName() ?: return
|
||||
|
||||
(activity as SimpleActivity).startCallWithConfirmationCheck(phoneNumber, name)
|
||||
}
|
||||
|
||||
private fun removeDefaultSIM() {
|
||||
@@ -314,6 +318,8 @@ class RecentCallsAdapter(
|
||||
|
||||
private fun getSelectedPhoneNumber() = getSelectedItems().firstOrNull()?.phoneNumber
|
||||
|
||||
private fun getSelectedName() = getSelectedItems().firstOrNull()?.name
|
||||
|
||||
private fun showPopupMenu(view: View, call: RecentCall) {
|
||||
finishActMode()
|
||||
val theme = activity.getPopupMenuTheme()
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.telecom.PhoneAccount
|
||||
import android.telecom.PhoneAccountHandle
|
||||
import android.telecom.TelecomManager
|
||||
import org.fossify.commons.activities.BaseSimpleActivity
|
||||
import org.fossify.commons.dialogs.CallConfirmationDialog
|
||||
import org.fossify.commons.extensions.*
|
||||
import org.fossify.commons.helpers.*
|
||||
import org.fossify.commons.models.contacts.Contact
|
||||
@@ -26,6 +27,16 @@ fun SimpleActivity.startCallIntent(recipient: String) {
|
||||
}
|
||||
}
|
||||
|
||||
fun SimpleActivity.startCallWithConfirmationCheck(recipient: String, name: String) {
|
||||
if (config.showCallConfirmation) {
|
||||
CallConfirmationDialog(this, name) {
|
||||
startCallIntent(recipient)
|
||||
}
|
||||
} else {
|
||||
startCallIntent(recipient)
|
||||
}
|
||||
}
|
||||
|
||||
fun SimpleActivity.launchCreateNewContactIntent() {
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_INSERT
|
||||
@@ -42,6 +53,16 @@ fun BaseSimpleActivity.callContactWithSim(recipient: String, useMainSIM: Boolean
|
||||
}
|
||||
}
|
||||
|
||||
fun BaseSimpleActivity.callContactWithSimWithConfirmationCheck(recipient: String, name: String, useMainSIM: Boolean) {
|
||||
if (config.showCallConfirmation) {
|
||||
CallConfirmationDialog(this, name) {
|
||||
callContactWithSim(recipient, useMainSIM)
|
||||
}
|
||||
} else {
|
||||
callContactWithSim(recipient, useMainSIM)
|
||||
}
|
||||
}
|
||||
|
||||
// handle private contacts differently, only Simple Contacts Pro can open them
|
||||
fun Activity.startContactDetailsIntent(contact: Contact) {
|
||||
val simpleContacts = "org.fossify.contacts"
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.fossify.phone.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import org.fossify.commons.dialogs.CallConfirmationDialog
|
||||
import org.fossify.commons.extensions.*
|
||||
import org.fossify.commons.helpers.*
|
||||
import org.fossify.commons.models.contacts.Contact
|
||||
@@ -12,6 +11,7 @@ import org.fossify.phone.activities.SimpleActivity
|
||||
import org.fossify.phone.adapters.RecentCallsAdapter
|
||||
import org.fossify.phone.databinding.FragmentRecentsBinding
|
||||
import org.fossify.phone.extensions.config
|
||||
import org.fossify.phone.extensions.startCallWithConfirmationCheck
|
||||
import org.fossify.phone.helpers.RecentsHelper
|
||||
import org.fossify.phone.interfaces.RefreshItemsListener
|
||||
import org.fossify.phone.models.CallLogItem
|
||||
@@ -141,13 +141,7 @@ class RecentsFragment(
|
||||
},
|
||||
itemClick = {
|
||||
val recentCall = it as RecentCall
|
||||
if (context.config.showCallConfirmation) {
|
||||
CallConfirmationDialog(activity as SimpleActivity, recentCall.name) {
|
||||
activity?.launchCallIntent(recentCall.phoneNumber)
|
||||
}
|
||||
} else {
|
||||
activity?.launchCallIntent(recentCall.phoneNumber)
|
||||
}
|
||||
activity?.startCallWithConfirmationCheck(recentCall.phoneNumber, recentCall.name)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user