Skip to content

Commit

Permalink
#121/인앱업데이트 내부테스트 전
Browse files Browse the repository at this point in the history
  • Loading branch information
sub101 authored and haeti-dev committed Feb 18, 2024
1 parent 66cea8d commit abecfc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
34 changes: 11 additions & 23 deletions app/src/main/java/sopt/uni/presentation/SplashActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package sopt.uni.presentation

import android.os.Bundle
import android.util.Log
import androidx.lifecycle.lifecycleScope
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.delay
import kotlinx.coroutines.launch
Expand All @@ -24,7 +20,7 @@ class SplashActivity : BindingActivity<ActivitySplashBinding>(R.layout.activity_
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
isUpdateAvailable()
isAvailableUpdateVersion()

lifecycleScope.launch {
delay(2000)
Expand All @@ -46,24 +42,16 @@ class SplashActivity : BindingActivity<ActivitySplashBinding>(R.layout.activity_
}
}

private fun isUpdateAvailable() {
// val appUpdateManager = AppUpdateManagerFactory.create(this)
// val appUpdateInfoTask = appUpdateManager.appUpdateInfo
// appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
// if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(
// AppUpdateType.IMMEDIATE,
// )
// ) {
// SparkleStorage.setUpdateAvailableBoolean(IS_UPDATE_AVAILABLE, true)
// Log.e("subin", "${SparkleStorage.getUpdateAvailableBoolean(IS_UPDATE_AVAILABLE)}")
// } else {
// SparkleStorage.setUpdateAvailableBoolean(IS_UPDATE_AVAILABLE, false)
// Log.e("subin", "${SparkleStorage.getUpdateAvailableBoolean(IS_UPDATE_AVAILABLE)}")
// }
// }
Log.e("hyeon","${SparkleStorage.getUpdateAvailableBoolean(IS_UPDATE_AVAILABLE)}")
if(SparkleStorage.getUpdateAvailableBoolean(IS_UPDATE_AVAILABLE)){
UpdateDialogFragment().show(supportFragmentManager,"UpdateDialog")
private fun showUpdateDialog() {
UpdateDialogFragment().show(
supportFragmentManager,
"UpdateDialog",
)
}

private fun isAvailableUpdateVersion() {
if (SparkleStorage.getUpdateAvailableBoolean(IS_UPDATE_AVAILABLE)) {
showUpdateDialog()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sopt.uni.presentation.home

import android.app.Activity.RESULT_OK
import android.app.Activity
import android.os.Bundle
import android.view.View
import android.widget.Toast
Expand All @@ -20,15 +20,14 @@ class UpdateDialogFragment :

private val startForResult =
registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) {
if (it.resultCode != RESULT_OK) {
if (it.resultCode != Activity.RESULT_OK) {
Toast.makeText(requireContext(), "업데이트에 실패했습니다. 다시 시도해주세요.", Toast.LENGTH_SHORT)
.show()
} else {
SparkleStorage.setUpdateAvailableBoolean(IS_UPDATE_AVAILABLE, false)
dismiss()
}
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand Down

0 comments on commit abecfc0

Please sign in to comment.