From 8bb1eaaf2e86623e42175aa7597daabc41e9b0b3 Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Thu, 16 May 2024 19:54:24 +0200 Subject: [PATCH] fix spotless Signed-off-by: Jonas Mayer --- .../client/jobs/BackgroundJobManager.kt | 2 +- .../client/jobs/BackgroundJobManagerImpl.kt | 6 +++--- .../client/jobs/ContentObserverWork.kt | 7 ++++++- .../com/nextcloud/client/jobs/FilesSyncWork.kt | 18 ++++++++++++------ .../ui/activity/SyncedFoldersActivity.kt | 2 +- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManager.kt b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManager.kt index 7578657009..36f6dc9218 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManager.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManager.kt @@ -128,7 +128,7 @@ interface BackgroundJobManager { fun startImmediateFilesSyncJob( syncedFolderID: Long, overridePowerSaving: Boolean = false, - changedFiles: Array = arrayOf(), + changedFiles: Array = arrayOf() ) fun scheduleOfflineSync() diff --git a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt index 3b8b2dbb88..c8bd86153a 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt @@ -405,8 +405,8 @@ internal class BackgroundJobManagerImpl( } override fun bothFilesSyncJobsRunning(syncedFolderID: Long): Boolean { - return workManager.isWorkRunning(JOB_PERIODIC_FILES_SYNC+"_"+syncedFolderID) && - workManager.isWorkRunning(JOB_IMMEDIATE_FILES_SYNC+"_"+syncedFolderID) + return workManager.isWorkRunning(JOB_PERIODIC_FILES_SYNC + "_" + syncedFolderID) && + workManager.isWorkRunning(JOB_IMMEDIATE_FILES_SYNC + "_" + syncedFolderID) } override fun schedulePeriodicFilesSyncJob( @@ -429,7 +429,7 @@ internal class BackgroundJobManagerImpl( override fun startImmediateFilesSyncJob( syncedFolderID: Long, overridePowerSaving: Boolean, - changedFiles: Array, + changedFiles: Array ) { val arguments = Data.Builder() .putBoolean(FilesSyncWork.OVERRIDE_POWER_SAVING, overridePowerSaving) diff --git a/app/src/main/java/com/nextcloud/client/jobs/ContentObserverWork.kt b/app/src/main/java/com/nextcloud/client/jobs/ContentObserverWork.kt index 72389e9a37..25724d4035 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/ContentObserverWork.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/ContentObserverWork.kt @@ -54,7 +54,12 @@ class ContentObserverWork( for (uri in params.triggeredContentUris) { changedFiles.add(uri.toString()) } - FilesSyncHelper.startFilesSyncForAllFolders(syncedFolderProvider, backgroundJobManager, false, changedFiles.toTypedArray()) + FilesSyncHelper.startFilesSyncForAllFolders( + syncedFolderProvider, + backgroundJobManager, + false, + changedFiles.toTypedArray() + ) } } diff --git a/app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt b/app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt index 97e80addf2..5bea81e5e1 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt @@ -64,7 +64,6 @@ class FilesSyncWork( private lateinit var syncedFolder: SyncedFolder - @Suppress("ReturnCount") private fun canExitEarly(changedFiles: Array?, syncedFolderID: Long): Boolean { // If we are in power save mode better to postpone scan and upload @@ -81,18 +80,21 @@ class FilesSyncWork( // or sync worker already running and no changed files to be processed val alreadyRunning = backgroundJobManager.bothFilesSyncJobsRunning(syncedFolderID) if (alreadyRunning && changedFiles.isNullOrEmpty()) { - Log_OC.d(TAG, "File-sync kill worker since another instance of the worker ($syncedFolderID) seems to be running already!") + Log_OC.d( + TAG, + "File-sync kill worker since another instance of the worker " + + "($syncedFolderID) seems to be running already!" + ) return true } val syncedFolderTmp = syncedFolderProvider.getSyncedFolderByID(syncedFolderID) if (syncedFolderTmp == null || !syncedFolderTmp.isEnabled || !syncedFolderTmp.isExisting) { - Log_OC.d(TAG, "File-sync kill worker since syncedFolder (${syncedFolderID}) is not enabled!") + Log_OC.d(TAG, "File-sync kill worker since syncedFolder ($syncedFolderID) is not enabled!") return true } syncedFolder = syncedFolderTmp - if (syncedFolder.isChargingOnly && !powerManagementService.battery.isCharging && !powerManagementService.battery.isFull @@ -109,7 +111,7 @@ class FilesSyncWork( val syncFolderId = inputData.getLong(SYNCED_FOLDER_ID, -1) val changedFiles = inputData.getStringArray(CHANGED_FILES) - backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class)+"_"+syncFolderId) + backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class) + "_" + syncFolderId) Log_OC.d(TAG, "File-sync worker started for folder ID: $syncFolderId") if (canExitEarly(changedFiles, syncFolderId)) { @@ -128,7 +130,11 @@ class FilesSyncWork( ) // Get changed files from ContentObserverWork (only images and videos) or by scanning filesystem - Log_OC.d(TAG, "File-sync worker (${syncedFolder.remotePath}) changed files from observer: " + changedFiles.contentToString()) + Log_OC.d( + TAG, + "File-sync worker (${syncedFolder.remotePath}) changed files from observer: " + + changedFiles.contentToString() + ) collectChangedFiles(changedFiles) Log_OC.d(TAG, "File-sync worker (${syncedFolder.remotePath}) finished checking files.") diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt index ff63450d7c..35769aa590 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt @@ -571,7 +571,7 @@ class SyncedFoldersActivity : } } if (syncedFolderDisplayItem.isEnabled) { - backgroundJobManager.startImmediateFilesSyncJob(syncedFolderDisplayItem.id ,overridePowerSaving = false) + backgroundJobManager.startImmediateFilesSyncJob(syncedFolderDisplayItem.id, overridePowerSaving = false) showBatteryOptimizationInfo() } }