Skip to content

Commit

Permalink
Update call state icons and text.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal authored and greyson-signal committed Apr 12, 2023
1 parent 2883c16 commit a183057
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.core.content.ContextCompat
import androidx.core.widget.TextViewCompat
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.database.CallTable
import org.thoughtcrime.securesms.database.MessageTypes
import org.thoughtcrime.securesms.databinding.CallLogAdapterItemBinding
import org.thoughtcrime.securesms.databinding.CallLogCreateCallLinkItemBinding
import org.thoughtcrime.securesms.databinding.ConversationListItemClearFilterBinding
Expand Down Expand Up @@ -151,30 +152,27 @@ class CallLogAdapter(
return
}

val event = model.call.call.event
val direction = model.call.call.direction

binding.callRecipientAvatar.setAvatar(GlideApp.with(binding.callRecipientAvatar), model.call.peer, true)
binding.callRecipientBadge.setBadgeFromRecipient(model.call.peer)
binding.callRecipientName.text = model.call.peer.getDisplayName(context)
presentCallInfo(event, direction, model.call.date)
presentCallInfo(model.call.call, model.call.date)
presentCallType(model)
}

private fun presentCallInfo(event: CallTable.Event, direction: CallTable.Direction, date: Long) {
private fun presentCallInfo(call: CallTable.Call, date: Long) {
binding.callInfo.text = context.getString(
R.string.CallLogAdapter__s_dot_s,
context.getString(getCallStateStringRes(event, direction)),
context.getString(getCallStateStringRes(call)),
DateUtils.getBriefRelativeTimeSpanString(context, Locale.getDefault(), date)
)

binding.callInfo.setRelativeDrawables(
start = getCallStateDrawableRes(event, direction)
start = getCallStateDrawableRes(call)
)

val color = ContextCompat.getColor(
context,
if (event == CallTable.Event.MISSED) {
if (call.event == CallTable.Event.MISSED) {
R.color.signal_colorError
} else {
R.color.signal_colorOnSurface
Expand Down Expand Up @@ -233,28 +231,39 @@ class CallLogAdapter(
}

@DrawableRes
private fun getCallStateDrawableRes(callEvent: CallTable.Event, callDirection: CallTable.Direction): Int {
if (callEvent == CallTable.Event.MISSED) {
return R.drawable.symbol_missed_incoming_compact_16
}

return if (callDirection == CallTable.Direction.INCOMING) {
R.drawable.symbol_arrow_downleft_compact_16
} else {
R.drawable.symbol_arrow_upright_compact_16
private fun getCallStateDrawableRes(call: CallTable.Call): Int {
return when (call.messageType) {
MessageTypes.MISSED_VIDEO_CALL_TYPE, MessageTypes.MISSED_AUDIO_CALL_TYPE -> R.drawable.symbol_missed_incoming_compact_16
MessageTypes.INCOMING_AUDIO_CALL_TYPE, MessageTypes.INCOMING_VIDEO_CALL_TYPE -> R.drawable.symbol_arrow_downleft_compact_16
MessageTypes.OUTGOING_AUDIO_CALL_TYPE, MessageTypes.OUTGOING_VIDEO_CALL_TYPE -> R.drawable.symbol_arrow_upright_compact_16
MessageTypes.GROUP_CALL_TYPE -> when {
call.event == CallTable.Event.MISSED -> R.drawable.symbol_missed_incoming_24
call.event == CallTable.Event.GENERIC_GROUP_CALL || call.event == CallTable.Event.JOINED -> R.drawable.symbol_group_compact_16
call.direction == CallTable.Direction.INCOMING -> R.drawable.symbol_arrow_downleft_compact_16
call.direction == CallTable.Direction.OUTGOING -> R.drawable.symbol_arrow_upright_compact_16
else -> throw AssertionError()
}
else -> error("Unexpected type ${call.type}")
}
}

@StringRes
private fun getCallStateStringRes(callEvent: CallTable.Event, callDirection: CallTable.Direction): Int {
if (callEvent == CallTable.Event.MISSED) {
return R.string.CallLogAdapter__missed
}

return if (callDirection == CallTable.Direction.INCOMING) {
R.string.CallLogAdapter__incoming
} else {
R.string.CallLogAdapter__outgoing
private fun getCallStateStringRes(call: CallTable.Call): Int {
return when (call.messageType) {
MessageTypes.MISSED_VIDEO_CALL_TYPE -> R.string.CallLogAdapter__missed
MessageTypes.MISSED_AUDIO_CALL_TYPE -> R.string.CallLogAdapter__missed
MessageTypes.INCOMING_AUDIO_CALL_TYPE -> R.string.CallLogAdapter__incoming
MessageTypes.INCOMING_VIDEO_CALL_TYPE -> R.string.CallLogAdapter__incoming
MessageTypes.OUTGOING_AUDIO_CALL_TYPE -> R.string.CallLogAdapter__outgoing
MessageTypes.OUTGOING_VIDEO_CALL_TYPE -> R.string.CallLogAdapter__outgoing
MessageTypes.GROUP_CALL_TYPE -> when {
call.event == CallTable.Event.MISSED -> R.string.CallPreference__missed_group_call
call.event == CallTable.Event.GENERIC_GROUP_CALL || call.event == CallTable.Event.JOINED -> R.string.CallPreference__group_call
call.direction == CallTable.Direction.INCOMING -> R.string.CallLogAdapter__incoming
call.direction == CallTable.Direction.OUTGOING -> R.string.CallLogAdapter__outgoing
else -> throw AssertionError()
}
else -> error("Unexpected type ${call.messageType}")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ object CallPreference {
MessageTypes.OUTGOING_AUDIO_CALL_TYPE, MessageTypes.OUTGOING_VIDEO_CALL_TYPE -> R.drawable.symbol_arrow_upright_24
MessageTypes.GROUP_CALL_TYPE -> when {
call.event == CallTable.Event.MISSED -> R.drawable.symbol_missed_incoming_24
call.event == CallTable.Event.GENERIC_GROUP_CALL || call.event == CallTable.Event.JOINED -> R.drawable.symbol_group_24
call.direction == CallTable.Direction.INCOMING -> R.drawable.symbol_arrow_downleft_24
call.direction == CallTable.Direction.OUTGOING -> R.drawable.symbol_arrow_upright_24
else -> throw AssertionError()
Expand All @@ -69,6 +70,7 @@ object CallPreference {
MessageTypes.OUTGOING_VIDEO_CALL_TYPE -> R.string.MessageRecord_outgoing_video_call
MessageTypes.GROUP_CALL_TYPE -> when {
call.event == CallTable.Event.MISSED -> R.string.CallPreference__missed_group_call
call.event == CallTable.Event.GENERIC_GROUP_CALL || call.event == CallTable.Event.JOINED -> R.string.CallPreference__group_call
call.direction == CallTable.Direction.INCOMING -> R.string.CallPreference__incoming_group_call
call.direction == CallTable.Direction.OUTGOING -> R.string.CallPreference__outgoing_group_call
else -> throw AssertionError()
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/symbol_group_compact_16.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:fillColor="#FF000000"
android:pathData="M8.6 5.06c0-1.44 0.99-2.71 2.4-2.71s2.4 1.27 2.4 2.7c0 0.74-0.24 1.43-0.65 1.95-0.41 0.52-1.03 0.9-1.75 0.9S9.66 7.52 9.25 7C8.85 6.48 8.6 5.79 8.6 5.06ZM11 3.65c-0.52 0-1.1 0.5-1.1 1.4 0 0.46 0.15 0.86 0.37 1.14C10.5 6.47 10.76 6.6 11 6.6s0.5-0.13 0.73-0.4c0.22-0.29 0.37-0.7 0.37-1.14 0-0.91-0.58-1.41-1.1-1.41Z"/>
<path
android:fillColor="#FF000000"
android:pathData="M5 8.6c0.7 0 1.37 0.14 1.98 0.4-0.35 0.3-0.66 0.66-0.92 1.04C5.73 9.95 5.38 9.9 5 9.9c-1.76 0-3.1 1.12-3.32 2.45h3.59l-0.02 0.4c0 0.31 0.03 0.61 0.08 0.9H1.26c-0.47 0-0.91-0.37-0.91-0.9C0.35 10.38 2.52 8.6 5 8.6Z"/>
<path
android:fillColor="#FF000000"
android:pathData="M11 8.6c-2.48 0-4.65 1.78-4.65 4.15 0 0.53 0.44 0.9 0.91 0.9h7.48c0.47 0 0.91-0.37 0.91-0.9 0-2.37-2.17-4.15-4.65-4.15Zm0 1.3c1.76 0 3.1 1.12 3.32 2.45H7.68C7.91 11.02 9.24 9.9 11 9.9Z"/>
<path
android:fillColor="#FF000000"
android:pathData="M5 2.35c-1.41 0-2.4 1.27-2.4 2.7C2.6 5.8 2.84 6.49 3.25 7 3.66 7.52 4.28 7.9 5 7.9S6.34 7.52 6.75 7C7.15 6.48 7.4 5.79 7.4 5.06c0-1.44-0.99-2.71-2.4-2.71Zm-1.1 2.7c0-0.9 0.58-1.4 1.1-1.4 0.52 0 1.1 0.5 1.1 1.4 0 0.46-0.15 0.86-0.37 1.14C5.5 6.47 5.24 6.6 5 6.6S4.5 6.47 4.27 6.2C4.05 5.9 3.9 5.5 3.9 5.05Z"/>
</vector>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5861,6 +5861,8 @@
<string name="CameraControls_continue_button_accessibility_label">Continue Button</string>

<!-- CallPreference -->
<!-- Generic group call in call info -->
<string name="CallPreference__group_call">Group call</string>
<!-- Missed group call in call info -->
<string name="CallPreference__missed_group_call">Missed group call</string>
<!-- Incoming group call in call info -->
Expand Down

0 comments on commit a183057

Please sign in to comment.