diff --git a/feature/src/main/java/com/teamdontbe/feature/homedetail/CommentBottomSheet.kt b/feature/src/main/java/com/teamdontbe/feature/homedetail/CommentBottomSheet.kt index 71161fa8..69ad634a 100644 --- a/feature/src/main/java/com/teamdontbe/feature/homedetail/CommentBottomSheet.kt +++ b/feature/src/main/java/com/teamdontbe/feature/homedetail/CommentBottomSheet.kt @@ -43,7 +43,6 @@ class CommentBottomSheet( private val homeViewModel by activityViewModels() private var totalCommentLength = 0 private var linkValidity = true - private var linkLength = 0 override fun initView() { binding.vm = homeViewModel @@ -94,7 +93,7 @@ class CommentBottomSheet( .show() else linkValidity = false handleLinkAndCancelBtnVisible(true) etCommentLink.requestFocus() - setUploadingCommentState(totalCommentLength + 1) + setUploadingCommentState(totalCommentLength) } private fun initCancelLinkBtnClickListener() = with(binding) { @@ -105,7 +104,6 @@ class CommentBottomSheet( setLinkErrorMessageValidity(linkValidity = true) linkValidity = true setUploadingCommentState(totalCommentLength) - setCommentMaxLength(POSTING_MAX - binding.etCommentLink.text.length + 1) } } @@ -116,9 +114,8 @@ class CommentBottomSheet( private fun checkLinkValidity() = with(binding.etCommentLink) { doAfterTextChanged { - linkLength = text.takeIf { it.isNotEmpty() }?.length?.plus(1) ?: 0 - setCommentMaxLength(POSTING_MAX - binding.etCommentLink.text.length) - totalCommentLength = binding.etCommentContent.length() + linkLength + setCommentMaxLength(POSTING_MAX - binding.etCommentLink.text.length + 1) + totalCommentLength = binding.etCommentContent.length() + text.length handleLinkErrorMessage( WEB_URL_PATTERN.matcher( text.toString() @@ -150,8 +147,8 @@ class CommentBottomSheet( private fun initEditText() = with(binding) { etCommentContent.doAfterTextChanged { text -> etCommentLink.filters = - arrayOf(InputFilter.LengthFilter(POSTING_MAX - text.toString().length)) - totalCommentLength = etCommentContent.text.length + linkLength + arrayOf(InputFilter.LengthFilter(POSTING_MAX - text.toString().length + 1)) + totalCommentLength = etCommentContent.text.length + etCommentLink.text.length setUploadingCommentState(totalCommentLength) debounceComment(text.toString()) } @@ -223,7 +220,7 @@ class CommentBottomSheet( homeViewModel.postCommentPosting( contentId, binding.etCommentContent.text.toString() + binding.etCommentLink.text.takeIf { it.isNotEmpty() } - ?.let { "\n$it" } + ?.let { "\n$it" }.orEmpty() ) dismiss() } diff --git a/feature/src/main/java/com/teamdontbe/feature/posting/PostingFragment.kt b/feature/src/main/java/com/teamdontbe/feature/posting/PostingFragment.kt index b322874e..63b3f7e5 100644 --- a/feature/src/main/java/com/teamdontbe/feature/posting/PostingFragment.kt +++ b/feature/src/main/java/com/teamdontbe/feature/posting/PostingFragment.kt @@ -42,11 +42,9 @@ class PostingFragment : BindingFragment(R.layout.fragmen private val postingViewModel by viewModels() private var totalContentLength = 0 private var linkValidity = true - private var linkLength = 0 override fun initView() { statusBarColorOf(R.color.white) - showKeyboard() initAnimation() @@ -150,7 +148,7 @@ class PostingFragment : BindingFragment(R.layout.fragmen LinkCountErrorSnackBar.make(binding.root) .show() } else { - handleUploadProgressAndBtn(totalContentLength + 1) + handleUploadProgressAndBtn(totalContentLength) setUploadingBtnValidity(false) linkValidity = false } @@ -166,7 +164,6 @@ class PostingFragment : BindingFragment(R.layout.fragmen setLinkErrorMessageValidity(linkValidity = true) linkValidity = true handleUploadProgressAndBtn(totalContentLength) - setContentMaxLength(POSTING_MAX - binding.etPostingLink.text.length + 1) } } @@ -177,10 +174,9 @@ class PostingFragment : BindingFragment(R.layout.fragmen private fun checkLinkValidity() = with(binding.etPostingLink) { doAfterTextChanged { - linkLength = text.takeIf { it.isNotEmpty() }?.length?.plus(1) ?: 0 - setContentMaxLength(POSTING_MAX - binding.etPostingLink.text.length) + setContentMaxLength(POSTING_MAX - binding.etPostingLink.text.length + 1) handleLinkErrorMessage(WEB_URL_PATTERN.matcher(text.toString()).find()) - totalContentLength = binding.etPostingContent.text.length + linkLength + totalContentLength = binding.etPostingContent.text.length + text.length handleUploadProgressAndBtn(totalContentLength) postingDebouncer.setDelay(text.toString(), POSTING_DEBOUNCE_DELAY) {} } @@ -237,8 +233,10 @@ class PostingFragment : BindingFragment(R.layout.fragmen binding.layoutUploadBar.btnUploadBarUpload.setOnClickListener { trackEvent(CLICK_POST_UPLOAD) postingViewModel.posting( - binding.etPostingContent.text.toString() + binding.etPostingLink.text.takeIf { it.isNotEmpty() } - ?.let { "\n$it" } + binding.etPostingContent.text.toString() + ( + binding.etPostingLink.text.takeIf { it.isNotEmpty() } + ?.let { "\n$it" }.orEmpty() + ) ) } } @@ -254,8 +252,8 @@ class PostingFragment : BindingFragment(R.layout.fragmen binding.run { etPostingContent.doAfterTextChanged { etPostingLink.filters = - arrayOf(InputFilter.LengthFilter(POSTING_MAX - etPostingContent.text.length)) - totalContentLength = etPostingContent.text.length + linkLength + arrayOf(InputFilter.LengthFilter(POSTING_MAX - etPostingContent.text.length + 1)) + totalContentLength = etPostingContent.text.length + etPostingLink.text.length handleUploadProgressAndBtn(totalContentLength) } } diff --git a/feature/src/main/res/drawable/shape_blue_10_cursor.xml b/feature/src/main/res/drawable/shape_blue_10_cursor.xml deleted file mode 100644 index ee13638e..00000000 --- a/feature/src/main/res/drawable/shape_blue_10_cursor.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/feature/src/main/res/layout/bottomsheet_comment.xml b/feature/src/main/res/layout/bottomsheet_comment.xml index 82db803d..d4be1cdf 100644 --- a/feature/src/main/res/layout/bottomsheet_comment.xml +++ b/feature/src/main/res/layout/bottomsheet_comment.xml @@ -187,7 +187,6 @@ android:inputType="textNoSuggestions|textVisiblePassword|textMultiLine" android:maxLength="500" android:textAppearance="@style/TextAppearance.DontBe.body_regular_14" - android:textCursorDrawable="@drawable/shape_blue_10_cursor" app:layout_constraintEnd_toEndOf="@id/view_comment_background" app:layout_constraintStart_toStartOf="@id/tv_comment_profile_nickname" app:layout_constraintTop_toBottomOf="@id/tv_comment_profile_nickname" @@ -203,6 +202,7 @@