diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f49d5deb..9055d587 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -82,7 +82,7 @@ android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize" /> (R.layout.activity_quest), - View.OnClickListener { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - changeFragment(QuestSubFragment()) - } - - override fun onClick(view: View?) { - when (view?.id) { - R.id.iv_basic_back -> finish() - } - } - - private fun changeFragment(fragment: Fragment) { - supportFragmentManager.beginTransaction() - .add(R.id.fragment_question, fragment) - .commit() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/QuestSubFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/QuestSubFragment.kt deleted file mode 100644 index 9eff34ca..00000000 --- a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/QuestSubFragment.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.sopt.umbba_android.presentation.onboarding - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.fragment.app.Fragment -import com.sopt.umbba_android.R -import com.sopt.umbba_android.databinding.FragmentQuestOneBinding -import com.sopt.umbba_android.util.binding.BindingFragment - -class QuestSubFragment : BindingFragment(R.layout.fragment_quest_one) { - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return super.onCreateView(inflater, container, savedInstanceState) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/SelectFamilyActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/SelectFamilyActivity.kt index df458873..359dab6c 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/SelectFamilyActivity.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/SelectFamilyActivity.kt @@ -6,6 +6,7 @@ import android.view.View import androidx.activity.viewModels import com.sopt.umbba_android.R import com.sopt.umbba_android.databinding.ActivitySelectFamilyBinding +import com.sopt.umbba_android.presentation.onboarding.quest.QuestActivity import com.sopt.umbba_android.presentation.onboarding.viewmodel.SelectFamilyViewModel import com.sopt.umbba_android.util.binding.BindingActivity diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestActivity.kt new file mode 100644 index 00000000..b48a42e0 --- /dev/null +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestActivity.kt @@ -0,0 +1,117 @@ +package com.sopt.umbba_android.presentation.onboarding.quest + +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.view.View +import androidx.activity.viewModels +import com.sopt.umbba_android.R +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.commit +import com.sopt.umbba_android.databinding.ActivityQuestBinding +import com.sopt.umbba_android.presentation.onboarding.NotifyTimeActivity +import com.sopt.umbba_android.presentation.onboarding.SetTimeActivity +import com.sopt.umbba_android.util.binding.BindingActivity + +class QuestActivity : BindingActivity(R.layout.activity_quest), + View.OnClickListener { + + private val viewModel by viewModels() + private var count = 0 + private var quest = arrayOfNulls(5) + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding.viewmodel = viewModel + binding.clickListener = this + + initFragment(QuestOneFragment()) + checkNextButtonEnabled() + clickNextButton() + } + + override fun onClick(view: View?) { + when (view?.id) { + R.id.iv_basic_back -> { + if (count in 1..4) { + supportFragmentManager.popBackStack("$count", FragmentManager.POP_BACK_STACK_INCLUSIVE) + binding.progressBar.progress -= 20 + count -= 1 + initChip() + setBeforeButtonClick(count) + } else { + finish() + } + } + } + } + + private fun setBeforeButtonClick(count: Int) { + when (quest[count].toString()) { + "응" -> viewModel.isClickedYes.value = true + "아니" -> viewModel.isClickedNo.value = true + "애매해" -> viewModel.isClickedAmbiguous.value = true + } + Log.d("viewmodel", "pop stack : ${count}번 : ${quest[count].toString()}") + } + + private fun initFragment(fragment: Fragment) { + supportFragmentManager.beginTransaction() + .add(R.id.fragment_question, fragment) + .addToBackStack("$count") + .commit() + } + + private fun changeFragment(fragment: Fragment) { + supportFragmentManager.commit { + replace(R.id.fragment_question, fragment) + .addToBackStack("$count") + } + } + + private fun checkNextButtonEnabled() { + viewModel.isClickedComplete.observe(this) { + binding.btnNext.isEnabled = true + } + } + + private fun clickNextButton() { + binding.btnNext.setOnClickListener { + Log.d("viewmodel", "chipText : ${viewModel.clickedChipText.value.toString()}") + Log.d("viewmodel", "count : ${count}") + quest[count] = viewModel.clickedChipText.value.toString() + Log.d("viewmodel", "배열 값 : ${quest[count]}") + initChip() + count += 1 + when (count) { + 0 -> changeFragment(QuestOneFragment()) + 1 -> changeFragment(QuestTwoFragment()) + 2 -> changeFragment(QuestThreeFragment()) + 3 -> changeFragment(QuestFourFragment()) + 4 -> changeFragment(QuestFiveFragment()) + 5 -> { + goNextActivity() + count = 4 + } + } + binding.progressBar.progress += 20 + } + } + + private fun initChip() { + with(viewModel) { + isClickedYes.value = false + isClickedNo.value = false + isClickedAmbiguous.value = false + } + } + + private fun goNextActivity() { + if (true) { //초대하는 측 + startActivity(Intent(this, SetTimeActivity::class.java)) + } else { //초대받는 측 + startActivity(Intent(this, NotifyTimeActivity::class.java)) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestFiveFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestFiveFragment.kt new file mode 100644 index 00000000..eed91a44 --- /dev/null +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestFiveFragment.kt @@ -0,0 +1,33 @@ +package com.sopt.umbba_android.presentation.onboarding.quest + +import android.os.Bundle +import android.view.View +import androidx.fragment.app.activityViewModels +import com.sopt.umbba_android.R +import com.sopt.umbba_android.databinding.FragmentQuestFiveBinding +import com.sopt.umbba_android.util.binding.BindingFragment + +class QuestFiveFragment : BindingFragment(R.layout.fragment_quest_five) { + private val viewModel by activityViewModels() + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.viewmodel = viewModel + + checkButtonComplete() + } + + private fun checkButtonComplete() { + viewModel.isClickedYes.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer1.text.toString() + } + viewModel.isClickedNo.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer2.text.toString() + } + viewModel.isClickedAmbiguous.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer3.text.toString() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestFourFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestFourFragment.kt new file mode 100644 index 00000000..bb416a5c --- /dev/null +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestFourFragment.kt @@ -0,0 +1,33 @@ +package com.sopt.umbba_android.presentation.onboarding.quest + +import android.os.Bundle +import android.view.View +import androidx.fragment.app.activityViewModels +import com.sopt.umbba_android.R +import com.sopt.umbba_android.databinding.FragmentQuestFourBinding +import com.sopt.umbba_android.util.binding.BindingFragment + +class QuestFourFragment : BindingFragment(R.layout.fragment_quest_four) { + private val viewModel by activityViewModels() + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.viewmodel = viewModel + + checkButtonComplete() + } + + private fun checkButtonComplete() { + viewModel.isClickedYes.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer1.text.toString() + } + viewModel.isClickedNo.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer2.text.toString() + } + viewModel.isClickedAmbiguous.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer3.text.toString() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestOneFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestOneFragment.kt new file mode 100644 index 00000000..1b4487a9 --- /dev/null +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestOneFragment.kt @@ -0,0 +1,37 @@ +package com.sopt.umbba_android.presentation.onboarding.quest + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.activityViewModels +import com.sopt.umbba_android.R +import com.sopt.umbba_android.databinding.FragmentQuestOneBinding +import com.sopt.umbba_android.util.binding.BindingFragment + +class QuestOneFragment : BindingFragment(R.layout.fragment_quest_one) { + + private val viewModel by activityViewModels() + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.viewmodel = viewModel + + checkButtonComplete() + } + + private fun checkButtonComplete() { + viewModel.isClickedYes.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer1.text.toString() + } + viewModel.isClickedNo.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer2.text.toString() + } + viewModel.isClickedAmbiguous.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer3.text.toString() + + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestThreeFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestThreeFragment.kt new file mode 100644 index 00000000..07450875 --- /dev/null +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestThreeFragment.kt @@ -0,0 +1,34 @@ +package com.sopt.umbba_android.presentation.onboarding.quest + +import android.os.Bundle +import android.view.View +import androidx.fragment.app.activityViewModels +import com.sopt.umbba_android.R +import com.sopt.umbba_android.databinding.FragmentQuestThreeBinding +import com.sopt.umbba_android.util.binding.BindingFragment + +class QuestThreeFragment : BindingFragment(R.layout.fragment_quest_three) { + + private val viewModel by activityViewModels() + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.viewmodel = viewModel + + checkButtonComplete() + } + + private fun checkButtonComplete() { + viewModel.isClickedYes.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer1.text.toString() + } + viewModel.isClickedNo.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer2.text.toString() + } + viewModel.isClickedAmbiguous.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer3.text.toString() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestTwoFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestTwoFragment.kt new file mode 100644 index 00000000..c4e8f51d --- /dev/null +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestTwoFragment.kt @@ -0,0 +1,35 @@ +package com.sopt.umbba_android.presentation.onboarding.quest + +import android.os.Bundle +import android.view.View +import androidx.fragment.app.activityViewModels +import com.sopt.umbba_android.R +import com.sopt.umbba_android.databinding.FragmentQuestTwoBinding +import com.sopt.umbba_android.util.binding.BindingFragment + +class QuestTwoFragment : BindingFragment(R.layout.fragment_quest_two) { + + private val viewModel by activityViewModels() + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.viewmodel = viewModel + + checkButtonComplete() + } + + private fun checkButtonComplete() { + viewModel.isClickedYes.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer1.text.toString() + } + viewModel.isClickedNo.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer2.text.toString() + } + viewModel.isClickedAmbiguous.observe(viewLifecycleOwner) { + viewModel.checkButtonComplete() + viewModel.clickedChipText.value = binding.btnAnswer3.text.toString() + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestViewModel.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestViewModel.kt new file mode 100644 index 00000000..52ee380b --- /dev/null +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestViewModel.kt @@ -0,0 +1,19 @@ +package com.sopt.umbba_android.presentation.onboarding.quest + +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class QuestViewModel : ViewModel() { + val isClickedYes = MutableLiveData() + val isClickedNo = MutableLiveData() + val isClickedAmbiguous = MutableLiveData() + + val isClickedComplete = MutableLiveData() + + val clickedChipText = MutableLiveData() + + fun checkButtonComplete() { + isClickedComplete.value = isClickedYes.value == true || isClickedNo.value == true || isClickedAmbiguous.value == true + } + +} \ No newline at end of file diff --git a/app/src/main/res/anim/fadein.xml b/app/src/main/res/anim/fadein.xml index 204a7305..2f67d37f 100644 --- a/app/src/main/res/anim/fadein.xml +++ b/app/src/main/res/anim/fadein.xml @@ -1,6 +1,6 @@ diff --git a/app/src/main/res/anim/fadeout.xml b/app/src/main/res/anim/fadeout.xml index 361f1577..71718b36 100644 --- a/app/src/main/res/anim/fadeout.xml +++ b/app/src/main/res/anim/fadeout.xml @@ -1,6 +1,6 @@ diff --git a/app/src/main/res/layout/activity_input_info.xml b/app/src/main/res/layout/activity_input_info.xml index 14fd2f6c..e6b34df4 100644 --- a/app/src/main/res/layout/activity_input_info.xml +++ b/app/src/main/res/layout/activity_input_info.xml @@ -54,7 +54,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/please_introduce_user" - android:textColor="@color/black" + android:textColor="@color/umbba_black" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -74,7 +74,7 @@ android:layout_marginStart="20dp" android:layout_marginTop="16dp" android:text="@string/what_is_your_name" - android:textColor="@color/black" + android:textColor="@color/umbba_black" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> diff --git a/app/src/main/res/layout/activity_quest.xml b/app/src/main/res/layout/activity_quest.xml index eb137e6d..2e0e303c 100644 --- a/app/src/main/res/layout/activity_quest.xml +++ b/app/src/main/res/layout/activity_quest.xml @@ -11,6 +11,10 @@ + + + + + app:layout_constraintTop_toBottomOf="@id/tv_sub_title" /> diff --git a/app/src/main/res/layout/fragment_quest_five.xml b/app/src/main/res/layout/fragment_quest_five.xml new file mode 100644 index 00000000..06492c38 --- /dev/null +++ b/app/src/main/res/layout/fragment_quest_five.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_quest_four.xml b/app/src/main/res/layout/fragment_quest_four.xml new file mode 100644 index 00000000..e4674c69 --- /dev/null +++ b/app/src/main/res/layout/fragment_quest_four.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_quest_one.xml b/app/src/main/res/layout/fragment_quest_one.xml index a1aa2617..c0aca49a 100644 --- a/app/src/main/res/layout/fragment_quest_one.xml +++ b/app/src/main/res/layout/fragment_quest_one.xml @@ -1,11 +1,18 @@ - + - + + + + + - - + app:layout_constraintTop_toBottomOf="@id/tv_question" + app:layout_constraintVertical_bias="0.503" + app:selectionRequired="true" + app:singleSelection="true"> + tools:layout_editor_absoluteX="32dp" + tools:layout_editor_absoluteY="110dp" /> + android:checked="@={viewmodel.isClickedNo}" + android:text="@string/no" + app:chipMinTouchTargetSize="0dp" /> + android:checked="@={viewmodel.isClickedAmbiguous}" + android:text="@string/ambiguous" + app:chipMinTouchTargetSize="0dp" /> diff --git a/app/src/main/res/layout/fragment_quest_three.xml b/app/src/main/res/layout/fragment_quest_three.xml new file mode 100644 index 00000000..3fb8fddf --- /dev/null +++ b/app/src/main/res/layout/fragment_quest_three.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_quest_two.xml b/app/src/main/res/layout/fragment_quest_two.xml new file mode 100644 index 00000000..df242889 --- /dev/null +++ b/app/src/main/res/layout/fragment_quest_two.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e2c4cde1..bc765d46 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -127,4 +127,10 @@ #%d %s + + + + 아니 + 애매해 + \ No newline at end of file