mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
show the callee name or number on the Dialer screen
This commit is contained in:
@ -3,20 +3,26 @@ package com.simplemobiletools.contacts.pro.activities
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
import kotlinx.android.synthetic.main.activity_dialer.*
|
||||
|
||||
class DialerActivity : SimpleActivity() {
|
||||
private var number = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_dialer)
|
||||
|
||||
if (intent.action == Intent.ACTION_CALL && intent.data != null && intent.dataString?.contains("tel:") == true) {
|
||||
val number = Uri.decode(intent.dataString).substringAfter("tel:")
|
||||
number = Uri.decode(intent.dataString).substringAfter("tel:")
|
||||
ContactsHelper(this).getContactWithNumber(number) {
|
||||
|
||||
runOnUiThread {
|
||||
updateCallee(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -25,4 +31,14 @@ class DialerActivity : SimpleActivity() {
|
||||
super.onResume()
|
||||
updateTextColors(dialer_holder)
|
||||
}
|
||||
|
||||
private fun updateCallee(contact: Contact?) {
|
||||
if (contact != null) {
|
||||
callee_big_name_number.text = contact.getNameToDisplay()
|
||||
callee_number.text = number
|
||||
} else {
|
||||
callee_big_name_number.text = number
|
||||
callee_number.beGone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user