Skip to content

Commit

Permalink
[FIX/#256] 컨플릭 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
crownjoe committed Mar 14, 2024
2 parents fc84f5a + 87a279d commit 0bdae1a
Show file tree
Hide file tree
Showing 39 changed files with 604 additions and 202 deletions.
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
<activity
android:name="com.going.presentation.onboarding.signup.SignUpActivity"
android:exported="false"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />

<activity
android:name="com.going.presentation.tendency.splash.TendencySplashActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ class DashBoardActivity :
checkIsFirstEntered()
setTabLayout()
setViewPager()
setTravelerName()
initSettingBtnClickListener()
initCreateTripBtnClickListener()
initOnBackPressedListener(binding.root)
}

override fun onResume() {
super.onResume()

setTravelerName()
}

private fun checkIsFirstEntered() {
if (intent.getBooleanExtra(IS_FIRST_ENTERED, false)) {
val tripId = intent.getLongExtra(TRIP_ID, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.res.TypedArray
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View.OnFocusChangeListener
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.isVisible
Expand Down Expand Up @@ -56,7 +57,11 @@ class EmojiCounterEditText(context: Context, attrs: AttributeSet) :
set(value) {
field = value

binding.btnDeleteText.isVisible = value != EditTextState.EMPTY
binding.run {
btnDeleteText.isVisible =
(value != EditTextState.EMPTY) && etEmojiCounterEtContent.hasFocus()
}

editTextStateMap[field]?.let { setEditTextState(it) }
}

Expand All @@ -70,6 +75,7 @@ class EmojiCounterEditText(context: Context, attrs: AttributeSet) :

initDeleteBtnClickListener()
setBindingContent(typedArray)
initEtFocusChangeListener()

typedArray.recycle()

Expand All @@ -84,7 +90,6 @@ class EmojiCounterEditText(context: Context, attrs: AttributeSet) :

private fun setBindingContent(typedArray: TypedArray) {
with(binding) {
btnDeleteText.isVisible = state != EditTextState.EMPTY
tvEmojiCounterEtTitle.text =
typedArray.getString(R.styleable.EmojiCounterEditText_title)
etEmojiCounterEtContent.hint =
Expand All @@ -96,6 +101,13 @@ class EmojiCounterEditText(context: Context, attrs: AttributeSet) :
canBlankError = typedArray.getBoolean(R.styleable.EmojiCounterEditText_canBlankError, false)
}

private fun initEtFocusChangeListener() {
binding.etEmojiCounterEtContent.onFocusChangeListener =
OnFocusChangeListener { _, hasFocus ->
binding.btnDeleteText.isVisible = hasFocus && (state != EditTextState.EMPTY)
}
}

private fun checkTextAvailable() {
binding.etEmojiCounterEtContent.doAfterTextChanged { text ->
val len = text.toString().getGraphemeLength()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.going.domain.entity.AuthState
import com.going.presentation.R
import com.going.presentation.dashboard.DashBoardActivity
import com.going.presentation.databinding.ActivitySignUpBinding
import com.going.presentation.tendency.splash.TendencySplashActivity
import com.going.presentation.util.initOnBackPressedListener
import com.going.presentation.util.navigateToScreenClear
import com.going.ui.base.BaseActivity
import com.going.ui.extension.setOnSingleClickListener
import com.going.ui.extension.toast
Expand Down Expand Up @@ -83,8 +81,12 @@ class SignUpActivity :
TendencySplashActivity.createIntent(
this,
TendencySplashActivity.TENDENCY
).apply { startActivity(this) }
).apply {
startActivity(this)
finish()
}
}

AuthState.FAILURE -> toast(getString(R.string.server_error))
AuthState.OTHER_PAGE -> return@onEach
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ProfileEditViewModel @Inject constructor(

private fun checkIsValueChanged() {
_isValueChanged.value =
nowName.length <= getMaxNameLen() && nowInfo.length <= getMaxInfoLen() && (isInfoChanged || isNameChanged)
nowName.isNotBlank() && nowName.length <= getMaxNameLen() && nowInfo.isNotBlank() && nowInfo.length <= getMaxInfoLen() && (isInfoChanged || isNameChanged)
}

fun patchUserInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class ProfileActivity :
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

getUserInfo()
observeUserInfoState()
initBackBtnClickListener()
initSaveImgBtnClickListener()
Expand All @@ -46,6 +45,7 @@ class ProfileActivity :
override fun onResume() {
super.onResume()
getUserInfo()
setFragmentHeight()
scrollTop()
}

Expand Down Expand Up @@ -80,6 +80,7 @@ class ProfileActivity :

if (profileViewModel.profileId.value != -1) {
viewProfileEmpty.isVisible = false
viewProfile.isVisible = true
UserTendencyResultList[number].apply {
ivProfile.load(profileImage) {
transformations(CircleCropTransformation())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,7 @@ class ParticipantProfileActivity :
btnTripProfileDownload.isVisible = this && profile.result != -1
btnProfileEdit.isVisible = this

if (!this) tvTripProfileTitle.setText(
getString(
R.string.participant_profile_friend_title,
profile.name
)
)
if (!this) tvTripProfileTitle.text = getString(R.string.participant_profile_friend_title)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import com.going.presentation.designsystem.textview.ChartTextView
import com.going.presentation.profile.participant.ParticipantProfileViewModel
import com.going.presentation.tendency.result.UserTendencyResultList
import com.going.presentation.tendency.splash.TendencySplashActivity
import com.going.presentation.util.navigateToScreenClear
import com.going.ui.base.BaseFragment
import com.going.ui.extension.setOnSingleClickListener
import com.going.ui.extension.toast
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
Expand All @@ -32,6 +32,7 @@ class ParticipantProfileCharacterFragment :

setViewModel()
btnParticipantProfileEmptyOwnerClickListener()
btnTripProfileRestartClickListener()
}

private fun setViewModel() {
Expand All @@ -53,6 +54,9 @@ class ParticipantProfileCharacterFragment :
UserTendencyResultList[result].run {
ivTripProfileBig.load(resultImage)

tvTripProfileType.text = profileTitle
tvTripProfileSubType.text = profileSubTitle

tvTripProfileTag1.text = getString(R.string.tag, tags[0])
tvTripProfileTag2.text = getString(R.string.tag, tags[1])
tvTripProfileTag3.text = getString(R.string.tag, tags[2])
Expand All @@ -73,7 +77,19 @@ class ParticipantProfileCharacterFragment :

private fun btnParticipantProfileEmptyOwnerClickListener() {
binding.btnParticipantProfileEmptyOwner.setOnClickListener {
requireActivity().navigateToScreenClear<TendencySplashActivity>()
TendencySplashActivity.createIntent(
requireActivity(),
TendencySplashActivity.PROFILE
).apply { startActivity(this) }
}
}

private fun btnTripProfileRestartClickListener() {
binding.btnTripProfileRestart.setOnSingleClickListener {
TendencySplashActivity.createIntent(
requireActivity(),
TendencySplashActivity.PROFILE
).apply { startActivity(this) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class ChangeTagActivity :
private var _adapter: ChangeTagAdapter? = null
private val adapter get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) }

private val preferenceAnswers = MutableList(5) { 0 }

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

initAdapter()
setTripId()
initPreferenceList()
observeIsButtonValid()
initItemDecoration()
initChangeClickListener()
initBackClickListener()
Expand All @@ -46,6 +46,10 @@ class ChangeTagActivity :
binding.rvChangeTag.adapter = adapter
}

private fun setTripId() {
tagViewModel.tripId = intent.getLongExtra(TRIP_ID, 0)
}

private fun initPreferenceList() {
if (intent != null) {
val styleA = intent.getIntExtra(STYLE_A, 0)
Expand All @@ -64,34 +68,28 @@ class ChangeTagActivity :
)
)

preferenceAnswers[0] = styleA
preferenceAnswers[1] = styleB
preferenceAnswers[2] = styleC
preferenceAnswers[3] = styleD
preferenceAnswers[4] = styleE
tagViewModel.setDefaultPreference(styleA, styleB, styleC, styleD, styleE)
}
}

private fun preferenceTagClickListener(item: ProfilePreferenceData, checkedIndex: Int) {
preferenceAnswers[item.number.toInt() - 1] = checkedIndex
setButtonValid()
sendPreferenceInfo()
}

private fun setButtonValid() {
binding.btnChangeStart.isEnabled = true
binding.btnChangeStart.setTextColor(
colorOf(R.color.white_000)
)
tagViewModel.checkIsPreferenceChange(item.number.toInt(), checkedIndex)
}

private fun sendPreferenceInfo() {
tagViewModel.tripId = intent.getLongExtra(TRIP_ID, 0)
tagViewModel.styleA.value = preferenceAnswers[0]
tagViewModel.styleB.value = preferenceAnswers[1]
tagViewModel.styleC.value = preferenceAnswers[2]
tagViewModel.styleD.value = preferenceAnswers[3]
tagViewModel.styleE.value = preferenceAnswers[4]
private fun observeIsButtonValid() {
tagViewModel.isButtonValid.flowWithLifecycle(lifecycle).onEach { state ->
if (state) {
binding.btnChangeStart.isEnabled = true
binding.btnChangeStart.setTextColor(
colorOf(R.color.white_000)
)
} else {
binding.btnChangeStart.isEnabled = false
binding.btnChangeStart.setTextColor(
colorOf(R.color.gray_200)
)
}
}.launchIn(lifecycleScope)
}

private fun initItemDecoration() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.going.presentation.profile.participant.profiletag.changetag

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.going.domain.entity.ProfilePreferenceData
import com.going.domain.entity.request.PreferenceChangeRequestModel
import com.going.domain.repository.ProfileRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand All @@ -20,24 +21,91 @@ class ChangeTagViewModel @Inject constructor(
private val _preferencePatchState = MutableSharedFlow<Boolean>()
val preferencePatchState: SharedFlow<Boolean> = _preferencePatchState

private val _isButtonValid = MutableStateFlow(false)
val isButtonValid: StateFlow<Boolean> = _isButtonValid

var tripId: Long = 0

val styleA = MutableLiveData(0)
val styleB = MutableLiveData(0)
val styleC = MutableLiveData(0)
val styleD = MutableLiveData(0)
val styleE = MutableLiveData(0)
private var defaultStyleA: Int? = 0
private var defaultStyleB: Int? = 0
private var defaultStyleC: Int? = 0
private var defaultStyleD: Int? = 0
private var defaultStyleE: Int? = 0

private var styleA: Int? = 0
private var styleB: Int? = 0
private var styleC: Int? = 0
private var styleD: Int? = 0
private var styleE: Int? = 0

private var isStyleAChanged: Boolean = false
private var isStyleBChanged: Boolean = false
private var isStyleCChanged: Boolean = false
private var isStyleDChanged: Boolean = false
private var isStyleEChanged: Boolean = false

fun setDefaultPreference(styleA: Int, styleB: Int, styleC: Int, styleD: Int, styleE: Int) {
defaultStyleA = styleA
this.styleA = styleA

defaultStyleB = styleB
this.styleB = styleB

defaultStyleC = styleC
this.styleC = styleC

defaultStyleD = styleD
this.styleD = styleD

defaultStyleE = styleE
this.styleE = styleE
}

fun checkIsPreferenceChange(number: Int, index: Int) {
when (number) {
1 -> {
styleA = index
isStyleAChanged = index != defaultStyleA
}

2 -> {
styleB = index
isStyleBChanged = index != defaultStyleB
}

3 -> {
styleC = index
isStyleCChanged = index != defaultStyleC
}

4 -> {
styleD = index
isStyleDChanged = index != defaultStyleD
}

5 -> {
styleE = index
isStyleEChanged = index != defaultStyleE
}
}
checkIsButtonValid()
}

private fun checkIsButtonValid() {
_isButtonValid.value =
isStyleAChanged || isStyleBChanged || isStyleCChanged || isStyleDChanged || isStyleEChanged
}

fun patchPreferenceTagToServer() {
viewModelScope.launch {
profileRepository.patchPreferenceTag(
tripId,
PreferenceChangeRequestModel(
styleA.value ?: 0,
styleB.value ?: 0,
styleC.value ?: 0,
styleD.value ?: 0,
styleE.value ?: 0
styleA ?: 0,
styleB ?: 0,
styleC ?: 0,
styleD ?: 0,
styleE ?: 0
)
)
.onSuccess {
Expand Down
Loading

0 comments on commit 0bdae1a

Please sign in to comment.