Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into feat/#57

� Conflicts:
�	app/src/main/java/com/sopt/umbba_android/presentation/qna/QuestionAnswerViewModel.kt
  • Loading branch information
ss99x2002 committed Jul 14, 2023
2 parents 33bf7ef + 49c65ef commit 7c2076d
Show file tree
Hide file tree
Showing 41 changed files with 941 additions and 31 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ dependencies {

// coil
implementation 'io.coil-kt:coil:2.4.0'
implementation 'io.coil-kt:coil-gif:2.4.0'

// Timber
implementation 'com.jakewharton.timber:timber:5.0.1'
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,25 @@
android:usesCleartextTraffic="true"
android:theme="@style/Theme.Umbbaandroid"
tools:targetApi="31">
<activity
android:name=".presentation.splash.OnboardingActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.onboarding.CommunicationActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.login.AgreePrivacyUseActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.onboarding.OnboardingFinishActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.onboarding.SetTimeActivity"
android:exported="true"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.invite.InviteActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
package com.sopt.umbba_android.presentation.invite

import android.content.Intent
import android.os.Bundle
import com.sopt.umbba_android.R
import com.sopt.umbba_android.databinding.ActivityInviteBinding
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)

goCommunicationActivity()
goInviteCodeActivity()
}

private fun goCommunicationActivity() {
binding.btnStart.setOnClickListener {
startActivity(Intent(this, CommunicationActivity::class.java))
}
}

