Skip to content

Commit

Permalink
๐Ÿ”— :: (#687) ์ธ ์•ฑ ์—…๋ฐ์ดํŠธ ๊ธฐ๋Šฅ ๊ตฌํ˜„
Browse files Browse the repository at this point in the history
๐Ÿ”— :: (#687) ์ธ ์•ฑ ์—…๋ฐ์ดํŠธ ๊ธฐ๋Šฅ ๊ตฌํ˜„
  • Loading branch information
parkuiery authored Jun 10, 2024
2 parents 6d0b9e2 + e272a17 commit 9e9a124
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,6 @@ dependencies {

testImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.junit)

implementation(libs.app.update)
}
23 changes: 23 additions & 0 deletions app/src/main/java/team/aliens/dms/android/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSiz
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.core.view.WindowCompat
import com.google.accompanist.adaptive.calculateDisplayFeatures
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
import com.google.android.play.core.install.model.AppUpdateType
import com.google.android.play.core.install.model.UpdateAvailability
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.StateFlow
import team.aliens.dms.android.core.designsystem.DmsTheme
Expand All @@ -30,6 +33,7 @@ class MainActivity : ComponentActivity() {
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
)

checkAppUpdate()
setContent {
val windowSizeClass = calculateWindowSizeClass(activity = this)
val displayFeatures = calculateDisplayFeatures(activity = this)
Expand All @@ -43,4 +47,23 @@ class MainActivity : ComponentActivity() {
}
}
}

private fun checkAppUpdate() {
val appUpdateManager = AppUpdateManagerFactory.create(this)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo

appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
val isUpdateAvailable =
appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE

if (isUpdateAvailable && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.IMMEDIATE,
this,
0,
)
}
}
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ accompanist = "0.34.0"
androidx-window = "1.3.0-alpha02"
activity = "1.8.2"
appcompat = "1.6.1"
appUpdate = "2.1.0"
core = "1.12.0"
datastorePreferences = "1.0.0"
espresso = "3.5.1"
Expand Down Expand Up @@ -58,6 +59,7 @@ androidx-compose-material = { group = "androidx.compose.material3", name = "mate
androidx-compose-material-window = { group = "androidx.compose.material3", name = "material3-window-size-class-android", version.ref = "materialCompose" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation" }
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hiltNavigation" }
app-update = { module = "com.google.android.play:app-update-ktx", version.ref = "appUpdate" }
composeDestinations = { group = "io.github.raamcosta.compose-destinations", name = "animations-core", version.ref = "composeDestination" }
composeDestinations-ksp = { group = "io.github.raamcosta.compose-destinations", name = "ksp", version.ref = "composeDestination" }
javax-inject = { module = "javax.inject:javax.inject", version.ref = "javaxInject" }
Expand Down

0 comments on commit 9e9a124

Please sign in to comment.