Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA] 온보딩 qa 수정 #138

Merged
merged 19 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
applicationId "sopt.motivoo"
minSdk 24
targetSdk 34
versionCode 4
versionName "1.0.1"
versionCode 1
versionName "1.0.0"

buildConfigField "String", "BASE_URL", properties["base_url"]
buildConfigField "String", "FIREBASE_RULE_UID", properties["firebase_rule_uid"]
Expand Down
Binary file modified app/release/app-release.aab
Binary file not shown.
Binary file added app/release/app-release.apk
Binary file not shown.
Binary file added app/release/app-release.apk.zip
Binary file not shown.
Binary file added app/release/motivoo.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"versionName": "1.0.0",
"outputFile": "app-release.apk"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class MotivooStorageImpl @Inject constructor(@ApplicationContext context: Contex
}
}

override var nickName: String
get() = pref.getString(NAME, "") ?: ""
set(value) = pref.edit { putString(NAME, value) }

override var userId: Long
set(value) = pref.edit { putLong(USER_ID, value) }
get() = pref.getLong(USER_ID, 0L)
Expand Down Expand Up @@ -83,7 +79,15 @@ class MotivooStorageImpl @Inject constructor(@ApplicationContext context: Contex

override fun clear() {
pref.edit {
clear()
remove(ACCESS_TOKEN)
remove(REFRESH_TOKEN)
remove(IS_LOGIN)
remove(IS_MATCHED)
remove(USER_ID)
remove(MY_GOAL_STEP_COUNT)
remove(OTHER_GOAL_STEP_COUNT)
remove(IS_ONBOARDING_FINISHED)
remove(IS_TERMS_FINISHED)
}
}

Expand All @@ -93,12 +97,13 @@ class MotivooStorageImpl @Inject constructor(@ApplicationContext context: Contex
remove(ACCESS_TOKEN)
remove(REFRESH_TOKEN)
remove(IS_LOGIN)
remove(IS_MATCHED)
remove(IS_ONBOARDING_FINISHED)
}
}

