Add chevron to pending participants view.

This commit is contained in:
Alex Hart 2024-09-13 10:06:17 -03:00 committed by Cody Henthorne
parent 636b5a4ba6
commit d1475228f7
3 changed files with 25 additions and 3 deletions

Binary file not shown.

View file

@ -6,6 +6,7 @@
package org.thoughtcrime.securesms.components.webrtc
import android.content.Context
import android.text.SpannableStringBuilder
import android.util.AttributeSet
import android.view.View
import android.widget.TextView
@ -14,8 +15,10 @@ import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.components.AvatarImageView
import org.thoughtcrime.securesms.fonts.SignalSymbols
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.service.webrtc.PendingParticipantCollection
import org.thoughtcrime.securesms.util.SpanUtil
import org.thoughtcrime.securesms.util.visible
/**
@ -55,8 +58,14 @@ class PendingParticipantsView @JvmOverloads constructor(
avatar.setAvatar(firstRecipient)
avatar.setOnClickListener { listener?.onLaunchRecipientSheet(firstRecipient) }
name.text = firstRecipient.getShortDisplayName(context)
name.text = SpannableStringBuilder(firstRecipient.getShortDisplayName(context))
.append(" ")
.append(SpanUtil.ofSize(
SignalSymbols.getSpannedString(context, SignalSymbols.Weight.REGULAR, SignalSymbols.Glyph.CHEVRON_RIGHT),
16
))
name.setOnClickListener { listener?.onLaunchRecipientSheet(firstRecipient) }
allow.setOnClickListener { listener?.onAllowPendingRecipient(firstRecipient) }
reject.setOnClickListener { listener?.onRejectPendingRecipient(firstRecipient) }

View file

@ -22,7 +22,8 @@ object SignalSymbols {
}
enum class Weight {
BOLD
BOLD,
REGULAR
}
private val cache = mutableMapOf<Weight, Typeface>()
@ -45,6 +46,7 @@ object SignalSymbols {
private fun getTypeface(context: Context, weight: Weight): Typeface {
return when (weight) {
Weight.BOLD -> getBoldWeightedFont(context)
Weight.REGULAR -> getRegularWeightedFont(context)
else -> error("Unsupported weight: $weight")
}
}
@ -60,6 +62,17 @@ object SignalSymbols {
}
}
private fun getRegularWeightedFont(context: Context): Typeface {
return cache.getOrPut(
Weight.REGULAR
) {
Typeface.createFromAsset(
context.assets,
"fonts/SignalSymbols-Regular.otf"
)
}
}
/**
* Custom TypefaceSpan to support TypefaceSpan in API<28
*