From a1e8550686610b05355aa4812c7a0252b1a71db0 Mon Sep 17 00:00:00 2001 From: b1urrrr Date: Fri, 12 May 2023 21:04:35 +0900 Subject: [PATCH] =?UTF-8?q?[MOD/#8]=20MBTI=20=EC=9E=85=EB=A0=A5=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/android/go/sopt/domain/model/User.kt | 3 --- .../sopt/presentation/login/LoginActivity.kt | 13 +++------- .../sopt/presentation/login/LoginViewModel.kt | 15 ++++------- .../presentation/signup/SignupActivity.kt | 2 -- .../presentation/signup/SignupViewModel.kt | 19 -------------- .../org/android/go/sopt/util/type/MBTI.kt | 5 ---- app/src/main/res/layout/activity_signup.xml | 26 ------------------- 7 files changed, 8 insertions(+), 75 deletions(-) delete mode 100644 app/src/main/java/org/android/go/sopt/util/type/MBTI.kt diff --git a/app/src/main/java/org/android/go/sopt/domain/model/User.kt b/app/src/main/java/org/android/go/sopt/domain/model/User.kt index cac352a..6fa189b 100644 --- a/app/src/main/java/org/android/go/sopt/domain/model/User.kt +++ b/app/src/main/java/org/android/go/sopt/domain/model/User.kt @@ -2,8 +2,6 @@ package org.android.go.sopt.domain.model import android.os.Parcelable import kotlinx.parcelize.Parcelize -import org.android.go.sopt.util.type.MBTI -import org.android.go.sopt.util.type.MBTI.NONE @Parcelize data class User( @@ -11,5 +9,4 @@ data class User( val pwd: String = "", val name: String = "익명", val specialty: String = "", - val mbti: MBTI = NONE, ) : Parcelable diff --git a/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt b/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt index 903d411..5f09c22 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt @@ -2,23 +2,20 @@ package org.android.go.sopt.presentation.login import android.app.Activity import android.content.Intent -import android.content.Intent.EXTRA_USER import android.os.Bundle import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels import dagger.hilt.android.AndroidEntryPoint import org.android.go.sopt.R import org.android.go.sopt.databinding.ActivityLoginBinding -import org.android.go.sopt.domain.model.User import org.android.go.sopt.presentation.main.MainActivity import org.android.go.sopt.presentation.signup.SignupActivity -import org.android.go.sopt.util.state.LocalUiState.Failure -import org.android.go.sopt.util.state.LocalUiState.Success import org.android.go.sopt.util.binding.BindingActivity -import org.android.go.sopt.util.extension.getCompatibleParcelableExtra import org.android.go.sopt.util.extension.setOnSingleClickListener import org.android.go.sopt.util.extension.showSnackbar import org.android.go.sopt.util.extension.showToast +import org.android.go.sopt.util.state.LocalUiState.Failure +import org.android.go.sopt.util.state.LocalUiState.Success @AndroidEntryPoint class LoginActivity : BindingActivity(R.layout.activity_login) { @@ -36,11 +33,7 @@ class LoginActivity : BindingActivity(R.layout.activity_lo val signupResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> if (result.resultCode == Activity.RESULT_OK) { - val resultData = result.data ?: return@registerForActivityResult - resultData.getCompatibleParcelableExtra(EXTRA_USER)?.let { user -> - viewModel.setSavedUser(user) - showSnackbar(binding.root, getString(R.string.login_signup_success_msg)) - } + showSnackbar(binding.root, getString(R.string.login_signup_success_msg)) } } diff --git a/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt index 49b4a65..7f77ed1 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt @@ -4,7 +4,6 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel -import org.android.go.sopt.domain.model.User import org.android.go.sopt.domain.repository.AuthRepository import org.android.go.sopt.util.state.LocalUiState import org.android.go.sopt.util.state.LocalUiState.Failure @@ -15,8 +14,6 @@ import javax.inject.Inject class LoginViewModel @Inject constructor( private val authRepository: AuthRepository, ) : ViewModel() { - var signedUpUser = User() - private val _loginState = MutableLiveData() val loginState: LiveData get() = _loginState @@ -29,21 +26,19 @@ class LoginViewModel @Inject constructor( } private fun setupAutoLogin() { - if (authRepository.getAutoLogin() && authRepository.getSignedUpUser() != null) _loginState.value = Success - } - - fun setSavedUser(savedUser: User) { - this.signedUpUser = savedUser + if (authRepository.getAutoLogin() && authRepository.getSignedUpUser() != null) { + _loginState.value = Success + } } - private fun isValidInput() = - !id.value.isNullOrBlank() && id.value == signedUpUser.id && !pwd.value.isNullOrBlank() && pwd.value == signedUpUser.pwd + private fun isValidInput() = !id.value.isNullOrBlank() && !pwd.value.isNullOrBlank() fun login() { if (!isValidInput()) { _loginState.value = Failure(null) return } + // TODO : 로그인 정보 저장 authRepository.setAutoLogin(true) _loginState.value = Success } diff --git a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupActivity.kt b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupActivity.kt index afc7b3b..c1efe8f 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupActivity.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupActivity.kt @@ -2,7 +2,6 @@ package org.android.go.sopt.presentation.signup import android.app.Activity import android.content.Intent -import android.content.Intent.EXTRA_USER import android.os.Bundle import androidx.activity.viewModels import dagger.hilt.android.AndroidEntryPoint @@ -71,7 +70,6 @@ class SignupActivity : BindingActivity(R.layout.activity_ private fun navigateToLoginScreen() { Intent(this, LoginActivity::class.java).apply { - this.putExtra(EXTRA_USER, viewModel.getUser()) setResult(Activity.RESULT_OK, this) if (!isFinishing) finish() } diff --git a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt index e6c9b45..9bbb909 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt @@ -7,15 +7,11 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import org.android.go.sopt.data.entity.remote.request.RequestPostSignUpDto -import org.android.go.sopt.domain.model.User import org.android.go.sopt.domain.repository.AuthRepository -import org.android.go.sopt.util.safeValueOf import org.android.go.sopt.util.state.RemoteUiState import org.android.go.sopt.util.state.RemoteUiState.Error import org.android.go.sopt.util.state.RemoteUiState.Failure import org.android.go.sopt.util.state.RemoteUiState.Success -import org.android.go.sopt.util.type.MBTI -import org.android.go.sopt.util.type.MBTI.NONE import retrofit2.HttpException import timber.log.Timber import javax.inject.Inject @@ -44,10 +40,6 @@ class SignupViewModel @Inject constructor( private val specialty: String get() = _specialty.value?.trim() ?: "" - val _mbti = MutableLiveData("") - private val mbti: MBTI - get() = safeValueOf(_mbti.value?.trim()?.uppercase(), NONE) - private fun isValidId() = id.isNotBlank() && id.length in MIN_ID_LENGTH..MAX_ID_LENGTH private fun isValidPwd() = pwd.isNotBlank() && pwd.length in MIN_PWD_LENGTH..MAX_PWD_LENGTH @@ -80,7 +72,6 @@ class SignupViewModel @Inject constructor( viewModelScope.launch { authRepository.postSignup(requestPostSignUpDto) .onSuccess { response -> - authRepository.setSignedUpUser(getUser()) _signupState.value = Success Timber.d("POST SIGNUP SUCCESS : $response") } @@ -97,16 +88,6 @@ class SignupViewModel @Inject constructor( } } - fun getUser(): User { - return User( - id = id, - pwd = pwd, - name = name, - specialty = specialty, - mbti = mbti, - ) - } - companion object { const val MIN_ID_LENGTH = 6 const val MAX_ID_LENGTH = 10 diff --git a/app/src/main/java/org/android/go/sopt/util/type/MBTI.kt b/app/src/main/java/org/android/go/sopt/util/type/MBTI.kt deleted file mode 100644 index 27b175d..0000000 --- a/app/src/main/java/org/android/go/sopt/util/type/MBTI.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.android.go.sopt.util.type - -enum class MBTI { - NONE, ISTJ, ISFJ, INFJ, INTJ, ISTP, ISFP, INFP, INTP, ESTP, ESFP, ENFP, ENTP, ESTJ, ESFJ, ENFJ, ENTJ -} diff --git a/app/src/main/res/layout/activity_signup.xml b/app/src/main/res/layout/activity_signup.xml index 71b6e19..7e299f4 100644 --- a/app/src/main/res/layout/activity_signup.xml +++ b/app/src/main/res/layout/activity_signup.xml @@ -137,32 +137,6 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_signup_specialty_label" /> - - - -