-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: 인앱 업데이트 및 스플래시 의존성 추가 * feat: 스플래시 themes 추가 * feat: 업데이트 메세지 상수화 * feat: 스플래시 화면 구현 및 업데이트 확인 적용 * feat: 배경 화면을 하얀색으로 변경 * fix: 플레이스토어 문제 해결 * refactor: splashScreen 코드 리팩터링 * refactor: splash 코드 리팩터링
- Loading branch information
1 parent
a5193e5
commit 45fb77c
Showing
7 changed files
with
153 additions
and
10 deletions.
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
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
92 changes: 92 additions & 0 deletions
92
...id/festago/app/src/main/java/com/festago/festago/presentation/ui/splash/SplashActivity.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,92 @@ | ||
package com.festago.festago.presentation.ui.splash | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.widget.Toast | ||
import androidx.activity.ComponentActivity | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.core.splashscreen.SplashScreen | ||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen | ||
import com.festago.festago.R | ||
import com.festago.festago.databinding.ActivitySplashBinding | ||
import com.festago.festago.presentation.ui.home.HomeActivity | ||
import com.google.android.play.core.appupdate.AppUpdateInfo | ||
import com.google.android.play.core.appupdate.AppUpdateManagerFactory | ||
import com.google.android.play.core.install.model.UpdateAvailability | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@SuppressLint("CustomSplashScreen") | ||
@AndroidEntryPoint | ||
class SplashActivity : ComponentActivity() { | ||
|
||
val binding by lazy { | ||
ActivitySplashBinding.inflate(layoutInflater) | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val splashScreen = installSplashScreen() | ||
splashScreen.setKeepOnScreenCondition { true } | ||
checkAppUpdate(splashScreen) | ||
setContentView(binding.root) | ||
} | ||
|
||
private fun checkAppUpdate(splashScreen: SplashScreen) { | ||
val appUpdateManager = AppUpdateManagerFactory.create(this) | ||
appUpdateManager.appUpdateInfo | ||
.addOnSuccessListener { appUpdateInfo -> | ||
handleOnSuccess(appUpdateInfo, splashScreen) | ||
}.addOnFailureListener { | ||
showHome() | ||
} | ||
} | ||
|
||
private fun handleOnSuccess(appUpdateInfo: AppUpdateInfo, splashScreen: SplashScreen) { | ||
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) { | ||
splashScreen.setKeepOnScreenCondition { false } | ||
requestUpdate() | ||
} else { | ||
showHome() | ||
} | ||
} | ||
|
||
private fun showHome() { | ||
startActivity(HomeActivity.getIntent(this)) | ||
finish() | ||
} | ||
|
||
private fun requestUpdate() { | ||
AlertDialog.Builder(this).apply { | ||
setTitle(getString(R.string.splash_app_update_request_dialog_title)) | ||
setMessage(getString(R.string.splash_app_update_request_dialog_message)) | ||
setNegativeButton(R.string.ok_dialog_btn_cancel) { _, _ -> | ||
handleCancelUpdate() | ||
} | ||
setPositiveButton(R.string.ok_dialog_btn_ok) { _, _ -> | ||
handleOkUpdate() | ||
} | ||
setCancelable(false) | ||
}.show() | ||
} | ||
|
||
private fun handleCancelUpdate() { | ||
Toast.makeText( | ||
this@SplashActivity, | ||
getString(R.string.splash_app_update_denied), | ||
Toast.LENGTH_SHORT, | ||
).show() | ||
finish() | ||
} | ||
|
||
private fun handleOkUpdate() { | ||
navigateToAppStore() | ||
finish() | ||
} | ||
|
||
private fun navigateToAppStore() { | ||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName"))) | ||
finish() | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
android/festago/app/src/main/res/layout/activity_splash.xml
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<data> | ||
|
||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".presentation.ui.splash.SplashActivity"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
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
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