Skip to content

Commit

Permalink
Add the information of Company to notification and avtivity
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelAliesch committed Nov 12, 2023
1 parent 0be6105 commit 8b1088f
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 21 deletions.
Expand Up @@ -25,6 +25,7 @@ import androidx.core.view.children
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.SimpleListItem
import com.simplemobiletools.commons.models.contacts.Contact
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.databinding.ActivityCallBinding
import com.simplemobiletools.dialer.dialogs.DynamicBottomSheetChooserDialog
Expand Down Expand Up @@ -570,6 +571,11 @@ class CallActivity : SimpleActivity() {
} else {
callerAvatar.setImageDrawable(null)
}

if (callContact!!.company.isNotEmpty() ) {
callerCompany.text = "${callContact!!.company}"
}

}
}

Expand Down
Expand Up @@ -50,6 +50,7 @@ class ConferenceCallsAdapter(
getCallContact(itemView.context, call) { callContact ->
root.post {
itemConferenceCallName.text = callContact.name.ifEmpty { itemView.context.getString(R.string.unknown_caller) }
itemConferenceCallCompany.text = callContact.company
SimpleContactsHelper(activity).loadContactImage(
callContact.photoUri,
itemConferenceCallImage,
Expand Down
Expand Up @@ -14,13 +14,13 @@ import com.simplemobiletools.dialer.models.CallContact

fun getCallContact(context: Context, call: Call?, callback: (CallContact) -> Unit) {
if (call.isConference()) {
callback(CallContact(context.getString(R.string.conference), "", "", ""))
callback(CallContact(context.getString(R.string.conference), "", "", "", ""))
return
}

val privateCursor = context.getMyContactsCursor(false, true)
ensureBackgroundThread {
val callContact = CallContact("", "", "", "")
val callContact = CallContact("", "", "", "", "")
val handle = try {
call?.details?.handle?.toString()
} catch (e: NullPointerException) {
Expand Down Expand Up @@ -54,6 +54,7 @@ fun getCallContact(context: Context, call: Call?, callback: (CallContact) -> Uni
val contact = contacts.firstOrNull { it.doesHavePhoneNumber(number) }
if (contact != null) {
callContact.name = contact.getNameToDisplay()
callContact.company = contact.organization.company.toString()
callContact.photoUri = contact.photoUri

if (contact.phoneNumbers.size > 1) {
Expand Down
Expand Up @@ -17,6 +17,7 @@ import com.simplemobiletools.commons.helpers.isOreoPlus
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.activities.CallActivity
import com.simplemobiletools.dialer.extensions.powerManager
import com.simplemobiletools.dialer.models.CallContact
import com.simplemobiletools.dialer.receivers.CallActionReceiver

class CallNotificationManager(private val context: Context) {
Expand Down Expand Up @@ -73,6 +74,8 @@ class CallNotificationManager(private val context: Context) {
setText(R.id.notification_caller_name, callerName)
setText(R.id.notification_call_status, context.getString(contentTextId))
setVisibleIf(R.id.notification_accept_call, callState == Call.STATE_RINGING)
setText(R.id.notification_caller_company, callContact.company)
setVisibleIf(R.id.notification_caller_company, callContact.company.isNotEmpty())

setOnClickPendingIntent(R.id.notification_decline_call, declinePendingIntent)
setOnClickPendingIntent(R.id.notification_accept_call, acceptPendingIntent)
Expand Down
@@ -1,4 +1,4 @@
package com.simplemobiletools.dialer.models

// a simpler Contact model containing just info needed at the call screen
data class CallContact(var name: String, var photoUri: String, var number: String, var numberLabel: String)
data class CallContact(var name: String, var company: String, var photoUri: String, var number: String, var numberLabel: String)
18 changes: 15 additions & 3 deletions app/src/main/res/layout/activity_call.xml
Expand Up @@ -33,15 +33,27 @@
tools:text="Caller name" />

<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/caller_number"
android:id="@+id/caller_company"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/normal_margin"
android:gravity="center_horizontal"
android:textSize="@dimen/call_status_text_size"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/caller_name_label"
app:layout_constraintTop_toBottomOf="@id/caller_name_label"
tools:text="Test Inc." />

<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/caller_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:gravity="center_horizontal"
android:textSize="@dimen/call_status_text_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/caller_name_label"
app:layout_constraintTop_toBottomOf="@id/caller_company"
tools:text="0912 345 678" />

<com.simplemobiletools.commons.views.MyTextView
Expand Down
36 changes: 28 additions & 8 deletions app/src/main/res/layout/call_notification.xml
Expand Up @@ -14,14 +14,34 @@
android:textStyle="bold"
tools:text="Caller name" />

<TextView
android:id="@+id/notification_call_status"
style="@style/TextAppearance.Compat.Notification.Title"
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/notification_caller_Infos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/notification_caller_name"
android:alpha="0.8"
tools:text="123 456 789" />
android:layout_below="@id/notification_caller_name"
android:layout_marginEnd="16dp"
android:layout_toStartOf="@+id/notification_thumbnail"
android:orientation="horizontal">

<TextView
android:id="@+id/notification_call_status"
style="@style/TextAppearance.Compat.Notification.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:alpha="0.8"
tools:text="123 456 789" />

<TextView
android:id="@+id/notification_caller_company"
style="@style/TextAppearance.Compat.Notification.Title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:alpha="0.8"
android:paddingLeft="16dp"
tools:text="Test Inc."
tools:visibility="invisible" />
</LinearLayout>

<ImageView
android:id="@+id/notification_thumbnail"
Expand All @@ -34,7 +54,7 @@
android:id="@+id/notification_actions_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/notification_call_status"
android:layout_below="@id/notification_caller_Infos"
android:layout_marginTop="@dimen/activity_margin"
android:orientation="horizontal">

Expand Down
27 changes: 20 additions & 7 deletions app/src/main/res/layout/item_conference_call.xml
Expand Up @@ -18,20 +18,33 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/item_conference_call_name"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:layout_toEndOf="@+id/item_conference_call_image"
android:ellipsize="end"
android:maxLines="1"
android:textSize="@dimen/bigger_text_size"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@+id/item_conference_call_image"
app:layout_constraintEnd_toStartOf="@+id/item_conference_call_split"
app:layout_constraintHorizontal_bias=".5"
app:layout_constraintStart_toEndOf="@+id/item_conference_call_image"
app:layout_constraintTop_toTopOf="@+id/item_conference_call_image"
tools:text="John Doe" />
app:layout_constraintVertical_bias=".5">

<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/item_conference_call_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:textSize="@dimen/bigger_text_size"
tools:text="John Doe" />

<TextView
android:id="@+id/item_conference_call_company"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Inc."
tools:visibility="visible" />
</LinearLayout>

<ImageButton
android:id="@+id/item_conference_call_end"
Expand Down

0 comments on commit 8b1088f

Please sign in to comment.