-
Notifications
You must be signed in to change notification settings - Fork 0
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
#273 [feat] 앱 버전이 맞지 않을 경우, 업데이트 화면 뜨게 하기 #274
Changes from 20 commits
1537930
3cbbb2c
9b119ca
4cb7c5f
74ab40a
73fe39b
78256da
c570cba
a3f5a7c
555f79a
bdebaf0
2034dc5
c030123
2e6744f
10c6fb5
f631c2d
96f0c6c
9abb91a
24baa99
4be191c
33130f8
a1a3192
44b9eac
f3a3b98
cb2bccd
b633534
d4ac96c
6baa58e
4877767
855c21e
04c2dcd
35bb9fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.sopt.peekabookaos.data.entity.response | ||
|
||
import com.sopt.peekabookaos.domain.entity.Version | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class VersionResponse( | ||
val imageUrl: String, | ||
val iosForceVersion: String, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 우리는 iOSForceVersion이라는 변수가 필요하지 않습니다! |
||
val androidForceVersion: String, | ||
@SerialName("text") | ||
val versionText: String | ||
) { | ||
fun toVersion(): Version = Version( | ||
imageUrl = this.imageUrl, | ||
androidForceVersion = this.androidForceVersion, | ||
versionText = this.versionText | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.sopt.peekabookaos.data.repository | ||
|
||
import com.sopt.peekabookaos.data.source.remote.ForceUpdateDataSource | ||
import com.sopt.peekabookaos.domain.entity.Version | ||
import com.sopt.peekabookaos.domain.repository.ForceUpdateRepository | ||
import javax.inject.Inject | ||
|
||
class ForceUpdateRepositoryImpl @Inject constructor( | ||
private val forceUpdateDataSource: ForceUpdateDataSource | ||
) : ForceUpdateRepository { | ||
override suspend fun getVersion(): Result<Version> = | ||
kotlin.runCatching { forceUpdateDataSource.getVersion() }.map { response -> | ||
requireNotNull(response.data).toVersion() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sopt.peekabookaos.data.service | ||
|
||
import com.sopt.peekabookaos.data.entity.BaseResponse | ||
import com.sopt.peekabookaos.data.entity.response.VersionResponse | ||
import retrofit2.http.GET | ||
|
||
interface ForceUpdateService { | ||
@GET("user/v1/version") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍👍👍 |
||
suspend fun getVersion(): BaseResponse<VersionResponse> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.sopt.peekabookaos.data.source.remote | ||
|
||
import com.sopt.peekabookaos.data.entity.BaseResponse | ||
import com.sopt.peekabookaos.data.entity.response.VersionResponse | ||
import com.sopt.peekabookaos.data.service.ForceUpdateService | ||
import javax.inject.Inject | ||
|
||
class ForceUpdateDataSource @Inject constructor( | ||
private val forceUpdateService: ForceUpdateService | ||
) { | ||
suspend fun getVersion(): BaseResponse<VersionResponse> = | ||
forceUpdateService.getVersion() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.sopt.peekabookaos.domain.entity | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
stellar-halo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
data class Version( | ||
val imageUrl: String = "", | ||
val androidForceVersion: String = "", | ||
val versionText: String = "" | ||
) : Parcelable |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.sopt.peekabookaos.domain.repository | ||
|
||
import com.sopt.peekabookaos.domain.entity.Version | ||
|
||
interface ForceUpdateRepository { | ||
suspend fun getVersion(): Result<Version> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sopt.peekabookaos.domain.usecase | ||
|
||
import com.sopt.peekabookaos.domain.repository.ForceUpdateRepository | ||
import javax.inject.Inject | ||
|
||
class GetVersionUseCase @Inject constructor( | ||
private val forceUpdateRepository: ForceUpdateRepository | ||
) { | ||
suspend operator fun invoke() = forceUpdateRepository.getVersion() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.sopt.peekabookaos.presentation.forceUpdate | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import com.sopt.peekabookaos.R | ||
import com.sopt.peekabookaos.databinding.ActivityForceUpdateBinding | ||
import com.sopt.peekabookaos.domain.entity.Version | ||
import com.sopt.peekabookaos.presentation.splash.SplashActivity.Companion.LATEST_VERSION | ||
import com.sopt.peekabookaos.util.binding.BindingActivity | ||
import com.sopt.peekabookaos.util.extensions.getParcelable | ||
|
||
class ForceUpdateActivity : | ||
BindingActivity<ActivityForceUpdateBinding>(R.layout.activity_force_update) { | ||
private lateinit var intentToPlayStore: Intent | ||
private val viewModel by viewModels<ForceUpdateViewModel>() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding.vm = viewModel | ||
getLatestVersion() | ||
initClickListener() | ||
} | ||
|
||
private fun initClickListener() { | ||
stellar-halo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
binding.btnForceUpdate.setOnClickListener { | ||
intentToPlayStore = Intent( | ||
Intent.ACTION_VIEW, | ||
Uri.parse("https://play.google.com/store/apps/details?id=com.sopt.peekabookaos&hl=ko-KR") | ||
) | ||
startActivity(intentToPlayStore) | ||
} | ||
} | ||
|
||
private fun getLatestVersion() { | ||
intent.getParcelable(LATEST_VERSION, Version::class.java) | ||
?.let { viewModel.getLatestVersion(it) } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.sopt.peekabookaos.presentation.forceUpdate | ||
|
||
import androidx.lifecycle.ViewModel | ||
import com.sopt.peekabookaos.domain.entity.Version | ||
|
||
class ForceUpdateViewModel : ViewModel() { | ||
lateinit var latestVersion: Version | ||
|
||
fun getLatestVersion(version: Version) { | ||
latestVersion = version | ||
} | ||
stellar-halo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,56 @@ | ||
package com.sopt.peekabookaos.presentation.splash | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.sopt.peekabookaos.domain.entity.SplashState | ||
import com.sopt.peekabookaos.domain.entity.Version | ||
import com.sopt.peekabookaos.domain.usecase.GetSplashStateUseCase | ||
import com.sopt.peekabookaos.domain.usecase.GetVersionUseCase | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.launch | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class SplashViewModel @Inject constructor( | ||
private val getSplashStateUseCase: GetSplashStateUseCase | ||
private val getSplashStateUseCase: GetSplashStateUseCase, | ||
private val getVersionUseCase: GetVersionUseCase | ||
) : ViewModel() { | ||
var latestVersion = Version() | ||
private val _isForceUpdateStatus = MutableLiveData(false) | ||
val isForceUpdateStatus: LiveData<Boolean> = _isForceUpdateStatus | ||
lateinit var majorVersion: String | ||
lateinit var minorVersion: String | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. public인 이유가 있나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로직 변경해서 바뀐 변수들은 private으로 처리했습니다 |
||
|
||
init { | ||
getVersion() | ||
} | ||
|
||
fun getSplashState(): SplashState = getSplashStateUseCase() | ||
|
||
fun getSplitVersion() = run { | ||
val versionSpiltList = latestVersion.androidForceVersion.split(".") | ||
majorVersion = versionSpiltList[0] | ||
minorVersion = versionSpiltList[1] | ||
} | ||
|
||
private fun getVersion() { | ||
viewModelScope.launch { | ||
getVersionUseCase() | ||
.onSuccess { response -> | ||
latestVersion = Version( | ||
response.imageUrl, | ||
response.androidForceVersion, | ||
response.versionText | ||
) | ||
_isForceUpdateStatus.value = true | ||
} | ||
.onFailure { throwable -> | ||
_isForceUpdateStatus.value = false | ||
Timber.e("$throwable") | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imageUrl이 현재 뷰에는 쓰이지 않는데 nullable 변수인지 서버한테 물어보면 좋을 것 같네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
꼼꼼한 핃백 감사합니다