show the callee name or number on the Dialer screen

This commit is contained in:
tibbi
2018-11-20 12:04:08 +01:00
parent cb629354c4
commit 099d7b6644
3 changed files with 63 additions and 5 deletions

View File

@ -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()
}
}
}