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)

View File

@ -29,18 +29,6 @@
app:layout_constraintTop_toBottomOf="@+id/caller_avatar"
tools:text="Caller name" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/caller_number_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:alpha="0.8"
android:textSize="@dimen/caller_number_text_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/caller_name_label"
tools:text="123 456 789" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ongoing_call_holder"
android:layout_width="match_parent"

View File

@ -8,7 +8,6 @@
<dimen name="incoming_call_button_size">72dp</dimen>
<dimen name="call_notification_button_size">30dp</dimen>
<dimen name="caller_name_text_size">26sp</dimen>
<dimen name="caller_number_text_size">20sp</dimen>
<dimen name="caller_name_text_size">28sp</dimen>
<dimen name="dialpad_text_size">34sp</dimen>
</resources>