Skip to content

Commit

Permalink
Merge pull request #127 from Team-Motivoo/feat/#116-onboarding-ui-change
Browse files Browse the repository at this point in the history
[feat] 온보딩 ui 변경
  • Loading branch information
l2zh authored Mar 25, 2024
2 parents 08daefa + a919332 commit 908b8bd
Show file tree
Hide file tree
Showing 65 changed files with 629 additions and 600 deletions.
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 1
versionName "1.0"
versionCode 4
versionName "1.0.1"

buildConfigField "String", "BASE_URL", properties["base_url"]
buildConfigField "String", "FIREBASE_RULE_UID", properties["firebase_rule_uid"]
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />

<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
Expand All @@ -40,18 +40,22 @@
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".presentation.home.broadcastreceiver.HomeAlarmReceiver"
<receiver
android:name=".presentation.home.broadcastreceiver.HomeAlarmReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED" />
</intent-filter>
</receiver>

<service
android:name=".presentation.home.service.StepCountService"
android:exported="false"
android:foregroundServiceType="dataSync" />
<activity android:name=".presentation.SampleDesignActivity"
android:exported="false"/>
android:foregroundServiceType="health" />

<activity
android:name=".presentation.SampleDesignActivity"
android:exported="false" />
<activity
android:name=".presentation.MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sopt.motivoo.data.datasource.remote

