From a22fbd1989ed761a5017395c89e18e22187d66d9 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 8 Apr 2024 17:33:48 +0200 Subject: [PATCH 01/12] refactor(convert WorkRequestFactory to kotlin): create kotlin class and implement periodic scan creation method --- .../foundation/e/drive/work/WorkLauncher.kt | 5 +- .../e/drive/work/WorkRequestFactory.java | 62 +--------------- .../e/drive/work/WorkRequestFactory.kt | 73 +++++++++++++++++++ 3 files changed, 77 insertions(+), 63 deletions(-) create mode 100644 app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt diff --git a/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt b/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt index ab0324f8..f79e2d68 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt @@ -18,7 +18,6 @@ import foundation.e.drive.periodicScan.FullScanWorker import foundation.e.drive.periodicScan.PeriodicScanWorker import foundation.e.drive.synchronization.SyncWorker import foundation.e.drive.utils.RootSyncedFolderProvider -import foundation.e.drive.work.WorkRequestFactory.WorkType /** * @author Vincent Bourgmayer @@ -40,7 +39,7 @@ class WorkLauncher private constructor(context: Context) { } fun enqueuePeriodicUserInfoFetching() { - val request = WorkRequestFactory.getPeriodicWorkRequest(WorkType.PERIODIC_USER_INFO) + val request = WorkRequestFactory.getPeriodicWorkRequest(PeriodicWorkType.FETCH_USER_INFO) workManager.enqueueUniquePeriodicWork( AccountUserInfoWorker.UNIQUE_WORK_NAME, ExistingPeriodicWorkPolicy.UPDATE, @@ -49,7 +48,7 @@ class WorkLauncher private constructor(context: Context) { } fun enqueuePeriodicFullScan() { - val request = WorkRequestFactory.getPeriodicWorkRequest(WorkType.PERIODIC_SCAN) + val request = WorkRequestFactory.getPeriodicWorkRequest(PeriodicWorkType.PERIODIC_SCAN) workManager.enqueueUniquePeriodicWork(PeriodicScanWorker.UNIQUE_WORK_NAME, ExistingPeriodicWorkPolicy.KEEP, request) diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java index 460ed576..139a949e 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java @@ -39,13 +39,11 @@ import foundation.e.drive.account.setup.RootFolderSetupWorker; import foundation.e.drive.models.SyncedFolder; import foundation.e.drive.periodicScan.FullScanWorker; import foundation.e.drive.periodicScan.ListAppsWorker; -import foundation.e.drive.periodicScan.PeriodicScanWorker; + import foundation.e.drive.synchronization.SyncWorker; public class WorkRequestFactory { public enum WorkType { - PERIODIC_USER_INFO, - PERIODIC_SCAN, ONE_TIME_FULL_SCAN, ONE_TIME_FORCED_FULL_SCAN, ONE_TIME_APP_LIST, @@ -55,64 +53,7 @@ public class WorkRequestFactory { ONE_TIME_SYNC } - private final static int PERIODIC_WORK_REPEAT_INTERVAL = 30; - private final static int PERIODIC_SCAN_FLEX_TIME = 5; - - /** - * Build an instance of PeriodicWorkRequest depending of the work type specified - * @param type WorkType. Should be FULL_SCAN or PERIODIC_USER_INFO or PERIODIC_APP_LIST - * If not, it will throw an InvalidParameterException - * @return Periodic WorkRequest - */ - @NonNull - public static PeriodicWorkRequest getPeriodicWorkRequest(@NonNull WorkType type) { - switch (type) { - case PERIODIC_SCAN: - return createPeriodicScanWorkRequest(); - case PERIODIC_USER_INFO: - return createPeriodicGetUserInfoWorkRequest(); - default: - throw new InvalidParameterException("Unsupported Work Type: " + type); - } - } - - /** - * Create a PeriodicWorkRequest instance for - * a Full scan with constraints on network (should - * be unmetered) and battery (shouldn't be low) - * @return instance of PeriodicWorkRequest - */ - @NonNull - private static PeriodicWorkRequest createPeriodicScanWorkRequest() { - final Constraints constraints = createUnmeteredNetworkAndHighBatteryConstraints(); - - final PeriodicWorkRequest.Builder workRequestBuilder = new PeriodicWorkRequest.Builder( - PeriodicScanWorker.class, - PERIODIC_WORK_REPEAT_INTERVAL, MINUTES, - PERIODIC_SCAN_FLEX_TIME, MINUTES); - - return workRequestBuilder.setConstraints(constraints) - .addTag(WORK_GENERIC_TAG) - .build(); - } - - /** - * Create a periodic work request to get userInfo - * @return instance of PeriodicWorkRequest - */ - @NonNull - private static PeriodicWorkRequest createPeriodicGetUserInfoWorkRequest() { - final Constraints constraints = new Constraints.Builder() - .setRequiredNetworkType(NetworkType.CONNECTED) - .build(); - - final PeriodicWorkRequest.Builder workRequestBuilder = new PeriodicWorkRequest.Builder(AccountUserInfoWorker.class, - PERIODIC_WORK_REPEAT_INTERVAL, MINUTES); - return workRequestBuilder.addTag(WORK_GENERIC_TAG) - .setConstraints(constraints) - .build(); - } /** * Build an instance of OneTimeWorkRequest depending of the work type specified. @@ -257,6 +198,7 @@ public class WorkRequestFactory { .build(); } + /** * Parse SyncedFolder instance in Data, used as data for WorkRequest * @param folder SyncedFolder instance diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt new file mode 100644 index 00000000..186f4f76 --- /dev/null +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt @@ -0,0 +1,73 @@ +package foundation.e.drive.work + +import androidx.work.Constraints +import androidx.work.NetworkType +import androidx.work.PeriodicWorkRequest +import androidx.work.PeriodicWorkRequestBuilder +import foundation.e.drive.account.AccountUserInfoWorker +import foundation.e.drive.periodicScan.PeriodicScanWorker +import foundation.e.drive.utils.AppConstants.WORK_GENERIC_TAG +import java.util.concurrent.TimeUnit.MINUTES + + +enum class PeriodicWorkType { + PERIODIC_FETCH_USER_INFO, + PERIODIC_SCAN} + +enum class OneTimeWorkType { + ONE_TIME_FULL_SCAN, + ONE_TIME_FORCED_FULL_SCAN, + ONE_TIME_APP_LIST, + ONE_TIME_USER_INFO, + ONE_TIME_ROOT_FOLDER_SETUP, + ONE_TIME_FINISH_SETUP, + ONE_TIME_SYNC +} +object WorkRequestFactory { + + private val PERIODIC_WORK_REPEAT_INTERVAL = 30L + private val PERIODIC_SCAN_FLEX_TIME = 5L + + /** + * Build an instance of PeriodicWorkRequest depending of the work type specified + * @param type WorkType. Should be PERIODIC_SCAN or PERIODIC_USER_INFO + * @return Periodic WorkRequest + */ + fun getPeriodicWorkRequest(type: PeriodicWorkType): PeriodicWorkRequest { + return when(type) { + PeriodicWorkType.PERIODIC_FETCH_USER_INFO -> createPeriodicGetUserInfoWorkRequest() + PeriodicWorkType.PERIODIC_SCAN -> createPeriodicScanWorkRequest() + } + } + + /** + * Create a PeriodicWorkRequest instance for + * a Full scan with constraints on network (any) and battery (not low) + * @return instance of PeriodicWorkRequest + */ + private fun createPeriodicScanWorkRequest(): PeriodicWorkRequest { + val constraint = Constraints.Builder() + .setRequiredNetworkType(NetworkType.CONNECTED) + .setRequiresBatteryNotLow(true) + .build() + + return PeriodicWorkRequestBuilder( + PERIODIC_WORK_REPEAT_INTERVAL, MINUTES, + PERIODIC_SCAN_FLEX_TIME,MINUTES) + .setConstraints(constraint) + .addTag(WORK_GENERIC_TAG) + .build() + } + + private fun createPeriodicGetUserInfoWorkRequest(): PeriodicWorkRequest { + val constraint = Constraints.Builder() + .setRequiredNetworkType(NetworkType.CONNECTED) + .build() + + return PeriodicWorkRequestBuilder( + PERIODIC_WORK_REPEAT_INTERVAL, MINUTES) + .setConstraints(constraint) + .addTag(WORK_GENERIC_TAG) + .build() + } +} \ No newline at end of file -- GitLab From cbf32b416804057f8235ceff2d64d54634656c16 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 8 Apr 2024 18:28:51 +0200 Subject: [PATCH 02/12] refactor (WorkRequestFactory conversion to kotlin): convert code about OneTime workRequest --- .../e/drive/work/WorkRequestFactory.java | 209 ------------------ .../e/drive/work/WorkRequestFactory.kt | 200 +++++++++++++++-- 2 files changed, 187 insertions(+), 222 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java index 139a949e..74226df2 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java @@ -8,215 +8,6 @@ package foundation.e.drive.work; -import static androidx.work.BackoffPolicy.LINEAR; -import static java.util.concurrent.TimeUnit.MINUTES; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_ENABLE; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_ID; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_LAST_ETAG; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_LAST_MODIFIED; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_LIBELLE; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_LOCAL_PATH; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_MEDIATYPE; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_REMOTE_PATH; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_SCAN_LOCAL; -import static foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_SCAN_REMOTE; -import static foundation.e.drive.utils.AppConstants.WORK_GENERIC_TAG; -import static foundation.e.drive.utils.AppConstants.WORK_SETUP_TAG; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.work.Constraints; -import androidx.work.Data; -import androidx.work.NetworkType; -import androidx.work.OneTimeWorkRequest; -import androidx.work.PeriodicWorkRequest; - -import java.security.InvalidParameterException; - -import foundation.e.drive.account.AccountUserInfoWorker; -import foundation.e.drive.account.setup.FinishSetupWorker; -import foundation.e.drive.account.setup.RootFolderSetupWorker; -import foundation.e.drive.models.SyncedFolder; -import foundation.e.drive.periodicScan.FullScanWorker; -import foundation.e.drive.periodicScan.ListAppsWorker; - -import foundation.e.drive.synchronization.SyncWorker; - public class WorkRequestFactory { - public enum WorkType { - ONE_TIME_FULL_SCAN, - ONE_TIME_FORCED_FULL_SCAN, - ONE_TIME_APP_LIST, - ONE_TIME_USER_INFO, - ONE_TIME_ROOT_FOLDER_SETUP, - ONE_TIME_FINISH_SETUP, - ONE_TIME_SYNC - } - - - - /** - * Build an instance of OneTimeWorkRequest depending of the work type specified. - * @param type Should be ONE_TIME_USER_INFO, or FIRST_START, or CREATE_REMOTE_DIR - * or it will throw InvalidParameterException - * @param syncedFolder this parameter is required for CREATE_REMOTE_DIR work type. If null it will throw an NPE. - * @return OneTimeWorkRequest's instance. - */ - @NonNull - public static OneTimeWorkRequest getOneTimeWorkRequest(@NonNull WorkType type, @Nullable SyncedFolder syncedFolder) { - switch (type) { - case ONE_TIME_APP_LIST: - return createAppListGenerationWorkRequest(); - case ONE_TIME_FULL_SCAN: - return createFullScanWorkRequest(false); - case ONE_TIME_FORCED_FULL_SCAN: - return createFullScanWorkRequest(true); - case ONE_TIME_USER_INFO: - return createGetUserInfoWorkRequest(); - case ONE_TIME_FINISH_SETUP: - return createFinishSetupWorkRequest(); - case ONE_TIME_ROOT_FOLDER_SETUP: - if (syncedFolder == null) throw new NullPointerException("Synced folder is null"); - return createRootFolderSetupWorkRequest(syncedFolder); - case ONE_TIME_SYNC: - return createSyncWorkRequest(); - default: - throw new InvalidParameterException("Unsupported Work Type: " + type); - } - } - - private static OneTimeWorkRequest createSyncWorkRequest() { - final Constraints constraints = new Constraints.Builder() - .setRequiredNetworkType(NetworkType.CONNECTED) - .setRequiresBatteryNotLow(true) - .build(); - - final OneTimeWorkRequest.Builder builder = new OneTimeWorkRequest.Builder(SyncWorker.class); - - return builder.setBackoffCriteria(LINEAR, 2, MINUTES).addTag(WORK_GENERIC_TAG) - .setConstraints(constraints) - .build(); - } - - /** - * Create a workRequest to generate file which contains list of installed apps - * @return the workRequest - */ - @NonNull - private static OneTimeWorkRequest createAppListGenerationWorkRequest() { - final OneTimeWorkRequest.Builder builder = new OneTimeWorkRequest.Builder(ListAppsWorker.class); - - return builder.setBackoffCriteria(LINEAR, 2, MINUTES) - .addTag(WORK_GENERIC_TAG) - .build(); - } - - /** - * Create a OneTimeWorkRequest instance for - * a Full scan with constraints on network (should - * be unmetered) and battery (shouldn't be low) - * @return instance of OneTimeWorkRequest - */ - @NonNull - private static OneTimeWorkRequest createFullScanWorkRequest(boolean forced) { - final Constraints constraints = createUnmeteredNetworkAndHighBatteryConstraints(); - - final OneTimeWorkRequest.Builder builder = new OneTimeWorkRequest.Builder(FullScanWorker.class); - - final Data data = new Data.Builder() - .putBoolean(FullScanWorker.ACTION_FORCED_SYNC_KEY, forced) - .build(); - - return builder.setBackoffCriteria(LINEAR, 2, MINUTES) - .setConstraints(constraints) - .setInputData(data) - .addTag(WORK_GENERIC_TAG) - .build(); - } - - - /** - * Instanciate a OneTimeWorkRequest to retrieve user info - * @return instance of OneTimeWorkRequest - */ - @NonNull - private static OneTimeWorkRequest createGetUserInfoWorkRequest() { - final Constraints constraints = createUnmeteredNetworkAndHighBatteryConstraints(); - - final OneTimeWorkRequest.Builder builder = new OneTimeWorkRequest.Builder(AccountUserInfoWorker.class); - - return builder.setBackoffCriteria(LINEAR, 2, MINUTES) - .addTag(WORK_GENERIC_TAG) - .addTag(WORK_SETUP_TAG) - .setConstraints(constraints) - .build(); - } - - /** - * Create a OneTime workRequest to create a remote folder - * With constraints on network (unmetered) and battery (not low) - * @param syncedFolder SyncedFolder instance with data about folder to create - * @return Instance OneTimeWorkRequest - */ - @NonNull - private static OneTimeWorkRequest createRootFolderSetupWorkRequest(@NonNull SyncedFolder syncedFolder) { - final Constraints constraints = createUnmeteredNetworkAndHighBatteryConstraints(); - - return new OneTimeWorkRequest.Builder( - RootFolderSetupWorker.class) - .setBackoffCriteria(LINEAR, 2, MINUTES) - .setInputData(createDataFromSyncedFolder(syncedFolder)) - .addTag(WORK_GENERIC_TAG) - .addTag(WORK_SETUP_TAG) - .setConstraints(constraints) - .build(); - } - - /** - * Create a OneTime WorkRequest which finish setup process - * @return Instance of OneTimeWorkRequest - */ - @NonNull - private static OneTimeWorkRequest createFinishSetupWorkRequest() { - return new OneTimeWorkRequest.Builder(FinishSetupWorker.class) - .setBackoffCriteria(LINEAR, 2, MINUTES) - .addTag(WORK_GENERIC_TAG) - .addTag(WORK_SETUP_TAG) - .build(); - } - - /** - * Create Constraints for unmetered network - * and battery not low - * @return instance of Constraints - */ - @NonNull - private static Constraints createUnmeteredNetworkAndHighBatteryConstraints() { - return new Constraints.Builder() - .setRequiredNetworkType(NetworkType.UNMETERED) - .setRequiresBatteryNotLow(true) - .build(); - } - - /** - * Parse SyncedFolder instance in Data, used as data for WorkRequest - * @param folder SyncedFolder instance - * @return Data instance - */ - @NonNull - private static Data createDataFromSyncedFolder(@NonNull SyncedFolder folder) { - return new Data.Builder() - .putInt(DATA_KEY_ID, folder.getId()) - .putString(DATA_KEY_LIBELLE, folder.getLibelle()) - .putString(DATA_KEY_LOCAL_PATH, folder.getLocalFolder()) - .putString(DATA_KEY_REMOTE_PATH, folder.getRemoteFolder()) - .putString(DATA_KEY_LAST_ETAG, folder.getLastEtag()) - .putLong(DATA_KEY_LAST_MODIFIED, folder.getLastModified()) - .putBoolean(DATA_KEY_SCAN_LOCAL, folder.isScanLocal()) - .putBoolean(DATA_KEY_SCAN_REMOTE, folder.isScanRemote()) - .putBoolean(DATA_KEY_ENABLE, folder.isEnabled()) - .putBoolean(DATA_KEY_MEDIATYPE, folder.isMediaType()) - .build(); - } } \ No newline at end of file diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt index 186f4f76..7a3de5bf 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt @@ -1,32 +1,60 @@ +/* + * Copyright © MURENA SAS 2022-2024. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/gpl.html + */ package foundation.e.drive.work +import androidx.work.BackoffPolicy.LINEAR import androidx.work.Constraints +import androidx.work.Data import androidx.work.NetworkType +import androidx.work.OneTimeWorkRequest +import androidx.work.OneTimeWorkRequestBuilder import androidx.work.PeriodicWorkRequest import androidx.work.PeriodicWorkRequestBuilder import foundation.e.drive.account.AccountUserInfoWorker +import foundation.e.drive.account.setup.FinishSetupWorker +import foundation.e.drive.account.setup.RootFolderSetupWorker +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_ENABLE +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_ID +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_LAST_ETAG +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_LAST_MODIFIED +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_LIBELLE +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_LOCAL_PATH +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_MEDIATYPE +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_REMOTE_PATH +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_SCAN_LOCAL +import foundation.e.drive.account.setup.RootFolderSetupWorker.DATA_KEY_SCAN_REMOTE +import foundation.e.drive.models.SyncedFolder +import foundation.e.drive.periodicScan.FullScanWorker +import foundation.e.drive.periodicScan.ListAppsWorker import foundation.e.drive.periodicScan.PeriodicScanWorker +import foundation.e.drive.synchronization.SyncWorker import foundation.e.drive.utils.AppConstants.WORK_GENERIC_TAG +import foundation.e.drive.utils.AppConstants.WORK_SETUP_TAG import java.util.concurrent.TimeUnit.MINUTES enum class PeriodicWorkType { - PERIODIC_FETCH_USER_INFO, + FETCH_USER_INFO, PERIODIC_SCAN} enum class OneTimeWorkType { - ONE_TIME_FULL_SCAN, - ONE_TIME_FORCED_FULL_SCAN, - ONE_TIME_APP_LIST, - ONE_TIME_USER_INFO, - ONE_TIME_ROOT_FOLDER_SETUP, - ONE_TIME_FINISH_SETUP, + FULL_SCAN, + USER_TRIGGERED_FULL_SCAN, + LIST_APPS, + FETCH_USER_INFO, + ROOT_FOLDER_SETUP, + FINISH_SETUP, ONE_TIME_SYNC } object WorkRequestFactory { - private val PERIODIC_WORK_REPEAT_INTERVAL = 30L - private val PERIODIC_SCAN_FLEX_TIME = 5L + private const val PERIODIC_WORK_REPEAT_INTERVAL = 30L + private const val PERIODIC_SCAN_FLEX_TIME = 5L /** * Build an instance of PeriodicWorkRequest depending of the work type specified @@ -34,19 +62,165 @@ object WorkRequestFactory { * @return Periodic WorkRequest */ fun getPeriodicWorkRequest(type: PeriodicWorkType): PeriodicWorkRequest { - return when(type) { - PeriodicWorkType.PERIODIC_FETCH_USER_INFO -> createPeriodicGetUserInfoWorkRequest() + return when (type) { + PeriodicWorkType.FETCH_USER_INFO -> createPeriodicGetUserInfoWorkRequest() PeriodicWorkType.PERIODIC_SCAN -> createPeriodicScanWorkRequest() } } + /** + * Build an instance of OneTimeWorkRequest depending of the work type specified. + * @param type Should be ONE_TIME_USER_INFO, or FIRST_START, or CREATE_REMOTE_DIR + * or it will throw InvalidParameterException + * @param syncedFolder @Nullable this parameter is required for CREATE_REMOTE_DIR work type. Throw an NPE if null. + * @return OneTimeWorkRequest's instance. + */ + fun createOneTimeWorkRequest(type: OneTimeWorkType, syncedFolder: SyncedFolder? = null): OneTimeWorkRequest { + return when (type) { + OneTimeWorkType.FULL_SCAN -> createFullScanWorkRequest(false) + OneTimeWorkType.USER_TRIGGERED_FULL_SCAN -> createFullScanWorkRequest(true) + OneTimeWorkType.LIST_APPS -> createAppListGenerationWorkRequest() + OneTimeWorkType.FETCH_USER_INFO -> createGetUserInfoWorkRequest() + OneTimeWorkType.ROOT_FOLDER_SETUP -> { + if (syncedFolder == null) { + throw NullPointerException("Cannot create RootFolderSetupWorker without syncFolder") + } + createRootFolderSetupWorkRequest(syncedFolder) + } + OneTimeWorkType.FINISH_SETUP -> createFinishSetupWorkRequest() + OneTimeWorkType.ONE_TIME_SYNC -> createSyncWorkRequest() + } + } + + /** + * Create a OneTimeWorkRequest instance for + * a Full scan with constraints on network (should + * be unmetered) and battery (shouldn't be low) + * @return instance of OneTimeWorkRequest + */ + private fun createFullScanWorkRequest(forced: Boolean): OneTimeWorkRequest { + val constraints = Constraints.Builder() + .setRequiredNetworkType(NetworkType.UNMETERED) + .setRequiresBatteryNotLow(true) + .build() + + val data = Data.Builder() + .putBoolean(FullScanWorker.ACTION_FORCED_SYNC_KEY, forced) + .build() + + return OneTimeWorkRequestBuilder() + .setBackoffCriteria(LINEAR, 2, MINUTES) + .setConstraints(constraints) + .setInputData(data) + .addTag(WORK_GENERIC_TAG) + .build() + } + + /** + * Create a workRequest to generate file which contains list of installed apps + * @return the workRequest + */ + private fun createAppListGenerationWorkRequest(): OneTimeWorkRequest { + return OneTimeWorkRequestBuilder() + .setBackoffCriteria(LINEAR, 2, MINUTES) + .addTag(WORK_GENERIC_TAG) + .build() + + } + + /** + * Instanciate a OneTimeWorkRequest to retrieve user info + * @return instance of OneTimeWorkRequest + */ + private fun createGetUserInfoWorkRequest(): OneTimeWorkRequest { + val constraints = Constraints.Builder() + .setRequiredNetworkType(NetworkType.UNMETERED) + .setRequiresBatteryNotLow(true) + .build() + + return OneTimeWorkRequestBuilder() + .setConstraints(constraints) + .setBackoffCriteria(LINEAR, 2, MINUTES) + .addTag(WORK_GENERIC_TAG) + .addTag(WORK_SETUP_TAG) + .build() + } + + /** + * Create a OneTime workRequest to create a remote folder + * With constraints on network (unmetered) and battery (not low) + * @param syncedFolder SyncedFolder instance with data about folder to create + * @return Instance OneTimeWorkRequest + */ + private fun createRootFolderSetupWorkRequest(syncedFolder: SyncedFolder): OneTimeWorkRequest { + val constraints = Constraints.Builder() + .setRequiredNetworkType(NetworkType.UNMETERED) + .setRequiresBatteryNotLow(true) + .build() + + return OneTimeWorkRequestBuilder() + .setInputData(createDataFromSyncedFolder(syncedFolder)) + .setConstraints(constraints) + .setBackoffCriteria(LINEAR, 2, MINUTES) + .addTag(WORK_GENERIC_TAG) + .addTag(WORK_SETUP_TAG) + .build() + } + + /** + * Parse SyncedFolder instance in Data, used as data for WorkRequest + * @param folder SyncedFolder instance + * @return Data instance + */ + private fun createDataFromSyncedFolder(folder: SyncedFolder): Data { + return Data.Builder() + .putInt(DATA_KEY_ID, folder.getId()) + .putString(DATA_KEY_LIBELLE, folder.getLibelle()) + .putString(DATA_KEY_LOCAL_PATH, folder.getLocalFolder()) + .putString(DATA_KEY_REMOTE_PATH, folder.getRemoteFolder()) + .putString(DATA_KEY_LAST_ETAG, folder.getLastEtag()) + .putLong(DATA_KEY_LAST_MODIFIED, folder.getLastModified()) + .putBoolean(DATA_KEY_SCAN_LOCAL, folder.isScanLocal()) + .putBoolean(DATA_KEY_SCAN_REMOTE, folder.isScanRemote()) + .putBoolean(DATA_KEY_ENABLE, folder.isEnabled()) + .putBoolean(DATA_KEY_MEDIATYPE, folder.isMediaType()) + .build() + + } + + /** + * Create a OneTime WorkRequest which finish setup process + * @return Instance of OneTimeWorkRequest + */ + private fun createFinishSetupWorkRequest(): OneTimeWorkRequest { + return OneTimeWorkRequestBuilder() + .setBackoffCriteria(LINEAR, 2, MINUTES) + .addTag(WORK_GENERIC_TAG) + .addTag(WORK_SETUP_TAG) + .build() + + } + + private fun createSyncWorkRequest(): OneTimeWorkRequest { + val constraints = Constraints.Builder() + .setRequiredNetworkType(NetworkType.CONNECTED) + .setRequiresBatteryNotLow(true) + .build() + + return OneTimeWorkRequestBuilder() + .setBackoffCriteria(LINEAR, 2, MINUTES) + .setConstraints(constraints) + .addTag(WORK_GENERIC_TAG) + .build() + } + /** * Create a PeriodicWorkRequest instance for * a Full scan with constraints on network (any) and battery (not low) * @return instance of PeriodicWorkRequest */ private fun createPeriodicScanWorkRequest(): PeriodicWorkRequest { - val constraint = Constraints.Builder() + val constraints = Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .setRequiresBatteryNotLow(true) .build() @@ -54,7 +228,7 @@ object WorkRequestFactory { return PeriodicWorkRequestBuilder( PERIODIC_WORK_REPEAT_INTERVAL, MINUTES, PERIODIC_SCAN_FLEX_TIME,MINUTES) - .setConstraints(constraint) + .setConstraints(constraints) .addTag(WORK_GENERIC_TAG) .build() } -- GitLab From 192f2a25d347b1b7044c3866b16337cfe3129319 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 8 Apr 2024 18:33:11 +0200 Subject: [PATCH 03/12] chore: fix call to WorkRequestFactory for onetime work request in WorkLauncher --- .../foundation/e/drive/work/WorkLauncher.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt b/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt index f79e2d68..57d4e153 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt @@ -56,7 +56,7 @@ class WorkLauncher private constructor(context: Context) { fun enqueueOneTimeFullScan(isForced: Boolean) { if (isForced) { - val request = WorkRequestFactory.getOneTimeWorkRequest(WorkType.ONE_TIME_FORCED_FULL_SCAN, + val request = WorkRequestFactory.createOneTimeWorkRequest(OneTimeWorkType.USER_TRIGGERED_FULL_SCAN, null) workManager.enqueueUniqueWork(FullScanWorker.UNIQUE_WORK_NAME, ExistingWorkPolicy.REPLACE, @@ -64,7 +64,7 @@ class WorkLauncher private constructor(context: Context) { return } - val request = WorkRequestFactory.getOneTimeWorkRequest(WorkType.ONE_TIME_FULL_SCAN, + val request = WorkRequestFactory.createOneTimeWorkRequest(OneTimeWorkType.FULL_SCAN, null) workManager.enqueueUniqueWork(FullScanWorker.UNIQUE_WORK_NAME, ExistingWorkPolicy.KEEP, @@ -72,13 +72,13 @@ class WorkLauncher private constructor(context: Context) { } fun enqueueOneTimeAppListGenerator() { - val request = WorkRequestFactory.getOneTimeWorkRequest(WorkType.ONE_TIME_APP_LIST, + val request = WorkRequestFactory.createOneTimeWorkRequest(OneTimeWorkType.LIST_APPS, null) workManager.enqueue(request) } fun enqueueOneTimeSync() { - val request = WorkRequestFactory.getOneTimeWorkRequest(WorkType.ONE_TIME_SYNC, null) + val request = WorkRequestFactory.createOneTimeWorkRequest(OneTimeWorkType.ONE_TIME_SYNC, null) workManager.enqueueUniqueWork(SyncWorker.UNIQUE_WORK_NAME, ExistingWorkPolicy.KEEP, request) } @@ -89,13 +89,13 @@ class WorkLauncher private constructor(context: Context) { return false } - val getUserInfoRequest = WorkRequestFactory.getOneTimeWorkRequest( - WorkType.ONE_TIME_USER_INFO, + val getUserInfoRequest = WorkRequestFactory.createOneTimeWorkRequest( + OneTimeWorkType.FETCH_USER_INFO, null ) - val finishSetupRequest = WorkRequestFactory.getOneTimeWorkRequest( - WorkType.ONE_TIME_FINISH_SETUP, + val finishSetupRequest = WorkRequestFactory.createOneTimeWorkRequest( + OneTimeWorkType.FINISH_SETUP, null ) @@ -118,8 +118,8 @@ class WorkLauncher private constructor(context: Context) { RootSyncedFolderProvider.getSyncedFolderRoots(context) return rootSyncedFolderList.map { - WorkRequestFactory.getOneTimeWorkRequest( - WorkType.ONE_TIME_ROOT_FOLDER_SETUP, + WorkRequestFactory.createOneTimeWorkRequest( + OneTimeWorkType.ROOT_FOLDER_SETUP, it ) } -- GitLab From cab8bed19bc27438c3a9f0adda16881529c81662 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 8 Apr 2024 18:45:14 +0200 Subject: [PATCH 04/12] chore: delete Java version of WorkRequestFactory --- .../foundation/e/drive/work/WorkRequestFactory.java | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java deleted file mode 100644 index 74226df2..00000000 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright © MURENA SAS 2022-2023. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ - -package foundation.e.drive.work; - -public class WorkRequestFactory { - -} \ No newline at end of file -- GitLab From 8bfd8da6d5620d5c0f7e101836a50c6d606a3617 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 8 Apr 2024 18:45:48 +0200 Subject: [PATCH 05/12] chore: fix call to WorkRequestFactory in PeriodicScanWorker.java --- .../e/drive/periodicScan/PeriodicScanWorker.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/periodicScan/PeriodicScanWorker.java b/app/src/main/java/foundation/e/drive/periodicScan/PeriodicScanWorker.java index ffaf89c6..bcfcfbe9 100644 --- a/app/src/main/java/foundation/e/drive/periodicScan/PeriodicScanWorker.java +++ b/app/src/main/java/foundation/e/drive/periodicScan/PeriodicScanWorker.java @@ -8,9 +8,6 @@ package foundation.e.drive.periodicScan; -import static foundation.e.drive.work.WorkRequestFactory.WorkType.ONE_TIME_APP_LIST; -import static foundation.e.drive.work.WorkRequestFactory.WorkType.ONE_TIME_FULL_SCAN; - import android.content.Context; import androidx.annotation.NonNull; @@ -23,6 +20,7 @@ import androidx.work.WorkerParameters; import java.util.ArrayList; import java.util.List; +import foundation.e.drive.work.OneTimeWorkType; import foundation.e.drive.work.WorkRequestFactory; import timber.log.Timber; @@ -43,10 +41,11 @@ public class PeriodicScanWorker extends Worker { public Result doWork() { try { final WorkManager workManager = WorkManager.getInstance(getApplicationContext()); + final WorkRequestFactory workRequestFactory = WorkRequestFactory.INSTANCE; final List workRequestsLists = new ArrayList<>(); - workRequestsLists.add(WorkRequestFactory.getOneTimeWorkRequest(ONE_TIME_APP_LIST, null)); - workRequestsLists.add(WorkRequestFactory.getOneTimeWorkRequest(ONE_TIME_FULL_SCAN, null)); + workRequestsLists.add(workRequestFactory.createOneTimeWorkRequest(OneTimeWorkType.LIST_APPS, null)); + workRequestsLists.add(workRequestFactory.createOneTimeWorkRequest(OneTimeWorkType.FULL_SCAN, null)); workManager.beginUniqueWork(FullScanWorker.UNIQUE_WORK_NAME, ExistingWorkPolicy.KEEP, workRequestsLists) .enqueue(); -- GitLab From e575dd9ff918706a40eebc442fe19e526a80d142 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 8 Apr 2024 18:48:51 +0200 Subject: [PATCH 06/12] fix: change FullScanWorkRequest's network constraint from UNMETERED to CONNECTED --- app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt index 7a3de5bf..56cf2d66 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt @@ -100,7 +100,7 @@ object WorkRequestFactory { */ private fun createFullScanWorkRequest(forced: Boolean): OneTimeWorkRequest { val constraints = Constraints.Builder() - .setRequiredNetworkType(NetworkType.UNMETERED) + .setRequiredNetworkType(NetworkType.CONNECTED) .setRequiresBatteryNotLow(true) .build() -- GitLab From 358d3a5cd946998edb6dcc0c5af1912daf17f24b Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Tue, 9 Apr 2024 07:55:28 +0000 Subject: [PATCH 07/12] chore: add missing new line at end of file --- app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt index 56cf2d66..3a0bcaba 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt @@ -244,4 +244,4 @@ object WorkRequestFactory { .addTag(WORK_GENERIC_TAG) .build() } -} \ No newline at end of file +} -- GitLab From 50005766a93a09eaf09f3ff4ec535d156b8a7eec Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 11 Apr 2024 07:58:51 +0000 Subject: [PATCH 08/12] chore: apply suggestion. Add extra space after enum in WorkRequestFactory --- app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt index 3a0bcaba..e7997bea 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt @@ -51,6 +51,7 @@ enum class OneTimeWorkType { FINISH_SETUP, ONE_TIME_SYNC } + object WorkRequestFactory { private const val PERIODIC_WORK_REPEAT_INTERVAL = 30L -- GitLab From ad6caf70f23f65117c00a71d847cd1207103f458 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 11 Apr 2024 10:03:12 +0200 Subject: [PATCH 09/12] chore: Apply suggestion. rename method & const in WorkRequestFactory --- .../java/foundation/e/drive/work/WorkLauncher.kt | 4 ++-- .../foundation/e/drive/work/WorkRequestFactory.kt | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt b/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt index 57d4e153..21027cb9 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkLauncher.kt @@ -39,7 +39,7 @@ class WorkLauncher private constructor(context: Context) { } fun enqueuePeriodicUserInfoFetching() { - val request = WorkRequestFactory.getPeriodicWorkRequest(PeriodicWorkType.FETCH_USER_INFO) + val request = WorkRequestFactory.createPeriodicWorkRequest(PeriodicWorkType.FETCH_USER_INFO) workManager.enqueueUniquePeriodicWork( AccountUserInfoWorker.UNIQUE_WORK_NAME, ExistingPeriodicWorkPolicy.UPDATE, @@ -48,7 +48,7 @@ class WorkLauncher private constructor(context: Context) { } fun enqueuePeriodicFullScan() { - val request = WorkRequestFactory.getPeriodicWorkRequest(PeriodicWorkType.PERIODIC_SCAN) + val request = WorkRequestFactory.createPeriodicWorkRequest(PeriodicWorkType.PERIODIC_SCAN) workManager.enqueueUniquePeriodicWork(PeriodicScanWorker.UNIQUE_WORK_NAME, ExistingPeriodicWorkPolicy.KEEP, request) diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt index e7997bea..ce6960fb 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt @@ -54,15 +54,15 @@ enum class OneTimeWorkType { object WorkRequestFactory { - private const val PERIODIC_WORK_REPEAT_INTERVAL = 30L - private const val PERIODIC_SCAN_FLEX_TIME = 5L + private const val PERIODIC_WORK_REPEAT_INTERVAL_IN_MIN = 30L + private const val PERIODIC_SCAN_FLEX_TIME_IN_MIN = 5L /** * Build an instance of PeriodicWorkRequest depending of the work type specified * @param type WorkType. Should be PERIODIC_SCAN or PERIODIC_USER_INFO * @return Periodic WorkRequest */ - fun getPeriodicWorkRequest(type: PeriodicWorkType): PeriodicWorkRequest { + fun createPeriodicWorkRequest(type: PeriodicWorkType): PeriodicWorkRequest { return when (type) { PeriodicWorkType.FETCH_USER_INFO -> createPeriodicGetUserInfoWorkRequest() PeriodicWorkType.PERIODIC_SCAN -> createPeriodicScanWorkRequest() @@ -227,8 +227,8 @@ object WorkRequestFactory { .build() return PeriodicWorkRequestBuilder( - PERIODIC_WORK_REPEAT_INTERVAL, MINUTES, - PERIODIC_SCAN_FLEX_TIME,MINUTES) + PERIODIC_WORK_REPEAT_INTERVAL_IN_MIN, MINUTES, + PERIODIC_SCAN_FLEX_TIME_IN_MIN,MINUTES) .setConstraints(constraints) .addTag(WORK_GENERIC_TAG) .build() @@ -240,7 +240,7 @@ object WorkRequestFactory { .build() return PeriodicWorkRequestBuilder( - PERIODIC_WORK_REPEAT_INTERVAL, MINUTES) + PERIODIC_WORK_REPEAT_INTERVAL_IN_MIN, MINUTES) .setConstraints(constraint) .addTag(WORK_GENERIC_TAG) .build() -- GitLab From 3e2b1c1b3a630bc74aa69a5a0ad72335fee0459b Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 15 Apr 2024 09:23:41 +0200 Subject: [PATCH 10/12] chore: fix: wrong doc in WorkRequestFactory --- .../main/java/foundation/e/drive/work/WorkRequestFactory.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt index ce6960fb..336c0b34 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt @@ -95,8 +95,7 @@ object WorkRequestFactory { /** * Create a OneTimeWorkRequest instance for - * a Full scan with constraints on network (should - * be unmetered) and battery (shouldn't be low) + * a Full scan with constraints on network (CONNECTED) and battery (shouldn't be low) * @return instance of OneTimeWorkRequest */ private fun createFullScanWorkRequest(forced: Boolean): OneTimeWorkRequest { @@ -217,7 +216,7 @@ object WorkRequestFactory { /** * Create a PeriodicWorkRequest instance for - * a Full scan with constraints on network (any) and battery (not low) + * a Full scan with constraints on network (CONNECTED) and battery (not low) * @return instance of PeriodicWorkRequest */ private fun createPeriodicScanWorkRequest(): PeriodicWorkRequest { -- GitLab From 25e00e771eeaf737e707e5d519188adf40f8899e Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Mon, 15 Apr 2024 07:51:31 +0000 Subject: [PATCH 11/12] feature: network constraint on fetching user info is now changed to 'connected' --- app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt index 336c0b34..f893338f 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt @@ -134,7 +134,7 @@ object WorkRequestFactory { */ private fun createGetUserInfoWorkRequest(): OneTimeWorkRequest { val constraints = Constraints.Builder() - .setRequiredNetworkType(NetworkType.UNMETERED) + .setRequiredNetworkType(NetworkType.CONNECTED) .setRequiresBatteryNotLow(true) .build() -- GitLab From 342c07d6239b3d464142b76ebfb5ec8b86abb148 Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Mon, 15 Apr 2024 09:53:53 +0000 Subject: [PATCH 12/12] chore: apply suggestion on method doc --- .../e/drive/work/WorkRequestFactory.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt index f893338f..0c3b245b 100644 --- a/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt +++ b/app/src/main/java/foundation/e/drive/work/WorkRequestFactory.kt @@ -58,7 +58,7 @@ object WorkRequestFactory { private const val PERIODIC_SCAN_FLEX_TIME_IN_MIN = 5L /** - * Build an instance of PeriodicWorkRequest depending of the work type specified + * Builds an instance of PeriodicWorkRequest depending of the work type specified * @param type WorkType. Should be PERIODIC_SCAN or PERIODIC_USER_INFO * @return Periodic WorkRequest */ @@ -70,7 +70,7 @@ object WorkRequestFactory { } /** - * Build an instance of OneTimeWorkRequest depending of the work type specified. + * Builds an instance of OneTimeWorkRequest depending of the work type specified. * @param type Should be ONE_TIME_USER_INFO, or FIRST_START, or CREATE_REMOTE_DIR * or it will throw InvalidParameterException * @param syncedFolder @Nullable this parameter is required for CREATE_REMOTE_DIR work type. Throw an NPE if null. @@ -94,7 +94,7 @@ object WorkRequestFactory { } /** - * Create a OneTimeWorkRequest instance for + * Creates a OneTimeWorkRequest instance for * a Full scan with constraints on network (CONNECTED) and battery (shouldn't be low) * @return instance of OneTimeWorkRequest */ @@ -117,7 +117,7 @@ object WorkRequestFactory { } /** - * Create a workRequest to generate file which contains list of installed apps + * Creates a workRequest to generate file which contains list of installed apps * @return the workRequest */ private fun createAppListGenerationWorkRequest(): OneTimeWorkRequest { @@ -129,7 +129,7 @@ object WorkRequestFactory { } /** - * Instanciate a OneTimeWorkRequest to retrieve user info + * Instantiates a OneTimeWorkRequest to retrieve user info * @return instance of OneTimeWorkRequest */ private fun createGetUserInfoWorkRequest(): OneTimeWorkRequest { @@ -147,7 +147,7 @@ object WorkRequestFactory { } /** - * Create a OneTime workRequest to create a remote folder + * Creates a OneTime workRequest to create a remote folder * With constraints on network (unmetered) and battery (not low) * @param syncedFolder SyncedFolder instance with data about folder to create * @return Instance OneTimeWorkRequest @@ -168,7 +168,7 @@ object WorkRequestFactory { } /** - * Parse SyncedFolder instance in Data, used as data for WorkRequest + * Parses SyncedFolder instance in Data, used as data for WorkRequest * @param folder SyncedFolder instance * @return Data instance */ @@ -189,7 +189,7 @@ object WorkRequestFactory { } /** - * Create a OneTime WorkRequest which finish setup process + * Creates a OneTime WorkRequest which finish setup process * @return Instance of OneTimeWorkRequest */ private fun createFinishSetupWorkRequest(): OneTimeWorkRequest { @@ -215,7 +215,7 @@ object WorkRequestFactory { } /** - * Create a PeriodicWorkRequest instance for + * Creates a PeriodicWorkRequest instance for * a Full scan with constraints on network (CONNECTED) and battery (not low) * @return instance of PeriodicWorkRequest */ -- GitLab