Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0.0 QA] 온보딩 수정 #325

Merged
merged 5 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,35 @@ package hous.release.android.presentation.feedback.feedback
import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.activity.OnBackPressedCallback
import androidx.activity.addCallback
import androidx.fragment.app.activityViewModels
import dagger.hilt.android.AndroidEntryPoint
import hous.release.android.R
import hous.release.android.databinding.FragmentFeedbackBinding
import hous.release.android.util.KeyBoardUtil
import hous.release.android.util.binding.BindingFragment
import hous.release.android.util.dialog.ConfirmClickListener
import hous.release.android.util.dialog.WarningDialogFragment
import hous.release.android.util.dialog.WarningType
import hous.release.android.util.extension.withArgs

@AndroidEntryPoint
class FeedbackFragment : BindingFragment<FragmentFeedbackBinding>(R.layout.fragment_feedback) {
private val feedbackViewModel by activityViewModels<FeedbackViewModel>()
private lateinit var onBackPressedCallback: OnBackPressedCallback

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.viewModel = feedbackViewModel
initEditTextClearFocus()
initBackBtnClickListener()
initBackBtnOnClick()
}

override fun onDestroyView() {
super.onDestroyView()
onBackPressedCallback.remove()
}

@SuppressLint("ClickableViewAccessibility")
Expand All @@ -29,9 +42,32 @@ class FeedbackFragment : BindingFragment<FragmentFeedbackBinding>(R.layout.fragm
}
}

private fun initBackBtnOnClick() {
requireActivity().onBackPressedDispatcher.apply {
addCallback {
showOutDialog()
}.also { callback ->
onBackPressedCallback = callback
}
}
}

private fun initBackBtnClickListener() {
binding.btnFeedbackBack.setOnClickListener {
requireActivity().finish()
showOutDialog()
}
}

private fun showOutDialog() {
WarningDialogFragment().withArgs {
putSerializable(
WarningDialogFragment.WARNING_TYPE,
WarningType.WARNING_PEED_BACK
)
putParcelable(
WarningDialogFragment.CONFIRM_ACTION,
ConfirmClickListener(confirmAction = { requireActivity().finish() })
)
}.show(childFragmentManager, WarningDialogFragment.DIALOG_WARNING)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hous.release.android.presentation.login

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.activity.addCallback
import androidx.activity.viewModels
Expand Down Expand Up @@ -29,7 +30,7 @@ class LoginActivity : BindingActivity<ActivityLoginBinding>(R.layout.activity_lo

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initKakaoLoginBtnClickListener()
initClickListener()
initIsSuccessKakaoLoginObserver()
initIsInitUserInfoObserver()
initBackPressedCallback()
Expand All @@ -38,6 +39,21 @@ class LoginActivity : BindingActivity<ActivityLoginBinding>(R.layout.activity_lo
initIsPermitAccessObserve()
}

private fun initClickListener() {
binding.btnLoginKakao.setOnClickListener {
startKakaoLogin()
}
binding.tvLoginDescUse.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.login_link_use)))
startActivity(intent)
}
binding.tvLoginDescPersonal.setOnClickListener {
val intent =
Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.login_link_personal)))
startActivity(intent)
}
}

