Skip to content

Commit

Permalink
Merge pull request #263 from TeamDon-tBe/feature/#262-link-qa
Browse files Browse the repository at this point in the history
[Feature/#262] : 3차 스프린트 link 관련 QA
  • Loading branch information
sohyun127 authored May 17, 2024
2 parents 0b21fde + 4dbce16 commit c5bfd36
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class CommentBottomSheet(
private val homeViewModel by activityViewModels<HomeViewModel>()
private var totalCommentLength = 0
private var linkValidity = true
private var linkLength = 0

override fun initView() {
binding.vm = homeViewModel
Expand Down Expand Up @@ -94,7 +93,7 @@ class CommentBottomSheet(
.show() else linkValidity = false
handleLinkAndCancelBtnVisible(true)
etCommentLink.requestFocus()
setUploadingCommentState(totalCommentLength + 1)
setUploadingCommentState(totalCommentLength)
}

private fun initCancelLinkBtnClickListener() = with(binding) {
Expand All @@ -105,7 +104,6 @@ class CommentBottomSheet(
setLinkErrorMessageValidity(linkValidity = true)
linkValidity = true
setUploadingCommentState(totalCommentLength)
setCommentMaxLength(POSTING_MAX - binding.etCommentLink.text.length + 1)
}
}

Expand All @@ -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()
Expand Down Expand Up @@ -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())
}
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ class PostingFragment : BindingFragment<FragmentPostingBinding>(R.layout.fragmen
private val postingViewModel by viewModels<PostingViewModel>()
private var totalContentLength = 0
private var linkValidity = true
private var linkLength = 0

override fun initView() {
statusBarColorOf(R.color.white)

showKeyboard()
initAnimation()

Expand Down Expand Up @@ -150,7 +148,7 @@ class PostingFragment : BindingFragment<FragmentPostingBinding>(R.layout.fragmen
LinkCountErrorSnackBar.make(binding.root)
.show()
} else {
handleUploadProgressAndBtn(totalContentLength + 1)
handleUploadProgressAndBtn(totalContentLength)
setUploadingBtnValidity(false)
linkValidity = false
}
Expand All @@ -166,7 +164,6 @@ class PostingFragment : BindingFragment<FragmentPostingBinding>(R.layout.fragmen
setLinkErrorMessageValidity(linkValidity = true)
linkValidity = true
handleUploadProgressAndBtn(totalContentLength)
setContentMaxLength(POSTING_MAX - binding.etPostingLink.text.length + 1)
}
}

Expand All @@ -177,10 +174,9 @@ class PostingFragment : BindingFragment<FragmentPostingBinding>(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) {}
}
Expand Down Expand Up @@ -237,8 +233,10 @@ class PostingFragment : BindingFragment<FragmentPostingBinding>(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()
)
)
}
}
Expand All @@ -254,8 +252,8 @@ class PostingFragment : BindingFragment<FragmentPostingBinding>(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)
}
}
Expand Down
6 changes: 0 additions & 6 deletions feature/src/main/res/drawable/shape_blue_10_cursor.xml

This file was deleted.

3 changes: 1 addition & 2 deletions feature/src/main/res/layout/bottomsheet_comment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -203,6 +202,7 @@

<EditText
android:id="@+id/et_comment_link"
style="@style/EditTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
Expand All @@ -217,7 +217,6 @@
android:textAppearance="@style/TextAppearance.DontBe.body_regular_14"
android:textColorHint="@color/gray_7"
android:textColorLink="@color/black"
android:textCursorDrawable="@drawable/shape_blue_10_cursor"
android:visibility="gone"
app:layout_constraintEnd_toStartOf="@id/iv_comment_cancel_link"
app:layout_constraintStart_toStartOf="@id/et_comment_content"
Expand Down
3 changes: 1 addition & 2 deletions feature/src/main/res/layout/fragment_posting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@
android:inputType="textVisiblePassword|textMultiLine|textNoSuggestions"
android:maxLength="500"
android:textAppearance="@style/TextAppearance.DontBe.body_regular_14"
android:textCursorDrawable="@drawable/shape_blue_10_cursor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/et_posting_link"
style="@style/EditTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
Expand All @@ -93,7 +93,6 @@
android:textAppearance="@style/TextAppearance.DontBe.body_regular_14"
android:textColorHint="@color/gray_7"
android:textColorLink="@color/black"
android:textCursorDrawable="@drawable/shape_blue_10_cursor"
android:visibility="gone"
app:background="@null"
app:layout_constraintEnd_toStartOf="@id/iv_posting_cancel_link"
Expand Down

0 comments on commit c5bfd36

Please sign in to comment.