lets actually remove the callers number if we know his name

This commit is contained in:
tibbi
2020-05-01 16:42:10 +02:00
parent 2a0cbe9b4f
commit 6be6b546f5
5 changed files with 4 additions and 25 deletions

View File

@ -107,8 +107,6 @@ class CallActivity : SimpleActivity() {
val callContact = CallManager.getCallContact(applicationContext) ?: return
caller_name_label.text = if (callContact.name.isNotEmpty()) callContact.name else getString(R.string.unknown_caller)
caller_number_label.text = callContact.number
caller_number_label.beVisibleIf(callContact.number.isNotEmpty())
if (callContactAvatar != null) {
caller_avatar.setImageBitmap(callContactAvatar)
@ -196,7 +194,7 @@ class CallActivity : SimpleActivity() {
val declinePendingIntent = PendingIntent.getBroadcast(this, 1, declineCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
val callerName = if (callContact != null && callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
val contentText = "${getString(R.string.incoming_call)} ${callContact?.number ?: ""}"
val contentText = getString(R.string.incoming_call)
val collapsedView = RemoteViews(packageName, R.layout.call_notification).apply {
setText(R.id.notification_caller_name, callerName)

View File

@ -46,7 +46,7 @@ class CallManager {
}
fun getCallContact(context: Context): CallContact? {
val callContact = CallContact("", "", "")
val callContact = CallContact("", "")
if (call == null) {
return callContact
}
@ -54,16 +54,10 @@ class CallManager {
val uri = Uri.decode(call!!.details.handle.toString())
if (uri.startsWith("tel:")) {
val number = uri.substringAfter("tel:")
callContact.number = number
callContact.name = context.getNameFromPhoneNumber(number)
callContact.photoUri = context.getPhotoUriFromPhoneNumber(number)
}
if (callContact.name.isEmpty() && callContact.number.isNotEmpty()) {
callContact.name = callContact.number
callContact.number = ""
}
return callContact
}
}

View File

@ -1,4 +1,4 @@
package com.simplemobiletools.contacts.pro.models
// a simpler Contact model containing just info needed at the call screen
data class CallContact(var name: String, var number: String, var photoUri: String)
data class CallContact(var name: String, var photoUri: String)