show the callee name or number on the Dialer screen
This commit is contained in:
parent
cb629354c4
commit
099d7b6644
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/dialer_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:focusableInTouchMode="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/calling_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dialer_top_margin"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/calling"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/callee_big_name_number"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:textSize="@dimen/dialpad_text_size"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/calling_label"
|
||||
tools:text="John"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/callee_number"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/callee_big_name_number"
|
||||
tools:text="123 456 789"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -7,5 +7,7 @@
|
|||
<dimen name="contact_item_with_number_height">56dp</dimen>
|
||||
<dimen name="create_new_contact_height">68dp</dimen>
|
||||
<dimen name="dialpad_button_size">60dp</dimen>
|
||||
<dimen name="dialer_top_margin">150dp</dimen>
|
||||
|
||||
<dimen name="dialpad_text_size">34sp</dimen>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue