diff --git a/app/src/main/java/com/sopt/umbba_android/domain/entity/User.kt b/app/src/main/java/com/sopt/umbba_android/domain/entity/User.kt new file mode 100644 index 00000000..1f5679b5 --- /dev/null +++ b/app/src/main/java/com/sopt/umbba_android/domain/entity/User.kt @@ -0,0 +1,14 @@ +package com.sopt.umbba_android.domain.entity + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +data class User( + var isReceiver: Boolean, + var name: String? = null, + var gender: String? = null, + var bornYear: Int? = null, + var isInvitorChild: Boolean? = null, + var relationInfo: String? = null +): Parcelable diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/invite/InviteActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/invite/InviteActivity.kt index f93c8664..2b40260b 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/invite/InviteActivity.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/invite/InviteActivity.kt @@ -2,12 +2,15 @@ package com.sopt.umbba_android.presentation.invite import android.content.Intent import android.os.Bundle +import android.util.Log import com.sopt.umbba_android.R import com.sopt.umbba_android.databinding.ActivityInviteBinding +import com.sopt.umbba_android.domain.entity.User import com.sopt.umbba_android.presentation.onboarding.CommunicationActivity import com.sopt.umbba_android.util.binding.BindingActivity class InviteActivity : BindingActivity(R.layout.activity_invite) { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -16,14 +19,24 @@ class InviteActivity : BindingActivity(R.layout.activity_ } private fun goCommunicationActivity() { + // 초대하는 측 binding.btnStart.setOnClickListener { - startActivity(Intent(this, CommunicationActivity::class.java)) + val userData = User(isReceiver = false) + Log.e("yeonjin", "invite parcelable : ${userData.isReceiver}") + startActivity(Intent(this, CommunicationActivity::class.java).apply { + putExtra("userData", userData) + }) } } private fun goInviteCodeActivity() { + // 초대받는 측 binding.btnInputCode.setOnClickListener { - startActivity(Intent(this, InviteCodeActivity::class.java)) + val userData = User(isReceiver = true) + Log.e("yeonjin", "invite parcelable : ${userData.isReceiver}") + startActivity(Intent(this, InviteCodeActivity::class.java).apply { + putExtra("userData", userData) + }) } } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/invite/InviteCodeActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/invite/InviteCodeActivity.kt index f35b1fba..0e3e6daa 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/invite/InviteCodeActivity.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/invite/InviteCodeActivity.kt @@ -1,6 +1,7 @@ package com.sopt.umbba_android.presentation.invite import android.content.Intent +import android.os.Build import android.os.Bundle import android.text.Editable import android.text.TextWatcher @@ -10,6 +11,7 @@ import androidx.activity.viewModels import com.google.android.material.snackbar.Snackbar import com.sopt.umbba_android.R import com.sopt.umbba_android.databinding.ActivityInviteCodeBinding +import com.sopt.umbba_android.domain.entity.User import com.sopt.umbba_android.presentation.invite.viewmodel.InviteCodeViewModel import com.sopt.umbba_android.presentation.onboarding.CommunicationActivity import com.sopt.umbba_android.util.ViewModelFactory @@ -84,8 +86,15 @@ class InviteCodeActivity : } private fun goCommunicationActivity() { - //초대하는측인지 초대받는측인지 보내기 - startActivity(Intent(this, CommunicationActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) + val userData = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra("userData", User::class.java) + } else { + intent.getParcelableExtra("userData") + } + Log.e("yeonjin", "inviteCode parcelable : ${userData?.isReceiver}") + startActivity(Intent(this, CommunicationActivity::class.java).apply { + putExtra("userData", userData) + }) } companion object { diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/CommunicationActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/CommunicationActivity.kt index 946620db..917371c3 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/CommunicationActivity.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/CommunicationActivity.kt @@ -1,9 +1,12 @@ package com.sopt.umbba_android.presentation.onboarding import android.content.Intent +import android.os.Build import android.os.Bundle +import android.util.Log import com.sopt.umbba_android.R import com.sopt.umbba_android.databinding.ActivityCommunicationBinding +import com.sopt.umbba_android.domain.entity.User import com.sopt.umbba_android.util.binding.BindingActivity class CommunicationActivity : BindingActivity(R.layout.activity_communication) { @@ -15,7 +18,15 @@ class CommunicationActivity : BindingActivity(R.la private fun goInputInfoActivity() { binding.btnStart.setOnClickListener { - startActivity(Intent(this, InputInfoActivity::class.java)) + val userData = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra("userData", User::class.java) + } else { + intent.getParcelableExtra("userData") + } + Log.e("yeonjin", "communication parcelable : ${userData?.isReceiver}") + startActivity(Intent(this, InputInfoActivity::class.java).apply { + putExtra("userData", userData) + }) } } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/InputInfoActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/InputInfoActivity.kt index e276ab5a..625e40d1 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/InputInfoActivity.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/InputInfoActivity.kt @@ -1,13 +1,16 @@ package com.sopt.umbba_android.presentation.onboarding import android.content.Intent +import android.os.Build import android.os.Bundle import android.text.Editable import android.text.TextWatcher +import android.util.Log import android.view.View import androidx.activity.viewModels import com.sopt.umbba_android.R import com.sopt.umbba_android.databinding.ActivityInputInfoBinding +import com.sopt.umbba_android.domain.entity.User import com.sopt.umbba_android.presentation.onboarding.quest.QuestActivity import com.sopt.umbba_android.presentation.onboarding.viewmodel.InputInfoViewModel import com.sopt.umbba_android.util.binding.BindingActivity @@ -48,6 +51,7 @@ class InputInfoActivity : BindingActivity(R.layout.act layoutInputName.error = null } } + override fun afterTextChanged(p0: Editable?) {} }) } @@ -67,6 +71,7 @@ class InputInfoActivity : BindingActivity(R.layout.act layoutInputYear.error = null } } + override fun afterTextChanged(p0: Editable?) {} }) } @@ -94,12 +99,47 @@ class InputInfoActivity : BindingActivity(R.layout.act } } + private fun saveInfo(user: User) { + with(binding) { + user.name = etName.text.toString() + user.gender = + if (chip1.isChecked) { + chip1.text.toString() + } else if (chip2.isChecked) { + chip2.text.toString() + } else { + null + } + user.bornYear = etYear.text.toString().toInt() + } + } + private fun goSelectFamilyActivity() { binding.btnNext.setOnClickListener { - if (true) { //초대하는 사람 - startActivity(Intent(this, SelectFamilyActivity::class.java)) - } else { //초대받는 사람 - startActivity(Intent(this, QuestActivity::class.java)) + val userData = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra("userData", User::class.java) + } else { + intent.getParcelableExtra("userData") + } + if (userData != null) { + saveInfo(userData) + if (!userData.isReceiver) { //초대하는 사람 + Log.e( + "yeonjin", + "inputInfo parcelable : ${userData?.isReceiver} + ${userData?.name} + ${userData?.gender} + ${userData?.bornYear}" + ) + startActivity(Intent(this, SelectFamilyActivity::class.java).apply { + putExtra("userData", userData) + }) + } else { //초대받는 사람 + Log.e( + "yeonjin", + "inputInfo parcelable : ${userData?.isReceiver} + ${userData?.name} + ${userData?.gender} + ${userData?.bornYear}" + ) + startActivity(Intent(this, QuestActivity::class.java).apply { + putExtra("userData", userData) + }) + } } } } diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/NotifyTimeActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/NotifyTimeActivity.kt index 85d01478..53050855 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/NotifyTimeActivity.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/NotifyTimeActivity.kt @@ -7,13 +7,14 @@ import android.net.Uri import android.os.Build import android.os.Bundle import android.provider.Settings +import android.util.Log import android.view.View import androidx.activity.result.contract.ActivityResultContracts import androidx.core.content.ContextCompat import com.google.android.material.snackbar.Snackbar import com.sopt.umbba_android.R import com.sopt.umbba_android.databinding.ActivityNotifyTimeBinding -import com.sopt.umbba_android.presentation.onboarding.quest.QuestActivity +import com.sopt.umbba_android.domain.entity.User import com.sopt.umbba_android.util.binding.BindingActivity class NotifyTimeActivity : @@ -24,7 +25,6 @@ class NotifyTimeActivity : if (isGranted) { // 알림권한 허용 o Snackbar.make(binding.root, "알림 권한이 허용되었습니다.", Snackbar.LENGTH_SHORT).show() - startActivity(Intent(this, OnboardingFinishActivity::class.java)) } else { // 알림권한 허용 x Snackbar.make(binding.root, "알림 권한이 없습니다.", Snackbar.LENGTH_SHORT).show() @@ -65,7 +65,20 @@ class NotifyTimeActivity : private fun setClickButton() { with(binding) { btnGoPast.setOnClickListener { - startActivity(Intent(this@NotifyTimeActivity, QuestActivity::class.java)) + val userData = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra("userData", User::class.java) + } else { + intent.getParcelableExtra("userData") + } + Log.e("yeonjin", "notifyTime parcelable : ${userData?.isReceiver}") + val questData = intent.getStringArrayExtra("questData") + if (questData != null) { + Log.e("yeonjin", "quest 배열 값 잘 들어옴") + } else { + Log.e("yeonjin", "quest 배열 값 안 들어옴") + } + //서버 연결 + startActivity(Intent(this@NotifyTimeActivity, OnboardingFinishActivity::class.java)) } } } 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 359dab6c..37eea778 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 @@ -1,11 +1,14 @@ package com.sopt.umbba_android.presentation.onboarding import android.content.Intent +import android.os.Build import android.os.Bundle +import android.util.Log 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.domain.entity.User 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 @@ -68,9 +71,33 @@ class SelectFamilyActivity : } } + private fun saveInfo(user: User) { + with(binding) { + user.isInvitorChild = chip1.isChecked + user.relationInfo = + if (chip3.isChecked) { + chip3.text.toString() + } else { + chip4.text.toString() + } + } + + } + private fun goQuestActivity() { binding.btnNext.setOnClickListener { - startActivity(Intent(this, QuestActivity::class.java)) + val userData = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra("userData", User::class.java) + } else { + intent.getParcelableExtra("userData") + } + if (userData != null) { + saveInfo(userData) + } + Log.e("yeonjin", "selectFamily parcelable : ${userData?.isReceiver} + ${userData?.isInvitorChild} + ${userData?.relationInfo}") + startActivity(Intent(this, QuestActivity::class.java).apply { + putExtra("userData", userData) + }) } } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/SetTimeActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/SetTimeActivity.kt index 72f90204..0309b207 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/SetTimeActivity.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/onboarding/SetTimeActivity.kt @@ -7,12 +7,14 @@ import android.net.Uri import android.os.Build import android.os.Bundle import android.provider.Settings +import android.util.Log import android.view.View import androidx.activity.result.contract.ActivityResultContracts import androidx.core.content.ContextCompat import com.google.android.material.snackbar.Snackbar import com.sopt.umbba_android.R import com.sopt.umbba_android.databinding.ActivitySetTimeBinding +import com.sopt.umbba_android.domain.entity.User import com.sopt.umbba_android.util.binding.BindingActivity import com.sopt.umbba_android.util.setTimeInterval @@ -58,7 +60,6 @@ class SetTimeActivity : BindingActivity(R.layout.activit if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) { Snackbar.make(binding.root, "알림 권한이 허용되어 있습니다.", Snackbar.LENGTH_SHORT).show() - startActivity(Intent(this, OnboardingFinishActivity::class.java)) } else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { // 왜 알림을 허용해야 하는지에 대한 설명 + 권한 거절 시 권한 설정 화면으로 이동 Snackbar.make(binding.root, "알림 권한을 설정하면 답변 작성 요청 알림을 받아볼 수 있습니다.", Snackbar.LENGTH_SHORT).show() @@ -74,6 +75,20 @@ class SetTimeActivity : BindingActivity(R.layout.activit private fun goOnboardingFinishActivity() { binding.btnNext.setOnClickListener { askNotificationPermission() + val userData = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra("userData", User::class.java) + } else { + intent.getParcelableExtra("userData") + } + Log.e("yeonjin", "setTime parcelables : $userData") + val questData = intent.getStringArrayExtra("questData") + if (questData != null) { + Log.e("yeonjin", "quest 배열 값 잘 들어옴") + } else { + Log.e("yeonjin", "quest 배열 값 안 들어옴") + } + //서버 연결 + startActivity(Intent(this, OnboardingFinishActivity::class.java)) } } } \ No newline at end of file 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 index b48a42e0..570dbeb2 100644 --- 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 @@ -1,6 +1,7 @@ package com.sopt.umbba_android.presentation.onboarding.quest import android.content.Intent +import android.os.Build import android.os.Bundle import android.util.Log import android.view.View @@ -10,6 +11,7 @@ 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.domain.entity.User import com.sopt.umbba_android.presentation.onboarding.NotifyTimeActivity import com.sopt.umbba_android.presentation.onboarding.SetTimeActivity import com.sopt.umbba_android.util.binding.BindingActivity @@ -35,7 +37,10 @@ class QuestActivity : BindingActivity(R.layout.activity_qu when (view?.id) { R.id.iv_basic_back -> { if (count in 1..4) { - supportFragmentManager.popBackStack("$count", FragmentManager.POP_BACK_STACK_INCLUSIVE) + supportFragmentManager.popBackStack( + "$count", + FragmentManager.POP_BACK_STACK_INCLUSIVE + ) binding.progressBar.progress -= 20 count -= 1 initChip() @@ -108,10 +113,26 @@ class QuestActivity : BindingActivity(R.layout.activity_qu } private fun goNextActivity() { - if (true) { //초대하는 측 - startActivity(Intent(this, SetTimeActivity::class.java)) - } else { //초대받는 측 - startActivity(Intent(this, NotifyTimeActivity::class.java)) + Log.e("yeonjin", "${quest[0]}${quest[1]}${quest[2]}${quest[3]}${quest[4]}") + val userData = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra("userData", User::class.java) + } else { + intent.getParcelableExtra("userData") } + val intent: Intent = + if (userData != null && !userData.isReceiver) { + Log.e("yeonjin", "quest parcelable : ${userData?.isReceiver}") + Intent(this, SetTimeActivity::class.java).apply { + putExtra("questData", quest) + putExtra("userData", userData) + } + } else { + Log.e("yeonjin", "quest parcelable : ${userData?.isReceiver}") + Intent(this, NotifyTimeActivity::class.java).apply { + putExtra("questData", quest) + putExtra("userData", userData) + } + } + startActivity(intent) } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_onboarding_finish.xml b/app/src/main/res/layout/activity_onboarding_finish.xml index d54744e1..f138b6c7 100644 --- a/app/src/main/res/layout/activity_onboarding_finish.xml +++ b/app/src/main/res/layout/activity_onboarding_finish.xml @@ -29,17 +29,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"/> - + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 96ae28dc..4845dae1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -132,6 +132,11 @@ 아니 애매해 + 지금 가족과 함께 살고 있어? + 고등학교를 졸업했어? + 결혼을 꼭 해야 한다고 생각해? + 뭔가를 크게 포기해본 경험이 있어? + 돌아가고 싶은 순간이 있어? # 어린시절