Skip to content

Commit

Permalink
Merge pull request #87 from Team-Umbba/feat/#82
Browse files Browse the repository at this point in the history
[Feat/#82] 초대하는 측 / 초대받는 측 분기처리
  • Loading branch information
yeoncheong authored Jul 19, 2023
2 parents 90ab546 + 37831a4 commit ee03739
Show file tree
Hide file tree
Showing 16 changed files with 198 additions and 41 deletions.
14 changes: 14 additions & 0 deletions app/src/main/java/com/sopt/umbba_android/domain/entity/User.kt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActivityInviteBinding>(R.layout.activity_invite) {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -16,14 +19,24 @@ class InviteActivity : BindingActivity<ActivityInviteBinding>(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)
})
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<User>("userData")
}
Log.e("yeonjin", "inviteCode parcelable : ${userData?.isReceiver}")
startActivity(Intent(this, CommunicationActivity::class.java).apply {
putExtra("userData", userData)
})
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ActivityCommunicationBinding>(R.layout.activity_communication) {
Expand All @@ -15,7 +18,15 @@ class CommunicationActivity : BindingActivity<ActivityCommunicationBinding>(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<User>("userData")
}
Log.e("yeonjin", "communication parcelable : ${userData?.isReceiver}")
startActivity(Intent(this, InputInfoActivity::class.java).apply {
putExtra("userData", userData)
})
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,6 +51,7 @@ class InputInfoActivity : BindingActivity<ActivityInputInfoBinding>(R.layout.act
layoutInputName.error = null
}
}

override fun afterTextChanged(p0: Editable?) {}
})
}
Expand All @@ -67,6 +71,7 @@ class InputInfoActivity : BindingActivity<ActivityInputInfoBinding>(R.layout.act
layoutInputYear.error = null
}
}

override fun afterTextChanged(p0: Editable?) {}
})
}
Expand Down Expand Up @@ -94,12 +99,47 @@ class InputInfoActivity : BindingActivity<ActivityInputInfoBinding>(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<User>("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)
})
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand All @@ -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()
Expand Down Expand Up @@ -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<User>("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))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<User>("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)
})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -58,7 +60,6 @@ class SetTimeActivity : BindingActivity<ActivitySetTimeBinding>(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()
Expand All @@ -74,6 +75,20 @@ class SetTimeActivity : BindingActivity<ActivitySetTimeBinding>(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<User>("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))
}
}
}
Loading

0 comments on commit ee03739

Please sign in to comment.