From 6d4eab47b7af0cd9d76a0f699045ede9fef706ae Mon Sep 17 00:00:00 2001 From: FerdyRod Date: Mon, 12 Feb 2024 14:42:01 +0100 Subject: [PATCH] Adds a no connection listener to Sync Dialog to show snackbar to users --- .../dataSetTable/DataSetTableActivity.kt | 13 ++++++++ .../datasetDetail/DataSetDetailActivity.java | 11 +++++++ .../datasetList/DataSetListFragment.kt | 17 +++++++++- .../eventCapture/EventCaptureActivity.kt | 13 ++++++++ .../org/dhis2/usescases/main/MainActivity.kt | 14 ++++++++ .../usescases/main/program/ProgramFragment.kt | 17 +++++++++- .../ProgramEventDetailActivity.kt | 32 +++++++++++++++++-- .../searchTrackEntity/SearchTEActivity.java | 21 ++++++++++-- .../TeiDashboardMobileActivity.kt | 16 +++++++++- .../teidata/TEIDataFragment.kt | 16 +++++++++- .../utils/granularsync/SyncStatusDialog.kt | 17 ++++++++++ .../granularsync/SyncStatusDialogProvider.kt | 3 ++ app/src/main/res/values/strings.xml | 1 + .../commons/sync/OnNoConnectionListener.kt | 5 +++ .../commons/sync/SyncComponentProvider.kt | 1 + .../java/org/dhis2/commons/sync/SyncDialog.kt | 2 ++ 16 files changed, 191 insertions(+), 8 deletions(-) create mode 100644 commons/src/main/java/org/dhis2/commons/sync/OnNoConnectionListener.kt diff --git a/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/DataSetTableActivity.kt b/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/DataSetTableActivity.kt index f4ac9f4095..27a71a94af 100644 --- a/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/DataSetTableActivity.kt +++ b/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/DataSetTableActivity.kt @@ -38,6 +38,7 @@ import org.dhis2.commons.extensions.closeKeyboard import org.dhis2.commons.matomo.Labels.Companion.CLICK import org.dhis2.commons.popupmenu.AppMenuHelper import org.dhis2.commons.sync.OnDismissListener +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.SyncContext import org.dhis2.databinding.ActivityDatasetTableBinding import org.dhis2.usescases.datasets.dataSetTable.dataSetDetail.DataSetDetailFragment.Companion.create @@ -172,6 +173,18 @@ class DataSetTableActivity : ActivityGlobalAbstract(), DataSetTableContract.View if (hasChanged) presenter.updateData() } }) + .onNoConnectionListener( + object : OnNoConnectionListener { + override fun onNoConnection() { + val contextView = findViewById(R.id.navigationBar) + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT, + ).show() + } + }, + ) .show(DATAVALUE_SYNC) } diff --git a/app/src/main/java/org/dhis2/usescases/datasets/datasetDetail/DataSetDetailActivity.java b/app/src/main/java/org/dhis2/usescases/datasets/datasetDetail/DataSetDetailActivity.java index 353e038802..e0529c293a 100644 --- a/app/src/main/java/org/dhis2/usescases/datasets/datasetDetail/DataSetDetailActivity.java +++ b/app/src/main/java/org/dhis2/usescases/datasets/datasetDetail/DataSetDetailActivity.java @@ -16,6 +16,8 @@ import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; +import com.google.android.material.snackbar.Snackbar; + import org.dhis2.App; import org.dhis2.R; import org.dhis2.bindings.ExtensionsKt; @@ -26,6 +28,7 @@ import org.dhis2.commons.filters.FiltersAdapter; import org.dhis2.commons.orgunitselector.OUTreeFragment; import org.dhis2.commons.sync.ConflictType; +import org.dhis2.commons.sync.OnNoConnectionListener; import org.dhis2.databinding.ActivityDatasetDetailBinding; import org.dhis2.ui.ThemeManager; import org.dhis2.usescases.datasets.datasetDetail.datasetList.DataSetListFragment; @@ -240,10 +243,18 @@ public void setProgress(boolean active) { @Override public void showGranularSync() { presenter.trackDataSetGranularSync(); + View contextView = findViewById(R.id.navigationBar); new SyncStatusDialog.Builder() .withContext(this, null) .withSyncContext(new SyncContext.DataSet(dataSetUid)) .onDismissListener(hasChanged -> presenter.refreshList()) + .onNoConnectionListener(() -> + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT + ).show() + ) .show("DATASET_SYNC"); } } diff --git a/app/src/main/java/org/dhis2/usescases/datasets/datasetDetail/datasetList/DataSetListFragment.kt b/app/src/main/java/org/dhis2/usescases/datasets/datasetDetail/datasetList/DataSetListFragment.kt index 2e75a4831b..f983002ab4 100644 --- a/app/src/main/java/org/dhis2/usescases/datasets/datasetDetail/datasetList/DataSetListFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/datasets/datasetDetail/datasetList/DataSetListFragment.kt @@ -5,9 +5,11 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.viewModels +import com.google.android.material.snackbar.Snackbar import org.dhis2.R import org.dhis2.commons.Constants import org.dhis2.commons.sync.OnDismissListener +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.SyncContext import org.dhis2.databinding.FragmentDataSetListBinding import org.dhis2.usescases.datasets.dataSetTable.DataSetTableActivity @@ -132,7 +134,20 @@ class DataSetListFragment : FragmentGlobalAbstract() { viewModel.updateData() } } - }).show(FRAGMENT_TAG) + }) + .onNoConnectionListener( + object : OnNoConnectionListener { + override fun onNoConnection() { + val contextView = activity.findViewById(R.id.navigationBar) + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT, + ).show() + } + }, + ) + .show(FRAGMENT_TAG) } companion object { diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCaptureActivity.kt b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCaptureActivity.kt index f2cdb99aa2..3adb553017 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCaptureActivity.kt +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCaptureActivity.kt @@ -22,6 +22,7 @@ import org.dhis2.commons.dialogs.AlertBottomDialog import org.dhis2.commons.dialogs.CustomDialog import org.dhis2.commons.dialogs.DialogClickListener import org.dhis2.commons.popupmenu.AppMenuHelper +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.SyncContext import org.dhis2.databinding.ActivityEventCaptureBinding import org.dhis2.ui.ErrorFieldList @@ -444,6 +445,18 @@ class EventCaptureActivity : SyncStatusDialog.Builder() .withContext(this) .withSyncContext(SyncContext.Event(eventUid!!)) + .onNoConnectionListener( + object : OnNoConnectionListener { + override fun onNoConnection() { + val contextView = findViewById(R.id.navigationBar) + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT, + ).show() + } + }, + ) .show("EVENT_SYNC") } diff --git a/app/src/main/java/org/dhis2/usescases/main/MainActivity.kt b/app/src/main/java/org/dhis2/usescases/main/MainActivity.kt index a4f8ab5539..26f4a3c4dd 100644 --- a/app/src/main/java/org/dhis2/usescases/main/MainActivity.kt +++ b/app/src/main/java/org/dhis2/usescases/main/MainActivity.kt @@ -22,6 +22,7 @@ import androidx.core.view.ViewCompat import androidx.databinding.DataBindingUtil import androidx.drawerlayout.widget.DrawerLayout import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.google.android.material.snackbar.Snackbar import org.dhis2.BuildConfig import org.dhis2.R import org.dhis2.bindings.app @@ -30,6 +31,7 @@ import org.dhis2.commons.filters.FilterItem import org.dhis2.commons.filters.FilterManager import org.dhis2.commons.filters.FiltersAdapter import org.dhis2.commons.sync.OnDismissListener +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.SyncContext import org.dhis2.databinding.ActivityMainBinding import org.dhis2.ui.dialogs.alert.AlertDialog @@ -304,6 +306,18 @@ class MainActivity : } }, ) + .onNoConnectionListener( + object : OnNoConnectionListener { + override fun onNoConnection() { + val contextView = findViewById(R.id.navigationBar) + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT, + ).show() + } + }, + ) .show("ALL_SYNC") } diff --git a/app/src/main/java/org/dhis2/usescases/main/program/ProgramFragment.kt b/app/src/main/java/org/dhis2/usescases/main/program/ProgramFragment.kt index 66430c381f..53294c5e57 100644 --- a/app/src/main/java/org/dhis2/usescases/main/program/ProgramFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/main/program/ProgramFragment.kt @@ -16,6 +16,7 @@ import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.core.view.ViewCompat import androidx.databinding.DataBindingUtil +import com.google.android.material.snackbar.Snackbar import org.dhis2.App import org.dhis2.R import org.dhis2.android.rtsm.commons.Constants.INTENT_EXTRA_APP_CONFIG @@ -27,6 +28,7 @@ import org.dhis2.bindings.dp import org.dhis2.commons.filters.FilterManager import org.dhis2.commons.orgunitselector.OUTreeFragment import org.dhis2.commons.sync.OnDismissListener +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.SyncContext import org.dhis2.databinding.FragmentProgramBinding import org.dhis2.usescases.general.FragmentGlobalAbstract @@ -220,7 +222,20 @@ class ProgramFragment : FragmentGlobalAbstract(), ProgramView { } } }, - ).show(FRAGMENT_TAG) + ) + .onNoConnectionListener( + object : OnNoConnectionListener { + override fun onNoConnection() { + val contextView = activity?.findViewById(R.id.navigationBar) + Snackbar.make( + contextView!!, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT, + ).show() + } + }, + ) + .show(FRAGMENT_TAG) } fun sharedView() = binding.drawerLayout diff --git a/app/src/main/java/org/dhis2/usescases/programEventDetail/ProgramEventDetailActivity.kt b/app/src/main/java/org/dhis2/usescases/programEventDetail/ProgramEventDetailActivity.kt index baa4b748e6..dd81e4506f 100644 --- a/app/src/main/java/org/dhis2/usescases/programEventDetail/ProgramEventDetailActivity.kt +++ b/app/src/main/java/org/dhis2/usescases/programEventDetail/ProgramEventDetailActivity.kt @@ -12,6 +12,7 @@ import androidx.activity.viewModels import androidx.constraintlayout.widget.ConstraintSet import androidx.databinding.DataBindingUtil import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.google.android.material.snackbar.Snackbar import dhis2.org.analytics.charts.ui.GroupAnalyticsFragment import org.dhis2.R import org.dhis2.bindings.app @@ -27,6 +28,7 @@ import org.dhis2.commons.matomo.Actions.Companion.CREATE_EVENT import org.dhis2.commons.network.NetworkUtils import org.dhis2.commons.orgunitselector.OUTreeFragment import org.dhis2.commons.sync.OnDismissListener +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.SyncContext import org.dhis2.databinding.ActivityProgramEventDetailBinding import org.dhis2.ui.ThemeManager @@ -195,7 +197,20 @@ class ProgramEventDetailActivity : override fun onDismiss(hasChanged: Boolean) { if (hasChanged) FilterManager.getInstance().publishData() } - }).show("EVENT_SYNC") + }) + .onNoConnectionListener( + object : OnNoConnectionListener { + override fun onNoConnection() { + val contextView = findViewById(R.id.navigationBar) + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT, + ).show() + } + }, + ) + .show("EVENT_SYNC") } public override fun onPause() { @@ -376,7 +391,20 @@ class ProgramEventDetailActivity : override fun onDismiss(hasChanged: Boolean) { if (hasChanged) FilterManager.getInstance().publishData() } - }).show(FRAGMENT_TAG) + }) + .onNoConnectionListener( + object : OnNoConnectionListener { + override fun onNoConnection() { + val contextView = findViewById(R.id.rootView) + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT, + ).show() + } + }, + ) + .show(FRAGMENT_TAG) } private fun showList() { diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEActivity.java b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEActivity.java index e504510e75..da8a6e8c81 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEActivity.java +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEActivity.java @@ -332,6 +332,7 @@ protected void onSaveInstanceState(@NonNull Bundle outState) { } private void openSyncDialog() { + View contextView = findViewById(R.id.navigationBar); new SyncStatusDialog.Builder() .withContext(this, null) .withSyncContext( @@ -339,7 +340,15 @@ private void openSyncDialog() { ) .onDismissListener(hasChanged -> { if (hasChanged) viewModel.refreshData(); - }).show("PROGRAM_SYNC"); + }) + .onNoConnectionListener(() -> + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT + ).show() + ) + .show("PROGRAM_SYNC"); } @Override @@ -582,6 +591,7 @@ public void setPrograms(List programs) { @Override public void showSyncDialog(String enrollmentUid) { + View contextView = findViewById(R.id.navigationBar); new SyncStatusDialog.Builder() .withContext(this, null) .withSyncContext( @@ -589,7 +599,14 @@ public void showSyncDialog(String enrollmentUid) { ) .onDismissListener(hasChanged -> { if (hasChanged) viewModel.refreshData(); - }).show("TEI_SYNC"); + }) + .onNoConnectionListener(() -> + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT + ).show() + ).show("TEI_SYNC"); } private void setInitialProgram(List programs) { diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardMobileActivity.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardMobileActivity.kt index b6ddd5bcde..618035a257 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardMobileActivity.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardMobileActivity.kt @@ -21,6 +21,7 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModelProvider import androidx.viewpager2.widget.ViewPager2 +import com.google.android.material.snackbar.Snackbar import org.dhis2.App import org.dhis2.R import org.dhis2.commons.Constants @@ -30,6 +31,7 @@ import org.dhis2.commons.filters.Filters import org.dhis2.commons.network.NetworkUtils import org.dhis2.commons.popupmenu.AppMenuHelper import org.dhis2.commons.sync.OnDismissListener +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.SyncContext import org.dhis2.databinding.ActivityDashboardMobileBinding import org.dhis2.ui.ThemeManager @@ -292,7 +294,19 @@ class TeiDashboardMobileActivity : finish() } } - }).show(TEI_SYNC) + }) + .onNoConnectionListener( + object : OnNoConnectionListener { + override fun onNoConnection() { + val contextView = findViewById(R.id.navigationBar) + Snackbar.make( + contextView, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT, + ).show() + } + }, + ).show(TEI_SYNC) } } diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt index 145ef18362..87591930ac 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt @@ -18,6 +18,7 @@ import androidx.recyclerview.widget.DividerItemDecoration import com.bumptech.glide.Glide import com.bumptech.glide.load.resource.bitmap.CircleCrop import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions +import com.google.android.material.snackbar.Snackbar import io.reactivex.Flowable import io.reactivex.Single import io.reactivex.functions.Consumer @@ -40,6 +41,7 @@ import org.dhis2.commons.orgunitselector.OUTreeFragment import org.dhis2.commons.resources.ColorUtils import org.dhis2.commons.resources.ObjectStyleUtils.getIconResource import org.dhis2.commons.sync.OnDismissListener +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.SyncContext.EnrollmentEvent import org.dhis2.databinding.FragmentTeiDataBinding import org.dhis2.usescases.eventsWithoutRegistration.eventInitial.EventInitialActivity @@ -619,7 +621,19 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { override fun onDismiss(hasChanged: Boolean) { if (hasChanged) FilterManager.getInstance().publishData() } - }).show(enrollmentUid) + }) + .onNoConnectionListener( + object : OnNoConnectionListener { + override fun onNoConnection() { + val contextView = activity?.findViewById(R.id.navigationBar) + Snackbar.make( + contextView!!, + R.string.sync_offline_check_connection, + Snackbar.LENGTH_SHORT, + ).show() + } + }, + ).show(enrollmentUid) } override fun displayCatComboOptionSelectorForEvents(data: List) { diff --git a/app/src/main/java/org/dhis2/utils/granularsync/SyncStatusDialog.kt b/app/src/main/java/org/dhis2/utils/granularsync/SyncStatusDialog.kt index 4f93b3944b..786e279a7b 100644 --- a/app/src/main/java/org/dhis2/utils/granularsync/SyncStatusDialog.kt +++ b/app/src/main/java/org/dhis2/utils/granularsync/SyncStatusDialog.kt @@ -32,6 +32,7 @@ import org.dhis2.bindings.showSMS import org.dhis2.commons.date.toDateSpan import org.dhis2.commons.network.NetworkUtils import org.dhis2.commons.sync.OnDismissListener +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.OnSyncNavigationListener import org.dhis2.commons.sync.SyncContext import org.dhis2.commons.ui.icons.SyncStateIcon @@ -69,6 +70,8 @@ class SyncStatusDialog : BottomSheetDialogFragment(), GranularSyncContracts.View private val viewModel: GranularSyncPresenter by viewModels { viewModelFactory } + var onNoConnectionListener: OnNoConnectionListener? = null + override fun onAttach(context: Context) { super.onAttach(context) (context.applicationContext as App).serverComponent()!!.plus( @@ -172,9 +175,16 @@ class SyncStatusDialog : BottomSheetDialogFragment(), GranularSyncContracts.View networkUtils.isOnline() -> syncGranular() viewModel.canSendSMS() && viewModel.isSMSEnabled(context?.showSMS() == true) -> syncSms() + !networkUtils.isOnline() && + !viewModel.isSMSEnabled(context?.showSMS() == true) -> showSnackbar() } } + private fun showSnackbar() { + dismiss() + onNoConnectionListener?.onNoConnection() + } + private fun syncGranular() { syncing = true viewModel.initGranularSync().observe( @@ -335,6 +345,7 @@ class SyncStatusDialog : BottomSheetDialogFragment(), GranularSyncContracts.View private var navigator: SyncStatusDialogNavigator? = null private lateinit var syncContext: SyncContext private var dismissListener: OnDismissListener? = null + private var noConnectionListener: OnNoConnectionListener? = null fun withContext( context: FragmentActivity, @@ -372,12 +383,18 @@ class SyncStatusDialog : BottomSheetDialogFragment(), GranularSyncContracts.View return this } + fun onNoConnectionListener(noConnectionListener: OnNoConnectionListener): Builder { + this.noConnectionListener = noConnectionListener + return this + } + private fun build(): SyncStatusDialog { return SyncStatusDialog().apply { arguments = Bundle().apply { putParcelable(SYNC_CONTEXT, syncContext) } dismissListenerDialog = dismissListener + onNoConnectionListener = noConnectionListener syncStatusDialogNavigator = navigator } } diff --git a/app/src/main/java/org/dhis2/utils/granularsync/SyncStatusDialogProvider.kt b/app/src/main/java/org/dhis2/utils/granularsync/SyncStatusDialogProvider.kt index ff67e89a02..8cdd3e45eb 100644 --- a/app/src/main/java/org/dhis2/utils/granularsync/SyncStatusDialogProvider.kt +++ b/app/src/main/java/org/dhis2/utils/granularsync/SyncStatusDialogProvider.kt @@ -2,6 +2,7 @@ package org.dhis2.utils.granularsync import androidx.fragment.app.FragmentActivity import org.dhis2.commons.sync.OnDismissListener +import org.dhis2.commons.sync.OnNoConnectionListener import org.dhis2.commons.sync.OnSyncNavigationListener import org.dhis2.commons.sync.SyncComponentProvider import org.dhis2.commons.sync.SyncContext @@ -13,6 +14,7 @@ class SyncStatusDialogProvider : SyncComponentProvider { syncContext: SyncContext, dismissListener: OnDismissListener?, onSyncNavigationListener: OnSyncNavigationListener?, + onNoConnectionListener: OnNoConnectionListener?, ) { val syncBuilder = SyncStatusDialog.Builder() .withContext(activity, onSyncNavigationListener) @@ -20,6 +22,7 @@ class SyncStatusDialogProvider : SyncComponentProvider { with(syncBuilder) { dismissListener?.let { onDismissListener(it) } + onNoConnectionListener?.let { onNoConnectionListener(it) } } syncBuilder .show(syncContext.conflictType().name) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a6240e2fb7..4e81363953 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -975,4 +975,5 @@ Remove Coordinates You don’t have access to data.\nContact your administrator. + Looks like you\'re offline. Please check you connection diff --git a/commons/src/main/java/org/dhis2/commons/sync/OnNoConnectionListener.kt b/commons/src/main/java/org/dhis2/commons/sync/OnNoConnectionListener.kt new file mode 100644 index 0000000000..5817f18355 --- /dev/null +++ b/commons/src/main/java/org/dhis2/commons/sync/OnNoConnectionListener.kt @@ -0,0 +1,5 @@ +package org.dhis2.commons.sync + +interface OnNoConnectionListener { + fun onNoConnection() +} diff --git a/commons/src/main/java/org/dhis2/commons/sync/SyncComponentProvider.kt b/commons/src/main/java/org/dhis2/commons/sync/SyncComponentProvider.kt index dd7065caa7..4c820108bf 100644 --- a/commons/src/main/java/org/dhis2/commons/sync/SyncComponentProvider.kt +++ b/commons/src/main/java/org/dhis2/commons/sync/SyncComponentProvider.kt @@ -8,5 +8,6 @@ interface SyncComponentProvider { syncContext: SyncContext, dismissListener: OnDismissListener? = null, onSyncNavigationListener: OnSyncNavigationListener? = null, + onNoConnectionListener: OnNoConnectionListener? = null, ) } diff --git a/commons/src/main/java/org/dhis2/commons/sync/SyncDialog.kt b/commons/src/main/java/org/dhis2/commons/sync/SyncDialog.kt index 6a8ae720f5..021572a310 100644 --- a/commons/src/main/java/org/dhis2/commons/sync/SyncDialog.kt +++ b/commons/src/main/java/org/dhis2/commons/sync/SyncDialog.kt @@ -9,6 +9,7 @@ class SyncDialog( val syncContext: SyncContext, private val dismissListener: OnDismissListener? = null, private val onSyncNavigationListener: OnSyncNavigationListener? = null, + private val onNoConnectionListener: OnNoConnectionListener? = null, ) { fun show() { (activity.applicationContext as? ComponentProvider) @@ -18,6 +19,7 @@ class SyncDialog( syncContext, dismissListener, onSyncNavigationListener, + onNoConnectionListener, ) } }