Skip to content

Commit

Permalink
[MERGE] #149 -> develop
Browse files Browse the repository at this point in the history
[Fix/149] QA 반영
  • Loading branch information
chattymin authored Jan 17, 2024
2 parents 7c783df + c894d86 commit 0bd2518
Show file tree
Hide file tree
Showing 20 changed files with 283 additions and 274 deletions.
9 changes: 5 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />

<application
android:name=".MyApp"
android:allowBackup="true"
android:icon="@mipmap/ic_doorip_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_doorip_launcher_round"
android:supportsRtl="true"
android:theme="@style/splash_delete"
Expand Down Expand Up @@ -102,10 +101,12 @@
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:host="kakaolink"
<data
android:host="kakaolink"
android:scheme="kakao${NATIVE_APP_KEY}" />
</intent-filter>
</activity>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.going.domain.entity

enum class NameState {
Empty, Success, Blank
Empty, Success, Blank, OVER
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class CreateTripActivity :
super.onCreate(savedInstanceState)

initBindingViewModel()
observeTextLength()
observeIsNameAvailable()
observeCheckStartDateAvailable()
observeCheckEndDateAvailable()
Expand All @@ -37,24 +36,10 @@ class CreateTripActivity :
binding.viewModel = viewModel
}

private fun observeTextLength() {
viewModel.nameLength.observe(this) { length ->
val maxNameLength = viewModel.getMaxNameLen()

if (length > maxNameLength) {
binding.etCreateTripName.apply {
setText(text?.subSequence(0, maxNameLength))
setSelection(maxNameLength)
}
}
}
}

