From c1ec4c29f63a95d3cc63e81efc8a1a0f2983d395 Mon Sep 17 00:00:00 2001 From: yeonjeen Date: Wed, 25 Dec 2024 13:07:46 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=8A=A4=ED=94=8C=EB=9E=98=EC=89=AC?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EA=B0=95=EC=A0=9C=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../into/websoso/ui/splash/SplashActivity.kt | 24 ++++++++++++++++--- .../into/websoso/ui/splash/SplashViewModel.kt | 14 +++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/into/websoso/ui/splash/SplashActivity.kt b/app/src/main/java/com/into/websoso/ui/splash/SplashActivity.kt index 0283dcd11..6952b66bc 100644 --- a/app/src/main/java/com/into/websoso/ui/splash/SplashActivity.kt +++ b/app/src/main/java/com/into/websoso/ui/splash/SplashActivity.kt @@ -8,6 +8,7 @@ import com.into.websoso.common.ui.base.BaseActivity import com.into.websoso.databinding.ActivityLoginBinding import com.into.websoso.ui.login.LoginActivity import com.into.websoso.ui.main.MainActivity +import com.into.websoso.ui.splash.dialog.MinimumVersionDialogFragment import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -21,15 +22,22 @@ class SplashActivity : BaseActivity(R.layout.activity_spla setupObserver() splashViewModel.autoLogin() + showMinimumVersionDialog() } private fun setupObserver() { splashViewModel.isAutoLogin.observe(this) { isAutoLogin -> lifecycleScope.launch { delay(1000L) - when (isAutoLogin) { - true -> navigateToMainActivity() - false -> navigateToLoginActivity() + splashViewModel.updateMinimumVersion { isUpdateRequired -> + if (isUpdateRequired) { + showMinimumVersionDialog() + } else { + when (isAutoLogin) { + true -> navigateToMainActivity() + false -> navigateToLoginActivity() + } + } } } } @@ -44,4 +52,14 @@ class SplashActivity : BaseActivity(R.layout.activity_spla startActivity(LoginActivity.getIntent(this)) finish() } + + private fun showMinimumVersionDialog() { + val dialog = MinimumVersionDialogFragment.newInstance() + dialog.isCancelable = false + dialog.show(supportFragmentManager, MINIMUM_VERSION_TAG) + } + + companion object { + private const val MINIMUM_VERSION_TAG = "MinimumVersionDialog" + } } diff --git a/app/src/main/java/com/into/websoso/ui/splash/SplashViewModel.kt b/app/src/main/java/com/into/websoso/ui/splash/SplashViewModel.kt index 2f17e7f79..a6e062e51 100644 --- a/app/src/main/java/com/into/websoso/ui/splash/SplashViewModel.kt +++ b/app/src/main/java/com/into/websoso/ui/splash/SplashViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.into.websoso.data.repository.AuthRepository +import com.into.websoso.data.repository.VersionRepository import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import javax.inject.Inject @@ -12,6 +13,7 @@ import javax.inject.Inject @HiltViewModel class SplashViewModel @Inject constructor( private val authRepository: AuthRepository, + private val versionRepository: VersionRepository, ) : ViewModel() { private var _isAutoLogin = MutableLiveData(false) @@ -32,4 +34,16 @@ class SplashViewModel @Inject constructor( } } } + + fun updateMinimumVersion(onUpdateRequired: (Boolean) -> Unit) { + viewModelScope.launch { + runCatching { + versionRepository.isUpdateRequired() + }.onSuccess { isUpdateRequired -> + onUpdateRequired(isUpdateRequired) + }.onFailure { + onUpdateRequired(false) + } + } + } } \ No newline at end of file