Skip to content

Commit

Permalink
Merge pull request #96 from Team-Umbba/fix/#95
Browse files Browse the repository at this point in the history
[Fix/#95] 답변, 설정 QA 반영
  • Loading branch information
ss99x2002 authored Jul 20, 2023
2 parents d46a428 + 1b71c1c commit 526583c
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
private fun setBackground(section: String) {
binding.ivBackground.load(
when (section) {
"어린시절" -> R.drawable.bg_home1
"학창시절" -> R.drawable.bg_home2
"청춘시절" -> R.drawable.bg_home3
"연애시절" -> R.drawable.bg_home4
getString(R.string.section1) -> R.drawable.bg_home1
getString(R.string.section2) -> R.drawable.bg_home2
getString(R.string.section3) -> R.drawable.bg_home3
getString(R.string.section4) -> R.drawable.bg_home4
else -> R.drawable.bg_home5
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.sopt.umbba_android.data.model.response.HomeCaseResponseDto
import com.sopt.umbba_android.data.model.response.HomeResponseDto
import com.sopt.umbba_android.data.repository.HomeRepositoryImpl
import kotlinx.coroutines.launch
import timber.log.Timber

class HomeViewModel(private val homeRepositoryImpl: HomeRepositoryImpl) : ViewModel() {
init {
Expand All @@ -22,17 +23,17 @@ class HomeViewModel(private val homeRepositoryImpl: HomeRepositoryImpl) : ViewMo
val homeData: LiveData<HomeResponseDto.HomeData> = _homeData

private var _topicTitle = MutableLiveData<String>()
val topicTitle:LiveData<String> = _topicTitle
val topicTitle: LiveData<String> = _topicTitle

fun getHomeData() {
private fun getHomeData() {
viewModelScope.launch {
homeRepositoryImpl.getHomeData()
.onSuccess { response ->
Log.e("hyeon", "getHomeData 성공")
Timber.e("getHomeData 성공")
_homeData.value = response.data
_topicTitle.value ="#${response.data.index} ${response.data.topic}"
_topicTitle.value = "#${response.data.index} ${response.data.topic}"
}.onFailure { error ->
Log.e("hyeon", "getHomeData 실패 " + error.message)
Timber.e("getHomeData 실패 " + error.message)
}
}
}
Expand All @@ -42,9 +43,9 @@ class HomeViewModel(private val homeRepositoryImpl: HomeRepositoryImpl) : ViewMo
homeRepositoryImpl.getResponseCase()
.onSuccess { response ->
_responseCaseData.value = response.data
Log.e("hyeon", "getResponseCode 성공")
Timber.e("getResponseCode 성공")
}.onFailure { error ->
Log.e("hyeon", "getResponseCode 실패 " + error.message)
Timber.e("getResponseCode 실패 " + error.message)
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class InviteCodeActivity :
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
val namePattern = Pattern.compile(INVITE_CODE_PATTERN)
if (!etCode.text?.matches(namePattern.toRegex())!!) {
layoutInputCode.error = "*올바른 초대코드 형식이 아닙니다."
layoutInputCode.error = getString(R.string.input_code_error)
} else {
layoutInputCode.error = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.sopt.umbba_android.data.model.response.ExampleResponseDto
import com.sopt.umbba_android.data.model.response.ListResponseDto
import com.sopt.umbba_android.databinding.ItemQuestionListBinding
import timber.log.Timber

class ListQuestionAdapter(private val itemClick: (ListResponseDto.ListData) -> (Unit)) :
ListAdapter<ListResponseDto.ListData, ListQuestionAdapter.ListViewHolder>(diffUtil) {
Expand All @@ -33,7 +34,7 @@ class ListQuestionAdapter(private val itemClick: (ListResponseDto.ListData) -> (
tvTopic.text = data.topic
root.setOnClickListener {
itemClick(data)
Log.e("hyeon","아이템 클릭 이벤트 발생")
Timber.e("아이템 클릭 이벤트 발생")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.sopt.umbba_android.presentation.list.viewmodel

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.sopt.umbba_android.data.model.response.ListResponseDto
import com.sopt.umbba_android.data.repository.ListRepositoryImpl
import kotlinx.coroutines.launch
import timber.log.Timber

class ListViewModel(private val listRepositoryImpl: ListRepositoryImpl) : ViewModel() {

Expand All @@ -23,7 +23,7 @@ class ListViewModel(private val listRepositoryImpl: ListRepositoryImpl) : ViewMo
listRepositoryImpl.getListData(sectionId).onSuccess { response ->
_listResponse.value = response.data
}.onFailure { error ->
Log.e("hyeon", "getList 실패 " + error.message)
Timber.e("getList 실패 " + error.message)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class InputInfoActivity : BindingActivity<ActivityInputInfoBinding>(R.layout.act
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 = "*형식이 올바르지 않습니다."
layoutInputName.error = getString(R.string.input_error)
} else if (etName.text.toString().length > 7) {
layoutInputName.error = "*7글자 이하로 작성해주세요."
layoutInputName.error = getString(R.string.input_error_max_seven)
} else {
layoutInputName.error = null
}
Expand All @@ -64,9 +64,9 @@ class InputInfoActivity : BindingActivity<ActivityInputInfoBinding>(R.layout.act
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 = "*형식이 올바르지 않습니다."
layoutInputYear.error = getString(R.string.input_error)
} else if (etYear.text.toString().length > 4) {
layoutInputYear.error = "*4글자로 작성해주세요."
layoutInputYear.error = getString(R.string.input_error_limit_four)
} else {
layoutInputYear.error = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ class SelectFamilyActivity :

private fun modifyMoreQuestion() {
if (binding.chip1.isChecked) {
binding.chip3.text = "엄마"
binding.chip4.text = "아빠"
binding.chip3.text = getString(R.string.mom)
binding.chip4.text = getString(R.string.dad)
} else {
binding.chip3.text = "아들"
binding.chip4.text = ""
binding.chip3.text = getString(R.string.son)
binding.chip4.text = getString(R.string.daughter)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.Toast
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.viewModels
import com.google.android.material.snackbar.Snackbar
import com.sopt.umbba_android.data.model.request.AnswerRequestDto
import com.sopt.umbba_android.databinding.FragmentConfirmAnswerDialogBinding
import com.sopt.umbba_android.presentation.qna.viewmodel.ConfirmAnswerDialogFragmentViewModel
Expand All @@ -36,7 +38,8 @@ class ConfirmAnswerDialogFragment : DialogFragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel.setDataFromBundle(Bundle())
viewModel.setDataFromBundle(arguments)
binding.vm = viewModel
setBackgroundDesign()
setBtnClickEvent()
observeResponseStatus()
Expand All @@ -61,7 +64,7 @@ class ConfirmAnswerDialogFragment : DialogFragment() {
dismiss()
}
btnConfirm.setOnClickListener {
Toast.makeText(requireActivity(), "답변이 전송되었습니다.", Toast.LENGTH_SHORT).show()
Snackbar.make(binding.root, "답변이 전송되었습니다.", Toast.LENGTH_SHORT).show()
viewModel.postAnswer(AnswerRequestDto(arguments?.getString("answer")))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.sopt.umbba_android.databinding.ActivityQuestionAnswerBinding
import com.sopt.umbba_android.presentation.qna.viewmodel.QuestionAnswerViewModel
import com.sopt.umbba_android.util.ViewModelFactory
import com.sopt.umbba_android.util.binding.BindingActivity
import timber.log.Timber

class QuestionAnswerActivity :
BindingActivity<ActivityQuestionAnswerBinding>(R.layout.activity_question_answer),
Expand All @@ -34,7 +35,7 @@ class QuestionAnswerActivity :

private fun observeQnaViewFlag() {
val qnaId = intent.getLongExtra("questionId", -1)
Log.e("hyeon", "qnaId activity에서" + qnaId.toString())
Timber.e( "qnaId activity에서" + qnaId.toString())
if (qnaId == -1L) {
viewModel.getQuestionAnswer()
viewModel.isBeforeList.value = false
Expand Down Expand Up @@ -63,6 +64,7 @@ class QuestionAnswerActivity :
private fun observeListQnaResponse() {
viewModel.listQnaResponse.observe(this@QuestionAnswerActivity) {
setBtnEnable(true)
setListAnswerText(it)
}
}

Expand All @@ -74,6 +76,12 @@ class QuestionAnswerActivity :
}
}

private fun setListAnswerText(data:ListQuestionAnswerResponseDto.QnaData){
with(binding){
tvAnswerOther.text = data.opponentAnswer
tvAnswerMe.text= data.myAnswer
}
}
private fun setAnswerText(data: QuestionAnswerResponseDto.QnaData) {
with(binding) {
if (data.isOpponentAnswer == true) {
Expand All @@ -83,16 +91,16 @@ class QuestionAnswerActivity :
setBlurText(false)
} else {
tvAnswerOther.text = data.opponentAnswer
tvAnswerMe.text = "하단 버튼을 눌러 답변을 입력하세요"
tvAnswerMe.text = getString(R.string.answer_me_hint)
setBlurText(true)
}
} else {
if (data.isMyAnswer == true) {
tvAnswerMe.text = data.myAnswer
} else {
tvAnswerMe.text = "하단 버튼을 눌러 답변을 입력하세요"
tvAnswerMe.text = getString(R.string.answer_me_hint)
}
tvAnswerOther.text = "상대방은 아직 답변하지 않았어요"
tvAnswerOther.text = getString(R.string.answer_opponent_hint)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.sopt.umbba_android.presentation.qna.viewmodel

import android.os.Bundle
import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.sopt.umbba_android.data.model.request.AnswerRequestDto
import com.sopt.umbba_android.data.repository.QuestionAnswerRepositoryImpl
import kotlinx.coroutines.launch
import timber.log.Timber

class ConfirmAnswerDialogFragmentViewModel(private val questionAnswerRepositoryImpl: QuestionAnswerRepositoryImpl) :
ViewModel() {
Expand All @@ -18,21 +18,22 @@ class ConfirmAnswerDialogFragmentViewModel(private val questionAnswerRepositoryI
var section = MutableLiveData<String>()
var topic = MutableLiveData<String>()

fun setDataFromBundle(bundle: Bundle) {
answer.value = bundle.getString("answer")
question.value = bundle.getString("question")
section.value = bundle.getString("section")
topic.value = bundle.getString("topic")
fun setDataFromBundle(bundle: Bundle?) {
answer.value = bundle?.getString("answer")
question.value = bundle?.getString("question")
section.value = bundle?.getString("section")
topic.value = bundle?.getString("topic")
Timber.e("setData ${topic.value}")
}

fun postAnswer(answerRequestDto: AnswerRequestDto) {
viewModelScope.launch {
questionAnswerRepositoryImpl.postAnswer(answerRequestDto)
.onSuccess { reseponse ->
Log.e("hyeon", "postAnswer 성공")
Timber.e( "postAnswer 성공")
responseStatus.value = reseponse.status
}.onFailure { error ->
Log.e("hyeon", "postAnswer 실패 " + error.message)
Timber.e("postAnswer 실패 " + error.message)
responseStatus.value = -1
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.sopt.umbba_android.data.model.response.ListQuestionAnswerResponseDto
import com.sopt.umbba_android.data.model.response.QuestionAnswerResponseDto
import com.sopt.umbba_android.data.repository.QuestionAnswerRepositoryImpl
import kotlinx.coroutines.launch
import timber.log.Timber

class QuestionAnswerViewModel(private val questionAnswerRepositoryImpl: QuestionAnswerRepositoryImpl) :
ViewModel() {
Expand All @@ -32,14 +33,14 @@ class QuestionAnswerViewModel(private val questionAnswerRepositoryImpl: Question
viewModelScope.launch {
questionAnswerRepositoryImpl.getQuestionAnswer()
.onSuccess { response ->
Log.e("hyeon", "getQuestionAnswer 성공")
Timber.e( "getQuestionAnswer 성공")
_qnaResponse.value = response.data
isMyAnswer.value = response.data.isMyAnswer
isOpponentAnswer.value = response.data.isOpponentAnswer
_topicTitle.value = "#${response.data.index} ${response.data.topic}"
appbarSection.value = response.data.section.toString()
}.onFailure { error ->
Log.e("hyeon", "getQuestionAnswer 실패 " + error.message)
Timber.e("getQuestionAnswer 실패 " + error.message)
}
}
}
Expand All @@ -51,9 +52,9 @@ class QuestionAnswerViewModel(private val questionAnswerRepositoryImpl: Question
_listQnaResponse.value = response.data
appbarSection.value = response.data.section.toString()
_topicTitle.value = "#${response.data.index} ${response.data.topic}"
Log.e("hyeon", "getListQuestionAnswer 성공")
Timber.e( "getListQuestionAnswer 성공")
}.onFailure { error ->
Log.e("hyeon", "getListQuestionAnswer 실패" + error.message)
Timber.e( "getListQuestionAnswer 실패" + error.message)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.sopt.umbba_android.databinding.FragmentSettingBinding
import com.sopt.umbba_android.presentation.onboarding.OnboardingFinishActivity
import com.sopt.umbba_android.util.binding.BindingFragment
import com.sopt.umbba_android.util.fcm.MyFirebaseMessagingService
import timber.log.Timber

class SettingFragment : BindingFragment<FragmentSettingBinding>(R.layout.fragment_setting) {

Expand All @@ -30,7 +31,6 @@ class SettingFragment : BindingFragment<FragmentSettingBinding>(R.layout.fragmen
private val notificationSettingsLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
// 앱의 설정 화면으로 이동한 후 결과를 처리하는 로직
Log.e("hyeon", "나 지금 돌아왔어요.")
setSwitchNotification()
}

Expand All @@ -39,7 +39,7 @@ class SettingFragment : BindingFragment<FragmentSettingBinding>(R.layout.fragmen
requireActivity(),
Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED
Log.e("hyeon", "현재 알림 허용이 되었니? " + binding.switchNotification.isChecked)
Timber.e("현재 알림 허용 값 = " + binding.switchNotification.isChecked)
}

private fun changeSwitchNotification() {
Expand All @@ -52,7 +52,6 @@ class SettingFragment : BindingFragment<FragmentSettingBinding>(R.layout.fragmen
val intent =
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(Uri.parse("package:" + requireActivity().packageName))
notificationSettingsLauncher.launch(intent)
Log.e("hyeon", "나 지금 switch 바꿨어요.")
}
}
}
Expand All @@ -66,23 +65,23 @@ class SettingFragment : BindingFragment<FragmentSettingBinding>(R.layout.fragmen
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://brawny-guan-098.notion.site/7b3e5f70a471468f8acbe56a1a4f4ec9?pvs=4")
Uri.parse(getString(R.string.notion_about_umbba))
)
)
}
clTos.setOnClickListener {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://www.notion.so/f1a14bf60ed4421f9b3761ef88906adb")
Uri.parse(getString(R.string.notion_tos))
)
)
}
clPrivacyNotice.setOnClickListener {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://www.notion.so/99fe0f58825d4f87bd3b987fadc623b6?pvs=4")
Uri.parse(getString(R.string.notion_privacy_notice))
) //공지사항 바꾸기
)
}
Expand Down
Loading

0 comments on commit 526583c

Please sign in to comment.