Skip to content

Commit 21446a0

Browse files
committed
【TUILiveKit】【Android】publish beta version 3.6.1
1 parent 43020d8 commit 21446a0

File tree

53 files changed

+855
-368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+855
-368
lines changed

live/tuilivekit/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ dependencies {
6969
def projects = this.rootProject.getAllprojects().stream().map { project -> project.name }.collect()
7070
api projects.contains("tuicore") ? project(':tuicore') : "com.tencent.liteav.tuikit:tuicore:8.8.7357"
7171

72-
api rootProject.getProperties().containsKey("atomicxCoreSdk") ? rootProject.ext.atomicxCoreSdk : "io.trtc.uikit:atomicx-core:3.6.1.66"
72+
api rootProject.getProperties().containsKey("roomEngineSdk") ? rootProject.ext.roomEngineSdk : "io.trtc.uikit:rtc_room_engine:3.5.0.954"
73+
api rootProject.getProperties().containsKey("atomicxCoreSdk") ? rootProject.ext.atomicxCoreSdk : "io.trtc.uikit:atomicx-core:3.5.0.954"
74+
api rootProject.getProperties().containsKey("liteavSdk") ? rootProject.ext.liteavSdk : "com.tencent.liteav:LiteAVSDK_Professional:12.8.0.19279"
7375
api rootProject.getProperties().containsKey("imSdk") ? rootProject.ext.imSdk : "com.tencent.imsdk:imsdk-plus:8.7.7201"
7476
api rootProject.getProperties().containsKey("common") ? rootProject.ext.common : "io.trtc.uikit:common:3.3.0.1194"
7577
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.trtc.uikit.livekit.component.barrage.view
2+
3+
import android.graphics.Canvas
4+
import android.graphics.Paint
5+
import android.graphics.drawable.Drawable
6+
import android.text.style.ReplacementSpan
7+
8+
class AnchorTagSpan(
9+
private val text: String,
10+
private val textColor: Int,
11+
private val textSize: Float,
12+
private val background: Drawable,
13+
private val tagWidth: Int,
14+
private val tagHeight: Int,
15+
private val margin: Int,
16+
private val isRtl: Boolean = false
17+
) : ReplacementSpan() {
18+
19+
override fun getSize(
20+
paint: Paint,
21+
text: CharSequence,
22+
start: Int,
23+
end: Int,
24+
fm: Paint.FontMetricsInt?
25+
): Int {
26+
fm?.run {
27+
val pfm = paint.fontMetricsInt
28+
val centerOffset = (tagHeight - (pfm.descent - pfm.ascent)) / 2
29+
ascent = pfm.ascent - centerOffset
30+
top = pfm.top - centerOffset
31+
bottom = pfm.descent + centerOffset
32+
descent = pfm.descent + centerOffset
33+
}
34+
return tagWidth + margin
35+
}
36+
37+
override fun draw(
38+
canvas: Canvas,
39+
text: CharSequence,
40+
start: Int,
41+
end: Int,
42+
x: Float,
43+
top: Int,
44+
y: Int,
45+
bottom: Int,
46+
paint: Paint
47+
) {
48+
val pfm = paint.fontMetricsInt
49+
val fontCenter = y + (pfm.descent + pfm.ascent) / 2
50+
val tagTop = fontCenter - tagHeight / 2
51+
52+
val tagX = if (isRtl) x + margin else x
53+
54+
background.setBounds(tagX.toInt(), tagTop, tagX.toInt() + tagWidth, tagTop + tagHeight)
55+
background.draw(canvas)
56+
57+
val originalTextSize = paint.textSize
58+
val originalColor = paint.color
59+
60+
paint.textSize = textSize
61+
paint.color = textColor
62+
paint.isFakeBoldText = true
63+
64+
val textWidth = paint.measureText(this.text.uppercase())
65+
val textX = tagX + (tagWidth - textWidth) / 2
66+
val textY = tagTop + tagHeight / 2 - (paint.descent() + paint.ascent()) / 2
67+
68+
canvas.drawText(this.text.uppercase(), textX, textY, paint)
69+
70+
paint.textSize = originalTextSize
71+
paint.color = originalColor
72+
paint.isFakeBoldText = false
73+
}
74+
}

live/tuilivekit/src/main/java/com/trtc/uikit/livekit/component/barrage/view/EmojiSpan.kt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.graphics.Paint
55
import android.graphics.drawable.Drawable
66
import android.text.style.ImageSpan
77
import androidx.core.graphics.withSave
8-
import com.trtc.tuikit.common.util.ScreenUtil
98

109
class EmojiSpan @JvmOverloads constructor(
1110
drawable: Drawable,
@@ -20,13 +19,14 @@ class EmojiSpan @JvmOverloads constructor(
2019
fm: Paint.FontMetricsInt?
2120
) = drawable.bounds.right.also {
2221
fm?.run {
23-
val fontHeight = paint.fontMetricsInt.run { bottom - top }
24-
val drHeight = drawable.bounds.bottom + ScreenUtil.dip2px(6f)
25-
val centerY = drHeight / 2 - fontHeight / 4
26-
ascent = -centerY
27-
top = -centerY
28-
bottom = centerY
29-
descent = centerY
22+
val pfm = paint.fontMetricsInt
23+
val drHeight = drawable.bounds.height()
24+
val fontHeight = pfm.descent - pfm.ascent
25+
val centerOffset = (drHeight - fontHeight) / 2
26+
ascent = pfm.ascent - centerOffset
27+
top = pfm.top - centerOffset
28+
bottom = pfm.descent + centerOffset
29+
descent = pfm.descent + centerOffset
3030
}
3131
}
3232

@@ -41,11 +41,12 @@ class EmojiSpan @JvmOverloads constructor(
4141
bottom: Int,
4242
paint: Paint
4343
) {
44-
canvas.run {
45-
withSave {
46-
translate(x, ((bottom - top - drawable.bounds.bottom) / 2 + top - emojiTranslateY).toFloat())
47-
drawable.draw(this)
48-
}
44+
canvas.withSave {
45+
val pfm = paint.fontMetricsInt
46+
val fontCenter = y + (pfm.descent + pfm.ascent) / 2
47+
val translateY = fontCenter - drawable.bounds.height() / 2 - emojiTranslateY
48+
translate(x, translateY.toFloat())
49+
drawable.draw(this)
4950
}
5051
}
5152
}

0 commit comments

Comments
 (0)