mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
lets actually remove the callers number if we know his name
This commit is contained in:
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user