private fun initIsUserObserve() {
loginViewModel.isJoiningRoom.observe(this) {
if (loginViewModel.isJoiningRoom.value == true) {
Expand Down Expand Up @@ -79,12 +95,6 @@ class LoginActivity : BindingActivity<ActivityLoginBinding>(R.layout.activity_lo
}
}

private fun initKakaoLoginBtnClickListener() {
binding.btnLoginKakao.setOnClickListener {
startKakaoLogin()
}
}

private fun startKakaoLogin() {
kakaoLoginService.startKakaoLogin(loginViewModel.kakaoLoginCallback)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import hous.release.android.util.ToastMessageUtil
import hous.release.android.util.binding.BindingActivity
import hous.release.android.util.dialog.DatePickerClickListener
import hous.release.android.util.dialog.DatePickerDialog
import hous.release.android.util.dialog.DatePickerDialog.Companion.USER_BIRTHDAY
import hous.release.android.util.dialog.WarningDialogFragment.Companion.CONFIRM_ACTION
import hous.release.android.util.extension.repeatOnStarted
import hous.release.android.util.extension.setOnSingleClickListener
import hous.release.android.util.extension.withArgs
import kotlin.system.exitProcess

@AndroidEntryPoint
Expand All @@ -29,11 +31,8 @@ class UserInputActivity : BindingActivity<ActivityUserInputBinding>(R.layout.act
super.onCreate(savedInstanceState)
binding.vm = userInputViewModel
initSignUpCollect()
initNextBtnOnClickListener()
initClickListener()
initBackPressedCallback()
initBirthdayOnClickListener()
initEditTextClearFocus()
initKeyboardNextClickListener()
}

private fun initSignUpCollect() {
Expand All @@ -47,12 +46,42 @@ class UserInputActivity : BindingActivity<ActivityUserInputBinding>(R.layout.act
}
}

private fun initNextBtnOnClickListener() {
binding.tvUserInputNext.setOnSingleClickListener {
@SuppressLint("ClickableViewAccessibility")
private fun initClickListener() {
binding.tvNavigateRoom.setOnSingleClickListener {
val toEnterRoom = Intent(this, EnterRoomActivity::class.java)
startActivity(toEnterRoom)
finishAffinity()
}
binding.etUserName.setOnEditorActionListener { _, actionId, _ ->
var handled = false
if (actionId == EditorInfo.IME_ACTION_NEXT) {
binding.etUserInputBirthday.performClick()
handled = true
}
KeyBoardUtil.hide(activity = this)
handled
}
binding.etUserInputBirthday.setOnSingleClickListener {
DatePickerDialog().withArgs {
putParcelable(
CONFIRM_ACTION,
DatePickerClickListener(
confirmActionWithDate = { date ->
userInputViewModel.initSelectedBirthDate(date)
}
)
)
putString(USER_BIRTHDAY, userInputViewModel.birthday.value)
}.show(supportFragmentManager, SELECT_BIRTHDAY)
}
binding.clUserInput.setOnTouchListener { _, _ ->
KeyBoardUtil.hide(activity = this)
return@setOnTouchListener false
}
binding.tvPrivateBirthday.setOnClickListener {
userInputViewModel.updateIsPrivateBirthday()
}
}

private fun initBackPressedCallback() {
Expand All @@ -76,43 +105,6 @@ class UserInputActivity : BindingActivity<ActivityUserInputBinding>(R.layout.act
)
}

private fun initBirthdayOnClickListener() {
binding.etUserInputBirthday.setOnSingleClickListener {
DatePickerDialog().apply {
arguments = Bundle().apply {
putParcelable(
CONFIRM_ACTION,
DatePickerClickListener(
confirmActionWithDate = { date ->
userInputViewModel.initSelectedBirthDate(date)
}
)
)
}
}.show(supportFragmentManager, SELECT_BIRTHDAY)
}
}

@SuppressLint("ClickableViewAccessibility")
private fun initEditTextClearFocus() {
binding.clUserInput.setOnTouchListener { _, _ ->
KeyBoardUtil.hide(activity = this)
return@setOnTouchListener false
}
}

private fun initKeyboardNextClickListener() {
binding.etUserInputNickname.setOnEditorActionListener { _, actionId, _ ->
var handled = false
if (actionId == EditorInfo.IME_ACTION_NEXT) {
binding.etUserInputBirthday.performClick()
handled = true
}
KeyBoardUtil.hide(activity = this)
handled
}
}

companion object {
private const val WAITING_DEADLINE = 2000L
private const val SELECT_BIRTHDAY = "select birthday"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class UserInputViewModel @Inject constructor(
private val _isSignedUp = MutableSharedFlow<Boolean>()
val isSignedUp = _isSignedUp.asSharedFlow()

fun updateIsPrivateBirthday() {
isPrivateBirthday.value = !isPrivateBirthday.value
}

fun signUp() {
viewModelScope.launch {
postSignUpUseCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,18 @@ class ProfileEditActivity :

private fun initBirthdayOnClickListener() {
binding.etProfileEditBirthday.setOnSingleClickListener {
DatePickerDialog().apply {
arguments = Bundle().apply {
putParcelable(
WarningDialogFragment.CONFIRM_ACTION,
DatePickerClickListener(
confirmActionWithDate = { date -> initDate(date) }
)
DatePickerDialog().withArgs {
putParcelable(
WarningDialogFragment.CONFIRM_ACTION,
DatePickerClickListener(
confirmActionWithDate = { date -> profileEditViewModel.initSelectedBirthDate(date) }
)
}
)
putString(DatePickerDialog.USER_BIRTHDAY, profileEditViewModel.birthday.value)
}.show(supportFragmentManager, SELECT_BIRTHDAY)
}
}

private fun initDate(date: String) {
profileEditViewModel.initSelectedBirthDate(date)
}

companion object {
private const val SELECT_BIRTHDAY = "select birthday"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ProfileEditViewModel @Inject constructor(
fun updateProfile() {
viewModelScope.launch {
putProfileEditUseCase(
birthday = birthday.value.replace("/", "-"),
birthday = birthday.value,
introduction = introduction.value,
isPublic = !isPrivateBirthday.value,
job = job.value,
Expand All @@ -66,7 +66,7 @@ class ProfileEditViewModel @Inject constructor(
}

fun initSelectedBirthDate(birth: String) {
birthday.value = birth.replace("-", "/")
birthday.value = birth
}

fun isPrivateBirthday(checked: Boolean) {
Expand All @@ -75,7 +75,7 @@ class ProfileEditViewModel @Inject constructor(

fun initData(profileData: ProfileEntity) {
originData.value = profileData.copy(
birthday = profileData.birthday.replace(".", "/"),
birthday = profileData.birthday.replace(".", "-"),
birthdayPublic = !profileData.birthdayPublic,
mbti = profileData.mbti ?: "",
job = profileData.job ?: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DatePickerDialog : DialogFragment() {

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
_binding = DialogDatePickerBinding.inflate(requireActivity().layoutInflater)
initDatePicker()
initConfirmTextClickListener()
initCancelTextClickListener()
initMaxDate()
Expand All @@ -42,11 +43,18 @@ class DatePickerDialog : DialogFragment() {
binding.datePickerDialogDatePicker.maxDate = Calendar.getInstance().timeInMillis
}

private fun getYearFormat(year: Int): String = year.toString()

private fun getMonthFormat(month: Int): String = "%02d".format(month + 1)

private fun getDayFormat(day: Int): String = "%02d".format(day)
private fun initDatePicker() {
val (year, month, day) = arguments?.getString(USER_BIRTHDAY)?.let {
if (it.isBlank()) return@let null
val date = it.split("-")
Triple(date[0].toInt(), date[1].toInt(), date[2].toInt())
} ?: Triple(
Calendar.getInstance()[Calendar.YEAR],
Calendar.getInstance()[Calendar.MONTH] + 1,
Calendar.getInstance()[Calendar.DAY_OF_MONTH]
)
binding.datePickerDialogDatePicker.init(year, month - 1, day, null)
}

private fun initConfirmTextClickListener() {
binding.tvDatePickerConfirm.setOnClickListener {
Expand All @@ -62,6 +70,9 @@ class DatePickerDialog : DialogFragment() {
}
dismiss()
}
binding.datePickerDialogDatePicker.setOnDateChangedListener { _, year, month, dayOfMonth ->
Timber.e("year: $year, month: $month, dayOfMonth: $dayOfMonth")
}
}

private fun initCancelTextClickListener() {
Expand All @@ -70,8 +81,17 @@ class DatePickerDialog : DialogFragment() {
}
}

private fun getYearFormat(year: Int): String = year.toString()

private fun getMonthFormat(month: Int): String = "%02d".format(month + 1)

private fun getDayFormat(day: Int): String = "%02d".format(day)
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}

companion object {
const val USER_BIRTHDAY = "birthDAY"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,11 @@ data class WarningDialogContent(
cancel = context.getString(R.string.warning_stop_test_cancel),
confirm = context.getString(R.string.warning_stop_test_confirm)
)
fun getWarningFeedBack(context: Context): WarningDialogContent =
WarningDialogContent(
title = context.getString(R.string.waring_peed_back_title),
desc = context.getString(R.string.waring_peed_back_desc),
cancel = context.getString(R.string.waring_peed_back_cancel),
confirm = context.getString(R.string.waring_peed_back_confirm)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class WarningDialogFragment : DialogFragment() {

WarningType.WARNING_STOP_TEST ->
WarningDialogContent().getWarningStopTest(requireContext())

WarningType.WARNING_PEED_BACK ->
WarningDialogContent().getWarningFeedBack(requireContext())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ enum class WarningType {
WARNING_DELETE_TO_DO,
WARNING_EDIT_PROFILE,
WARNING_LOGOUT,
WARNING_STOP_TEST
WARNING_STOP_TEST,
WARNING_PEED_BACK,
}
Loading
Loading