add handling for dialpad presses during calls

This commit is contained in:
tibbi 2020-05-02 23:04:08 +02:00
parent f5d8822bef
commit 1e979e2b6e
2 changed files with 27 additions and 0 deletions

View file

@ -22,6 +22,7 @@ import com.simplemobiletools.commons.helpers.isOreoMr1Plus
import com.simplemobiletools.commons.helpers.isOreoPlus
import com.simplemobiletools.commons.helpers.isQPlus
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.extensions.addCharacter
import com.simplemobiletools.contacts.pro.extensions.audioManager
import com.simplemobiletools.contacts.pro.extensions.config
import com.simplemobiletools.contacts.pro.extensions.startCallIntent
@ -31,6 +32,7 @@ import com.simplemobiletools.contacts.pro.helpers.DECLINE_CALL
import com.simplemobiletools.contacts.pro.models.CallContact
import com.simplemobiletools.contacts.pro.receivers.CallActionReceiver
import kotlinx.android.synthetic.main.activity_call.*
import kotlinx.android.synthetic.main.dialpad.*
import java.util.*
class CallActivity : SimpleActivity() {
@ -120,9 +122,29 @@ class CallActivity : SimpleActivity() {
endCall()
}
dialpad_0_holder.setOnClickListener { dialpadPressed('0') }
dialpad_1.setOnClickListener { dialpadPressed('1') }
dialpad_2.setOnClickListener { dialpadPressed('2') }
dialpad_3.setOnClickListener { dialpadPressed('3') }
dialpad_4.setOnClickListener { dialpadPressed('4') }
dialpad_5.setOnClickListener { dialpadPressed('5') }
dialpad_6.setOnClickListener { dialpadPressed('6') }
dialpad_7.setOnClickListener { dialpadPressed('7') }
dialpad_8.setOnClickListener { dialpadPressed('8') }
dialpad_9.setOnClickListener { dialpadPressed('9') }
dialpad_0_holder.setOnLongClickListener { dialpadPressed('+'); true }
dialpad_asterisk.setOnClickListener { dialpadPressed('*') }
dialpad_hashtag.setOnClickListener { dialpadPressed('#') }
dialpad_wrapper.setBackgroundColor(config.backgroundColor)
}
private fun dialpadPressed(char: Char) {
CallManager.keypad(char)
dialpad_input.addCharacter(char)
}
private fun toggleSpeaker() {
isSpeakerOn = !isSpeakerOn
val drawable = if (isSpeakerOn) R.drawable.ic_speaker_on_vector else R.drawable.ic_speaker_off_vector

View file

@ -45,6 +45,11 @@ class CallManager {
call!!.state
}
fun keypad(c: Char) {
call?.playDtmfTone(c)
call?.stopDtmfTone()
}
fun getCallContact(context: Context): CallContact? {
val callContact = CallContact("", "", "")
if (call == null) {