From 293405c8d1b334ceb7e15bfc58ca20c3c73256e7 Mon Sep 17 00:00:00 2001 From: renhaoting <370797079@qq.com> Date: Wed, 29 Oct 2025 14:53:48 +0800 Subject: [PATCH] =?UTF-8?q?sound=20=E9=80=89=E6=8B=A9=E5=99=A8=20RV?= =?UTF-8?q?=E8=B5=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../visualnovel/entity/response/ChatSound.kt | 7 +-- .../visualnovel/ui/chat/ui/ChatSettingView.kt | 50 ++++++++++++++++-- .../ExpandSoundSelectView.kt | 46 ++++++++-------- .../expandableSelector/ExpandSoundSubView.kt | 15 ++++-- .../layout_expand_sound_select_view.xml | 9 ++-- .../res/mipmap-xxhdpi/setting_sound_icon.webp | Bin 0 -> 1830 bytes .../app/src/main/res/values/strings.xml | 1 + 7 files changed, 88 insertions(+), 40 deletions(-) create mode 100644 VisualNovel/app/src/main/res/mipmap-xxhdpi/setting_sound_icon.webp diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/entity/response/ChatSound.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/entity/response/ChatSound.kt index e3b0354..41af03a 100644 --- a/VisualNovel/app/src/main/java/com/remax/visualnovel/entity/response/ChatSound.kt +++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/entity/response/ChatSound.kt @@ -6,10 +6,6 @@ import kotlinx.parcelize.Parcelize @Parcelize data class ChatSound( - /** - * code - */ - val code: String, /** * id @@ -34,7 +30,7 @@ data class ChatSound( /** * actor 性别 */ - var isMale: Boolean, + val isMale: Boolean, /** * 当前用户是否解锁 false:未解锁,true:解锁 @@ -50,7 +46,6 @@ data class ChatSound( * 解锁类型 MEMBER:会员 HEARTBEAT_LEVEL:心动等级 */ val unlockType: String? = null, - var isDefault: Boolean, var select: Boolean = false ) : Parcelable { companion object { diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/ChatSettingView.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/ChatSettingView.kt index ac008f0..e74a3a2 100644 --- a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/ChatSettingView.kt +++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/ChatSettingView.kt @@ -9,6 +9,7 @@ import android.widget.LinearLayout import androidx.core.graphics.toColorInt import com.remax.visualnovel.R import com.remax.visualnovel.databinding.LayoutChatMenuViewBinding +import com.remax.visualnovel.entity.response.ChatSound import com.remax.visualnovel.ui.chat.ui.expandableSelector.SelectorItem class ChatSettingView @JvmOverloads constructor( @@ -25,11 +26,12 @@ class ChatSettingView @JvmOverloads constructor( } - initAiModelList() + initAiModelSelectorView() + initSoundSelectorView() } - fun initAiModelList() { + fun initAiModelSelectorView() { val items = listOf( SelectorItem( name = "Max-0618", @@ -63,9 +65,51 @@ class ChatSettingView @JvmOverloads constructor( mBinding.aiModelSelector.setTitleIcon(R.mipmap.setting_ai_model) mBinding.aiModelSelector.setItems(items) mBinding.aiModelSelector.selectItem(0) - //mBinding.aiModelSelector.setTitleText(R.string.xxxx) + } + fun initSoundSelectorView() { + val items = listOf( + ChatSound( + id = 1L, + name = "Sound-1", + description = "This is description for sound-1", + isMale = true, + imgUrl = "aa" + ), + ChatSound( + id = 2L, + name = "Sound-2", + description = "This is description for sound-2", + isMale = true, + imgUrl = "aa" + ), + ChatSound( + id = 3L, + name = "Sound-3", + description = "This is description for sound-3", + isMale = true, + imgUrl = "aa" + ), + + ChatSound( + id = 4L, + name = "Sound-4", + description = "This is description for sound-4", + isMale = true, + imgUrl = "aa" + ), + + ChatSound( + id = 5L, + name = "Sound-5", + description = "This is description for sound-5", + isMale = true, + imgUrl = "aa" + ) + ) + + mBinding.soundActorSelector.setItems(items) } diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/expandableSelector/ExpandSoundSelectView.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/expandableSelector/ExpandSoundSelectView.kt index 8360981..7822393 100644 --- a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/expandableSelector/ExpandSoundSelectView.kt +++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/expandableSelector/ExpandSoundSelectView.kt @@ -5,13 +5,18 @@ import android.animation.AnimatorListenerAdapter import android.animation.ObjectAnimator import android.animation.ValueAnimator import android.content.Context +import android.graphics.drawable.GradientDrawable import android.util.AttributeSet import android.view.LayoutInflater -import android.view.ViewGroup +import android.view.View import android.view.animation.AccelerateDecelerateInterpolator import android.widget.LinearLayout +import android.widget.TextView import com.remax.visualnovel.R -import com.remax.visualnovel.databinding.LayoutExpandSoundSelectViewBinding +import com.remax.visualnovel.databinding.LayoutExpandSelectViewBinding +import com.remax.visualnovel.databinding.LayoutSettingSoundSubViewBinding +import com.remax.visualnovel.entity.response.ChatSound +import com.remax.visualnovel.utils.spannablex.utils.dp class ExpandSoundSelectView @JvmOverloads constructor( @@ -19,8 +24,8 @@ class ExpandSoundSelectView @JvmOverloads constructor( attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : LinearLayout(context, attrs, defStyleAttr) { - - private lateinit var mBinding: LayoutExpandSoundSelectViewBinding + private lateinit var mBinding: LayoutExpandSelectViewBinding + private lateinit var mExpandView : ExpandSoundSubView private var isExpanded = false private var animationDuration = 300 @@ -31,19 +36,13 @@ class ExpandSoundSelectView @JvmOverloads constructor( } private fun initView(context: Context, attrs: AttributeSet?) { - mBinding = LayoutExpandSoundSelectViewBinding.inflate(LayoutInflater.from(context)) - setupAttributes(attrs) - setupClickListeners() - } + mBinding = LayoutExpandSelectViewBinding.inflate(LayoutInflater.from(context), this, true) - private fun setupAttributes(attrs: AttributeSet?) { - attrs?.let { - val typedArray = context.obtainStyledAttributes(it, R.styleable.ExpandableSelector) - val title = typedArray.getString(R.styleable.ExpandableSelector_titleText) - title?.let { mBinding.titleText.text = it } - animationDuration = typedArray.getInt(R.styleable.ExpandableSelector_animationDuration, 300) - typedArray.recycle() - } + mExpandView = ExpandSoundSubView(context) + mBinding.itemsContainer.addView(mExpandView, LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)) + setTitleText(R.string.title_sound_actor) + setTitleIcon(R.mipmap.setting_sound_icon) + setupClickListeners() } private fun setupClickListeners() { @@ -59,6 +58,10 @@ class ExpandSoundSelectView @JvmOverloads constructor( mBinding.titleText.text = context.resources.getString(titleRes) } + fun setItems(newItems: List) { + mExpandView.setItems(newItems) + } + fun toggle() { if (isExpanded) collapse() else expand() @@ -68,7 +71,7 @@ class ExpandSoundSelectView @JvmOverloads constructor( if (isExpanded) return isExpanded = true - mBinding.itemsContainer.visibility = VISIBLE + mBinding.itemsContainer.visibility = View.VISIBLE animateArrow(0f, 90f) // param height anim val animator = ValueAnimator.ofInt(0, getItemsHeight()) @@ -101,7 +104,7 @@ class ExpandSoundSelectView @JvmOverloads constructor( } animator.addListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { - mBinding.itemsContainer.visibility = GONE + mBinding.itemsContainer.visibility = View.GONE } }) animator.start() @@ -134,11 +137,4 @@ class ExpandSoundSelectView @JvmOverloads constructor( interface OnItemSelectedListener { fun onItemSelected(position: Int, item: SelectorItem) } - - - /* new added */ - fun setCustomExpandView(expandView: ViewGroup) { - mBinding.itemsContainer.addView(expandView) - } - } \ No newline at end of file diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/expandableSelector/ExpandSoundSubView.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/expandableSelector/ExpandSoundSubView.kt index fc98a3e..b27760c 100644 --- a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/expandableSelector/ExpandSoundSubView.kt +++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ui/expandableSelector/ExpandSoundSubView.kt @@ -9,11 +9,14 @@ import com.drake.brv.annotaion.DividerOrientation import com.drake.brv.utils.bindingAdapter import com.drake.brv.utils.divider import com.drake.brv.utils.grid +import com.drake.brv.utils.linear +import com.drake.brv.utils.models import com.drake.brv.utils.setup import com.remax.visualnovel.R import com.remax.visualnovel.databinding.LayoutItemSettingSoundBinding import com.remax.visualnovel.databinding.LayoutSettingSoundSubViewBinding import com.remax.visualnovel.entity.response.ChatSound +import com.remax.visualnovel.extension.glide.load import com.remax.visualnovel.widget.uitoken.changeBackground import com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout @@ -22,11 +25,12 @@ class ExpandSoundSubView @JvmOverloads constructor( attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : LinearLayout(context, attrs, defStyleAttr) { + private lateinit var items: List private var mBinding: LayoutSettingSoundSubViewBinding init { - mBinding = LayoutSettingSoundSubViewBinding.inflate(LayoutInflater.from(context)) + mBinding = LayoutSettingSoundSubViewBinding.inflate(LayoutInflater.from(context), this, true) with(mBinding) { initRadioGroup(radioGroup) initRv(itemsRv) @@ -46,7 +50,7 @@ class ExpandSoundSubView @JvmOverloads constructor( } private fun initRv(itemsRv: RecyclerView) { - itemsRv.grid(2) + itemsRv.linear(VERTICAL) .divider { setDivider(16, true) orientation = DividerOrientation.VERTICAL @@ -73,7 +77,7 @@ class ExpandSoundSubView @JvmOverloads constructor( val item = getModel() with(getBinding()) { if (!item.imgUrl.isNullOrEmpty()) { - userAvatar.setImageResource(R.mipmap.sex_man_big) + userAvatar.load(item.imgUrl) } else { userAvatar.setImageResource(if (item.isMale) R.mipmap.ic_gender_male else R.mipmap.ic_gender_female) } @@ -87,5 +91,10 @@ class ExpandSoundSubView @JvmOverloads constructor( } } + fun setItems(newItems: List) { + items = newItems + mBinding.itemsRv.models = items + } + } \ No newline at end of file diff --git a/VisualNovel/app/src/main/res/layout/layout_expand_sound_select_view.xml b/VisualNovel/app/src/main/res/layout/layout_expand_sound_select_view.xml index 18eea4a..b7048a6 100644 --- a/VisualNovel/app/src/main/res/layout/layout_expand_sound_select_view.xml +++ b/VisualNovel/app/src/main/res/layout/layout_expand_sound_select_view.xml @@ -18,7 +18,8 @@ android:id="@+id/icon" android:layout_width="24dp" android:layout_height="24dp" - android:layout_centerVertical="true" /> + android:layout_centerVertical="true" + android:src="@mipmap/setting_sound_play"/> + android:textStyle="normal" + android:text="@string/title_sound_actor" + /> + android:visibility="gone"> =4}H?sR%I&y z*yGlY7)KM=?EnB>s9UT*Cv9vT8)488z#7GVGc-jG45gy&tkqoIaB5q70Ss#E=II?0 zv_W6>kZQhtL(A9ts^Y(c+X%!EZ%8r)bp#dK9Li}I#JhYqSX0bi8*C=#UqXXIA&sM$ zsm^E{hzSsD`hLM)U$A!&Rjj`TY0St0VdA~SCO(}EG0?>cdP_ka4nhDL*a2(t`Jpjn zlxzS@<^YgL`W*9O08kbOz#hTp7~&oPvUC8r&7WhR?bbt$X2@^y@d03(1;7qB z0KRz(z;^fbImrD>ZfejJ9LkFVHD3?_h(HaT1cAUCXhWnA6;%%yLls8pNCKc^L6enh zkSx22utQ^-yPVRL=hu{{6xx11kfj9sCu;6g?m1Zl)A^B{rx3XJWMa;v%x95#)Y|S? ziF4Tk6tb2}-W!h^RN-jrrl)#|msewgPr2QP>! zy(tad^QQBrMXD--AwN>qgTf9LixVdFaK|nz2>c7Q+D53`F1Q$ku(|optfqQZtYw-2 zXW!vWSf{blxxT}(l{+Z0EAxHv9&2-%33<}7QtEU$YbkZnjr;6Ton+vgY;~7lPY-?YEoVDg7vxy{ojQMzcP_>Ky`LLXUoHMeNbDY)T zA!N^*ZMYxbLbk7s9o0l!*814VFZbjyuSdkdy+ucm6vK#Sd_`{BK3|*79JP4D;2C*d z{=N^SogMtfR;+wux1rMPlAg_Sw9Q?3vOsz5m1FhTbPK>q;(e7n1IXyvgse7)ve8ZHOl12Qk^8*R z_(gOU4DNs1tLNC|E@{_g+e132%YMaA^^IBw_J^T`D7wir8Zo$zS~6es%gqU8OwkqS zPh#nWvfQ*!W!NF5!^-8Y7bA=IvGfzMGs(M0S3NGx4qXzMBEpPCnfFES`zEs$XxFQ zh2KAAcuPxL3l8+u}Ws(T-AW?oXPj7=nv{WcPHbf zYJVHh#F{Rz(5GvMQSk6KyJCxnSvcnDn&kt7L(7#I$(}cfyy&gncI6j+c&W8+*vtfU zh)vCYb$XKP5*zQb#30tyUeizK=Z}wJ3wxqPF*|v+@-0}5Pq?ebjl;KWL;cWC(8Tc< z<94c%E~&(qyhF%^ND>Ox+}l*6NMPve+Y2=dG6=_(-c(Gm_Kf_*7om4GeXLhrHM3}N zn8_A3#=^C!edTE*?Gq7aRd1d!vM4%7N(r>LPIYUyol6~M_hk3#YjyQkY5O*uLPeJC zEgA|#m+ZSV?EGufg_M@yS(S`aVY(NOVA3_Tj}!LyH{u>$*((2TxHRCHP?F5Qy(NmF z*G0i+G9RQww^#-v6zV>`VC0^$P}=72^&S6OjecHN+(AWTIax`7f6{szb6l~)LLnq# e(OtC!xn^YO*T!}!!0dP#JXrdEZDGYy8vG3nWyRP4 literal 0 HcmV?d00001 diff --git a/VisualNovel/app/src/main/res/values/strings.xml b/VisualNovel/app/src/main/res/values/strings.xml index 2f0b91b..246fe9d 100644 --- a/VisualNovel/app/src/main/res/values/strings.xml +++ b/VisualNovel/app/src/main/res/values/strings.xml @@ -480,5 +480,6 @@ Play dialogue only Maximum number of response tokens Font Size + Voice actor \ No newline at end of file