diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f51aae814..b8920df5c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -59,6 +59,7 @@ android:name=".presentation.ui.joingroup.JoinGroupCodeActivity" android:exported="false" android:screenOrientation="portrait" + android:windowSoftInputMode="adjustPan" tools:ignore="LockedOrientationActivity" /> (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 { @@ -136,13 +131,8 @@ class PlanActivity : BindingActivity(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-- } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/plan/PlanViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/plan/PlanViewModel.kt index 983f57817..a9447cef9 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/plan/PlanViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/plan/PlanViewModel.kt @@ -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) @@ -245,6 +244,12 @@ 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 @@ -252,5 +257,7 @@ class PlanViewModel @Inject constructor( 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() } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/plan/planopenchatting/PlanOpenChattingFragment.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/plan/planopenchatting/PlanOpenChattingFragment.kt index 677a6a4d1..b895f8484 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/plan/planopenchatting/PlanOpenChattingFragment.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/plan/planopenchatting/PlanOpenChattingFragment.kt @@ -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 @@ -16,10 +20,10 @@ 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() { @@ -27,4 +31,10 @@ class PlanOpenChattingFragment : requireActivity().hideKeyboard(it) } } + + private fun collectData() { + planViewModel.planOpenChattingLink.flowWithLifecycle(viewLifecycleOwner.lifecycle).onEach { openChattingLink -> + planViewModel.validityOpenChattingLink() + }.launchIn(viewLifecycleOwner.lifecycleScope) + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bc72e92cf..50994c1aa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -193,6 +193,7 @@ 오픈채팅방 링크를\n추가해주세요! 링크를 입력해주세요 채팅방 링크 + 유효하지 않은 오픈채팅방 링크입니다. 핑글을 개최할\n준비 되었나요?