Skip to content

Commit

Permalink
Merge pull request #85 from IITA-AKILIMO/develop
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
masgeek authored Sep 11, 2023
2 parents 5d1c6ab + 18d123b commit 1a12562
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 11 additions & 6 deletions app/src/main/java/com/akilimo/rya/updates/InAppUpdate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.google.android.material.snackbar.Snackbar
import com.google.android.play.core.appupdate.AppUpdateInfo
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.InstallState
import com.google.android.play.core.install.InstallStateUpdatedListener
import com.google.android.play.core.install.model.AppUpdateType
Expand All @@ -20,7 +21,7 @@ class InAppUpdate(private val parentActivity: Activity) {
private val appUpdateManager: AppUpdateManager?
private var updateType = AppUpdateType.FLEXIBLE
private val UPDATE_REQUEST_CODE = 500
private val RESULT_CANCELLED = 501
private val RESULT_CANCELLED = 0

init {
appUpdateManager = AppUpdateManagerFactory.create(parentActivity)
Expand All @@ -35,15 +36,19 @@ class InAppUpdate(private val parentActivity: Activity) {
}

fun checkForUpdates() {
appUpdateManager!!.appUpdateInfo.addOnSuccessListener { info: AppUpdateInfo ->
val isUpdateAvailable = info.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
val updateAllowed = info.isUpdateTypeAllowed(updateType)
appUpdateManager!!.appUpdateInfo.addOnSuccessListener { updateInfo: AppUpdateInfo ->
val isUpdateAvailable =
updateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
val updateAllowed = updateInfo.isUpdateTypeAllowed(updateType)
if (isUpdateAvailable && updateAllowed) {
val updateOptions = AppUpdateOptions
.newBuilder(updateType)
.build()
try {
appUpdateManager.startUpdateFlowForResult(
info,
updateType,
updateInfo,
parentActivity,
updateOptions,
UPDATE_REQUEST_CODE
)
} catch (ex: SendIntentException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.SpinnerAdapter
import android.widget.Toast
import android.window.OnBackInvokedDispatcher
import androidx.appcompat.app.AppCompatActivity
import com.akilimo.rya.AppDatabase
import com.akilimo.rya.adapter.MySpinnerAdapter
Expand Down Expand Up @@ -274,6 +275,9 @@ class UserProfileActivity : AppCompatActivity() {
finish()
}



@Deprecated("Deprecated in Java")
override fun onBackPressed() {
super.onBackPressed()
if (!hasError) {
Expand Down

0 comments on commit 1a12562

Please sign in to comment.