schedule two-way-sync via isTwoWaySyncEnabled

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-10-30 10:47:06 +01:00 committed by Alper Öztürk
parent 832a63b5a6
commit 488589d2a7
4 changed files with 16 additions and 1 deletions

View file

@ -171,4 +171,5 @@ interface BackgroundJobManager {
fun startOfflineOperations()
fun startPeriodicallyOfflineOperation()
fun scheduleInternal2WaySync(intervalMinutes: Long)
fun cancelInternal2WaySyncJob()
}

View file

@ -707,4 +707,8 @@ internal class BackgroundJobManagerImpl(
workManager.enqueueUniquePeriodicWork(JOB_INTERNAL_TWO_WAY_SYNC, ExistingPeriodicWorkPolicy.UPDATE, request)
}
override fun cancelInternal2WaySyncJob() {
workManager.cancelJob(JOB_INTERNAL_TWO_WAY_SYNC)
}
}

View file

@ -375,7 +375,11 @@ public class MainApp extends Application implements HasAndroidInjector, NetworkC
backgroundJobManager.scheduleMediaFoldersDetectionJob();
backgroundJobManager.startMediaFoldersDetectionJob();
backgroundJobManager.schedulePeriodicHealthStatus();
backgroundJobManager.scheduleInternal2WaySync(preferences.getTwoWaySyncInterval());
if (preferences.isTwoWaySyncEnabled()) {
backgroundJobManager.scheduleInternal2WaySync(preferences.getTwoWaySyncInterval());
}
backgroundJobManager.startPeriodicallyOfflineOperation();
}

View file

@ -79,6 +79,12 @@ class InternalTwoWaySyncActivity : BaseActivity(), Injectable {
preferences.setTwoWaySyncStatus(isChecked)
setupList()
setVisibilities()
if (isChecked) {
backgroundJobManager.scheduleInternal2WaySync(preferences.twoWaySyncInterval)
} else {
backgroundJobManager.cancelInternal2WaySyncJob()
}
}
}