diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinGroupCodeActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinGroupCodeActivity.kt index db81b8b8c..e6ca4682b 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinGroupCodeActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinGroupCodeActivity.kt @@ -32,7 +32,6 @@ class JoinGroupCodeActivity : initLayout() addListeners() - addObservers() collectData() } @@ -60,12 +59,6 @@ class JoinGroupCodeActivity : } } - private fun addObservers() { - viewModel.joinGroupCodeEditText.observe(this) { editText -> - binding.btnJoinGroupCodeNext.isEnabled = editText.isNotEmpty() - } - } - private fun collectData() { viewModel.joinGroupInfoState.flowWithLifecycle(lifecycle).onEach { uiState -> when (uiState) { @@ -131,6 +124,10 @@ class JoinGroupCodeActivity : is UiState.Empty -> Timber.tag(JOIN_GROUP_CODE_ACTIVITY).d(EMPTY) } }.launchIn(lifecycleScope) + + viewModel.joinGroupCodeEditText.flowWithLifecycle(lifecycle).onEach { editText -> + binding.btnJoinGroupCodeNext.isEnabled = editText.isNotEmpty() + }.launchIn(lifecycleScope) } private fun navigateToJoinGroupSuccess() { diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinViewModel.kt index e8b6a613c..a91bee370 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinViewModel.kt @@ -1,6 +1,5 @@ package org.sopt.pingle.presentation.ui.joingroup -import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel @@ -45,7 +44,7 @@ class JoinViewModel @Inject constructor( MutableStateFlow>(UiState.Empty) val joinGroupCodeState get() = _joinGroupCodeState - val joinGroupCodeEditText = MutableLiveData() + val joinGroupCodeEditText = MutableStateFlow("") private var oldPosition = DEFAULT_OLD_POSITION diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/main/mypingle/MyPingleFragment.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/main/mypingle/MyPingleFragment.kt index 8afdf42c8..49cffa92c 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/main/mypingle/MyPingleFragment.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/main/mypingle/MyPingleFragment.kt @@ -58,7 +58,7 @@ class MyPingleFragment : BindingFragment(R.layout.fragm binding.rvMyPingle.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { super.onScrollStateChanged(recyclerView, newState) - if (newState == RecyclerView.SCROLL_STATE_IDLE) { + if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { when (viewModel.myPingleType.value) { MyPingleType.SOON -> AmplitudeUtils.trackEvent(SCROLL_SOONPINGLE) MyPingleType.DONE -> AmplitudeUtils.trackEvent(SCROLL_DONEPINGLE) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupinput/NewGroupInputFragment.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupinput/NewGroupInputFragment.kt index 05a4c9a40..9a9fb21cc 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupinput/NewGroupInputFragment.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupinput/NewGroupInputFragment.kt @@ -6,6 +6,7 @@ import androidx.fragment.app.activityViewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import org.sopt.pingle.R @@ -31,6 +32,13 @@ class NewGroupInputFragment : collectData() } + override fun onResume() { + super.onResume() + + binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled = + newGroupViewModel.isNewGroupBtnCheckName.value + } + private fun addListeners() { binding.etNewGroupInputGroupName.btnEditTextCheck.setOnClickListener { newGroupViewModel.getNewGroupCheckName() } } @@ -48,32 +56,38 @@ class NewGroupInputFragment : } private fun collectNewGroupCheckNameState() { - newGroupViewModel.newGroupCheckNameState.flowWithLifecycle(lifecycle).onEach { uiState -> - when (uiState) { - is UiState.Success -> { - if (uiState.data.result) { - PingleSnackbar.makeSnackbar( - binding.root, - stringOf(R.string.new_group_input_snackbar_guide), - SNACKBAR_BOTTOM_MARGIN, - SnackbarType.GUIDE - ) - binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled = false - newGroupViewModel.setIsNewGroupBtnCheckName(true) - } else { - PingleSnackbar.makeSnackbar( - binding.root, - stringOf(R.string.new_group_input_snackbar_warning), - SNACKBAR_BOTTOM_MARGIN, - SnackbarType.WARNING + newGroupViewModel.newGroupCheckNameState.flowWithLifecycle(lifecycle) + .distinctUntilChanged() + .onEach { uiState -> + when (uiState) { + is UiState.Success -> { + if (uiState.data.result) { + PingleSnackbar.makeSnackbar( + binding.root, + stringOf(R.string.new_group_input_snackbar_guide), + SNACKBAR_BOTTOM_MARGIN, + SnackbarType.GUIDE + ) + binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled = false + newGroupViewModel.setIsNewGroupBtnCheckName(true) + } else { + PingleSnackbar.makeSnackbar( + binding.root, + stringOf(R.string.new_group_input_snackbar_warning), + SNACKBAR_BOTTOM_MARGIN, + SnackbarType.WARNING + ) + } + AmplitudeUtils.trackEventWithProperty( + COMPLETE_DOUBLECHECK, + GROUP_NAME, + binding.etNewGroupInputGroupName.editText.text ) } - AmplitudeUtils.trackEventWithProperty(COMPLETE_DOUBLECHECK, GROUP_NAME, binding.etNewGroupInputGroupName.editText.text) - } - else -> {} - } - }.launchIn(lifecycleScope) + else -> {} + } + }.launchIn(lifecycleScope) } companion object { diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupkeyword/NewGroupKeywordFragment.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupkeyword/NewGroupKeywordFragment.kt index 79a7d677b..cf7874854 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupkeyword/NewGroupKeywordFragment.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupkeyword/NewGroupKeywordFragment.kt @@ -2,6 +2,7 @@ package org.sopt.pingle.presentation.ui.newgroup.newgroupkeyword import android.os.Bundle import android.view.View +import androidx.core.view.forEach import androidx.fragment.app.activityViewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope @@ -28,6 +29,20 @@ class NewGroupKeywordFragment : collectData() } + override fun onResume() { + super.onResume() + + with(newGroupViewModel.newGroupKeywordValue.value) { + if (isNotEmpty()) { + binding.cgNewGroupKeyword.forEach { childChip -> + (childChip as Chip).let { chip -> + if (chip.text == this) chip.isChecked = true + } + } + } + } + } + private fun initLayout() { newGroupViewModel.getNewGroupKeywords() } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/splash/SplashActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/splash/SplashActivity.kt index 2983156d2..5162687c6 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/splash/SplashActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/splash/SplashActivity.kt @@ -2,36 +2,70 @@ package org.sopt.pingle.presentation.ui.splash import android.content.Intent import android.os.Bundle +import androidx.activity.viewModels import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen +import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint -import javax.inject.Inject import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import org.sopt.pingle.R -import org.sopt.pingle.data.datasource.local.PingleLocalDataSource import org.sopt.pingle.databinding.ActivitySplashBinding +import org.sopt.pingle.presentation.ui.auth.AuthViewModel +import org.sopt.pingle.presentation.ui.main.MainActivity +import org.sopt.pingle.presentation.ui.onboarding.onboarding.OnboardingActivity import org.sopt.pingle.presentation.ui.onboarding.onboardingexplanation.OnboardingExplanationActivity import org.sopt.pingle.util.base.BindingActivity +import org.sopt.pingle.util.view.UiState @AndroidEntryPoint class SplashActivity : BindingActivity(R.layout.activity_splash) { - @Inject - lateinit var localStorage: PingleLocalDataSource + private val authViewModel by viewModels() + override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() super.onCreate(savedInstanceState) loadSplashScreen() + collectData() } private fun loadSplashScreen() { lifecycleScope.launch { delay(SPLASH_SCREEN_DELAY_TIME) - navigateToAuth() + if (authViewModel.isLocalToken()) { + if (authViewModel.isLocalGroupId()) navigateToMain() else authViewModel.getUserInfo() + } else { + navigateToOnboardingExplanation() + } + } + } + + private fun collectData() { + authViewModel.userInfoState.flowWithLifecycle(lifecycle).onEach { uiState -> + when (uiState) { + is UiState.Success -> if (uiState.data.groups.isEmpty()) navigateToOnboarding() else navigateToMain() + else -> Unit + } + }.launchIn(lifecycleScope) + } + + private fun navigateToMain() { + Intent(this, MainActivity::class.java).apply { + startActivity(this) } + finish() + } + + private fun navigateToOnboarding() { + Intent(this, OnboardingActivity::class.java).apply { + startActivity(this) + } + finish() } - private fun navigateToAuth() { + private fun navigateToOnboardingExplanation() { Intent(this, OnboardingExplanationActivity::class.java).apply { startActivity(this) } diff --git a/app/src/main/res/layout/activity_join_group_code.xml b/app/src/main/res/layout/activity_join_group_code.xml index 30afa9b5f..2404b54e3 100644 --- a/app/src/main/res/layout/activity_join_group_code.xml +++ b/app/src/main/res/layout/activity_join_group_code.xml @@ -108,8 +108,10 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="4dp" + android:maxLines="2" android:textAppearance="@style/TextAppearance.Pingle.Title.Semi.24" android:textColor="@color/black" + app:layout_constraintEnd_toStartOf="@id/gl_group_info_end" app:layout_constraintStart_toEndOf="@id/gl_group_info_start" app:layout_constraintTop_toBottomOf="@id/tv_join_group_code_tag" tools:text="SOPT" /> @@ -170,8 +172,8 @@ app:layout_constraintEnd_toStartOf="@id/gl_end" app:layout_constraintStart_toEndOf="@id/gl_start" app:layout_constraintTop_toBottomOf="@id/layout_join_group_code_group_info" - app:pingleEditTextMaxLength="12" app:pingleEditTextHint="@string/join_group_code_invitation_hint" + app:pingleEditTextMaxLength="12" app:pingleEditTextTitle="@string/join_group_code_invitation" /> diff --git a/app/src/main/res/layout/item_join_group_search.xml b/app/src/main/res/layout/item_join_group_search.xml index 19d053b04..f6a044664 100644 --- a/app/src/main/res/layout/item_join_group_search.xml +++ b/app/src/main/res/layout/item_join_group_search.xml @@ -22,39 +22,49 @@ android:orientation="vertical" app:layout_constraintGuide_begin="@dimen/spacing18" /> + + + app:layout_constraintGuide_end="@dimen/spacing10" /> - + + + app:layout_constraintTop_toBottomOf="@id/gl_top" /> @@ -63,7 +73,7 @@ android:id="@+id/iv_join_group_search_check" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginEnd="@dimen/spacing10" + android:layout_marginEnd="10dp" android:src="@{joinGroupSearch.isSelected ? @drawable/ic_all_check_selected_24 : @drawable/ic_all_check_default_24}" app:layout_constraintBottom_toBottomOf="@id/tv_join_group_search_tag" app:layout_constraintEnd_toStartOf="@id/gl_end"