private fun observeIsNameAvailable() {
viewModel.isNameAvailable.observe(this) { state ->
setColors(
false,
viewModel.nameLength.value ?: 0,
state,
binding.tvNameCounter,
) { background ->
binding.etCreateTripName.background = ResourcesCompat.getDrawable(
Expand Down Expand Up @@ -99,17 +84,17 @@ class CreateTripActivity :
}

private fun setColors(
hasFocus: Boolean,
length: Int,
state: NameState,
counter: TextView,
setBackground: (Int) -> Unit,
) {
val (color, background) = when {
viewModel.isNameAvailable.value != NameState.Blank && hasFocus -> R.color.gray_700 to R.drawable.shape_rect_4_gray700_line
length == 0 -> R.color.gray_200 to R.drawable.shape_rect_4_gray200_line
viewModel.isNameAvailable.value == NameState.Blank && counter == binding.tvNameCounter -> R.color.red_500 to R.drawable.shape_rect_4_red500_line
else -> R.color.gray_700 to R.drawable.shape_rect_4_gray700_line
val (color, background) = when (state) {
NameState.Empty -> R.color.gray_200 to R.drawable.shape_rect_4_gray200_line
NameState.Success -> R.color.gray_700 to R.drawable.shape_rect_4_gray700_line
NameState.Blank -> R.color.red_500 to R.drawable.shape_rect_4_red500_line
NameState.OVER -> R.color.red_500 to R.drawable.shape_rect_4_red500_line
}

setCounterColor(counter, color)
setBackground(background)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ class CreateTripViewModel : ViewModel() {
val isTripAvailable = MutableLiveData(false)
var isCheckTripAvailable = MutableLiveData(false)

fun getMaxNameLen() = MAX_TRIP_LEN

fun checkNameAvailable() {
nameLength.value = name.value?.getGraphemeLength()

isNameAvailable.value = when {
nameLength.value == 0 -> NameState.Empty
(nameLength.value ?: 0) > MAX_TRIP_LEN -> NameState.OVER
name.value.isNullOrBlank() -> NameState.Blank
else -> NameState.Success
}
Expand Down Expand Up @@ -60,7 +59,6 @@ class CreateTripViewModel : ViewModel() {
} else {
isEndDateAvailable.value = false
checkTripAvailable()

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ class OnboardingProfileSettingActivity :

initBindingViewModel()
initOnLineInfoEditorActionListener()
initSetOnFocusChangeListener()
initSignUpBtnClickListener()
observeIsNameAvailable()
observeTextLength()
observeIsInfoAvailable()
observeIsSignUpState()
initOnBackPressedListener()
}
Expand All @@ -52,12 +51,17 @@ class OnboardingProfileSettingActivity :
}
}

private fun initSetOnFocusChangeListener() {
binding.etOnboardingProfileSettingName.setOnFocusChangeListener { _, hasFocus ->
private fun initSignUpBtnClickListener() {
binding.btnOnboardingProfileSettingFinish.setOnSingleClickListener {
viewModel.startSignUp()
}
}

private fun observeIsNameAvailable() {
viewModel.isNameAvailable.observe(this) { state ->
setColors(
hasFocus,
viewModel.nowNameLength.value ?: 0,
binding.tvNameCounter,
state,
) { background ->
binding.etOnboardingProfileSettingName.background = ResourcesCompat.getDrawable(
this.resources,
Expand All @@ -66,12 +70,13 @@ class OnboardingProfileSettingActivity :
)
}
}
}

binding.etOnboardingProfileSettingInfo.setOnFocusChangeListener { _, hasFocus ->
private fun observeIsInfoAvailable() {
viewModel.isInfoAvailable.observe(this) { state ->
setColors(
hasFocus,
viewModel.nowInfoLength.value ?: 0,
binding.tvInfoCounter,
state,
) { background ->
binding.etOnboardingProfileSettingInfo.background = ResourcesCompat.getDrawable(
this.resources,
Expand All @@ -82,39 +87,16 @@ class OnboardingProfileSettingActivity :
}
}

private fun initSignUpBtnClickListener() {
binding.btnOnboardingProfileSettingFinish.setOnSingleClickListener {
viewModel.startSignUp()
}
}

private fun observeIsNameAvailable() {
viewModel.isNameAvailable.observe(this) { state ->
setColors(
false,
viewModel.nowNameLength.value ?: 0,
binding.tvNameCounter,
) { background ->
binding.etOnboardingProfileSettingName.background = ResourcesCompat.getDrawable(
this.resources,
background,
theme,
)
}
}
}

private fun setColors(
hasFocus: Boolean,
length: Int,
counter: TextView,
state: NameState,
setBackground: (Int) -> Unit,
) {
val (color, background) = when {
viewModel.isNameAvailable.value != NameState.Blank && hasFocus -> R.color.gray_700 to R.drawable.shape_rect_4_gray700_line
length == 0 -> R.color.gray_200 to R.drawable.shape_rect_4_gray200_line
viewModel.isNameAvailable.value == NameState.Blank && counter == binding.tvNameCounter -> R.color.red_500 to R.drawable.shape_rect_4_red500_line
else -> R.color.gray_700 to R.drawable.shape_rect_4_gray700_line
val (color, background) = when (state) {
NameState.Empty -> R.color.gray_200 to R.drawable.shape_rect_4_gray200_line
NameState.Success -> R.color.gray_700 to R.drawable.shape_rect_4_gray700_line
NameState.Blank -> R.color.red_500 to R.drawable.shape_rect_4_red500_line
NameState.OVER -> R.color.red_500 to R.drawable.shape_rect_4_red500_line
}

setCounterColor(counter, color)
Expand All @@ -125,31 +107,6 @@ class OnboardingProfileSettingActivity :
counter.setTextColor(getColor(color))
}

// 커스텀 글자수 제한 함수
private fun observeTextLength() {
viewModel.nowNameLength.observe(this) { length ->
val maxNameLength = viewModel.getMaxNameLen()

if (length > maxNameLength) {
binding.etOnboardingProfileSettingName.apply {
setText(text?.subSequence(0, maxNameLength))
setSelection(maxNameLength)
}
}
}

viewModel.nowInfoLength.observe(this) { length ->
val maxInfoLength = viewModel.getMaxInfoLen()

if (length > maxInfoLength) {
binding.etOnboardingProfileSettingInfo.apply {
setText(text?.subSequence(0, maxInfoLength))
setSelection(maxInfoLength)
}
}
}
}

private fun observeIsSignUpState() {
viewModel.isSignUpState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,31 @@ class OnboardingProfileSettingViewModel @Inject constructor(
val nowInfoLength = MutableLiveData(0)

val isNameAvailable = MutableLiveData(NameState.Empty)
val isInfoAvailable = MutableLiveData(NameState.Empty)
val isProfileAvailable = MutableLiveData(false)

private val _isSignUpState = MutableStateFlow(AuthState.LOADING)
val isSignUpState: StateFlow<AuthState> = _isSignUpState

fun getMaxNameLen() = MAX_NAME_LEN
fun getMaxInfoLen() = MAX_INFO_LEN

fun checkProfileAvailable() {
nowNameLength.value = name.value.getGraphemeLength()
nowInfoLength.value = info.value.getGraphemeLength()

isNameAvailable.value = when {
nowNameLength.value == 0 -> NameState.Empty
name.value.isBlank() -> NameState.Blank
(nowNameLength.value ?: 0) > 3 -> NameState.OVER
else -> NameState.Success
}

val isInfoAvailable = nowInfoLength.value in 1..MAX_INFO_LEN
isInfoAvailable.value = when {
nowInfoLength.value == 0 -> NameState.Empty
(nowInfoLength.value ?: 0) > MAX_INFO_LEN -> NameState.OVER
else -> NameState.Success
}

isProfileAvailable.value =
(isNameAvailable.value == NameState.Success) && isInfoAvailable
(isNameAvailable.value == NameState.Success) && (isInfoAvailable.value == NameState.Success)
}

fun startSignUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_spl
setStatusBarColor()
checkConnectedNetwork()
observeUserState()

}

private fun setStatusBarColor() {
Expand Down Expand Up @@ -105,5 +104,4 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_spl
}
finish()
}

}
Loading

0 comments on commit 0bd2518

Please sign in to comment.