Updated list of call log icon depending on status and dir + text color

This commit is contained in:
Sylvain Berfini 2023-08-16 16:39:50 +02:00
parent cc4bc0c3b0
commit 8be39a6871
9 changed files with 81 additions and 3 deletions

View file

@ -1,17 +1,25 @@
package org.linphone.ui.main.calls.model
import androidx.annotation.IntegerRes
import androidx.lifecycle.MutableLiveData
import org.linphone.core.Call
import org.linphone.core.Call.Dir
import org.linphone.core.CallLog
import org.linphone.utils.LinphoneUtils
import org.linphone.utils.TimestampUtils
class CallLogHistoryModel(callLog: CallLog) {
val isOutgoing = MutableLiveData<Boolean>()
val isSuccessful = MutableLiveData<Boolean>()
val dateTime = MutableLiveData<String>()
val duration = MutableLiveData<String>()
@IntegerRes
val iconResId = MutableLiveData<Int>()
init {
// Core thread
isOutgoing.postValue(callLog.dir == Dir.Outgoing)
@ -30,5 +38,8 @@ class CallLogHistoryModel(callLog: CallLog) {
duration.postValue(
TimestampUtils.durationToString(callLog.duration)
)
isSuccessful.postValue(callLog.status == Call.Status.Success)
iconResId.postValue(LinphoneUtils.getIconResId(callLog.status, callLog.dir))
}
}

View file

@ -1,13 +1,15 @@
package org.linphone.ui.main.calls.model
import androidx.annotation.IntegerRes
import androidx.lifecycle.MutableLiveData
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.core.Call.Dir
import org.linphone.core.CallLog
import org.linphone.ui.main.contacts.model.ContactAvatarModel
import org.linphone.utils.LinphoneUtils
import org.linphone.utils.TimestampUtils
class CallLogModel(val callLog: CallLog) {
class CallLogModel(private val callLog: CallLog) {
val id = callLog.callId ?: callLog.refKey
val address = if (callLog.dir == Dir.Outgoing) callLog.remoteAddress else callLog.fromAddress
@ -18,6 +20,9 @@ class CallLogModel(val callLog: CallLog) {
val isOutgoing = MutableLiveData<Boolean>()
@IntegerRes
val iconResId = MutableLiveData<Int>()
val dateTime = MutableLiveData<String>()
init {
@ -42,6 +47,8 @@ class CallLogModel(val callLog: CallLog) {
fakeFriend.address = address
avatarModel = ContactAvatarModel(fakeFriend)
}
iconResId.postValue(LinphoneUtils.getIconResId(callLog.status, callLog.dir))
}
fun delete() {

View file

@ -19,11 +19,15 @@
*/
package org.linphone.utils
import androidx.annotation.IntegerRes
import androidx.emoji2.text.EmojiCompat
import java.util.Locale
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.core.Address
import org.linphone.core.Call
import org.linphone.core.Call.Dir
import org.linphone.core.Call.Status
import org.linphone.core.ChatRoom
import org.linphone.core.tools.Log
@ -93,6 +97,35 @@ class LinphoneUtils {
}
}
@IntegerRes
fun getIconResId(callStatus: Status, callDir: Dir): Int {
return when (callStatus) {
Status.Missed -> {
if (callDir == Dir.Outgoing) {
R.drawable.outgoing_call_missed
} else {
R.drawable.incoming_call_missed
}
}
Status.Success -> {
if (callDir == Dir.Outgoing) {
R.drawable.outgoing_call
} else {
R.drawable.incoming_call
}
}
else -> {
if (callDir == Dir.Outgoing) {
R.drawable.outgoing_call_rejected
} else {
R.drawable.incoming_call_rejected
}
}
}
}
private fun getChatRoomId(localAddress: Address, remoteAddress: Address): String {
val localSipUri = localAddress.clone()
localSipUri.clean()

View file

@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="18dp"
android:height="18dp"
android:viewportWidth="18"
android:viewportHeight="18">
<path
android:name="path_1"
android:pathData="M 16.5 18 C 17.328 18 18 17.328 18 16.5 C 18 15.672 17.328 15 16.5 15 L 5.121 15 L 17.561 2.561 C 18.146 1.975 18.146 1.025 17.561 0.439 C 16.975 -0.146 16.025 -0.146 15.439 0.439 L 3 12.879 L 3 1.5 C 3 0.672 2.328 0 1.5 0 C 0.672 0 0 0.672 0 1.5 L 0 16.5 C 0 17.328 0.672 18 1.5 18 L 16.5 18 Z"
android:fillColor="#dd5f5f"
android:strokeWidth="1"/>
</vector>

View file

@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="18dp"
android:height="18dp"
android:viewportWidth="18"
android:viewportHeight="18">
<path
android:name="path"
android:pathData="M 1.5 0 C 0.672 0 0 0.672 0 1.5 C 0 2.328 0.672 3 1.5 3 L 12.879 3 L 0.439 15.439 C -0.146 16.025 -0.146 16.975 0.439 17.561 C 1.025 18.146 1.975 18.146 2.561 17.561 L 15 5.121 L 15 16.5 C 15 17.328 15.672 18 16.5 18 C 17.328 18 18 17.328 18 16.5 L 18 1.5 C 18 0.672 17.328 0 16.5 0 L 1.5 0 Z"
android:fillColor="#dd5f5f"
android:strokeWidth="1"/>
</vector>

View file

@ -24,7 +24,7 @@
android:layout_height="16dp"
android:layout_marginTop="20dp"
android:layout_marginStart="2dp"
android:src="@{model.isOutgoing() ? @drawable/outgoing_call : @drawable/incoming_call, default=@drawable/outgoing_call}"
android:src="@{model.iconResId, default=@drawable/outgoing_call}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -51,6 +51,7 @@
android:gravity="center"
android:text="@{model.dateTime, default=`13 aout 2023 | 19:47`}"
android:textSize="12sp"
android:textColor="@{model.isSuccessful ? @color/gray_9 : @color/red_danger, default=@color/gray_9}"
app:layout_constraintStart_toEndOf="@id/call_status"
app:layout_constraintTop_toBottomOf="@id/direction_label"
app:layout_constraintBottom_toTopOf="@id/separator"/>

View file

@ -67,7 +67,7 @@
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginBottom="10dp"
android:src="@{model.isOutgoing() ? @drawable/outgoing_call : @drawable/incoming_call, default=@drawable/outgoing_call}"
android:src="@{model.iconResId, default=@drawable/outgoing_call}"
app:layout_constraintStart_toStartOf="@id/name"
app:layout_constraintTop_toBottomOf="@id/name"
app:layout_constraintBottom_toTopOf="@id/separator" />