Skip to content

Commit

Permalink
[Fix/#106] 자체 QA 후 발견된 오류 수정 (#110)
Browse files Browse the repository at this point in the history
* [Chore/#106] 텍스트 수정

* [Fix/#106] 물리백키와 앱 내 뒤로가기 로직 일치시키기

* [Chore/#106] Response 타입 수정

* [Fix/#106] 앱 삭제 후 다시 접속 시 온보딩부터 시작하는 오류 해결

* [Feat/#106] 화면 클릭 시 키보드 닫는 기능 추가
  • Loading branch information
yeoncheong authored Aug 26, 2023
1 parent 2d84714 commit a9b14c0
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,29 @@ class LoginActivity : BindingActivity<ActivityLoginBinding>(R.layout.activity_lo
}

private fun setAutoLogin() {
// 액세스 토큰이 있을 때 - 앱을 그냥 껐다 켰을 때
if (!SharedPreferences.getString(USER_TOKEN).isNullOrBlank()) {
showOnboardForFirst()
// 액세스 토큰이 없을 때 - 최초 가입인가? or 로그아웃이나 앱삭제를 이유로 다시 로그인하는가?
} else {
viewModel.getTokenResult.observe(this) { response ->
setUserInfo(response.accessToken)
if (SharedPreferences.getOnboardingBoolean(DID_USER_CLEAR_ONBOARD)
&& SharedPreferences.getInviteCodeBoolean(DID_USER_CLEAR_INVITE_CODE)
) {
goMainActivity()
} else {
setUserInfo(response.tokenDto.accessToken)

// 온보딩 x 연결 x
if (response.username == null && !response.isMatchFinish) {
Log.d("LoginActivity", "온보딩 x 연결 x")
goAgreePrivacyUseActivity()
}
// 온보딩 x 연결 o -> 초대받는 측
else if (response.username == null) {
Log.d("LoginActivity", "온보딩 x 연결 o")
goInputInfoActivity()
}
// 온보딩 o -> 연결 여부와 관계 없이 main으로 이동임
else {
Log.d("LoginActivity", "온보딩 o")
goMainActivity()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import timber.log.Timber

class LoginViewModel(private val loginRepositoryImpl: LoginRepositoryImpl) : ViewModel() {

private val _getTokenResult: MutableLiveData<LoginResponseDto.LoginData.TokenData> = MutableLiveData()
val getTokenResult: LiveData<LoginResponseDto.LoginData.TokenData>
private val _getTokenResult: MutableLiveData<LoginResponseDto.LoginData> = MutableLiveData()
val getTokenResult: LiveData<LoginResponseDto.LoginData>
get() = _getTokenResult

fun login(fcmToken: String) {
Expand All @@ -27,7 +27,7 @@ class LoginViewModel(private val loginRepositoryImpl: LoginRepositoryImpl) : Vie
)
).onSuccess { response ->
Timber.d("login 성공")
_getTokenResult.value = response.data.tokenDto
_getTokenResult.value = response.data
}.onFailure { error ->
Timber.e("login 실패 $error")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.view.MotionEvent
import android.view.View
import androidx.activity.viewModels
import com.sopt.umbba_android.R
Expand All @@ -14,6 +15,7 @@ import com.sopt.umbba_android.domain.entity.User
import com.sopt.umbba_android.presentation.onboarding.quest.QuestActivity
import com.sopt.umbba_android.presentation.onboarding.viewmodel.InputInfoViewModel
import com.sopt.umbba_android.util.binding.BindingActivity
import com.sopt.umbba_android.util.hideKeyboard
import com.sopt.umbba_android.util.setOnSingleClickListener
import java.util.regex.Pattern

Expand Down Expand Up @@ -141,4 +143,13 @@ class InputInfoActivity : BindingActivity<ActivityInputInfoBinding>(R.layout.act
const val HANGUL_PATTERN = "^[가-힣]*$"
const val NUMBER_PATTERN = "^([12]\\d{3})*$"
}

override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
this.currentFocus?.let { hideKeyboard(it) }
with(binding) {
etName.clearFocus()
etYear.clearFocus()
}
return super.dispatchTouchEvent(ev)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ package com.sopt.umbba_android.presentation.onboarding.quest
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import com.sopt.umbba_android.R
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.commit
import com.sopt.umbba_android.data.local.SharedPreferences
import com.sopt.umbba_android.R
import com.sopt.umbba_android.data.local.SharedPreferences.setOnboardingBoolean
import com.sopt.umbba_android.databinding.ActivityQuestBinding
import com.sopt.umbba_android.domain.entity.User
import com.sopt.umbba_android.presentation.login.LoginActivity
import com.sopt.umbba_android.presentation.login.LoginActivity.Companion.DID_USER_CLEAR_INVITE_CODE
import com.sopt.umbba_android.presentation.login.LoginActivity.Companion.DID_USER_CLEAR_ONBOARD
import com.sopt.umbba_android.presentation.onboarding.NotifyTimeActivity
Expand All @@ -26,6 +24,12 @@ import com.sopt.umbba_android.util.setOnSingleClickListener
class QuestActivity : BindingActivity<ActivityQuestBinding>(R.layout.activity_quest),
View.OnClickListener {

private val backPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
clickBeforeButton()
}
}

private val viewModel by viewModels<QuestViewModel>() { ViewModelFactory(this) }
private var count = 0
private var quest = arrayOfNulls<String>(5)
Expand All @@ -35,6 +39,7 @@ class QuestActivity : BindingActivity<ActivityQuestBinding>(R.layout.activity_qu
super.onCreate(savedInstanceState)
binding.viewmodel = viewModel
binding.clickListener = this
this.onBackPressedDispatcher.addCallback(this, backPressedCallback)

initFragment(QuestOneFragment())
checkNextButtonEnabled()
Expand All @@ -44,22 +49,26 @@ class QuestActivity : BindingActivity<ActivityQuestBinding>(R.layout.activity_qu
override fun onClick(view: View?) {
when (view?.id) {
R.id.iv_basic_back -> {
if (count in 1..4) {
supportFragmentManager.popBackStack(
"$count",
FragmentManager.POP_BACK_STACK_INCLUSIVE
)
binding.progressBar.progress -= 20
count -= 1
initChip()
setBeforeButtonClick(count)
} else {
finish()
}
clickBeforeButton()
}
}
}

private fun clickBeforeButton() {
if (count in 1..4) {
supportFragmentManager.popBackStack(
"$count",
FragmentManager.POP_BACK_STACK_INCLUSIVE
)
binding.progressBar.progress -= 20
count -= 1
initChip()
setBeforeButtonClick(count)
} else {
finish()
}
}

private fun setBeforeButtonClick(count: Int) {
when (quest[count].toString()) {
getString(R.string.yes) -> viewModel.isClickedYes.value = true
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/com/sopt/umbba_android/util/HideKeyboard.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.sopt.umbba_android.util

import android.app.Activity
import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager

fun Context.hideKeyboard(view: View) {
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
}
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!--invite activity-->
<string name="btn_start">시작하기</string>
<string name="or">----------------- or ----------------</string>
<string name="did_you_receive_code">카카오톡 초대 코드를 받고 왔어요</string>
<string name="did_you_receive_code">초대 코드를 받고 왔어요</string>
<string name="btn_start_code">초대코드로 시작하기</string>

<!--input info activity-->
Expand Down

0 comments on commit a9b14c0

Please sign in to comment.