private fun goInviteCodeActivity() {
binding.btnInputCode.setOnClickListener {
startActivity(Intent(this, InviteCodeActivity::class.java))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.sopt.umbba_android.presentation.login

import android.content.Intent
import android.graphics.Typeface
import android.os.Bundle
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.StyleSpan
import android.text.util.Linkify
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.sopt.umbba_android.R
import com.sopt.umbba_android.databinding.ActivityAgreePrivacyUseBinding
import com.sopt.umbba_android.presentation.invite.InviteActivity
import com.sopt.umbba_android.util.binding.BindingActivity
import java.util.regex.Pattern

class AgreePrivacyUseActivity : BindingActivity<ActivityAgreePrivacyUseBinding>(R.layout.activity_agree_privacy_use) {

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

clickAllAgreeButton()
clickCircleButton()
setHyperLinkAndColorInTermsTextView()
setHyperLinkAndColorInPrivacyTextView()
goInviteActivity()
}

private fun clickAllAgreeButton() {
with(binding) {
btnAllAgreeCheck.setOnClickListener {
btnAllAgreeCheck.isSelected = !btnAllAgreeCheck.isSelected
checkAllAgreeButton()
}
}
}

private fun checkAllAgreeButton() {
with(binding) {
if (btnAllAgreeCheck.isSelected) {
btnUp14.isSelected = true
btnAgreeTermsAndCondition.isSelected = true
btnAgreePrivacy.isSelected = true
btnNext.isEnabled = true
} else {
btnUp14.isSelected = false
btnAgreeTermsAndCondition.isSelected = false
btnAgreePrivacy.isSelected = false
btnNext.isEnabled = false
}
}
}

private fun clickCircleButton() {
with(binding) {
btnUp14.setOnClickListener {
btnUp14.isSelected = !btnUp14.isSelected
checkAllCircleButton()
}
btnAgreeTermsAndCondition.setOnClickListener {
btnAgreeTermsAndCondition.isSelected = !btnAgreeTermsAndCondition.isSelected
checkAllCircleButton()
}
btnAgreePrivacy.setOnClickListener {
btnAgreePrivacy.isSelected = !btnAgreePrivacy.isSelected
checkAllCircleButton()
}
}
}

private fun checkAllCircleButton() {
with(binding) {
if (btnUp14.isSelected && btnAgreeTermsAndCondition.isSelected && btnAgreePrivacy.isSelected) {
btnAllAgreeCheck.isSelected = true
btnNext.isEnabled = true
} else {
btnAllAgreeCheck.isSelected = false
btnNext.isEnabled = false
}
}
}

private fun setHyperLinkAndColorInTermsTextView() {
with(binding) {
setHyperLinkToTextView("서비스 이용약관", tvAgreeTermsAndCondition, "https://www.notion.so/f1a14bf60ed4421f9b3761ef88906adb?pvs=4")
setLinkTextColorToBlack(tvAgreeTermsAndCondition)
setLinkBold(tvAgreeTermsAndCondition, 13)
}
}

private fun setHyperLinkAndColorInPrivacyTextView() {
with(binding) {
setHyperLinkToTextView("개인정보 수집 및 이용", tvAgreePrivacy, "https://www.notion.so/99fe0f58825d4f87bd3b987fadc623b6?pvs=4")
setLinkTextColorToBlack(tvAgreePrivacy)
setLinkBold(tvAgreePrivacy, 17)
}
}

private fun setHyperLinkToTextView(text: String, view: TextView, uri: String) {
val transform = Linkify.TransformFilter { match, url -> "" }
val pattern = Pattern.compile(text)

Linkify.addLinks(view, pattern, uri, null, transform)
}

private fun setLinkTextColorToBlack(view: TextView) {
view.setLinkTextColor(ContextCompat.getColor(this, R.color.umbba_black))
}

private fun setLinkBold(view: TextView, end: Int) {
val sentence = SpannableStringBuilder(view.text)
sentence.setSpan(StyleSpan(Typeface.BOLD), 5, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
view.text = sentence
}

private fun goInviteActivity() {
binding.btnNext.setOnClickListener {
startActivity(Intent(this, InviteActivity::class.java))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sopt.umbba_android.presentation.login

import android.content.Intent
import android.os.Bundle
import com.sopt.umbba_android.R
import com.sopt.umbba_android.databinding.ActivityLoginBinding
Expand All @@ -8,5 +9,18 @@ import com.sopt.umbba_android.util.binding.BindingActivity
class LoginActivity : BindingActivity<ActivityLoginBinding>(R.layout.activity_login) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

loginWithKaKao()
}

private fun loginWithKaKao() {
//TODO("카카오 로그인 및 자동 로그인 진행")
goAgreePrivacyUseActivity()
}

private fun goAgreePrivacyUseActivity() {
binding.btnKakaoLogin.setOnClickListener {
startActivity(Intent(this, AgreePrivacyUseActivity::class.java))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.sopt.umbba_android.presentation.onboarding

import android.content.Intent
import android.os.Bundle
import com.sopt.umbba_android.R
import com.sopt.umbba_android.databinding.ActivityCommunicationBinding
import com.sopt.umbba_android.util.binding.BindingActivity

class CommunicationActivity : BindingActivity<ActivityCommunicationBinding>(R.layout.activity_communication) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

goInputInfoActivity()
}

private fun goInputInfoActivity() {
binding.btnStart.setOnClickListener {
startActivity(Intent(this, InputInfoActivity::class.java))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,108 @@
package com.sopt.umbba_android.presentation.onboarding

import android.content.Intent
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
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.presentation.viewmodel.InputInfoViewModel
import com.sopt.umbba_android.util.binding.BindingActivity
import java.util.regex.Pattern

class InputInfoActivity : BindingActivity<ActivityInputInfoBinding>(R.layout.activity_input_info),
View.OnClickListener {

private val viewModel by viewModels<InputInfoViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.clickListener = this
binding.viewmodel = viewModel

checkAllInfoComplete()
validateName()
validateYear()
goSelectFamilyActivity()
}

override fun onClick(view: View?) {
when (view?.id) {
R.id.iv_basic_back -> finish()
}
}

private fun validateName() {
with(binding) {
etName.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
val namePattern = Pattern.compile(HANGUL_PATTERN)
if (!etName.text?.matches(namePattern.toRegex())!!) {
layoutInputName.error = "*형식이 올바르지 않습니다."
} else if (etName.text.toString().length > 7) {
layoutInputName.error = "*7글자 이하로 작성해주세요."
} else {
layoutInputName.error = null
}
}
override fun afterTextChanged(p0: Editable?) {}
})
}
}

private fun validateYear() {
with(binding) {
etYear.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
val yearPattern = Pattern.compile(NUMBER_PATTERN)
if (!etYear.text?.matches(yearPattern.toRegex())!!) {
layoutInputYear.error = "*형식이 올바르지 않습니다."
} else if (etYear.text.toString().length > 4) {
layoutInputYear.error = "*4글자로 작성해주세요."
} else {
layoutInputYear.error = null
}
}
override fun afterTextChanged(p0: Editable?) {}
})
}
}

private fun checkAllInfoComplete() {
viewModel.name.observe(this) {
viewModel.checkInfoComplete()
}
viewModel.man.observe(this) {
viewModel.checkInfoComplete()
}
viewModel.woman.observe(this) {
viewModel.checkInfoComplete()
}
viewModel.year.observe(this) {
viewModel.checkInfoComplete()
}
viewModel.isAllInfoComplete.observe(this) {
binding.btnNext.isEnabled =
binding.layoutInputName.error.isNullOrEmpty() && binding.layoutInputYear.error.isNullOrEmpty() && binding.etYear.text.toString()
.isNotEmpty() && binding.etName.text.toString().isNotEmpty()
}
}

private fun goSelectFamilyActivity() {
binding.btnNext.setOnClickListener {
if (true) { //초대하는 사람
startActivity(Intent(this, SelectFamilyActivity::class.java))
} else { //초대받는 사람
startActivity(Intent(this, QuestActivity::class.java))
}
}
}

companion object {
const val HANGUL_PATTERN = "^[가-힣]*$"
const val NUMBER_PATTERN = "^([12]\\d{3})*$"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sopt.umbba_android.presentation.onboarding

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.sopt.umbba_android.R

class OnboardingFinishActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_onboarding_finish)
}
}
Loading

0 comments on commit 7c2076d

Please sign in to comment.