feat(report): 캐릭터 댓글 신고 사유를 라디오 버튼으로 변경 및 비활성 시각화

- 댓글 신고 사유 리스트 변경
- 댓글 신고 사유 선택 UI를 RadioGroup/RadioButton으로 전환
- 선택 전 신고 버튼 비활성화 및 alpha 적용으로 시각적 비활성화 처리
- 선택 시 버튼 활성화 및 alpha 복구
This commit is contained in:
2025-08-22 03:04:50 +09:00
parent 7dd6d46a5f
commit 52c1f61109
2 changed files with 56 additions and 25 deletions

View File

@@ -1,15 +1,18 @@
package kr.co.vividnext.sodalive.chat.character.comment package kr.co.vividnext.sodalive.chat.character.comment
import android.os.Bundle import android.os.Bundle
import android.util.TypedValue
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button import android.widget.Button
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout import android.widget.RadioButton
import android.widget.RadioGroup
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import kr.co.vividnext.sodalive.R import kr.co.vividnext.sodalive.R
@@ -39,33 +42,48 @@ class CharacterCommentReportBottomSheet : BottomSheetDialogFragment() {
): View { ): View {
val view = inflater.inflate(R.layout.dialog_character_comment_report, container, false) val view = inflater.inflate(R.layout.dialog_character_comment_report, container, false)
val tvTitle = view.findViewById<TextView>(R.id.tv_title) val tvTitle = view.findViewById<TextView>(R.id.tv_title)
val llList = view.findViewById<LinearLayout>(R.id.ll_reason_list) val rgList = view.findViewById<RadioGroup>(R.id.rg_reason_list)
val btnReport = view.findViewById<Button>(R.id.btn_report) val btnReport = view.findViewById<Button>(R.id.btn_report)
val ivClose = view.findViewById<ImageView>(R.id.iv_close) val ivClose = view.findViewById<ImageView>(R.id.iv_close)
tvTitle.text = getString(R.string.report_title) tvTitle.text = getString(R.string.report_title)
btnReport.isEnabled = false setReportEnabled(btnReport, false)
val items = reasons ?: DEFAULT_REASONS val items = reasons ?: DEFAULT_REASONS
val textColor = ContextCompat.getColor(requireContext(), R.color.white)
// 동적 리스트 구성: 단일 선택 // RadioButton 동적 생성 및 단일 선택 처리
items.forEachIndexed { index, text -> items.forEachIndexed { index, text ->
val itemView = inflater.inflate(R.layout.item_report_reason, llList, false) val rb = RadioButton(requireContext()).apply {
val tvText = itemView.findViewById<TextView>(R.id.tv_reason) id = View.generateViewId()
val ivCheck = itemView.findViewById<ImageView>(R.id.iv_check) tag = index
tvText.text = text this.text = text
ivCheck.isVisible = index == selectedIndex // 텍스트 색: 흰색
itemView.setOnClickListener { setTextColor(textColor)
selectedIndex = index // 텍스트 크기: 기존 15sp의 1.3배 -> 19.5sp
// 전체를 다시 그릴 정도는 아니므로 자식들만 순회하며 체크 상태 갱신 setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f)
for (i in 0 until llList.childCount) { // 폰트: pretendard_regular
val child = llList.getChildAt(i) try {
val check = child.findViewById<ImageView>(R.id.iv_check) typeface = ResourcesCompat.getFont(context, R.font.pretendard_regular)
check?.isVisible = i == selectedIndex } catch (_: Exception) { /* 폰트 미존재 대비 안전 처리 */ }
// 항목 간 간격: 기존 paddingVertical 12dp의 1.3배 -> 15.6dp
val vPadPx = (14f * resources.displayMetrics.density).toInt()
setPadding(paddingLeft, vPadPx, paddingRight, vPadPx)
// 버튼 틴트는 시스템 기본 사용, 필요 시 색상 리소스 적용 가능
} }
btnReport.isEnabled = true // 항목 좌우 여백은 유지, 필요 시 LayoutParams로 마진 조정 가능
rgList.addView(rb)
}
rgList.setOnCheckedChangeListener { group, checkedId ->
if (checkedId != -1) {
val selected = group.findViewById<RadioButton>(checkedId)
selectedIndex = (selected.tag as? Int) ?: -1
setReportEnabled(btnReport, true)
} else {
selectedIndex = -1
setReportEnabled(btnReport, false)
} }
llList.addView(itemView)
} }
ivClose.setOnClickListener { dismiss() } ivClose.setOnClickListener { dismiss() }
@@ -80,11 +98,22 @@ class CharacterCommentReportBottomSheet : BottomSheetDialogFragment() {
return view return view
} }
private fun setReportEnabled(button: Button, enabled: Boolean) {
button.isEnabled = enabled
button.alpha = if (enabled) 1.0f else 0.4f
}
companion object { companion object {
private const val ARG_REASONS = "arg_reasons" private const val ARG_REASONS = "arg_reasons"
private val DEFAULT_REASONS = arrayListOf( private val DEFAULT_REASONS = arrayListOf(
"스팸/광고", "욕설/비하", "음란물/불건전", "개인정보 노출", "기타" "원치 않는 상업성 콘텐츠 또는 스팸",
"아동 학대",
"증오시 표현 또는 노골적인 폭력",
"테러 조장",
"희롱 또는 괴롭힘",
"자살 또는 자해",
"잘못된 정보"
) )
fun newInstance(reasons: ArrayList<String>? = null): CharacterCommentReportBottomSheet { fun newInstance(reasons: ArrayList<String>? = null): CharacterCommentReportBottomSheet {

View File

@@ -27,7 +27,7 @@
android:layout_height="24dp" android:layout_height="24dp"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:contentDescription="@null" android:contentDescription="@null"
android:src="@drawable/ic_circle_x_white" /> android:src="@drawable/ic_close_white" />
</RelativeLayout> </RelativeLayout>
<View <View
@@ -36,8 +36,8 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:background="#78909C" /> android:background="#78909C" />
<LinearLayout <RadioGroup
android:id="@+id/ll_reason_list" android:id="@+id/rg_reason_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
@@ -50,6 +50,8 @@
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:backgroundTint="@color/color_3bb9f1" android:backgroundTint="@color/color_3bb9f1"
android:enabled="false" android:enabled="false"
android:fontFamily="@font/pretendard_bold"
android:text="@string/report_button" android:text="@string/report_button"
android:textColor="@color/white" /> android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout> </LinearLayout>