Skip to content

Commit

Permalink
Merge pull request #204 from TeamPINGLE/mod-open-link-validity
Browse files Browse the repository at this point in the history
[mod] 오픈채팅방 유효성검사
  • Loading branch information
DoReMinWoo authored Mar 7, 2024
2 parents c0a72b2 + 5b15b9d commit 003633f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
android:name=".presentation.ui.joingroup.JoinGroupCodeActivity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".presentation.ui.joingroup.JoinGroupSearchActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,8 @@ class PlanActivity : BindingActivity<ActivityPlanBinding>(R.layout.activity_plan
private fun addListeners() {
binding.btnPlan.setOnClickListener {
when (binding.vpPlan.currentItem) {
fragmentList.size - SUB_LIST_SIZE -> {
planViewModel.postPlanMeeting()
}

else -> {
binding.vpPlan.currentItem++
}
fragmentList.size - SUB_LIST_SIZE -> planViewModel.postPlanMeeting()
else -> binding.vpPlan.currentItem++
}
}
binding.toolbar.ivAllTopbarArrowWithTitleArrowLeft.setOnClickListener {
Expand Down Expand Up @@ -136,13 +131,8 @@ class PlanActivity : BindingActivity<ActivityPlanBinding>(R.layout.activity_plan

private fun navigateToPreviousPage() {
when (binding.vpPlan.currentItem) {
FIRST_PAGE -> {
navigateToPlanAnnouncement()
}

else -> {
binding.vpPlan.currentItem--
}
FIRST_PAGE -> navigateToPlanAnnouncement()
else -> binding.vpPlan.currentItem--
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ class PlanViewModel @Inject constructor(
(currentPage == PlanType.DATETIME.position && planDate.isNotBlank() && startTime.isNotBlank() && endTime.isNotBlank()) ||
(currentPage == PlanType.LOCATION.position && selectedLocation != null) ||
(
currentPage == PlanType.RECRUITMENT.position && selectedRecruitment.isNotBlank() && checkRecruitment(
selectedRecruitment
)
currentPage == PlanType.RECRUITMENT.position && selectedRecruitment.isNotBlank() &&
checkRecruitment(selectedRecruitment)
) ||
(currentPage == PlanType.OPENCHATTING.position && planOpenChattingLink.isNotBlank()) ||
(currentPage == PlanType.SUMMARY.position)
Expand Down Expand Up @@ -245,12 +244,20 @@ class PlanViewModel @Inject constructor(
}
}

fun validityOpenChattingLink() {
openChattingLinkRegexPattern.find(planOpenChattingLink.value)?.value?.let { matchedString ->
planOpenChattingLink.value = matchedString
}
}

companion object {
const val FIRST_PAGE_POSITION = 0
const val DEFAULT_OLD_POSITION = -1
const val DEFAULT_RECRUITMENT = "1"
const val START_RECRUITMENT = 2
const val END_RECRUITMENT = 99
const val BLANK_STRING = " "
val openChattingLinkRegexPattern =
"""https://open.kakao.com/o/[A-Za-z0-9]+""".toRegex()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package org.sopt.pingle.presentation.ui.plan.planopenchatting
import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.pingle.R
import org.sopt.pingle.databinding.FragmentPlanOpenChattingBinding
import org.sopt.pingle.presentation.ui.plan.PlanViewModel
Expand All @@ -16,15 +20,21 @@ class PlanOpenChattingFragment :
private val planViewModel: PlanViewModel by activityViewModels()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.viewModel = planViewModel

addListeners()
collectData()
}

private fun addListeners() {
binding.root.setOnClickListener {
requireActivity().hideKeyboard(it)
}
}

private fun collectData() {
planViewModel.planOpenChattingLink.flowWithLifecycle(viewLifecycleOwner.lifecycle).onEach { openChattingLink ->
planViewModel.validityOpenChattingLink()
}.launchIn(viewLifecycleOwner.lifecycleScope)
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
<string name="plan_open_chatting_title">오픈채팅방 링크를\n추가해주세요!</string>
<string name="plan_open_chatting_hint">링크를 입력해주세요</string>
<string name="plan_open_chatting_text_title">채팅방 링크</string>
<string name="plan_open_chatting_snackbar">유효하지 않은 오픈채팅방 링크입니다.</string>

<!-- plan summary confirmation -->
<string name="plan_summary_confirmation_title">핑글을 개최할\n준비 되었나요?</string>
Expand Down

0 comments on commit 003633f

Please sign in to comment.