From 25bae9de73b29fc7a8f4e34cdb518fa2940e8341 Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Mon, 26 Feb 2024 20:20:16 +0900 Subject: [PATCH 01/10] =?UTF-8?q?feat:=20=EC=9D=B8=EC=95=B1=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EB=9D=BC=EC=9D=B4=EB=B8=8C?= =?UTF-8?q?=EB=9F=AC=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index f3374f0..8fd38e6 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -112,6 +112,10 @@ dependencies { // Material chart implementation("app.priceguard:materialchart:0.2.2") + + // In app update + implementation("com.google.android.play:app-update:2.1.0") + implementation("com.google.android.play:app-update-ktx:2.1.0") } kapt { From 94c359d9ce0af89c120aebb98e70d50644a68df8 Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Mon, 26 Feb 2024 20:23:17 +0900 Subject: [PATCH 02/10] =?UTF-8?q?chore:=20=EB=9D=BC=EC=9D=B4=EB=B8=8C?= =?UTF-8?q?=EB=9F=AC=EB=A6=AC=20=EB=B2=84=EC=A0=84=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle.kts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 8fd38e6..7e2afb0 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -70,8 +70,6 @@ dependencies { implementation("com.google.android.material:material:1.11.0") implementation("androidx.activity:activity-ktx:1.8.2") implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.navigation:navigation-fragment-ktx:2.7.6") - implementation("androidx.navigation:navigation-ui-ktx:2.7.6") // Retrofit, Serialization implementation("com.squareup.retrofit2:retrofit:2.9.0") @@ -92,7 +90,7 @@ dependencies { androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") // Navigation - val navVersion = "2.7.6" + val navVersion = "2.7.7" implementation("androidx.navigation:navigation-fragment-ktx:$navVersion") implementation("androidx.navigation:navigation-ui-ktx:$navVersion") @@ -107,8 +105,8 @@ dependencies { // Worker implementation("androidx.work:work-runtime-ktx:2.9.0") - implementation("androidx.hilt:hilt-work:1.1.0") - kapt("androidx.hilt:hilt-compiler:1.1.0") + implementation("androidx.hilt:hilt-work:1.2.0") + kapt("androidx.hilt:hilt-compiler:1.2.0") // Material chart implementation("app.priceguard:materialchart:0.2.2") From 6f792d6b618bf5e995356805b82ef15f002baf99 Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Mon, 26 Feb 2024 21:29:38 +0900 Subject: [PATCH 03/10] =?UTF-8?q?feat:=20=EC=9D=B8=EC=95=B1=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=ED=94=84=EB=A1=AC=ED=94=84?= =?UTF-8?q?=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/priceguard/ui/home/HomeActivity.kt | 43 +++++++++++++++++++ android/app/src/main/res/values/strings.xml | 2 + 2 files changed, 45 insertions(+) diff --git a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt index 14a48b7..9b3c427 100644 --- a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt +++ b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt @@ -5,6 +5,8 @@ import android.content.pm.PackageManager import android.os.Build import android.os.Bundle import android.util.Log +import android.widget.Toast +import androidx.activity.result.ActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat @@ -22,6 +24,10 @@ import app.priceguard.ui.util.openNotificationSettings import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.GoogleApiAvailability import com.google.android.material.snackbar.Snackbar +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 +import com.google.android.play.core.install.model.UpdateAvailability import dagger.hilt.android.AndroidEntryPoint import java.util.concurrent.TimeUnit @@ -30,6 +36,8 @@ class HomeActivity : AppCompatActivity() { private lateinit var binding: ActivityHomeBinding private lateinit var snackbar: Snackbar + private val appUpdateManager = AppUpdateManagerFactory.create(this) + private val updateType = AppUpdateType.IMMEDIATE override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -47,6 +55,7 @@ class HomeActivity : AppCompatActivity() { override fun onResume() { super.onResume() checkForGooglePlayServices() + checkAppUpdates() if (ContextCompat.checkSelfPermission( this, @@ -128,6 +137,40 @@ class HomeActivity : AppCompatActivity() { } } + private fun checkAppUpdates() { + val appUpdateInfoTask = appUpdateManager.appUpdateInfo + val activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult -> + when (result.resultCode) { + RESULT_CANCELED -> { + Toast.makeText(this, getString(R.string.update_cancel_warning), Toast.LENGTH_LONG).show() + } + com.google.android.play.core.install.model.ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> { + Toast.makeText(this, getString(R.string.update_failed), Toast.LENGTH_LONG).show() + } + } + } + + appUpdateInfoTask.addOnSuccessListener { info -> + if (info.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && + info.isUpdateTypeAllowed(updateType) + ) { + appUpdateManager.startUpdateFlowForResult( + info, + activityResultLauncher, + AppUpdateOptions.newBuilder(updateType).build() + ) + } + + if (info.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) { + appUpdateManager.startUpdateFlowForResult( + info, + activityResultLauncher, + AppUpdateOptions.newBuilder(updateType).build() + ) + } + } + } + private fun showNotificationOffSnackbar() { if (snackbar.isShown) return snackbar.show() diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 39f9865..676beba 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -152,4 +152,6 @@ 추천 상품이 준비중입니다. 품절 등록 가능한 상품 개수를 초과하였습니다. + 업데이트 미적용시 앱 사용에 지장이 생길 수 있습니다. + 업데이트에 실패하였습니다. 다시 시도해 주세요. \ No newline at end of file From 83240a2937ae1fbba40f17f8dbf5de66954ef16a Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Mon, 26 Feb 2024 21:48:57 +0900 Subject: [PATCH 04/10] =?UTF-8?q?fix:=20registerForActivityResult=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=20=EC=8B=9C=20IllegalStateException=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/priceguard/ui/home/HomeActivity.kt | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt index 9b3c427..31a98fa 100644 --- a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt +++ b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt @@ -7,6 +7,8 @@ import android.os.Bundle import android.util.Log import android.widget.Toast import androidx.activity.result.ActivityResult +import androidx.activity.result.ActivityResultLauncher +import androidx.activity.result.IntentSenderRequest import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat @@ -24,6 +26,7 @@ import app.priceguard.ui.util.openNotificationSettings import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.GoogleApiAvailability import com.google.android.material.snackbar.Snackbar +import com.google.android.play.core.appupdate.AppUpdateManager 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 @@ -36,8 +39,9 @@ class HomeActivity : AppCompatActivity() { private lateinit var binding: ActivityHomeBinding private lateinit var snackbar: Snackbar - private val appUpdateManager = AppUpdateManagerFactory.create(this) + private lateinit var appUpdateManager: AppUpdateManager private val updateType = AppUpdateType.IMMEDIATE + private lateinit var activityResultLauncher: ActivityResultLauncher override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -45,6 +49,7 @@ class HomeActivity : AppCompatActivity() { binding = ActivityHomeBinding.inflate(layoutInflater) setContentView(binding.root) + setupAppUpdate() enqueueWorker() initSnackBar() checkForGooglePlayServices() @@ -137,18 +142,29 @@ class HomeActivity : AppCompatActivity() { } } - private fun checkAppUpdates() { - val appUpdateInfoTask = appUpdateManager.appUpdateInfo - val activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult -> - when (result.resultCode) { - RESULT_CANCELED -> { - Toast.makeText(this, getString(R.string.update_cancel_warning), Toast.LENGTH_LONG).show() - } - com.google.android.play.core.install.model.ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> { - Toast.makeText(this, getString(R.string.update_failed), Toast.LENGTH_LONG).show() + private fun setupAppUpdate() { + appUpdateManager = AppUpdateManagerFactory.create(this) + activityResultLauncher = + registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult -> + when (result.resultCode) { + RESULT_CANCELED -> { + Toast.makeText( + this, + getString(R.string.update_cancel_warning), + Toast.LENGTH_LONG + ).show() + } + + com.google.android.play.core.install.model.ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> { + Toast.makeText(this, getString(R.string.update_failed), Toast.LENGTH_LONG) + .show() + } } } - } + } + + private fun checkAppUpdates() { + val appUpdateInfoTask = appUpdateManager.appUpdateInfo appUpdateInfoTask.addOnSuccessListener { info -> if (info.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && From d6550776087ae3454908cfe790374ba9fce12fe6 Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Mon, 4 Mar 2024 20:40:05 +0900 Subject: [PATCH 05/10] =?UTF-8?q?feat:=20Flexible=ED=95=9C=20=EC=9D=B8?= =?UTF-8?q?=EC=95=B1=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=A7=80?= =?UTF-8?q?=EC=9B=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/priceguard/ui/home/HomeActivity.kt | 34 +++++++++++++------ android/app/src/main/res/values/strings.xml | 1 + 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt index 31a98fa..c977c76 100644 --- a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt +++ b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt @@ -23,13 +23,16 @@ import app.priceguard.service.UpdateTokenWorker import app.priceguard.ui.util.SystemNavigationColorState import app.priceguard.ui.util.applySystemNavigationBarColor import app.priceguard.ui.util.openNotificationSettings +import app.priceguard.ui.util.showConfirmDialog import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.GoogleApiAvailability import com.google.android.material.snackbar.Snackbar import com.google.android.play.core.appupdate.AppUpdateManager import com.google.android.play.core.appupdate.AppUpdateManagerFactory import com.google.android.play.core.appupdate.AppUpdateOptions +import com.google.android.play.core.install.InstallStateUpdatedListener import com.google.android.play.core.install.model.AppUpdateType +import com.google.android.play.core.install.model.InstallStatus import com.google.android.play.core.install.model.UpdateAvailability import dagger.hilt.android.AndroidEntryPoint import java.util.concurrent.TimeUnit @@ -40,8 +43,17 @@ class HomeActivity : AppCompatActivity() { private lateinit var binding: ActivityHomeBinding private lateinit var snackbar: Snackbar private lateinit var appUpdateManager: AppUpdateManager - private val updateType = AppUpdateType.IMMEDIATE private lateinit var activityResultLauncher: ActivityResultLauncher + private val updateListener = InstallStateUpdatedListener { state -> + if (state.installStatus() == InstallStatus.DOWNLOADED) { + appUpdateManager.completeUpdate() + } + + if (state.installStatus() == InstallStatus.FAILED) { + Toast.makeText(this, getString(R.string.update_failed), Toast.LENGTH_LONG) + .show() + } + } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -55,12 +67,12 @@ class HomeActivity : AppCompatActivity() { checkForGooglePlayServices() setBottomNavigationBar() askNotificationPermission() + checkAppUpdates() } override fun onResume() { super.onResume() checkForGooglePlayServices() - checkAppUpdates() if (ContextCompat.checkSelfPermission( this, @@ -73,6 +85,11 @@ class HomeActivity : AppCompatActivity() { } } + override fun onDestroy() { + super.onDestroy() + appUpdateManager.unregisterListener(updateListener) + } + private fun enqueueWorker() { val saveRequest = PeriodicWorkRequestBuilder(730, TimeUnit.HOURS) @@ -148,11 +165,7 @@ class HomeActivity : AppCompatActivity() { registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult -> when (result.resultCode) { RESULT_CANCELED -> { - Toast.makeText( - this, - getString(R.string.update_cancel_warning), - Toast.LENGTH_LONG - ).show() + showConfirmDialog(getString(R.string.warning), getString(R.string.update_cancel_warning)) } com.google.android.play.core.install.model.ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> { @@ -161,6 +174,7 @@ class HomeActivity : AppCompatActivity() { } } } + appUpdateManager.registerListener(updateListener) } private fun checkAppUpdates() { @@ -168,12 +182,12 @@ class HomeActivity : AppCompatActivity() { appUpdateInfoTask.addOnSuccessListener { info -> if (info.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && - info.isUpdateTypeAllowed(updateType) + info.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE) ) { appUpdateManager.startUpdateFlowForResult( info, activityResultLauncher, - AppUpdateOptions.newBuilder(updateType).build() + AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build() ) } @@ -181,7 +195,7 @@ class HomeActivity : AppCompatActivity() { appUpdateManager.startUpdateFlowForResult( info, activityResultLauncher, - AppUpdateOptions.newBuilder(updateType).build() + AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build() ) } } diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 676beba..d7473b6 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -154,4 +154,5 @@ 등록 가능한 상품 개수를 초과하였습니다. 업데이트 미적용시 앱 사용에 지장이 생길 수 있습니다. 업데이트에 실패하였습니다. 다시 시도해 주세요. + 경고 \ No newline at end of file From 062e00a60b26bb02a6db0a9d0fd74b4056d6180c Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Mon, 4 Mar 2024 21:12:16 +0900 Subject: [PATCH 06/10] =?UTF-8?q?feat:=20=EC=A6=89=EC=8B=9C=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=ED=95=B4=EC=95=BC=EB=90=98=EB=8A=94?= =?UTF-8?q?=20=EB=B2=84=EC=A0=84=EA=B3=BC=20=EA=B8=89=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EC=9D=80=20=EB=B2=84=EC=A0=84=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/priceguard/ui/home/HomeActivity.kt | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt index c977c76..d392011 100644 --- a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt +++ b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt @@ -43,7 +43,8 @@ class HomeActivity : AppCompatActivity() { private lateinit var binding: ActivityHomeBinding private lateinit var snackbar: Snackbar private lateinit var appUpdateManager: AppUpdateManager - private lateinit var activityResultLauncher: ActivityResultLauncher + private lateinit var flexibleAppUpdateResultLauncher: ActivityResultLauncher + private lateinit var immediateAppUpdateResultLauncher: ActivityResultLauncher private val updateListener = InstallStateUpdatedListener { state -> if (state.installStatus() == InstallStatus.DOWNLOADED) { appUpdateManager.completeUpdate() @@ -161,7 +162,20 @@ class HomeActivity : AppCompatActivity() { private fun setupAppUpdate() { appUpdateManager = AppUpdateManagerFactory.create(this) - activityResultLauncher = + flexibleAppUpdateResultLauncher = + registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult -> + when (result.resultCode) { + RESULT_CANCELED -> { + showConfirmDialog(getString(R.string.warning), getString(R.string.update_cancel_warning)) + } + + com.google.android.play.core.install.model.ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> { + Toast.makeText(this, getString(R.string.update_failed), Toast.LENGTH_LONG) + .show() + } + } + } + immediateAppUpdateResultLauncher = registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult -> when (result.resultCode) { RESULT_CANCELED -> { @@ -186,18 +200,37 @@ class HomeActivity : AppCompatActivity() { ) { appUpdateManager.startUpdateFlowForResult( info, - activityResultLauncher, + flexibleAppUpdateResultLauncher, AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build() ) } - if (info.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) { + if (info.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && + info.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE) && + info.updatePriority() >= 3 + ) { appUpdateManager.startUpdateFlowForResult( info, - activityResultLauncher, - AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build() + immediateAppUpdateResultLauncher, + AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build() ) } + + if (info.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) { + if (info.updatePriority() >= 3) { + appUpdateManager.startUpdateFlowForResult( + info, + immediateAppUpdateResultLauncher, + AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build() + ) + } else { + appUpdateManager.startUpdateFlowForResult( + info, + flexibleAppUpdateResultLauncher, + AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build() + ) + } + } } } From b71eee105416588a104113e6f6a6657a6074aebd Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Mon, 4 Mar 2024 22:41:01 +0900 Subject: [PATCH 07/10] =?UTF-8?q?feat:=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=EA=B0=80=20=EA=B0=95=EC=A0=9C=20=EB=90=98=EC=97=88?= =?UTF-8?q?=EC=9D=84=EB=95=8C=20=EC=95=B1=EC=9D=84=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EB=AA=BB=ED=95=98=EA=B2=8C=EB=81=94=20UI?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/app/priceguard/ui/home/HomeActivity.kt | 7 ++++--- .../main/java/app/priceguard/ui/util/Dialog.kt | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt index d392011..a1bcbb3 100644 --- a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt +++ b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt @@ -20,10 +20,12 @@ import androidx.work.WorkManager import app.priceguard.R import app.priceguard.databinding.ActivityHomeBinding import app.priceguard.service.UpdateTokenWorker +import app.priceguard.ui.data.DialogConfirmAction import app.priceguard.ui.util.SystemNavigationColorState import app.priceguard.ui.util.applySystemNavigationBarColor import app.priceguard.ui.util.openNotificationSettings import app.priceguard.ui.util.showConfirmDialog +import app.priceguard.ui.util.showDialogWithAction import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.GoogleApiAvailability import com.google.android.material.snackbar.Snackbar @@ -179,12 +181,11 @@ class HomeActivity : AppCompatActivity() { registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult -> when (result.resultCode) { RESULT_CANCELED -> { - showConfirmDialog(getString(R.string.warning), getString(R.string.update_cancel_warning)) + showDialogWithAction(getString(R.string.warning), getString(R.string.update_cancel_warning), DialogConfirmAction.FINISH) } com.google.android.play.core.install.model.ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> { - Toast.makeText(this, getString(R.string.update_failed), Toast.LENGTH_LONG) - .show() + showDialogWithAction(getString(R.string.error), getString(R.string.update_failed), DialogConfirmAction.FINISH) } } } diff --git a/android/app/src/main/java/app/priceguard/ui/util/Dialog.kt b/android/app/src/main/java/app/priceguard/ui/util/Dialog.kt index 7b3de7e..5bf53dc 100644 --- a/android/app/src/main/java/app/priceguard/ui/util/Dialog.kt +++ b/android/app/src/main/java/app/priceguard/ui/util/Dialog.kt @@ -39,6 +39,23 @@ fun Fragment.showDialogWithAction( dialogFragment.show(requireActivity().supportFragmentManager, tag) } +fun AppCompatActivity.showDialogWithAction( + title: String, + message: String, + action: DialogConfirmAction = DialogConfirmAction.NOTHING +) { + val tag = "confirm_dialog_fragment_with_action_from_activity" + if (supportFragmentManager.findFragmentByTag(tag) != null) return + + val dialogFragment = ConfirmDialogFragment() + val bundle = Bundle() + bundle.putString("title", title) + bundle.putString("message", message) + bundle.putString("actionString", action.name) + dialogFragment.arguments = bundle + dialogFragment.show(supportFragmentManager, tag) +} + fun AppCompatActivity.showDialogWithLogout() { val tag = "error_dialog_fragment_from_activity" if (supportFragmentManager.findFragmentByTag(tag) != null) return From bd7064c8d39a7be6fc0c653cbb52bc219e3306e1 Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Wed, 6 Mar 2024 02:22:44 +0900 Subject: [PATCH 08/10] =?UTF-8?q?fix:=20=ED=95=84=EC=88=98=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=8B=9C=20=EA=B2=BD=EA=B3=A0=20?= =?UTF-8?q?=EB=AC=B8=EA=B5=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/src/main/java/app/priceguard/ui/home/HomeActivity.kt | 2 +- android/app/src/main/res/values/strings.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt index a1bcbb3..cda20ca 100644 --- a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt +++ b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt @@ -181,7 +181,7 @@ class HomeActivity : AppCompatActivity() { registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult -> when (result.resultCode) { RESULT_CANCELED -> { - showDialogWithAction(getString(R.string.warning), getString(R.string.update_cancel_warning), DialogConfirmAction.FINISH) + showDialogWithAction(getString(R.string.warning), getString(R.string.must_update), DialogConfirmAction.FINISH) } com.google.android.play.core.install.model.ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> { diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index d7473b6..87933d0 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -155,4 +155,5 @@ 업데이트 미적용시 앱 사용에 지장이 생길 수 있습니다. 업데이트에 실패하였습니다. 다시 시도해 주세요. 경고 + 필수 업데이트 미적용 시 앱 사용이 불가능 합니다. \ No newline at end of file From 6395070948809adeb52cdf3de01fecd221088c0b Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Wed, 6 Mar 2024 02:29:20 +0900 Subject: [PATCH 09/10] =?UTF-8?q?refactor:=20=EC=95=B1=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EB=A1=9C=EC=A7=81=20=EA=B0=84?= =?UTF-8?q?=EA=B2=B0=ED=95=98=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/priceguard/ui/home/HomeActivity.kt | 44 +++++-------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt index cda20ca..974385c 100644 --- a/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt +++ b/android/app/src/main/java/app/priceguard/ui/home/HomeActivity.kt @@ -194,43 +194,19 @@ class HomeActivity : AppCompatActivity() { private fun checkAppUpdates() { val appUpdateInfoTask = appUpdateManager.appUpdateInfo + var appUpdateOptions = AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build() + var activityResultLauncher = flexibleAppUpdateResultLauncher appUpdateInfoTask.addOnSuccessListener { info -> - if (info.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && - info.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE) - ) { - appUpdateManager.startUpdateFlowForResult( - info, - flexibleAppUpdateResultLauncher, - AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build() - ) - } - - if (info.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && - info.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE) && - info.updatePriority() >= 3 - ) { - appUpdateManager.startUpdateFlowForResult( - info, - immediateAppUpdateResultLauncher, - AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build() - ) - } - - if (info.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) { - if (info.updatePriority() >= 3) { - appUpdateManager.startUpdateFlowForResult( - info, - immediateAppUpdateResultLauncher, - AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build() - ) - } else { - appUpdateManager.startUpdateFlowForResult( - info, - flexibleAppUpdateResultLauncher, - AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build() - ) + when (info.updateAvailability()) { + UpdateAvailability.UPDATE_AVAILABLE, UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS -> { + if (info.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE) && info.updatePriority() >= 3) { + activityResultLauncher = immediateAppUpdateResultLauncher + appUpdateOptions = AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build() + } + appUpdateManager.startUpdateFlowForResult(info, activityResultLauncher, appUpdateOptions) } + else -> {} } } } From f06f7e23e9100de79837110cdf8f2e54a91bca83 Mon Sep 17 00:00:00 2001 From: Taewan Park Date: Wed, 6 Mar 2024 02:30:03 +0900 Subject: [PATCH 10/10] =?UTF-8?q?fix:=20=EB=AC=B8=EB=B2=95=EC=97=90=20?= =?UTF-8?q?=EB=A7=9E=EA=B2=8C=20=EB=AC=B8=EC=9E=90=EC=97=B4=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 87933d0..87aec21 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -152,7 +152,7 @@ 추천 상품이 준비중입니다. 품절 등록 가능한 상품 개수를 초과하였습니다. - 업데이트 미적용시 앱 사용에 지장이 생길 수 있습니다. + 업데이트 미적용 시 앱 사용에 지장이 생길 수 있습니다. 업데이트에 실패하였습니다. 다시 시도해 주세요. 경고 필수 업데이트 미적용 시 앱 사용이 불가능 합니다.