Skip to content

Commit

Permalink
[MERGE/#3] merge develop into seminar2
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed Apr 11, 2023
2 parents f839685 + cf01bbd commit b8e3d1f
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 31 deletions.
45 changes: 34 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
### 리드미는 주로 블로그, 노션 제출 과제의 링크를 첨부하는데 써주시면 됩니다. 그 외엔 자유롭게 이용해주세요 !

## 과제 링크 제출란

## 템플릿 설명
## Template Description
```
레포지터리에는 총 2개의 브랜치가 있습니다.
### main
가장 기본이 되는 브랜치입니다. 새로운 연습 환경을 만들고자 할때 이 브랜치에서 새로운 브랜치를 파셔서 만드시면 됩니다.
### develop
여러분의 대부분의 과제는 이 브랜치에서 이뤄지게 될 것입니다.
main : 가장 기본이 되는 브랜치입니다. 새로운 연습 환경을 만들고자 할때 이 브랜치에서 새로운 브랜치를 파셔서 만드시면 됩니다.
develop : 여러분의 대부분의 과제는 이 브랜치에서 이뤄지게 될 것입니다.
develop/view 브랜치에서 새로운 feature 브랜치(seminar1, week1, feature/1 등 자유)를 파고 작업을 진행하면서

과제를 완료하면 해당 과제를 develop PR을 올려주시고 금잔디조원들에게 코드리뷰를 받으시면 됩니다 !

머지까지 완료하시면 과제 완료로 인정하겠습니다 !
```
<br>

## Summary
| Week | Topic | Link |
| :--: | :---: | :--: |
| 1 | Activity Life Cycle | [🔗](https://github.com/GO-SOPT-ANDROID/chaeyeon-jeon/blob/seminar1/summary/Activity%20Life%20Cycle.md) |
| | EditText inputType | [🔗](https://github.com/GO-SOPT-ANDROID/chaeyeon-jeon/blob/seminar1/summary/EditText%20inputType.md) |
| | Task & Back Stack | [🔗](https://github.com/GO-SOPT-ANDROID/chaeyeon-jeon/blob/seminar1/summary/Task%20%26%20Back%20Stack.md) |
<br>

<!--
| | | [🔗]() |
-->


## Commit Convention
- ✨ **[FEAT]** : 새로운 기능 구현
- ✅ **[MOD]** : 코드 수정 및 내부 파일 수정
- ➕ **[ADD]** : 부수적인 코드 추가 및 라이브러리 추가, 새로운 파일 생성
- 🎀 **[CHORE]** : 버전 코드 수정, 패키지 구조 변경, 타입 및 변수명 변경 등의 작은 작업
- ⚰️ **[DEL]** : 쓸모없는 코드나 파일 삭제
- 💄 **[UI]** : UI 작업
- 🔨 **[FIX]** : 버그 및 오류 해결
- 🚑️ **[HOTFIX]** : issue나 QA에서 문의된 급한 버그 및 오류 해결
- 🔀 **[MERGE]** : 다른 브랜치와의 MERGE
- 🚚 **[MOVE]** : 프로젝트 내 파일이나 코드의 이동
- ⏪️ **[RENAME]** : 파일 이름 변경
- ♻️ **[REFACTOR]** : 전면 수정
- 📝 **[DOCS]** : README나 WIKI 등의 문서 개정
3 changes: 2 additions & 1 deletion app/src/main/java/org/android/go/sopt/data/entity/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package org.android.go.sopt.data.entity
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(
val id: String = "",
val pwd: String = "",
val name: String? = "",
val specialty: String? = "",
val mbti: MBTI? = null,
val mbti: MBTI? = NONE,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ class LoginActivity : BindingActivity<ActivityLoginBinding>(R.layout.activity_lo
private fun setupLoginState() {
viewModel.loginState.observe(this) { state ->
when (state) {
is Success -> {
showToast(getString(R.string.login_login_success_msg))
Intent(this, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(this)
}
}
is Success -> intentToMain()
is Failure -> showSnackbar(binding.root, getString(R.string.wrong_input_msg))
}
}
}

private fun intentToMain() {
showToast(getString(R.string.login_login_success_msg))
Intent(this, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(this)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ import org.android.go.sopt.util.binding.BindingActivity

@AndroidEntryPoint
class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main) {
private val viewModel by viewModels<MainViewModel>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.vm = viewModel

initNavigationBar()
}

private fun initNavigationBar() {
supportFragmentManager.findFragmentById(R.id.fcv_main_container) ?: navigateTo<HomeFragment>()
supportFragmentManager.findFragmentById(R.id.fcv_main_container)
?: navigateTo<HomeFragment>()
}

private inline fun <reified T : Fragment> navigateTo() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.android.go.sopt.presentation.main

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import org.android.go.sopt.data.entity.User
import org.android.go.sopt.domain.AuthRepository
import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor(
private val authRepository: AuthRepository,
) : ViewModel() {
val signedUpUser = MutableLiveData<User>()

init {
signedUpUser.value = getSignedUpUser()
}

private fun getSignedUpUser(): User = authRepository.getSignedUpUser() ?: User()

fun clearLocalPref() {
authRepository.clearLocalPref()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ class SignupActivity : BindingActivity<ActivitySignupBinding>(R.layout.activity_
private fun setupSignupState() {
viewModel.signupState.observe(this) { state ->
when (state) {
is Success -> {
Intent(this, LoginActivity::class.java).apply {
this.putExtra(EXTRA_USER, viewModel.getUser())
setResult(Activity.RESULT_OK, this)
finish()
}
}
is Success -> intentToLogin()
is Failure -> {
when (state.code) {
INVALID_ID_CODE -> showSnackbar(
Expand All @@ -63,4 +57,12 @@ class SignupActivity : BindingActivity<ActivitySignupBinding>(R.layout.activity_
}
}
}

private fun intentToLogin() {
Intent(this, LoginActivity::class.java).apply {
this.putExtra(EXTRA_USER, viewModel.getUser())
setResult(Activity.RESULT_OK, this)
if (!isFinishing) finish()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.android.go.sopt.util.UiState.Failure
import org.android.go.sopt.util.UiState.Success
import org.android.go.sopt.util.safeValueOf
import org.android.go.sopt.util.type.MBTI
import org.android.go.sopt.util.type.MBTI.NONE
import javax.inject.Inject

@HiltViewModel
Expand All @@ -27,9 +28,11 @@ class SignupViewModel @Inject constructor(
val specialty = MutableLiveData("")
val mbti = MutableLiveData("")

private fun isValidId(id: String?) = !id.isNullOrBlank() && id.length in 6..10
private fun isValidId(id: String?) =
!id.isNullOrBlank() && id.length in MIN_ID_LENGTH..MAX_ID_LENGTH

private fun isValidPwd(pwd: String?) = !pwd.isNullOrBlank() && pwd.length in 8..12
private fun isValidPwd(pwd: String?) =
!pwd.isNullOrBlank() && pwd.length in MIN_PWD_LENGTH..MAX_PWD_LENGTH

fun signup() {
if (!isValidId(id.value)) {
Expand All @@ -50,11 +53,16 @@ class SignupViewModel @Inject constructor(
requireNotNull(pwd.value).trim(),
name.value?.trim(),
specialty.value?.trim(),
safeValueOf<MBTI>(mbti.value?.trim()?.uppercase()),
safeValueOf<MBTI>(mbti.value?.trim()?.uppercase()) ?: NONE,
)
}

companion object {
const val MIN_ID_LENGTH = 6
const val MAX_ID_LENGTH = 10
const val MIN_PWD_LENGTH = 8
const val MAX_PWD_LENGTH = 12

const val INVALID_ID_CODE = 100
const val INVALID_PWD_CODE = 101
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/android/go/sopt/util/type/MBTI.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.android.go.sopt.util.type

enum class MBTI {
ISTJ, ISFJ, INFJ, INTJ, ISTP, ISFP, INFP, INTP, ESTP, ESFP, ENFP, ENTP, ESTJ, ESFJ, ENFJ, ENTJ
NONE, ISTJ, ISFJ, INFJ, INTJ, ISTP, ISFP, INFP, INTP, ESTP, ESFP, ENFP, ENTP, ESTJ, ESFJ, ENFJ, ENTJ
}
3 changes: 3 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

<data>

<variable
name="vm"
type="org.android.go.sopt.presentation.main.MainViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_signup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
android:hint="@string/login_id_hint"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLength="@{vm.MAX_ID_LENGTH}"
android:paddingVertical="12dp"
android:text="@={vm.id}"
app:layout_constraintTop_toBottomOf="@id/tv_signup_id_label" />
Expand All @@ -74,6 +75,7 @@
android:hint="@string/login_pwd_hint"
android:imeOptions="actionNext"
android:inputType="textPassword"
android:maxLength="@{vm.MAX_PWD_LENGTH}"
android:paddingVertical="12dp"
android:text="@={vm.pwd}"
app:layout_constraintTop_toBottomOf="@id/tv_signup_pwd_label" />
Expand Down

0 comments on commit b8e3d1f

Please sign in to comment.