sound 模块 RadioGroup Ui 调整
This commit is contained in:
		
							parent
							
								
									35481519c5
								
							
						
					
					
						commit
						d9ca052d8e
					
				|  | @ -117,7 +117,7 @@ class ChatSettingView @JvmOverloads constructor( | |||
|                 id = 2L, | ||||
|                 name = "Sound-2", | ||||
|                 description = "This is description for sound-2", | ||||
|                 isMale = true, | ||||
|                 isMale = false, | ||||
|                 imgUrl = "" | ||||
|             ), | ||||
| 
 | ||||
|  | @ -133,7 +133,7 @@ class ChatSettingView @JvmOverloads constructor( | |||
|                 id = 4L, | ||||
|                 name = "Sound-4", | ||||
|                 description = "This is description for sound-4", | ||||
|                 isMale = true, | ||||
|                 isMale = false, | ||||
|                 imgUrl = "" | ||||
|             ), | ||||
| 
 | ||||
|  |  | |||
|  | @ -20,6 +20,8 @@ class FontSetView @JvmOverloads constructor( | |||
|     private var mBinding: LayoutFontSetViewBinding | ||||
| 
 | ||||
|     private var mFontValue = 16  // 12, 14, 16, 18, 20 | ||||
|     private val mFontMinValue = 16 | ||||
|     private val mFontMaxValue = 20 | ||||
| 
 | ||||
|     init { | ||||
|         mBinding = LayoutFontSetViewBinding.inflate(LayoutInflater.from(context), this, true) | ||||
|  | @ -32,13 +34,17 @@ class FontSetView @JvmOverloads constructor( | |||
|     private fun setupClickListeners() { | ||||
|         with (mBinding) { | ||||
|             ivFontPlus.setOnClickListener { | ||||
|                 mFontValue -= GAP | ||||
|                 if (mFontValue > mFontMinValue) { | ||||
|                     mFontValue -= GAP | ||||
|                 } | ||||
|                 tvFontValue.text = mFontValue.toString() | ||||
|                 levelSeekbar.setLevel((mFontValue - 16)/GAP) | ||||
|             } | ||||
| 
 | ||||
|             ivFontAdd.setOnClickListener { | ||||
|                 mFontValue += GAP | ||||
|                 if (mFontValue < mFontMinValue) { | ||||
|                     mFontValue += GAP | ||||
|                 } | ||||
|                 tvFontValue.text = mFontValue.toString() | ||||
|                 levelSeekbar.setLevel((mFontValue - 16)/GAP) | ||||
|             } | ||||
|  | @ -50,6 +56,12 @@ class FontSetView @JvmOverloads constructor( | |||
|                     fromUser: Boolean | ||||
|                 ) { | ||||
|                     mFontValue = 16 + level * GAP | ||||
|                     if (mFontValue > mFontMaxValue) { | ||||
|                         mFontValue = mFontMaxValue | ||||
|                     } | ||||
|                     if (mFontValue < mFontMinValue) { | ||||
|                         mFontValue = mFontMinValue | ||||
|                     } | ||||
|                     tvFontValue.text = mFontValue.toString() | ||||
|                 } | ||||
| 
 | ||||
|  |  | |||
|  | @ -110,7 +110,7 @@ class LevelSeekBar @JvmOverloads constructor( | |||
|     } | ||||
| 
 | ||||
|     private fun drawTrack(canvas: Canvas) { | ||||
|         val centerY = height / 2f | ||||
|         val centerY = height / 2f + 3 // TODO check y location | ||||
|         val trackTop = centerY - trackHeight / 2 | ||||
|         val trackBottom = centerY + trackHeight / 2 | ||||
| 
 | ||||
|  |  | |||
|  | @ -46,7 +46,7 @@ class ExpandBubbleSubView @JvmOverloads constructor( | |||
|             }.setup { | ||||
|                 addType<ChatBubble>(R.layout.layout_item_setting_bubble) | ||||
| 
 | ||||
|                 onClick(R.id.tv_select) { | ||||
|                 onClick(R.id.iv_select) { | ||||
|                     val bubble = getModel<ChatBubble>() | ||||
|                     if (!bubble.select) { | ||||
|                         itemsRv.bindingAdapter.models?.filterIsInstance<ChatBubble>()?.forEach { item -> | ||||
|  |  | |||
|  | @ -5,18 +5,15 @@ 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.View | ||||
| import android.view.animation.AccelerateDecelerateInterpolator | ||||
| import android.widget.LinearLayout | ||||
| import android.widget.TextView | ||||
| import com.remax.visualnovel.R | ||||
| 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( | ||||
|  | @ -43,6 +40,12 @@ class ExpandSoundSelectView @JvmOverloads constructor( | |||
|         setTitleText(R.string.title_sound_actor) | ||||
|         setTitleIcon(R.mipmap.setting_sound_icon) | ||||
|         setupClickListeners() | ||||
| 
 | ||||
|         mExpandView.setEventListener(object: ExpandSoundSubView.IEventListener { | ||||
|             override fun onSoundSelected(sound: ChatSound) { | ||||
|                 setTitleText(sound.name) | ||||
|             } | ||||
|         }) | ||||
|     } | ||||
| 
 | ||||
|     private fun setupClickListeners() { | ||||
|  | @ -58,6 +61,10 @@ class ExpandSoundSelectView @JvmOverloads constructor( | |||
|         mBinding.titleText.text = context.resources.getString(titleRes) | ||||
|     } | ||||
| 
 | ||||
|     fun setTitleText(title: String) { | ||||
|         mBinding.titleText.text = title | ||||
|     } | ||||
| 
 | ||||
|     fun setItems(newItems: List<ChatSound>) { | ||||
|         mExpandView.setItems(newItems) | ||||
|     } | ||||
|  |  | |||
|  | @ -8,7 +8,6 @@ import androidx.recyclerview.widget.RecyclerView | |||
| 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 | ||||
|  | @ -17,7 +16,8 @@ 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.utils.ResUtil | ||||
| import com.remax.visualnovel.widget.uitoken.setBgColorDirectly | ||||
| import com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout | ||||
| 
 | ||||
| class ExpandSoundSubView @JvmOverloads constructor( | ||||
|  | @ -28,6 +28,13 @@ class ExpandSoundSubView @JvmOverloads constructor( | |||
|     private lateinit var items: List<ChatSound> | ||||
|     private var mBinding: LayoutSettingSoundSubViewBinding | ||||
| 
 | ||||
|     private lateinit var mEventListener: IEventListener | ||||
| 
 | ||||
| 
 | ||||
|     interface IEventListener { | ||||
|         fun onSoundSelected(sound: ChatSound) | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     init { | ||||
|         mBinding = LayoutSettingSoundSubViewBinding.inflate(LayoutInflater.from(context), this, true) | ||||
|  | @ -45,14 +52,15 @@ class ExpandSoundSubView @JvmOverloads constructor( | |||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     fun setSelectedSound() { | ||||
| 
 | ||||
|     fun setEventListener(eventListener: IEventListener) { | ||||
|         mEventListener = eventListener | ||||
|     } | ||||
| 
 | ||||
|     private fun initRv(itemsRv: RecyclerView) { | ||||
|         itemsRv.linear(VERTICAL) | ||||
|             .divider { | ||||
|                 setDivider(16, true) | ||||
|                 setDivider(5, true) | ||||
|                 orientation = DividerOrientation.VERTICAL | ||||
|             }.setup { | ||||
|                 addType<ChatSound>(R.layout.layout_item_setting_sound) | ||||
|  | @ -62,14 +70,14 @@ class ExpandSoundSubView @JvmOverloads constructor( | |||
|                     playActorSound(bubble) | ||||
|                 } | ||||
| 
 | ||||
|                 onClick(R.id.tv_select) { | ||||
|                     val bubble = getModel<ChatSound>() | ||||
|                     if (!bubble.select) { | ||||
|                 onClick(R.id.item_root) { | ||||
|                     val sound = getModel<ChatSound>() | ||||
|                     if (!sound.select) { | ||||
|                         itemsRv.bindingAdapter.models?.filterIsInstance<ChatSound>()?.forEach { item -> | ||||
|                             item.select = item == bubble | ||||
|                             item.select = item == sound | ||||
|                         } | ||||
|                         itemsRv.bindingAdapter.notifyDataSetChanged() | ||||
|                         setSelectedSound() | ||||
|                         mEventListener.onSoundSelected(sound) | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|  | @ -83,9 +91,10 @@ class ExpandSoundSubView @JvmOverloads constructor( | |||
|                         } | ||||
| 
 | ||||
|                         tvSoundName.text = item.name | ||||
|                         itemRoot.changeBackground(backgroundUIColorToken = if (item.isMale) R.string.male_bg else R.string.female_bg) | ||||
|                         tvSoundDescrible.setTextColor(context.resources.getColor(if (item.isMale) R.color.male_text_color else R.color.female_text_color)) | ||||
|                         itemRoot.setBgColorDirectly(bgColor = if (item.isMale) R.color.male_bg else R.color.female_bg, radius = ResUtil.getPixelSize(R.dimen.dp_10).toFloat()) | ||||
|                         tvSoundDescrible.setTextColor(ResUtil.getColor(if (item.isMale) R.color.male_text_color else R.color.female_text_color)) | ||||
|                         tvSoundDescrible.text = item.description | ||||
|                         ivSelect.setImageResource(if (item.select) R.drawable.sound_item_selected else R.drawable.sound_item_unselected) | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  |  | |||
|  | @ -0,0 +1,7 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <!-- 选中状态 --> | ||||
|     <item android:drawable="@drawable/radio_checked" android:state_checked="true" /> | ||||
|     <!-- 未选中状态 --> | ||||
|     <item android:drawable="@drawable/radio_unchecked" android:state_checked="false" /> | ||||
| </selector> | ||||
|  | @ -0,0 +1,8 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:shape="oval"> | ||||
|     <solid android:color="@android:color/white" /> | ||||
|     <size | ||||
|         android:width="@dimen/dp_10" | ||||
|         android:height="@dimen/dp_10" /> | ||||
| </shape> | ||||
|  | @ -0,0 +1,12 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <!-- 外层彩色圆环 --> | ||||
|     <item> | ||||
|         <shape android:shape="oval"> | ||||
|             <solid android:color="@color/transparent" /> | ||||
|             <size android:width="@dimen/dp_10" android:height="@dimen/dp_10" /> | ||||
|             <stroke android:color="@color/grayf6" android:width="@dimen/dp_2" /> | ||||
|         </shape> | ||||
|     </item> | ||||
| 
 | ||||
| </layer-list> | ||||
|  | @ -0,0 +1,16 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <item> | ||||
|         <shape android:shape="oval"> | ||||
|             <solid android:color="@color/black" /> | ||||
|             <size android:width="@dimen/dp_13" android:height="@dimen/dp_13" /> | ||||
|         </shape> | ||||
|     </item> | ||||
| 
 | ||||
|     <item> | ||||
|         <shape android:shape="oval"> | ||||
|             <size android:width="@dimen/dp_13" android:height="@dimen/dp_13" /> | ||||
|             <stroke android:color="@color/glo_color_green_90" android:width="@dimen/dp_2" /> | ||||
|         </shape> | ||||
|     </item> | ||||
| </layer-list> | ||||
|  | @ -0,0 +1,10 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <item> | ||||
|         <shape android:shape="oval"> | ||||
|             <solid android:color="@color/black" /> | ||||
|             <size android:width="@dimen/dp_13" android:height="@dimen/dp_13" /> | ||||
|         </shape> | ||||
|     </item> | ||||
| 
 | ||||
| </layer-list> | ||||
|  | @ -4,9 +4,9 @@ | |||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="wrap_content" | ||||
|     android:id="@+id/item_root" | ||||
|     app:backgroundColorToken="@string/color_glo_color_orange_10" | ||||
|     app:radiusToken="@string/radius_m" | ||||
|     android:padding="@dimen/dp_10" | ||||
|     app:advRadius="@dimen/dp_10" | ||||
|     app:advBgColor="@color/male_bg" | ||||
|     > | ||||
| 
 | ||||
| 
 | ||||
|  | @ -21,8 +21,8 @@ | |||
|             android:id="@+id/userAvatar" | ||||
|             android:layout_width="@dimen/dp_55" | ||||
|             android:layout_height="@dimen/dp_55" | ||||
|             app:backgroundColorToken="@string/color_primary_normal" | ||||
|             app:radiusToken="@string/radius_round" /> | ||||
|             app:advBgColor="@color/black" | ||||
|             app:advRadius="@dimen/dp_28" /> | ||||
| 
 | ||||
|         <com.remax.visualnovel.widget.uitoken.view.UITokenImageView | ||||
|             android:layout_width="@dimen/dp_20" | ||||
|  | @ -36,20 +36,13 @@ | |||
|     </FrameLayout> | ||||
| 
 | ||||
| 
 | ||||
|     <com.remax.visualnovel.widget.uitoken.view.UITokenTextView | ||||
|         android:id="@+id/tv_select" | ||||
|     <com.remax.visualnovel.widget.uitoken.view.UITokenImageView | ||||
|         android:id="@+id/iv_select" | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_alignParentEnd="true" | ||||
|         android:layout_centerVertical="true" | ||||
|         android:paddingVertical="@dimen/dp_8" | ||||
|         android:paddingHorizontal="@dimen/dp_10" | ||||
|         android:text="@string/select" | ||||
|         android:textSize="@dimen/sp_12" | ||||
|         android:textStyle="bold" | ||||
|         app:backgroundColorToken="@string/color_txt_primary_normal" | ||||
|         app:radiusToken="@string/radius_pill" | ||||
|         android:textColor="@color/chat_setting_ai_model_recommend_color" | ||||
|         android:src="@drawable/sound_item_selected" | ||||
|         /> | ||||
| 
 | ||||
| 
 | ||||
|  | @ -58,7 +51,7 @@ | |||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_toEndOf="@+id/left_container" | ||||
|         android:layout_toStartOf="@+id/tv_select" | ||||
|         android:layout_toStartOf="@+id/iv_select" | ||||
|         android:layout_marginHorizontal="@dimen/dp_9" | ||||
|         android:layout_centerVertical="true" | ||||
|         android:orientation="vertical" | ||||
|  |  | |||
|  | @ -12,12 +12,12 @@ | |||
|         android:layout_height="wrap_content" | ||||
|         android:gravity="center_vertical" | ||||
|         android:orientation="horizontal" | ||||
|         app:backgroundColorToken="@string/color_chat_setting_item_bg" | ||||
|         app:radiusToken="@string/radius_m" | ||||
|         app:advRadius="@dimen/dp_12" | ||||
|         app:advBgColor="@color/chat_setting_sex_radio_bg" | ||||
|         android:padding="@dimen/dp_12" | ||||
|         > | ||||
| 
 | ||||
|         <com.remax.visualnovel.widget.ui.RadioCheckButton | ||||
|         <!--<com.remax.visualnovel.widget.ui.RadioCheckButton | ||||
|             android:id="@+id/radio_all" | ||||
|             android:layout_width="16dp" | ||||
|             android:layout_height="16dp" | ||||
|  | @ -35,7 +35,43 @@ | |||
|             android:layout_width="16dp" | ||||
|             android:layout_height="16dp" | ||||
|             android:layout_marginLeft="@dimen/dp_20" | ||||
|             app:radioCheck="true" /> | ||||
|             app:radioCheck="true" />--> | ||||
| 
 | ||||
|         <RadioGroup | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:orientation="horizontal"> | ||||
| 
 | ||||
|             <RadioButton | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/all" | ||||
|                 android:button="@drawable/radio_button_selector" | ||||
|                 android:paddingHorizontal="@dimen/dp_5" | ||||
|                 android:textColor="@color/white" | ||||
|                 android:checked="true" | ||||
|                 /> | ||||
| 
 | ||||
|             <RadioButton | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/male" | ||||
|                 android:layout_marginLeft="10dp" | ||||
|                 android:layout_marginRight="10dp" | ||||
|                 android:paddingHorizontal="@dimen/dp_5" | ||||
|                 android:button="@drawable/radio_button_selector" | ||||
|                 android:textSize="@dimen/sp_13" | ||||
|                 android:textColor="@color/white" /> | ||||
| 
 | ||||
|             <RadioButton | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/female" | ||||
|                 android:paddingHorizontal="@dimen/dp_5" | ||||
|                 android:button="@drawable/radio_button_selector" | ||||
|                 android:textColor="@color/white" | ||||
|                 /> | ||||
|         </RadioGroup> | ||||
| 
 | ||||
|     </com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout> | ||||
| 
 | ||||
|  |  | |||
|  | @ -216,6 +216,9 @@ | |||
|     <!--  Font seekbar  --> | ||||
|     <color name="seekbar_color">#ffa4a8b7</color> | ||||
| 
 | ||||
|     <color name="chat_setting_sex_radio_bg">#ff241e2f</color> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue