Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.widget.PopupWindow
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import umc.onairmate.R
import umc.onairmate.data.model.entity.ParticipantData
import umc.onairmate.data.model.entity.UserData
import umc.onairmate.databinding.PopupParticipantOptionsBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import umc.onairmate.R
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
Expand Down Expand Up @@ -73,11 +74,13 @@ class ChatRoomParticipantsFragment : Fragment() {
adapter = ChatRoomParticipantRVAdapter( object : ParticipantItemClickListener {
// 팝업 - 신고 클릭
override fun clickReport(data: ParticipantData) {
val text = data.nickname+"님을 신고하시겠습니까?"
val textList = listOf(text,"예","아니오")
showPopup(text =textList, left = {
Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show()
}, right = {} )
// val text = data.nickname+"님을 신고하시겠습니까?"
// val textList = listOf(text,"예","아니오")
// showPopup(text =textList, left = {
// Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show()
// }, right = {} )

showReportPopup()
}
Comment on lines +77 to 84
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

신고 클릭 시 AlertDialog로 레이아웃만 띄워 로직이 전혀 연결되지 않습니다. ReportDialogFragment를 사용해 데이터와 콜백을 연결하세요.
현재 showReportPopup()은 닉네임 타이틀/제출 액션/닫기 등이 동작하지 않습니다.

-                showReportPopup()
+                showReportDialog(data)

아래의 showReportDialog 구현 제안을 참고해 주세요.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
app/src/main/java/umc/onairmate/ui/chat_room/drawer/participants/ChatRoomParticipantsFragment.kt
around lines 77 to 84, the current showReportPopup() only displays a static
AlertDialog layout with no data or callbacks wired; replace this with
ReportDialogFragment usage: instantiate
ReportDialogFragment.newInstance(nickname or data.id as needed), set its submit
and close callbacks (e.g., fragment.setOnSubmit { reason ->
submitReport(memberId, reason) } and fragment.setOnClose { /* dismiss */ }),
show it via childFragmentManager, and remove the old showReportPopup call so the
dialog title, submit action and close behavior are fully connected to the
fragment logic and backend report handling.


// 팝업 - 추천하기 클릭
Expand Down Expand Up @@ -164,11 +167,12 @@ class ChatRoomParticipantsFragment : Fragment() {

// 클릭 리스너 연결
popupBinding.tvReport.setOnClickListener {
val text = data.nickname+"님을 신고하시겠습니까?"
val textList = listOf(text,"예","아니오")
showPopup(text =textList, left = {
Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show()
}, right = {} )
// val text = data.nickname+"님을 신고하시겠습니까?"
// val textList = listOf(text,"예","아니오")
// showPopup(text =textList, left = {
// Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show()
// }, right = {} )
showReportPopup()
popupWindow.dismiss()
Comment on lines 169 to 176
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

팝업 메뉴의 신고도 동일하게 ReportDialogFragment로 연결 필요.
AlertDialog 단순 inflate는 기능 미구현 상태를 유발합니다.

-            showReportPopup()
+            showReportDialog(data)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
popupBinding.tvReport.setOnClickListener {
val text = data.nickname+"님을 신고하시겠습니까?"
val textList = listOf(text,"","아니오")
showPopup(text =textList, left = {
Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show()
}, right = {} )
// val text = data.nickname+"님을 신고하시겠습니까?"
// val textList = listOf(text,"예","아니오")
// showPopup(text =textList, left = {
// Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show()
// }, right = {} )
showReportPopup()
popupWindow.dismiss()
popupBinding.tvReport.setOnClickListener {
showReportDialog(data)
popupWindow.dismiss()
}

}
popupBinding.tvRecommend.setOnClickListener {
Expand All @@ -190,4 +194,16 @@ class ChatRoomParticipantsFragment : Fragment() {

popupWindow.showAsDropDown(anchorView, offsetX, offsetY)
}

//방장쪽에도 함수 있다함.
private fun showReportPopup(){
val dialogView = LayoutInflater.from(requireContext())
.inflate(R.layout.dialog_report, null)

val dialog = android.app.AlertDialog.Builder(requireContext())
.setView(dialogView)
.create()

dialog.show()
}
Comment on lines +197 to +208
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

AlertDialog로의 단순 inflate(showReportPopup)는 제거하고 ReportDialogFragment를 사용하세요.
참가자 정보 전달, 제출 콜백 처리, UI 바인딩을 일관되게 처리할 수 있습니다.

아래처럼 교체를 제안드립니다. (현재 ReportDialogFragment의 생성자 패턴을 그대로 사용한 최소 변경안)

-    //방장쪽에도 함수 있다함.
-    private fun showReportPopup(){
-        val dialogView = LayoutInflater.from(requireContext())
-            .inflate(R.layout.dialog_report, null)
-
-        val dialog = android.app.AlertDialog.Builder(requireContext())
-            .setView(dialogView)
-            .create()
-
-        dialog.show()
-    }
+    private fun showReportDialog(target: ParticipantData) {
+        ReportDialogFragment(
+            participant = target,
+            onSubmit = { reasons, extra ->
+                // TODO: 서버 신고 API 연동 (예: viewModel.reportUser)
+                Toast.makeText(
+                    requireContext(),
+                    "${target.nickname}님 신고 접수(${reasons.joinToString()})",
+                    Toast.LENGTH_SHORT
+                ).show()
+            }
+        ).show(parentFragmentManager, "ReportDialog")
+    }

참고: ReportDialogFragment의 생성자 주입은 프로세스 재시작 시 크래시 위험이 있어, newInstance(arguments) 방식으로의 리팩터도 아래 코멘트에서 제안드립니다.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
//방장쪽에도 함수 있다함.
private fun showReportPopup(){
val dialogView = LayoutInflater.from(requireContext())
.inflate(R.layout.dialog_report, null)
val dialog = android.app.AlertDialog.Builder(requireContext())
.setView(dialogView)
.create()
dialog.show()
}
private fun showReportDialog(target: ParticipantData) {
ReportDialogFragment(
participant = target,
onSubmit = { reasons, extra ->
// TODO: 서버 신고 API 연동 (예: viewModel.reportUser)
Toast.makeText(
requireContext(),
"${target.nickname}님 신고 접수(${reasons.joinToString()})",
Toast.LENGTH_SHORT
).show()
}
).show(parentFragmentManager, "ReportDialog")
}
🤖 Prompt for AI Agents
In
app/src/main/java/umc/onairmate/ui/chat_room/drawer/participants/ChatRoomParticipantsFragment.kt
around lines 197 to 208, replace the manual AlertDialog inflate showReportPopup
implementation with instantiation and presentation of ReportDialogFragment:
create the fragment using its current constructor pattern, pass the selected
participant info and a submit callback (or listener) so the fragment can handle
data binding and submission, and show it via
parentFragmentManager.beginTransaction()/show(parentFragmentManager, TAG) or
fragment.show(parentFragmentManager, TAG). Also update the callback wiring so
the fragment returns submission results to this fragment. Finally, mark a TODO
to refactor ReportDialogFragment to a newInstance(arguments) factory method for
safe argument passing on process restart.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package umc.onairmate.ui.chat_room.drawer.participants

import android.app.Dialog
import android.content.res.Resources
import android.os.Bundle
import androidx.fragment.app.DialogFragment
import umc.onairmate.data.model.entity.ParticipantData
import umc.onairmate.databinding.DialogReportBinding

class ReportDialogFragment(
private val participant: ParticipantData,
private val onSubmit: (reasons: List<String>, extraReason: String) -> Unit
) : DialogFragment() {
Comment on lines +10 to +13
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fragment에 생성자로 인자/콜백을 주입하면 프로세스 재시작 시 복원에 실패해 크래시 납니다. newInstance(ARG) + setter/FragmentResult로 전환하세요.
안정성을 위해 표준 패턴으로 리팩터가 필요합니다.

아래와 같이 최소 변경으로 전환을 제안드립니다.

-class ReportDialogFragment(
-    private val participant: ParticipantData,
-    private val onSubmit: (reasons: List<String>, extraReason: String) -> Unit
-) : DialogFragment() {
+class ReportDialogFragment : DialogFragment() {
 
-    private var _binding: DialogReportBinding? = null
+    private var _binding: DialogReportBinding? = null
     private val binding get() = _binding!!
+    private lateinit var participant: ParticipantData
+    private var onSubmit: ((reasons: List<String>, extraReason: String) -> Unit)? = null
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        participant = requireArguments().getParcelable(ARG_PARTICIPANT)!!
+    }
 
     override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
         // layoutInflater 사용
         _binding = DialogReportBinding.inflate(layoutInflater)
@@
-            onSubmit(reasons, extraReason)
+            onSubmit?.invoke(reasons, extraReason)
             dismiss()
         }
@@
-        return dialog
+        return dialog
     }
@@
 }
 
-private fun Int.dpToPx(): Int {
-    return (this * Resources.getSystem().displayMetrics.density).toInt()
-}
+companion object {
+    private const val ARG_PARTICIPANT = "arg_participant"
+    fun newInstance(participant: ParticipantData) = ReportDialogFragment().apply {
+        arguments = Bundle().apply { putParcelable(ARG_PARTICIPANT, participant) }
+    }
+}
+
+fun setOnSubmitListener(listener: (List<String>, String) -> Unit) {
+    this.onSubmit = listener
+}

이후 호출부에서는:

ReportDialogFragment.newInstance(target).apply {
    setOnSubmitListener { reasons, extra -> /* ... */ }
}.show(parentFragmentManager, "ReportDialog")

Also applies to: 15-17, 41-43

🤖 Prompt for AI Agents
In
app/src/main/java/umc/onairmate/ui/chat_room/drawer/participants/ReportDialogFragment.kt
around lines 10-13 (and also for lines 15-17, 41-43), the fragment currently
takes ParticipantData and an onSubmit callback via its primary constructor which
breaks fragment state restoration; change to the standard pattern: remove
constructor parameters, add a companion object newInstance(participant:
ParticipantData) that packages the participant (or its
id/serializable/parcelable fields) into a Bundle and sets it as arguments,
restore the participant from arguments in onCreate/onCreateView, and replace the
constructor callback with either a nullable setOnSubmitListener(reasons,
extra)->Unit setter or the FragmentResult API (provide setOnSubmitListener
method or sendResult in submit path). Update all call sites to use
ReportDialogFragment.newInstance(...).apply { setOnSubmitListener { ... } }.
Ensure fields are nullable and accessed after arguments restore to avoid
crashes.


private var _binding: DialogReportBinding? = null
private val binding get() = _binding!!

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
// layoutInflater 사용
_binding = DialogReportBinding.inflate(layoutInflater)

// 타이틀 세팅
binding.tvTitle.text = "[${participant.nickname}]의 신고 사유"

// 닫기 버튼
binding.btnClose.setOnClickListener {
dismiss()
}

// 제출 버튼
binding.btnSubmit.setOnClickListener {
val reasons = mutableListOf<String>()
if (binding.cbSpam.isChecked) reasons.add("스팸, 도배")
if (binding.cbSpoiler.isChecked) reasons.add("스포성 채팅")
if (binding.cbAbuse.isChecked) reasons.add("욕설")
if (binding.cbHate.isChecked) reasons.add("혐오 발언")
if (binding.cbNickname.isChecked) reasons.add("부적절한 닉네임 사용")

val extraReason = binding.etDetail.text.toString()

onSubmit(reasons, extraReason)
dismiss()
}

// Dialog 직접 생성
val dialog = Dialog(requireContext())
dialog.setContentView(binding.root)
dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
dialog.setCanceledOnTouchOutside(true)

// 다이얼로그 크기 고정 (피그마에서 요구한 크기)
dialog.window?.setLayout(320.dpToPx(), 494.dpToPx()) // dp → px 변환 필요

return dialog
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}

private fun Int.dpToPx(): Int {
return (this * Resources.getSystem().displayMetrics.density).toInt()
}
Loading