import sopt.motivoo.data.model.request.onboarding.RequestOnboardingDto
import sopt.motivoo.data.model.request.onboarding.RequestPostInviteCodeDto
import sopt.motivoo.data.model.response.onboarding.ResponseFinishedOnboardingDto
import sopt.motivoo.data.model.response.onboarding.ResponseGetInviteCodeDto
import sopt.motivoo.data.model.response.onboarding.ResponseGetMatchedResultDto
import sopt.motivoo.data.model.response.onboarding.ResponseOnboardingDto
Expand All @@ -21,9 +20,6 @@ class OnboardingDataSource @Inject constructor(
suspend fun getInviteCode(): ResponseGetInviteCodeDto =
onboardingService.getInviteCode()

suspend fun getOnboardingFinished(): ResponseFinishedOnboardingDto =
onboardingService.getOnboardingFinished()

suspend fun patchInviteCode(
requestPostInviteCodeDto: RequestPostInviteCodeDto
): ResponsePostInviteCodeDto =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@ data class ResponseLoginDto(
@SerialName("refresh_token")
val refreshToken: String,
@SerialName("token_type")
val tokenType: String
val tokenType: String,
@SerialName("is_finished_onboarding")
val isFinishedOnboarding: Boolean,
@SerialName("is_matched")
val isMatched: Boolean
)

fun toLoginInfo(): LoginInfo {
return LoginInfo(
accessToken = data.accessToken,
nickName = data.nickname,
id = data.id,
refreshToken = data.refreshToken
refreshToken = data.refreshToken,
isOnboardingFinished = data.isFinishedOnboarding,
isMatched = data.isMatched
)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package sopt.motivoo.data.repository

import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import sopt.motivoo.domain.repository.NetworkRepository
import sopt.motivoo.util.NetworkState
import javax.inject.Inject
Expand All @@ -11,11 +9,4 @@ class NetworkRepositoryImpl @Inject constructor(
) : NetworkRepository {

override val networkStateFlow = networkState.networkState

private val _isLoading = MutableSharedFlow<Boolean>(replay = 1)
override val isLoading get() = _isLoading.asSharedFlow()

override suspend fun setLoading(isLoading: Boolean) {
_isLoading.emit(isLoading)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package sopt.motivoo.data.repository
import sopt.motivoo.data.datasource.remote.OnboardingDataSource
import sopt.motivoo.data.model.request.onboarding.RequestOnboardingDto
import sopt.motivoo.data.model.request.onboarding.RequestPostInviteCodeDto
import sopt.motivoo.data.model.response.onboarding.ResponseFinishedOnboardingDto
import sopt.motivoo.data.model.response.onboarding.ResponseOnboardingDto
import sopt.motivoo.domain.entity.onboarding.GetMatchedInfo
import sopt.motivoo.domain.entity.onboarding.InviteCodeInfo
Expand All @@ -23,9 +22,6 @@ class OnboardingRepositoryImpl @Inject constructor(
override suspend fun getInviteCode(): Result<InviteCodeInfo> =
runCatching { onboardingDataSource.getInviteCode().toGetInviteCode() }

override suspend fun getOnboardingFinished(): Result<ResponseFinishedOnboardingDto> =
runCatching { onboardingDataSource.getOnboardingFinished() }

override suspend fun patchInviteCode(requestPostInviteCodeDto: RequestPostInviteCodeDto): Result<MatchedInfo> =
runCatching {
onboardingDataSource.patchInviteCode(requestPostInviteCodeDto).toMatchedInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import retrofit2.http.PATCH
import retrofit2.http.POST
import sopt.motivoo.data.model.request.onboarding.RequestOnboardingDto
import sopt.motivoo.data.model.request.onboarding.RequestPostInviteCodeDto
import sopt.motivoo.data.model.response.onboarding.ResponseFinishedOnboardingDto
import sopt.motivoo.data.model.response.onboarding.ResponseGetInviteCodeDto
import sopt.motivoo.data.model.response.onboarding.ResponseGetMatchedResultDto
import sopt.motivoo.data.model.response.onboarding.ResponseOnboardingDto
Expand All @@ -21,9 +20,6 @@ interface OnboardingService {
@POST("parentchild/invite")
suspend fun getInviteCode(): ResponseGetInviteCodeDto

@GET("user/onboarding")
suspend fun getOnboardingFinished(): ResponseFinishedOnboardingDto

@PATCH("parentchild/match")
suspend fun patchInviteCode(
@Body requestPostInviteCodeDto: RequestPostInviteCodeDto
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/sopt/motivoo/di/NavigationModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package sopt.motivoo.di

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import sopt.motivoo.domain.entity.MotivooStorage
import sopt.motivoo.util.NavigationDecider
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object NavigationModule {
@Provides
@Singleton
fun provideNavigationDecider(motivooStorage: MotivooStorage): NavigationDecider =
NavigationDecider(motivooStorage)
}
7 changes: 0 additions & 7 deletions app/src/main/java/sopt/motivoo/di/RetrofitModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,19 @@ import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import sopt.motivoo.BuildConfig.BASE_URL
import sopt.motivoo.BuildConfig.DEBUG
import sopt.motivoo.data.datasource.local.MotivooStorageImpl
import sopt.motivoo.data.datasource.remote.intercepter.AuthInterceptor
import sopt.motivoo.data.datasource.remote.intercepter.ErrorInterceptor
import sopt.motivoo.data.datasource.remote.listener.AuthTokenRefreshListener
import sopt.motivoo.data.datasource.remote.listener.AuthTokenRefreshListenerImpl
import sopt.motivoo.data.datasource.remote.listener.NetworkErrorListener
import sopt.motivoo.data.datasource.remote.listener.NetworkErrorListenerImpl
import sopt.motivoo.domain.entity.MotivooStorage
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object RetrofitModule {

@Provides
@Singleton
fun provideDataStore(motivooStorageImpl: MotivooStorageImpl): MotivooStorage =
motivooStorageImpl

@Provides
@Singleton
@AuthInterceptorQualifier
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/sopt/motivoo/di/StorageModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package sopt.motivoo.di

import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import sopt.motivoo.data.datasource.local.MotivooStorageImpl
import sopt.motivoo.domain.entity.MotivooStorage
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object StorageModule {
@Provides
@Singleton
fun provideMotivooStorage(@ApplicationContext context: Context): MotivooStorage =
MotivooStorageImpl(context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ data class LoginInfo(
val nickName: String,
val id: Long,
val refreshToken: String,
val isOnboardingFinished: Boolean,
val isMatched: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ import kotlinx.coroutines.flow.SharedFlow
interface NetworkRepository {

val networkStateFlow: SharedFlow<Boolean>
val isLoading: SharedFlow<Boolean>
suspend fun setLoading(isLoading: Boolean)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package sopt.motivoo.domain.repository
import retrofit2.http.Body
import sopt.motivoo.data.model.request.onboarding.RequestOnboardingDto
import sopt.motivoo.data.model.request.onboarding.RequestPostInviteCodeDto
import sopt.motivoo.data.model.response.onboarding.ResponseFinishedOnboardingDto
import sopt.motivoo.data.model.response.onboarding.ResponseOnboardingDto
import sopt.motivoo.domain.entity.onboarding.GetMatchedInfo
import sopt.motivoo.domain.entity.onboarding.InviteCodeInfo
Expand All @@ -15,8 +14,6 @@ interface OnboardingRepository {

suspend fun getInviteCode(): Result<InviteCodeInfo>

suspend fun getOnboardingFinished(): Result<ResponseFinishedOnboardingDto>

suspend fun patchInviteCode(requestPostInviteCodeDto: RequestPostInviteCodeDto): Result<MatchedInfo>

suspend fun getMatchedResult(): Result<GetMatchedInfo>
Expand Down
45 changes: 15 additions & 30 deletions app/src/main/java/sopt/motivoo/presentation/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.navigation.ui.setupWithNavController
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
Expand All @@ -32,6 +33,7 @@ import sopt.motivoo.presentation.onboarding.OnboardingViewModel
import sopt.motivoo.presentation.onboarding.WhatActivityQuestionFragmentDirections
import sopt.motivoo.presentation.onboarding.WhatExerciseQuestionFragmentDirections
import sopt.motivoo.presentation.type.NavigationSourceType
import sopt.motivoo.util.NetworkState
import sopt.motivoo.util.extension.checkNetworkState
import sopt.motivoo.util.extension.colorOf
import sopt.motivoo.util.extension.hideKeyboard
Expand All @@ -56,10 +58,13 @@ class MainActivity : AppCompatActivity() {
@Inject
lateinit var mainDispatcher: CoroutineDispatcher

@Inject
lateinit var networkState: NetworkState

override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.Theme_MOTIVOOAOS)
super.onCreate(savedInstanceState)
installSplashScreen()
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
initView()
Expand All @@ -69,26 +74,16 @@ class MainActivity : AppCompatActivity() {
}

private fun collectData() {
mainViewModel.isLoading.flowWithLifecycle(
lifecycle,
Lifecycle.State.STARTED
).onEach { isLoading ->
val navController: NavController = findNavController(R.id.fc_main)
if (isLoading && navController.currentDestination?.id != R.id.loadingFragment) {
navController.navigate(R.id.loadingFragment)
} else if (!isLoading && navController.currentDestination?.id == R.id.loadingFragment) {
navController.popBackStack()
}
}.launchIn(lifecycleScope)

mainViewModel.networkState.flowWithLifecycle(
lifecycle,
Lifecycle.State.STARTED
).onEach { isConnected ->
if (!isConnected) {
showNetworkErrorDialog()
}
}.launchIn(lifecycleScope)
)
.distinctUntilChanged()
.onEach { isConnected ->
if (!isConnected) {
showNetworkErrorDialog()
}
}.launchIn(lifecycleScope)

onboardingViewModel.navigationEvent.flowWithLifecycle(
lifecycle,
Expand Down Expand Up @@ -137,17 +132,9 @@ class MainActivity : AppCompatActivity() {
}

private fun initView() {
val redirectToLogin = intent.getBooleanExtra(REDIRECT_TO_LOGIN, false)
val navController =
supportFragmentManager.findFragmentById(R.id.fc_main)?.findNavController()

if (redirectToLogin) {
val bundle = Bundle().apply {
putBoolean(REDIRECT_TO_LOGIN, true)
}
navController?.setGraph(R.navigation.navigation_main, bundle)
}

with(binding) {
bnvMain.itemIconTintList = null
navController?.let { navController ->
Expand Down Expand Up @@ -304,10 +291,8 @@ class MainActivity : AppCompatActivity() {

override fun onDestroy() {
authTokenRefreshListener.clearOnTokenRefreshFailedCallback()
networkErrorListener.clearOnApiCallFailedCallback()
networkState.cleanup()
super.onDestroy()
}

companion object {
const val REDIRECT_TO_LOGIN = "redirectToLogin"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ class MainViewModel @Inject constructor(
) : ViewModel() {

val networkState: SharedFlow<Boolean> = networkRepository.networkStateFlow
val isLoading: SharedFlow<Boolean> = networkRepository.isLoading
}
54 changes: 0 additions & 54 deletions app/src/main/java/sopt/motivoo/presentation/SplashFragment.kt

This file was deleted.

Loading

0 comments on commit 908b8bd

Please sign in to comment.