companion object {
private const val FILE_NAME = "MtDataStore"
private const val NAME = "name"
const val ACCESS_TOKEN = "accessToken"
const val REFRESH_TOKEN = "refreshToken"
private const val IS_LOGIN = "isLogin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ data class RequestOnboardingDto(
@SerialName("is_exercise")
val isExercise: Boolean,
@SerialName("type")
val type: String
val type: String,
@SerialName("nickname")
val nickname: String
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sopt.motivoo.domain.entity

interface MotivooStorage {
var nickName: String
var accessToken: String
var refreshToken: String
var isUserLoggedIn: Boolean
Expand Down
18 changes: 10 additions & 8 deletions app/src/main/java/sopt/motivoo/presentation/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class MainActivity : AppCompatActivity() {

private fun setTopVisible(navController: NavController) {
val topVisibleDestinations = setOf(
R.id.nickNameFragment,
R.id.ageQuestionFragment,
R.id.doExerciseQuestionFragment,
R.id.frequencyQuestionFragment,
Expand All @@ -215,7 +216,7 @@ class MainActivity : AppCompatActivity() {
R.id.whatExerciseQuestionFragment,
R.id.whatActivityQuestionFragment
)
val backInvisibleDestinations = setOf(R.id.ageQuestionFragment)
val backInvisibleDestinations = setOf(R.id.nickNameFragment)

navController.addOnDestinationChangedListener { _, destination, _ ->
binding.clOnboardingToolbar.visibility =
Expand All @@ -228,13 +229,14 @@ class MainActivity : AppCompatActivity() {

private fun getProgressValue(destinationId: Int): Float {
return when (destinationId) {
R.id.ageQuestionFragment -> 1f
R.id.doExerciseQuestionFragment -> 2f
R.id.whatExerciseQuestionFragment -> 3f
R.id.whatActivityQuestionFragment -> 3f
R.id.frequencyQuestionFragment -> 4f
R.id.timeQuestionFragment -> 5f
R.id.soreSpotQuestionFragment -> 6f
R.id.nickNameFragment -> 1f
R.id.ageQuestionFragment -> 2f
R.id.doExerciseQuestionFragment -> 3f
R.id.whatExerciseQuestionFragment -> 4f
R.id.whatActivityQuestionFragment -> 4f
R.id.frequencyQuestionFragment -> 5f
R.id.timeQuestionFragment -> 6f
R.id.soreSpotQuestionFragment -> 7f
else -> 0f
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class LoginFragment : BindingFragment<FragmentLoginBinding>(R.layout.fragment_lo
.onEach { event ->
when (event) {
NavigationEvent.Home -> findNavController().navigate(R.id.action_loginFragment_to_homeFragment)
NavigationEvent.AgeQuestion -> findNavController().navigate(R.id.action_loginFragment_to_ageQuestionFragment)
NavigationEvent.NickName -> findNavController().navigate(R.id.action_loginFragment_to_nickNameFragment)
NavigationEvent.StartMotivoo -> findNavController().navigate(R.id.action_loginFragment_to_startMotivooFragment)
NavigationEvent.TermsOfUse -> findNavController().navigate(R.id.action_loginFragment_to_termsOfUseFragment)
NavigationEvent.Permission -> findNavController().navigate(R.id.action_loginFragment_to_permissionFragment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SplashFragment : BindingFragment<FragmentSplashBinding>(R.layout.fragment_
.onEach { event ->
when (event) {
NavigationEvent.Home -> navigateToFragment(R.id.action_splashFragment_to_homeFragment)
NavigationEvent.AgeQuestion -> navigateToFragment(R.id.action_splashFragment_to_ageQuestionFragment)
NavigationEvent.NickName -> navigateToFragment(R.id.action_splashFragment_to_nickNameFragment)
NavigationEvent.StartMotivoo -> navigateToFragment(R.id.action_splashFragment_to_startMotivooFragment)
NavigationEvent.Login -> navigateToFragment(R.id.action_splashFragment_to_loginFragment)
NavigationEvent.TermsOfUse -> navigateToFragment(R.id.action_splashFragment_to_termsOfUseFragment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TermsOfUseFragment :
private fun clickDoneButton() {
binding.btnTermsOfUseDone.setOnSingleClickListener {
motivooStorage.isFinishedTermsOfUse = true
findNavController().navigate(R.id.action_termsOfUseFragment_to_AgeQuestionFragment)
findNavController().navigate(R.id.action_termsOfUseFragment_to_nickNameFragment)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ class GetInviteCodeFragment :
private fun setClipboard() {
val clipboard: ClipboardManager =
requireContext().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val inviteCode = binding.tvGetInviteCode.text
val clip = ClipData.newPlainText(INVITE_CODE, inviteCode)

binding.btnGetInviteCodeCopy.setOnSingleClickListener {
val inviteCode = binding.tvGetInviteCode.text
val clip = ClipData.newPlainText(INVITE_CODE, inviteCode)
clipboard.setPrimaryClip(clip)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2)
setClipBoardToastAnimation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.os.Bundle
import android.transition.TransitionManager
import android.view.View
import android.view.ViewGroup
import androidx.activity.OnBackPressedCallback
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Lifecycle
Expand Down Expand Up @@ -34,7 +33,6 @@ class AgeQuestionFragment :

collectData()
clickNextButton()
overrideOnBackPressed()
}

private fun clickNextButton() {
Expand Down Expand Up @@ -126,17 +124,6 @@ class AgeQuestionFragment :
binding.clUserType.layoutParams = layoutParams
}

private fun overrideOnBackPressed() {
requireActivity().onBackPressedDispatcher.addCallback(
viewLifecycleOwner,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
requireActivity().finishAffinity()
}
}
)
}

companion object {
private const val TOP_MARGIN = 13
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package sopt.motivoo.presentation.onboarding

import android.os.Bundle
import android.view.View
import android.view.animation.AnimationUtils
import androidx.activity.OnBackPressedCallback
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import sopt.motivoo.R
import sopt.motivoo.databinding.FragmentNicknameBinding
import sopt.motivoo.util.binding.BindingFragment
import sopt.motivoo.util.extension.drawableOf
import sopt.motivoo.util.extension.setOnSingleClickListener

class NickNameFragment : BindingFragment<FragmentNicknameBinding>(R.layout.fragment_nickname) {

private val onboardingViewModel by activityViewModels<OnboardingViewModel>()
private var lastNickNameLength = 0

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.onboardingViewModel = onboardingViewModel
collectData()
clickNextButton()
overrideOnBackPressed()
}

private fun clickNextButton() {
binding.btnNicknameDone.setOnSingleClickListener {
findNavController().navigate(R.id.action_nickNameFragment_to_ageQuestionFragment)
}
}

private fun collectData() {
onboardingViewModel.nickName.flowWithLifecycle(
viewLifecycleOwner.lifecycle,
Lifecycle.State.STARTED
)
.distinctUntilChanged()
.onEach { it?.let { it1 -> handleNickNameChange(it1) } }
.launchIn(viewLifecycleOwner.lifecycleScope)
}

private fun handleNickNameChange(nickName: String) {
val currentLength = nickName.length
binding.btnNicknameDone.isEnabled = nickName.isNotEmpty()

if (currentLength >= 8 && lastNickNameLength != currentLength) {
setErrorAnimation()
} else if (currentLength < 8) {
resetErrorState()
}

lastNickNameLength = currentLength
}

private fun setErrorAnimation() {
val fadeIn = AnimationUtils.loadAnimation(context, R.anim.fade_in)
with(binding) {
tvNicknameErrorMessage.startAnimation(fadeIn)
etNickname.background =
requireContext().drawableOf(R.drawable.shape_edittext_error_radius8)
tvNicknameErrorMessage.visibility = View.VISIBLE

lifecycleScope.launch {
delay(FOUR_SECONDS)
val fadeOut = AnimationUtils.loadAnimation(context, R.anim.fade_out)
binding.tvNicknameErrorMessage.startAnimation(fadeOut)
binding.tvNicknameErrorMessage.visibility = View.INVISIBLE
binding.etNickname.background =
requireContext().drawableOf(R.drawable.selector_edittext_input)
}
}
}

private fun resetErrorState() {
binding.tvNicknameErrorMessage.visibility = View.INVISIBLE
binding.etNickname.background =
requireContext().drawableOf(R.drawable.selector_edittext_input)
}

private fun overrideOnBackPressed() {
requireActivity().onBackPressedDispatcher.addCallback(
viewLifecycleOwner,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
requireActivity().finishAffinity()
}
}
)
}

companion object {
const val FOUR_SECONDS = 4000L
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class OnboardingViewModel @Inject constructor(

val age = MutableStateFlow<String?>(null)

val nickName = MutableStateFlow<String?>(null)

val isFirst = MutableLiveData(true)

val isValidAge: StateFlow<Boolean?> = age.map { ageString ->
Expand Down Expand Up @@ -178,7 +180,8 @@ class OnboardingViewModel @Inject constructor(
exerciseTime = timeTypeString,
exerciseType = exerciseType,
isExercise = isDoExercise,
type = userTypeString
type = userTypeString,
nickname = nickName.value.toString()
)
onboardingRepository.postOnboardingInfo(requestDto)
.onSuccess {
Expand Down
22 changes: 11 additions & 11 deletions app/src/main/java/sopt/motivoo/util/NavigationDecider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ class NavigationDecider @Inject constructor(
) {
fun determineNavigationDestination(): NavigationEvent {
return when {
!motivooStorage.isFinishedPermission && motivooStorage.isUserLoggedIn ->
NavigationEvent.Permission
motivooStorage.isUserMatched ->
NavigationEvent.Home

!motivooStorage.isFinishedTermsOfUse && motivooStorage.isUserLoggedIn ->
NavigationEvent.TermsOfUse
!motivooStorage.isUserMatched && motivooStorage.isFinishedOnboarding && motivooStorage.isUserLoggedIn && motivooStorage.isFinishedTermsOfUse && motivooStorage.isFinishedPermission ->
NavigationEvent.StartMotivoo

!motivooStorage.isUserMatched && !motivooStorage.isFinishedOnboarding && motivooStorage.isUserLoggedIn ->
NavigationEvent.AgeQuestion
!motivooStorage.isUserMatched && !motivooStorage.isFinishedOnboarding && motivooStorage.isUserLoggedIn && motivooStorage.isFinishedTermsOfUse && motivooStorage.isFinishedPermission ->
NavigationEvent.NickName

!motivooStorage.isUserMatched && motivooStorage.isFinishedOnboarding && motivooStorage.isUserLoggedIn ->
NavigationEvent.StartMotivoo
!motivooStorage.isFinishedTermsOfUse && motivooStorage.isFinishedPermission && motivooStorage.isUserLoggedIn ->
NavigationEvent.TermsOfUse

motivooStorage.isUserMatched && motivooStorage.isFinishedOnboarding && motivooStorage.isUserLoggedIn ->
NavigationEvent.Home
!motivooStorage.isFinishedPermission && motivooStorage.isUserLoggedIn ->
NavigationEvent.Permission

else ->
NavigationEvent.Login
Expand All @@ -31,7 +31,7 @@ class NavigationDecider @Inject constructor(

sealed class NavigationEvent {
data object Home : NavigationEvent()
data object AgeQuestion : NavigationEvent()
data object NickName : NavigationEvent()
data object StartMotivoo : NavigationEvent()
data object Login : NavigationEvent()
data object Permission : NavigationEvent()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
app:progressView_autoAnimate="true"
app:progressView_colorBackground="@color/gray_100_F4F5F9"
app:progressView_colorProgress="@color/red_400_FF6259"
app:progressView_max="6"
app:progressView_max="7"
app:progressView_min="0"
app:progressView_progress="4"
app:progressView_progressFromPrevious="true" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/bottom_sheet_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
android:id="@+id/pv_loading"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/gray_600_7072764d"
android:background="@color/white_FFFFFF4d"
android:padding="150dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/dialog_home_photo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:id="@+id/pv_loading"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/gray_600_7072764d"
android:background="@color/white_FFFFFF4d"
android:padding="150dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_exercise.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
android:id="@+id/pv_loading"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/gray_600_7072764d"
android:background="@color/white_FFFFFF4d"
android:padding="150dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
Loading
Loading