diff --git a/app/src/main/java/com/chwl/app/ui/widget/dialog/AllServiceGiftLevelDialog.kt b/app/src/main/java/com/chwl/app/ui/widget/dialog/AllServiceGiftLevelDialog.kt index 65c449ba1..5da309167 100644 --- a/app/src/main/java/com/chwl/app/ui/widget/dialog/AllServiceGiftLevelDialog.kt +++ b/app/src/main/java/com/chwl/app/ui/widget/dialog/AllServiceGiftLevelDialog.kt @@ -22,6 +22,7 @@ import com.chwl.app.databinding.DialogGiftAllServiceLevelBinding import com.chwl.core.initial.InitialModel import com.chwl.core.noble.bean.AllServiceGiftProtocol import com.chwl.library.utils.JavaUtil +import com.example.lib_utils.ktx.getStringById import io.reactivex.Observable import io.reactivex.disposables.Disposable import java.util.concurrent.TimeUnit @@ -98,21 +99,19 @@ class AllServiceGiftLevelDialog : BaseDialog { } else { binding.tvCount.text = "X${data.giftNum}" } - SpannableTextBuilder(binding.tvMessage) - .appendText( - data.sendUserNick, + val message = context.getString(R.string.all_gift_message_format) + .format(data.sendUserNick ?: "", data.recvUserNick ?: "", data.giftName ?: "") + SpannableTextBuilder(binding.tvMessage).appendText(message) + .setTextStyle( + data.sendUserNick ?: "", binding.tvMessage.context.getColorById(R.color.color_FFE468) ) - .appendText( - R.string.avroom_widget_messageview_0137.toStringRes(), - binding.tvMessage.context.getColorById(R.color.white) - ) - .appendText( + .setTextStyle( data.recvUserNick + " ", binding.tvMessage.context.getColorById(R.color.color_FFE468) ) - .appendText( - data.giftName, + .setTextStyle( + data.giftName ?: "", binding.tvMessage.context.getColorById(R.color.white) ).apply() when (data.levelNum.toIntOrNull()) { diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_recharge_auto_mirrored.xml b/app/src/main/res/drawable-xhdpi/ic_arrow_recharge_auto_mirrored.xml new file mode 100644 index 000000000..464a8c1d4 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/ic_arrow_recharge_auto_mirrored.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_bottom_gift.xml b/app/src/main/res/layout/dialog_bottom_gift.xml index 0d33938d7..273372522 100644 --- a/app/src/main/res/layout/dialog_bottom_gift.xml +++ b/app/src/main/res/layout/dialog_bottom_gift.xml @@ -134,7 +134,7 @@ android:id="@+id/gift_indicator" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center_vertical" /> + android:layout_gravity="start|center_vertical" /> @@ -181,7 +181,7 @@ android:layout_height="wrap_content" android:src="@drawable/ic_week_star" /> - + app:drawableEndCompat="@drawable/ic_arrow_recharge_auto_mirrored" /> diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index e872b548a..e9c1cdc26 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -5264,4 +5264,5 @@ كمية النقود المراد صرفها لا يمكن أن تتجاوز %s (نقود) إجمالي العائدات (نقود) + %1$s يعطي إلى %2$s %3$s \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 7a0a6a2fd..5ff0cac19 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -5206,4 +5206,5 @@ (金幣) 總收入(金幣) 来遇见你的专属声音 + %1$s 送给 %2$s %3$s \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 742c8bcf8..ab6403513 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5241,6 +5241,7 @@ \'s gift shared room A little heart has been sent to the other party~ + %1$s give to %2$s %3$s diff --git a/libs/lib_utils/src/main/java/com/example/lib_utils/spannable/SpannableTextBuilder.kt b/libs/lib_utils/src/main/java/com/example/lib_utils/spannable/SpannableTextBuilder.kt index bd74fa794..1de51695d 100644 --- a/libs/lib_utils/src/main/java/com/example/lib_utils/spannable/SpannableTextBuilder.kt +++ b/libs/lib_utils/src/main/java/com/example/lib_utils/spannable/SpannableTextBuilder.kt @@ -65,63 +65,17 @@ class SpannableTextBuilder(private val textView: TextView) { val start = spannableBuilder.length spannableBuilder.append(text) val end = spannableBuilder.length - - // 文本颜色 - if (textColor != null) { - spannableBuilder.setSpan( - ForegroundColorSpan(textColor), - start, - end, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE - ) - } - - // 文本背景颜色 - if (backgroundColor != null) { - spannableBuilder.setSpan( - BackgroundColorSpan(backgroundColor), - start, - end, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE - ) - } - - // 文本大小 - if (textSize != null) { - spannableBuilder.setSpan( - AbsoluteSizeSpan(textSize, true), - start, - end, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE - ) - } - - // 文本样式 - if (textStyle != null) { - spannableBuilder.setSpan( - StyleSpan(textStyle), - start, - end, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE - ) - } - - // 下划线 - if (underline == true) { - spannableBuilder.setSpan(UnderlineSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) - } - - // 点击事件 - if (clickListener != null) { - // 设置highlightColor=Color.TRANSPARENT,可以解决点击时的高亮色问题,但光标的区域选中也是透明的,貌似对用户体验不太好 -// textView.highlightColor = Color.TRANSPARENT - textView.movementMethod = LinkMovementMethod.getInstance() - val clickableSpan = TextClickableSpan( - clickListener, text, textColor - ?: textView.currentTextColor, underline ?: false - ) - spannableBuilder.setSpan(clickableSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) - } + setTextStyle( + text, + start, + end, + textColor, + backgroundColor, + textSize, + textStyle, + underline, + clickListener + ) return this } @@ -224,6 +178,109 @@ class SpannableTextBuilder(private val textView: TextView) { return this } + private fun setTextStyle( + text: String, + start: Int, + end: Int, + @ColorInt textColor: Int? = null, + @ColorInt backgroundColor: Int? = null, + textSize: Int? = null, + textStyle: Int? = null, + underline: Boolean? = null, + clickListener: ((String) -> Unit)? = null + ): SpannableTextBuilder { + if (start < 0 || end > spannableBuilder.length) { + return this + } + // 文本颜色 + if (textColor != null) { + spannableBuilder.setSpan( + ForegroundColorSpan(textColor), + start, + end, + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE + ) + } + + // 文本背景颜色 + if (backgroundColor != null) { + spannableBuilder.setSpan( + BackgroundColorSpan(backgroundColor), + start, + end, + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE + ) + } + + // 文本大小 + if (textSize != null) { + spannableBuilder.setSpan( + AbsoluteSizeSpan(textSize, true), + start, + end, + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE + ) + } + + // 文本样式 + if (textStyle != null) { + spannableBuilder.setSpan( + StyleSpan(textStyle), + start, + end, + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE + ) + } + + // 下划线 + if (underline == true) { + spannableBuilder.setSpan(UnderlineSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + } + + // 点击事件 + if (clickListener != null) { + // 设置highlightColor=Color.TRANSPARENT,可以解决点击时的高亮色问题,但光标的区域选中也是透明的,貌似对用户体验不太好 +// textView.highlightColor = Color.TRANSPARENT + textView.movementMethod = LinkMovementMethod.getInstance() + val clickableSpan = TextClickableSpan( + clickListener, text, textColor + ?: textView.currentTextColor, underline ?: false + ) + spannableBuilder.setSpan(clickableSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + } + return this + } + + fun setTextStyle( + text: String, + @ColorInt textColor: Int? = null, + @ColorInt backgroundColor: Int? = null, + textSize: Int? = null, + textStyle: Int? = null, + underline: Boolean? = null, + clickListener: ((String) -> Unit)? = null + ): SpannableTextBuilder { + if (text.isEmpty()) { + return this + } + val start = spannableBuilder.indexOf(text) + if (start == -1) { + return this + } + val end = start + text.length + return setTextStyle( + text, + start, + end, + textColor, + backgroundColor, + textSize, + textStyle, + underline, + clickListener + ) + } + fun build(): SpannableStringBuilder { return spannableBuilder }