Skip to content
Merged
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 @@ -3,8 +3,8 @@ package com.into.websoso.ui.createFeed
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.graphics.Rect
import android.os.Bundle
import android.text.method.ScrollingMovementMethod
import android.view.MotionEvent
import android.view.View
import android.view.inputmethod.InputMethodManager
Expand Down Expand Up @@ -57,9 +57,22 @@ class CreateFeedActivity : BaseActivity<ActivityCreateFeedBinding>(activity_crea
createFeedImagePickerLauncher()

override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
val imm: InputMethodManager =
getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(currentFocus?.windowToken, 0)
if (ev.action == MotionEvent.ACTION_DOWN) {
val focusView = currentFocus
if (focusView is android.widget.EditText) {
val outRect = Rect()
focusView.getGlobalVisibleRect(outRect)

// 터치한 좌표가 EditText 영역 밖일 경우에만 키보드 숨김 및 포커스 해제
if (!outRect.contains(ev.rawX.toInt(), ev.rawY.toInt())) {
focusView.clearFocus()
val imm: InputMethodManager =
getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(currentFocus?.windowToken, 0)
Comment on lines +68 to +71
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Mar 10, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

clearFocus() 호출 후 currentFocus가 null이 될 수 있습니다.

Line 68에서 clearFocus()를 호출한 후, Line 71에서 currentFocus?.windowToken을 사용하고 있습니다. 포커스가 해제되면 currentFocus가 null을 반환할 수 있어, hideSoftInputFromWindow에 null이 전달될 수 있습니다.

이미 focusView를 캡처해두었으므로, 해당 뷰의 windowToken을 직접 사용하는 것이 안전합니다.

🛠️ 수정 제안
                 if (!outRect.contains(ev.rawX.toInt(), ev.rawY.toInt())) {
                     focusView.clearFocus()
                     val imm: InputMethodManager =
                         getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
-                    imm.hideSoftInputFromWindow(currentFocus?.windowToken, 0)
+                    imm.hideSoftInputFromWindow(focusView.windowToken, 0)
                 }
📝 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
focusView.clearFocus()
val imm: InputMethodManager =
getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(currentFocus?.windowToken, 0)
focusView.clearFocus()
val imm: InputMethodManager =
getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(focusView.windowToken, 0)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/into/websoso/ui/createFeed/CreateFeedActivity.kt`
around lines 68 - 71, The code calls focusView.clearFocus() and then uses
currentFocus?.windowToken when hiding the keyboard, which can be null; instead
use the captured focusView's windowToken directly. Update the
InputMethodManager.hideSoftInputFromWindow call to pass focusView.windowToken
(from the existing focusView variable) rather than currentFocus?.windowToken so
the token is non-null even after clearFocus(); keep the same InputMethodManager
retrieval logic around getSystemService and imm.hideSoftInputFromWindow.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

이것만 봐주세용

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PR 설명 이미지: 텍스트 "etnstnwtnwtn"이 청록색으로 선택되어 있고, 상단에 잘라내기·복사·번역·공유 툴바가 표시되어 있습니다. 이번 PR의 드래그/선택 수정이 정상 작동하는 것을 보여주고 있습니다. 🎉


@m6z1, 제가 남긴 댓글 내용만 확인해 드릴게요.

지적 내용은 유효합니다. clearFocus()를 호출한 직후 currentFocus는 null을 반환할 수 있기 때문에, hideSoftInputFromWindow에 null 토큰이 전달될 수 있습니다.

focusView는 이미 clearFocus() 호출 전에 캡처해 두었으므로, 그 참조를 그대로 사용하는 것이 안전합니다:

                 if (!outRect.contains(ev.rawX.toInt(), ev.rawY.toInt())) {
                     focusView.clearFocus()
                     val imm: InputMethodManager =
                         getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
-                    imm.hideSoftInputFromWindow(currentFocus?.windowToken, 0)
+                    imm.hideSoftInputFromWindow(focusView.windowToken, 0)
                 }

Android의 IMM이 null 토큰을 내부적으로 처리하더라도, focusView.windowToken을 직접 쓰는 것이 의도가 명확하고 더 견고합니다.

}
}
}

return super.dispatchTouchEvent(ev)
}

Expand Down Expand Up @@ -99,15 +112,19 @@ class CreateFeedActivity : BaseActivity<ActivityCreateFeedBinding>(activity_crea
@SuppressLint("ClickableViewAccessibility")
private fun setupCustomScroll() {
binding.etCreateFeedContent.setOnTouchListener { view, event ->
if (view.hasFocus()) {
view.parent.requestDisallowInterceptTouchEvent(true)
if ((event.action and MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
when (event.action and MotionEvent.ACTION_MASK) {
MotionEvent.ACTION_DOWN -> {
// 터치 시작 시 부모 개입 차단
view.parent.requestDisallowInterceptTouchEvent(true)
}

MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
view.parent.requestDisallowInterceptTouchEvent(false)
}
}

false
}
binding.etCreateFeedContent.movementMethod = ScrollingMovementMethod()
}

private fun onCreateFeedClick() {
Expand Down Expand Up @@ -138,8 +155,11 @@ class CreateFeedActivity : BaseActivity<ActivityCreateFeedBinding>(activity_crea

when {
editFeedModel == null -> createFeedViewModel.createFeed()

editFeedModel.feedId == DEFAULT_FEED_ID -> createFeedViewModel.createFeed()

editFeedModel.feedCategory.isEmpty() -> createFeedViewModel.createFeed()

else -> createFeedViewModel.editFeed(
feedId = editFeedModel.feedId,
)
Expand Down