Skip to content

Commit

Permalink
mylife: smoother myhealth background sync (fixes #5065) (#5066)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Jan 17, 2025
1 parent cc97f01 commit eedf082
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 26
targetSdkVersion 34
versionCode 2219
versionName "0.22.19"
versionCode 2220
versionName "0.22.20"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/org/ole/planet/myplanet/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.ole.planet.myplanet.MainApplication
import org.ole.planet.myplanet.base.BaseResourceFragment.Companion.backgroundDownload
import org.ole.planet.myplanet.base.BaseResourceFragment.Companion.getAllLibraryList
import org.ole.planet.myplanet.callback.TeamPageListener
Expand Down Expand Up @@ -64,7 +63,6 @@ class MainApplication : Application(), Application.ActivityLifecycleCallbacks {
var isCollectionSwitchOn = false
var showDownload = false
var isSyncRunning = false
var showHealthDialog = true
var listener: TeamPageListener? = null
val androidId: String get() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,6 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa
}

override fun syncKeyId() {
di = DialogUtils.CustomProgressDialog(requireContext())
di?.setText(getString(R.string.syncing_health_please_wait))
if (model?.getRoleAsString()?.contains("health") == true) {
settings?.let { TransactionSyncManager.syncAllHealthData(mRealm, it, this) }
} else {
Expand All @@ -400,12 +398,10 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa

override fun onSyncComplete() {
di?.dismiss()
Utilities.toast(activity, getString(R.string.myhealth_synced_successfully))
}

override fun onSyncFailed(msg: String?) {
di?.dismiss()
Utilities.toast(activity, getString(R.string.myhealth_synced_failed))
}

override fun showTaskListDialog() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.ole.planet.myplanet.ui.dashboard

import android.content.DialogInterface
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
Expand All @@ -19,7 +18,6 @@ import androidx.recyclerview.widget.RecyclerView
import io.realm.Case
import io.realm.Realm
import kotlinx.coroutines.*
import org.ole.planet.myplanet.MainApplication
import org.ole.planet.myplanet.R
import org.ole.planet.myplanet.databinding.FragmentHomeBellBinding
import org.ole.planet.myplanet.model.RealmCertification
Expand Down Expand Up @@ -66,13 +64,8 @@ class BellDashboardFragment : BaseDashboardFragment() {
showBadges()
checkPendingSurveys()

if (model?.id?.startsWith("guest") == false && TextUtils.isEmpty(model?.key) && MainApplication.showHealthDialog) {
AlertDialog.Builder(requireActivity(), R.style.CustomAlertDialog)
.setMessage(getString(R.string.health_record_not_available_sync_health_data))
.setPositiveButton(getString(R.string.sync)) { _: DialogInterface?, _: Int ->
syncKeyId()
MainApplication.showHealthDialog = false
}.setNegativeButton(getString(R.string.cancel), null).show()
if (model?.id?.startsWith("guest") == false && TextUtils.isEmpty(model?.key)) {
syncKeyId()
}
}

Expand Down

0 comments on commit eedf082

Please sign in to comment.