-
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
Merged
stellar-halo
merged 32 commits into
develop
from
feature/#273-feat-bookshelf-version-update-notification
Nov 6, 2023
+330
−2
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
1537930
#273[feat]force_update xml 추가 및 string 업데이트
3cbbb2c
#273[feat] Version, VersionResponse data class 추가
9b119ca
#273[feat] ForceUpdateActivity 추가 및 버튼 클릭시, 플레이 스토어 화면으로 넘어가게 코드 작성
4cb7c5f
#273[feat] ForceUpdateActivity 추가
74ab40a
#273[feat] ForceUpdate 서버 연결 파일 추가(DataSource, Repository, Repository…
73fe39b
#273[feat] ForceUpdate Repo 모듈에 추가
78256da
#273[feat] SplashActivity에 dataObserver로 서버 통신 성공 시, 현재 appName과 비교 후…
c570cba
#273[feat] ktlint 정렬
a3f5a7c
#273[feat] ktlint 정렬
555f79a
#273[feat] ktlint 정렬
bdebaf0
#273[chore] Version domain entity 불필요한 변수 삭제
stellar-halo 2034dc5
#273[chore] forceUpdateActivity에서 intent private으로 변경
stellar-halo c030123
#273[fix] splash 화면 전에 업데이트 뷰로 이동하던 코드 수정
stellar-halo 2e6744f
#273[chore] viewModel 서버 통신 변수명 수정(isVersionStatus -> isForceUpdateSt…
stellar-halo 10c6fb5
#273[chore] 데이터 바인딩에 따른 안쓰는 string 아이템 삭제
stellar-halo f631c2d
#273[fix] ForceUpdateActivity에 VERSION 엔티티 넘기기
stellar-halo 96f0c6c
#273[fix] VERSION 엔티티로 변경
stellar-halo 9abb91a
#273[add] viewModel 생성, view와 데이터 바인딩 연결, intent로 값 받아오기
stellar-halo 24baa99
#273[fix] Parcelable 추가
stellar-halo 4be191c
#273[fix] forceUpdateViewModel과 연결
stellar-halo 33130f8
#273[add] versionDetail, versionState 엔티티 추가
stellar-halo a1a3192
#273[fix] viewModel로 버전 비교 로직 이전
stellar-halo 44b9eac
#273[fix] update state 엔티티 추가로 when으로 변경하여 분기 처리
stellar-halo f3a3b98
#273[fix] private 처리
stellar-halo cb2bccd
#273[fix] vm -> viewModel 약어 교체
stellar-halo b633534
#273[fix] listener 함수명 구체적으로 변경 및 뷰모델 캡슐화
stellar-halo d4ac96c
#273[fix] checkUpdateVersion 리턴값 수정
stellar-halo 6baa58e
#273[fix] checkUpdateVersion 반대로 되어있던 리턴값 수정
stellar-halo 4877767
#273[fix] 스토어 링크 object로 추출, 함수명 자세하게 수정
stellar-halo 855c21e
#273[fix] MutableLiveData, LiveData로 변경 및 그에 따른 null 처리 추가.
stellar-halo 04c2dcd
#273[fix] String으로 스토어 링크 추출
stellar-halo 35bb9fd
#273[fix] 불필요한 변수 삭제 및 observer 수정
stellar-halo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/sopt/peekabookaos/data/entity/response/VersionResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/sopt/peekabookaos/data/repository/ForceUpdateRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/sopt/peekabookaos/data/service/ForceUpdateService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/sopt/peekabookaos/data/source/remote/ForceUpdateDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/sopt/peekabookaos/domain/entity/Version.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/sopt/peekabookaos/domain/entity/VersionDetail.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.sopt.peekabookaos.domain.entity | ||
|
||
data class VersionDetail( | ||
val major: String, | ||
val minor: String | ||
) |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/sopt/peekabookaos/domain/entity/VersionState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.sopt.peekabookaos.domain.entity | ||
|
||
enum class VersionState { | ||
LATEST, OUTDATED | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/sopt/peekabookaos/domain/repository/ForceUpdateRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/sopt/peekabookaos/domain/usecase/GetVersionUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/sopt/peekabookaos/presentation/forceUpdate/ForceUpdateActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.viewModel = viewModel | ||
getLatestVersion() | ||
initUpdateBtnClickListener() | ||
} | ||
|
||
private fun initUpdateBtnClickListener() { | ||
binding.btnForceUpdate.setOnClickListener { | ||
intentToPlayStore = Intent( | ||
Intent.ACTION_VIEW, | ||
Uri.parse(getString(R.string.force_update_store_link)) | ||
) | ||
startActivity(intentToPlayStore) | ||
} | ||
} | ||
|
||
private fun getLatestVersion() { | ||
intent.getParcelable(LATEST_VERSION, Version::class.java) | ||
?.let { viewModel.getLatestVersion(it) } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/sopt/peekabookaos/presentation/forceUpdate/ForceUpdateViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.sopt.peekabookaos.presentation.forceUpdate | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.sopt.peekabookaos.domain.entity.Version | ||
|
||
class ForceUpdateViewModel : ViewModel() { | ||
private val _latestVersion: MutableLiveData<Version> = MutableLiveData() | ||
val latestVersion: LiveData<Version> = _latestVersion | ||
|
||
fun getLatestVersion(version: Version) { | ||
_latestVersion.value = version | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 52 additions & 1 deletion
53
app/src/main/java/com/sopt/peekabookaos/presentation/splash/SplashViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,65 @@ | ||
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.BuildConfig | ||
import com.sopt.peekabookaos.domain.entity.SplashState | ||
import com.sopt.peekabookaos.domain.entity.Version | ||
import com.sopt.peekabookaos.domain.entity.VersionDetail | ||
import com.sopt.peekabookaos.domain.entity.VersionState | ||
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() { | ||
private val _latestVersion: MutableLiveData<Version> = MutableLiveData() | ||
val latestVersion: LiveData<Version> = _latestVersion | ||
private lateinit var latestVersionDetail: VersionDetail | ||
private lateinit var appVersionDetail: VersionDetail | ||
|
||
init { | ||
getVersion() | ||
} | ||
|
||
fun getSplashState(): SplashState = getSplashStateUseCase() | ||
|
||
fun checkUpdateVersion(): VersionState { | ||
latestVersionDetail = | ||
spiltVersionToMajorMinor(requireNotNull(latestVersion.value?.androidForceVersion) { "version is null" }) | ||
appVersionDetail = spiltVersionToMajorMinor(BuildConfig.VERSION_NAME) | ||
return if (appVersionDetail.major != latestVersionDetail.major || appVersionDetail.minor != latestVersionDetail.minor) VersionState.OUTDATED | ||
else VersionState.LATEST | ||
} | ||
|
||
private fun spiltVersionToMajorMinor(versionName: String): VersionDetail { | ||
val versionSpiltList = versionName.split(".") | ||
val major = versionSpiltList[0] | ||
val minor = versionSpiltList[1] | ||
return VersionDetail(major, minor) | ||
} | ||
|
||
private fun getVersion() { | ||
viewModelScope.launch { | ||
getVersionUseCase() | ||
.onSuccess { response -> | ||
_latestVersion.value = Version( | ||
response.imageUrl, | ||
response.androidForceVersion, | ||
response.versionText | ||
) | ||
} | ||
.onFailure { throwable -> | ||
Timber.e("$throwable") | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
꼼꼼한 핃백 감사합니다