Skip to content

Commit

Permalink
[MERGE] #117 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#117] 인앱 강제 업데이트 구현
  • Loading branch information
Marchbreeze authored Sep 5, 2024
2 parents 4180a34 + a3845b0 commit 3c29fce
Show file tree
Hide file tree
Showing 15 changed files with 109 additions and 60 deletions.
2 changes: 0 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
kotlin("kapt")
id("kotlin-parcelize")
id("dagger.hilt.android.plugin")
id("com.google.android.gms.oss-licenses-plugin")
}

android {
Expand Down Expand Up @@ -108,7 +107,6 @@ dependencies {
implementation(retrofit)
implementation(retrofitJsonConverter)
implementation(timber)
implementation(ossLicense)
}

KakaoDependencies.run {
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ buildscript {
classpath(ClassPathPlugins.gradle)
classpath(ClassPathPlugins.kotlinGradle)
classpath(ClassPathPlugins.hilt)
classpath(ClassPathPlugins.oss)
}
}

Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ object Constants {
const val compileSdk = 34
const val minSdk = 28
const val targetSdk = 34
const val versionCode = 4
const val versionName = "1.0.1"
const val versionCode = 5
const val versionName = "1.0.2"
}
25 changes: 9 additions & 16 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ object AndroidXDependencies {
"androidx.lifecycle:lifecycle-common-java8:${Versions.lifecycleVersion}"
const val workManager = "androidx.work:work-runtime-ktx:${Versions.workManagerVersion}"

const val hiltWorkManager = "androidx.hilt:hilt-work:1.0.0"
const val hiltWorkManager = "androidx.hilt:hilt-work:${Versions.hiltWorkVersion}"
const val hilt = "com.google.dagger:hilt-android:${Versions.hiltVersion}"
const val ossLicense =
"com.google.android.gms:play-services-oss-licenses:${Versions.ossVersion}"
}

object TestDependencies {
Expand All @@ -42,41 +40,37 @@ object TestDependencies {
const val espresso = "androidx.test.espresso:espresso-core:${Versions.espressoVersion}"
}

object MaterialDesignDependencies {
object GoogleDependencies {
const val materialDesign =
"com.google.android.material:material:${Versions.materialDesignVersion}"
const val mlkit = "com.google.mlkit:text-recognition-korean:${Versions.mlkitVersion}"
const val appUpdate = "com.google.android.play:app-update-ktx:${Versions.appUpdateVersion}"
}

object KaptDependencies {
const val hiltAndroidCompiler = "com.google.dagger:hilt-compiler:${Versions.hiltVersion}"
const val hiltCompiler = "com.google.dagger:hilt-compiler:${Versions.hiltVersion}"
const val hiltWorkManagerCompiler = "androidx.hilt:hilt-compiler:1.0.0"
const val hiltWorkManagerCompiler = "androidx.hilt:hilt-compiler:${Versions.hiltWorkVersion}"
}

object ThirdPartyDependencies {
const val coil = "io.coil-kt:coil:${Versions.coilVersion}"

const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofitVersion}"
const val retrofitJsonConverter =
"com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:${Versions.kotlinSerializationConverterVersion}"

const val okHttpBom = "com.squareup.okhttp3:okhttp-bom:${Versions.okHttpVersion}"
const val okHttp = "com.squareup.okhttp3:okhttp"
const val okHttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor"

const val timber = "com.jakewharton.timber:timber:${Versions.timberVersion}"

const val ossLicense =
"com.google.android.gms:play-services-oss-licenses:${Versions.ossVersion}"
const val coil = "io.coil-kt:coil:${Versions.coilVersion}"
const val lottie = "com.airbnb.android:lottie:${Versions.lottieVersion}"

const val progressView = "com.github.skydoves:progressview:${Versions.progressViewVersion}"
const val balloon = "com.github.skydoves:balloon:${Versions.balloonVersion}"
const val lottie = "com.airbnb.android:lottie:${Versions.lottieVersion}"
const val circleIndicator = "me.relex:circleindicator:${Versions.circleIndicatorVersion}"
const val circularProgressBar =
"com.mikhaellopez:circularprogressbar:${Versions.circularProgressBar}"
const val circleIndicator = "me.relex:circleindicator:${Versions.circleIndicatorVersion}"
const val shimmer = "com.facebook.shimmer:shimmer:${Versions.shimmerVersion}"

const val mlkit = "com.google.mlkit:text-recognition-korean:${Versions.mlkitVersion}"
}

object JitpackDependencies {
Expand All @@ -87,7 +81,6 @@ object ClassPathPlugins {
const val gradle = "com.android.tools.build:gradle:${Versions.gradleVersion}"
const val kotlinGradle = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlinVersion}"
const val hilt = "com.google.dagger:hilt-android-gradle-plugin:${Versions.hiltVersion}"
const val oss = "com.google.android.gms:oss-licenses-plugin:${Versions.ossPluginVersion}"
}

object FirebaseDependencies {
Expand Down
5 changes: 2 additions & 3 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ object Versions {
const val legacySupportVersion = "1.0.0"
const val securityVersion = "1.1.0-alpha06"
const val hiltVersion = "2.46.1"
const val hiltWorkVersion = "1.0.0"
const val fragmentKtxVersion = "1.5.7"
const val navigationVersion = "2.7.7"
const val webkitVersion = "1.8.0"
const val coroutinesAndroidVersion = "1.7.1"
const val lifecycleVersion = "2.6.1"
const val ossPluginVersion = "0.10.4"
const val ossVersion = "17.0.0"
const val splashVersion = "1.0.1"
const val workManagerVersion = "2.8.1"
const val coilVersion = "2.4.0"
Expand All @@ -34,8 +33,8 @@ object Versions {
const val circularProgressBar = "3.1.0"
const val kakaoVersion = "2.20.3"
const val circleIndicatorVersion = "2.1.6"
const val shimmerVersion = "0.5.0"
const val mlkitVersion = "16.0.0"
const val appUpdateVersion = "2.1.0"

const val iamportVersion = "v1.4.5"

Expand Down
4 changes: 2 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
implementation(AndroidXDependencies.lifeCycleKtx)

// Material Design
implementation(MaterialDesignDependencies.materialDesign)
implementation(GoogleDependencies.materialDesign)

// Hilt
implementation(AndroidXDependencies.hilt)
Expand All @@ -47,4 +47,4 @@ dependencies {
testImplementation(TestDependencies.jUnit)
androidTestImplementation(TestDependencies.androidTest)
androidTestImplementation(TestDependencies.espresso)
}
}
10 changes: 5 additions & 5 deletions data/src/main/java/co/orange/data/dto/response/SellInfoDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ data class SellInfoDto(
@SerialName("salePrice")
val salePrice: Int,
@SerialName("orderId")
val orderId: String,
@SerialName("buyerNickname")
val buyerNickname: String,
val orderId: String?,
@SerialName("buyerNickName")
val buyerNickname: String?,
@SerialName("paidAt")
val paidAt: String,
val paidAt: String?,
@SerialName("addressInfo")
val addressInfo: AddressInfoDto,
@SerialName("paymentMethod")
val paymentMethod: String,
val paymentMethod: String?,
) {
fun toModel() =
SellInfoModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ data class SellInfoModel(
val imgUrl: String,
val originPrice: Int,
val salePrice: Int,
val orderId: String,
val buyerNickname: String,
val paidAt: String,
val orderId: String?,
val buyerNickname: String?,
val paidAt: String?,
val addressInfo: AddressInfoModel,
val paymentMethod: String,
val paymentMethod: String?,
)
6 changes: 3 additions & 3 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ dependencies {
kapt(hiltWorkManagerCompiler)
}

MaterialDesignDependencies.run {
GoogleDependencies.run {
implementation(materialDesign)
implementation(mlkit)
implementation(appUpdate)
}

TestDependencies.run {
Expand All @@ -101,13 +103,11 @@ dependencies {
ThirdPartyDependencies.run {
implementation(coil)
implementation(timber)
implementation(ossLicense)
implementation(progressView)
implementation(balloon)
implementation(lottie)
implementation(circularProgressBar)
implementation(circleIndicator)
implementation(mlkit)
}

JitpackDependencies.run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SellInfoActivity :
tvInfoDeliveryPhone.text = item.addressInfo.recipientPhone
tvInfoTransactionMethod.text = item.paymentMethod
tvInfoTransactionDate.text =
item.paidAt.convertDateTime(OLD_DATE_PATTERN, NEW_DATE_PATTERN)
item.paidAt?.convertDateTime(OLD_DATE_PATTERN, NEW_DATE_PATTERN)
tvInfoPayKakao.text = item.originPrice.setPriceForm()
tvInfoPayReal.text = item.salePrice.setPriceForm()
tvInfoPayTotal.text = item.salePrice.setPriceForm()
Expand Down Expand Up @@ -127,7 +127,7 @@ class SellInfoActivity :
btnSellConfirm.setText(btnTextResId)
btnSellConfirm.isEnabled = isButtonEnabled
ivSellToast.isVisible = isButtonEnabled
if (status != ItemStatus.ON_SALE.name) {
if (status == ItemStatus.ON_SALE.name) {
tvInfoTransaction.isVisible = false
layoutInfoBuyer.isVisible = false
layoutInfoDelivery.isVisible = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SellInfoViewModel
viewModelScope.launch {
sellRepository.getItemDetailInfo(itemId)
.onSuccess {
orderId = it.orderId
orderId = it.orderId.orEmpty()
_getSellInfoState.value = UiState.Success(it)
}.onFailure {
_getSellInfoState.value = UiState.Failure(it.message.orEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SellOnboardingViewModel
viewModelScope.launch {
sellRepository.getSignedUrl(selectedImageName)
.onSuccess {
uploadedUrl = it.signedUrl
uploadedUrl = URL_GCP + selectedImageName
putImageToCloud(it.signedUrl)
}
.onFailure {
Expand Down Expand Up @@ -95,4 +95,8 @@ class SellOnboardingViewModel
fun resetProductIdState() {
_changingImageState.value = UiState.Empty
}

companion object {
private const val URL_GCP = "https://storage.googleapis.com/ddanzi_bucket/"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,97 @@ package co.orange.presentation.splash
import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.IntentSenderRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.lifecycleScope
import co.orange.core.base.BaseActivity
import co.orange.core.extension.setNavigationBarColorFromResource
import co.orange.core.extension.setStatusBarColorFromResource
import co.orange.core.extension.toast
import co.orange.presentation.main.MainActivity
import com.google.android.play.core.appupdate.AppUpdateInfo
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
import com.google.android.play.core.appupdate.AppUpdateOptions
import com.google.android.play.core.install.model.AppUpdateType.IMMEDIATE
import com.google.android.play.core.install.model.UpdateAvailability.UPDATE_AVAILABLE
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kr.genti.presentation.BuildConfig
import kr.genti.presentation.R
import kr.genti.presentation.databinding.ActivitySplashBinding

@AndroidEntryPoint
class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_splash) {
private val appUpdateManager by lazy { AppUpdateManagerFactory.create(this) }

private val activityResultLauncher: ActivityResultLauncher<IntentSenderRequest> =
registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) {
if (it.resultCode != RESULT_OK) {
toast("업데이트가 취소되었습니다.")
finishAffinity()
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setStatusBarColor()
setNavigationBarColor()
setStatusBarColorFromResource(R.color.black)
setNavigationBarColorFromResource(R.color.black)
}

override fun onResume() {
super.onResume()
checkConnectedNetwork()
}

private fun setStatusBarColor() = setStatusBarColorFromResource(R.color.black)
private fun checkConnectedNetwork() {
if (NetworkManager.checkNetworkState(this@SplashActivity)) {
checkAppUpdateAvailable()
} else {
showNetworkErrorAlertDialog()
}
}

private fun checkAppUpdateAvailable() {
if (BuildConfig.DEBUG) {
navigateToMain()
} else {
appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
if (isAppUpdateNeeded(appUpdateInfo)) {
requestUpdate(appUpdateInfo)
} else {
navigateToMain()
}
}.addOnFailureListener {
toast("업데이트에 실패했습니다.")
navigateToMain()
}
}
}

private fun isAppUpdateNeeded(appUpdateInfo: AppUpdateInfo) =
appUpdateInfo.updateAvailability() == UPDATE_AVAILABLE &&
appUpdateInfo.isUpdateTypeAllowed(IMMEDIATE)

private fun setNavigationBarColor() = setNavigationBarColorFromResource(R.color.black)
private fun requestUpdate(appUpdateInfo: AppUpdateInfo) {
runCatching {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
activityResultLauncher,
AppUpdateOptions.newBuilder(IMMEDIATE).build(),
)
}
}

private fun checkConnectedNetwork() {
private fun navigateToMain() {
lifecycleScope.launch {
delay(DELAY_TIME)
if (NetworkManager.checkNetworkState(this@SplashActivity)) {
Intent(this@SplashActivity, MainActivity::class.java).apply {
startActivity(this)
}
finish()
} else {
showNetworkErrorAlertDialog()
Intent(this@SplashActivity, MainActivity::class.java).apply {
startActivity(this)
}
finish()
}
}

Expand Down
11 changes: 6 additions & 5 deletions presentation/src/main/res/layout/activity_sell_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/sell_info_tv_message"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/sell_info_tv_message" />

<TextView
android:id="@+id/tv_info_transaction"
Expand Down Expand Up @@ -119,10 +119,10 @@
android:layout_marginTop="18dp"
android:background="@color/gray_1"
android:scaleType="centerCrop"
android:src="@drawable/mock_img_product"
app:layout_constraintDimensionRatio="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_info_product_title" />
app:layout_constraintTop_toBottomOf="@id/tv_info_product_title"
tools:src="@drawable/mock_img_product" />

<TextView
android:id="@+id/tv_info_product_price"
Expand Down Expand Up @@ -408,7 +408,8 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="22dp"
android:layout_marginBottom="30dp"
android:background="@drawable/shape_black_fill_10_rect"
android:background="@drawable/sel_btn"
android:enabled="false"
android:gravity="center"
android:paddingVertical="16dp"
android:text="@string/sell_info_btn_fix_sell"
Expand Down
Loading

0 comments on commit 3c29fce

Please sign in to comment.