-
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 10 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,21 @@ | ||
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, | ||
iosForceVersion = this.iosForceVersion, | ||
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,8 @@ | ||
package com.sopt.peekabookaos.domain.entity | ||
|
||
data class Version( | ||
val imageUrl: String = "", | ||
val iosForceVersion: String = "", | ||
stellar-halo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val androidForceVersion: String = "", | ||
val versionText: String = "" | ||
) |
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,24 @@ | ||
package com.sopt.peekabookaos.presentation.forceUpdate | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import com.sopt.peekabookaos.R | ||
import com.sopt.peekabookaos.databinding.ActivityForceUpdateBinding | ||
import com.sopt.peekabookaos.util.binding.BindingActivity | ||
|
||
class ForceUpdateActivity : | ||
BindingActivity<ActivityForceUpdateBinding>(R.layout.activity_force_update) { | ||
lateinit var intentToPlayStore: Intent | ||
stellar-halo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
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) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
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.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 _versionName: MutableLiveData<String> = MutableLiveData() | ||
val versionName: LiveData<String> = _versionName | ||
private val _isVersionStatus = MutableLiveData(false) | ||
val isVersionStatus: LiveData<Boolean> = _isVersionStatus | ||
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. UiState라는 데이터클래스를 만들어서 변수를 하나에 관리하는 건 어떨까요? 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. 당장은 여기에서만 쓰이니 안만드는게 좋겠다고 생각했는데, 나중엔 다른 곳에서도 쓰일 수도 있겠네요..! 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. 음 .. 개인적으론 코딩스타일인 것 같아서 다음에 uiState 공부하고 적용해보면 좋을 것 같아요 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. isVersionStatus보다는 isForceUpdate가 더 직관적인 것 같은데 어떻게 생각하시나요? 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. 서버 통신 변수명이니까 status가 들어가는 것이 좋아보여 isForceUpdateStatus로 변경했습니다 |
||
|
||
fun getSplashState(): SplashState = getSplashStateUseCase() | ||
|
||
fun getVersion() { | ||
viewModelScope.launch { | ||
getVersionUseCase() | ||
.onSuccess { response -> | ||
_versionName.value = response.androidForceVersion | ||
_isVersionStatus.value = true | ||
} | ||
.onFailure { throwable -> | ||
_isVersionStatus.value = false | ||
Timber.e("$throwable") | ||
} | ||
} | ||
} | ||
stellar-halo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<data> | ||
|
||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/network_background" | ||
tools:context=".presentation.splash.SplashActivity"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="40dp" | ||
android:background="@color/peeka_beige" | ||
android:elevation="20dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<TextView | ||
android:id="@+id/tv_force_update_title" | ||
style="@style/NameBd" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="22dp" | ||
android:gravity="center" | ||
android:text="@string/force_update_title" | ||
android:textColor="@color/peeka_red" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_force_update_content" | ||
style="@style/H2Md" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="5dp" | ||
android:gravity="center" | ||
android:text="@string/force_update_content" | ||
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. 데이터바인딩이 필요해보입니다 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. 현재는 고정문구라하여 데바 안하겠습니다! |
||
android:textColor="@color/peeka_red" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_force_update_title" /> | ||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/btn_force_update" | ||
style="@style/H1Bd" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="16dp" | ||
android:layout_marginTop="15dp" | ||
android:layout_marginBottom="16dp" | ||
android:background="@color/peeka_red" | ||
android:paddingVertical="10dp" | ||
android:text="@string/force_update_button" | ||
android:textColor="@color/peeka_white" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_force_update_content" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,4 +206,9 @@ | |
<string name="profile_modify_intoduce_hint">한 줄 소개는 40자까지 쓸 수 있어요!</string> | ||
<string name="blocked_user_empty">차단된 사용자가 없어요.</string> | ||
<string name="profile_modify_timeStamp">yyyyMMdd_HHmmss</string> | ||
|
||
<!-- Force Update --> | ||
<string name="force_update_title">앗! 피카북이 달라졌어요</string> | ||
<string name="force_update_content">어느 기능이 추가되었는지 알아볼까요?</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. 아마 이 내용을 서버에서 보내주기 때문에 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. 넵!🫡 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. 지금 전부 고정문구라네요! |
||
<string name="force_update_button">업데이트 하러 가기</string> | ||
</resources> |
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.
꼼꼼한 핃백 감사합니다