From a6a8564a1fc9e8c00716c17a7b18726e35291c63 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Thu, 16 Mar 2023 18:32:49 +0100 Subject: [PATCH 01/12] Updated the Gradle Versions Plugin --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9b63a936e16..437ee52d0ad 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21" classpath "org.jlleitschuh.gradle:ktlint-gradle:10.1.0" - classpath "com.github.ben-manes:gradle-versions-plugin:0.44.0" + classpath "com.github.ben-manes:gradle-versions-plugin:0.46.0" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3" classpath "com.google.android.gms:oss-licenses-plugin:0.10.6" } From 5514455ce351f8b7a49eb7dc358d12096567e032 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Thu, 16 Mar 2023 22:50:23 +0100 Subject: [PATCH 02/12] Updated Dependencies and Versions --- .../main/java/dependencies/Dependencies.kt | 34 +++++++++---------- .../src/main/java/dependencies/Versions.kt | 12 +++---- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/buildSrc/src/main/java/dependencies/Dependencies.kt b/buildSrc/src/main/java/dependencies/Dependencies.kt index bc34ce13a45..5f71757b519 100644 --- a/buildSrc/src/main/java/dependencies/Dependencies.kt +++ b/buildSrc/src/main/java/dependencies/Dependencies.kt @@ -1,41 +1,41 @@ package dependencies object Dependencies { - const val desugar = "com.android.tools:desugar_jdk_libs:1.1.5" + const val desugar = "com.android.tools:desugar_jdk_libs:2.0.2" const val androidx_startup = "androidx.startup:startup-runtime:1.1.1" - const val androidx_annotations = "androidx.annotation:annotation:1.5.0" + const val androidx_annotations = "androidx.annotation:annotation:1.6.0" const val androidx_lifecycle_runtime_ktx = "androidx.lifecycle:lifecycle-runtime-ktx:${Versions.lifecycle}" const val androidx_viewpager2= "androidx.viewpager2:viewpager2:1.0.0" const val androidx_lifecycle_livedata_ktx = "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.lifecycle}" const val androidx_lifecycle_viewmodel_ktx = "androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.lifecycle}" const val androidx_core_ktx = "androidx.core:core-ktx:1.9.0" - const val androidx_browser = "androidx.browser:browser:1.4.0" - const val androidx_recyclerview = "androidx.recyclerview:recyclerview:1.2.1" + const val androidx_browser = "androidx.browser:browser:1.5.0" + const val androidx_recyclerview = "androidx.recyclerview:recyclerview:1.3.0" const val androidx_fragment = "androidx.fragment:fragment:${Versions.androidx_fragment}" const val androidx_navigation_fragment_ktx = "androidx.navigation:navigation-fragment-ktx:2.5.3" const val androidx_navigation_ui = "androidx.navigation:navigation-ui-ktx:2.5.3" - const val androidx_appcompat = "androidx.appcompat:appcompat:1.5.1" + const val androidx_appcompat = "androidx.appcompat:appcompat:1.6.1" const val androidx_work_runtime = "androidx.work:work-runtime:${Versions.work}" const val androidx_cardview = "androidx.cardview:cardview:1.0.0" const val androidx_exinterface = "androidx.exifinterface:exifinterface:1.3.6" const val androidx_multidex = "androidx.multidex:multidex:2.0.1" const val androidx_preference_ktx = "androidx.preference:preference-ktx:1.2.0" const val androidx_fragment_ktx = "androidx.fragment:fragment-ktx:${Versions.androidx_fragment}" - const val android_material = "com.google.android.material:material:1.7.0" + const val android_material = "com.google.android.material:material:1.8.0" const val android_flexbox = "com.google.android.flexbox:flexbox:3.0.0" - const val google_api_client_android = "com.google.api-client:google-api-client-android:2.1.1" - const val google_api_services_drive = "com.google.apis:google-api-services-drive:v3-rev20221023-2.0.0" - const val google_api_services_sheets = "com.google.apis:google-api-services-sheets:v4-rev20220927-2.0.0" - const val play_services_auth = "com.google.android.gms:play-services-auth:20.4.0" + const val google_api_client_android = "com.google.api-client:google-api-client-android:2.2.0" + const val google_api_services_drive = "com.google.apis:google-api-services-drive:v3-rev20230212-2.0.0" + const val google_api_services_sheets = "com.google.apis:google-api-services-sheets:v4-rev20230227-2.0.0" + const val play_services_auth = "com.google.android.gms:play-services-auth:20.4.1" const val play_services_maps = "com.google.android.gms:play-services-maps:18.1.0" const val play_services_location = "com.google.android.gms:play-services-location:20.0.0" // Check if map screens still work when upgrading const val play_services_oss_licenses = "com.google.android.gms:play-services-oss-licenses:17.0.0" - const val mapbox_android_sdk = "com.mapbox.maps:android:10.10.0" + const val mapbox_android_sdk = "com.mapbox.maps:android:10.11.2" const val osmdroid = "org.osmdroid:osmdroid-android:6.1.14" const val guava = "com.google.guava:guava:31.1-android" const val squareup_okhttp = "com.squareup.okhttp3:okhttp:${Versions.okhttp3}" const val squareup_okhttp_tls = "com.squareup.okhttp3:okhttp-tls:${Versions.okhttp3}" - const val burgstaller_okhttp_digest = "io.github.rburgst:okhttp-digest:3.0" + const val burgstaller_okhttp_digest = "io.github.rburgst:okhttp-digest:3.0.1" const val persian_joda_time = "com.github.mohamadian:persianjodatime:1.2" const val myanmar_calendar = "com.github.chanmratekoko:myanmar-calendar:1.0.6.RC3" const val bikram_sambat = "bikramsambat:bikram-sambat:1.1.0" @@ -58,16 +58,16 @@ object Dependencies { const val caverock_androidsvg = "com.caverock:androidsvg-aar:1.4" const val mp4parser_muxer = "org.mp4parser:muxer:1.9.41" // Check if https://github.com/getodk/collect/issues/5323 no longer takes place before upgrading const val kotlin_stdlib = "org.jetbrains.kotlin:kotlin-stdlib:1.7.22" - const val gson = "com.google.code.gson:gson:2.10" + const val gson = "com.google.code.gson:gson:2.10.1" const val firebase_analytics = "com.google.firebase:firebase-analytics:21.2.0" - const val firebase_crashlytics = "com.google.firebase:firebase-crashlytics:18.3.2" + const val firebase_crashlytics = "com.google.firebase:firebase-crashlytics:18.3.5" const val fastlane_screengrab = "tools.fastlane:screengrab:2.1.1" const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.10" const val timber = "com.jakewharton.timber:timber:5.0.1" const val slf4j_api = "org.slf4j:slf4j-api:2.0.6" const val slf4j_timber = "com.arcao:slf4j-timber:3.1@aar" const val emoji_java = "com.vdurmont:emoji-java:5.1.1" - const val json_schema_validator = "com.networknt:json-schema-validator:1.0.75" + const val json_schema_validator = "com.networknt:json-schema-validator:1.0.78" const val splashscreen = "androidx.core:core-splashscreen:1.0.0" const val camerax_core = "androidx.camera:camera-core:${Versions.camerax}" const val camerax_view = "androidx.camera:camera-view:${Versions.camerax}" @@ -81,14 +81,14 @@ object Dependencies { const val mockito_inline = "org.mockito:mockito-inline:${Versions.mockito}" const val mockito_kotlin = "org.mockito.kotlin:mockito-kotlin:4.1.0" const val androidx_fragment_testing = "androidx.fragment:fragment-testing:${Versions.androidx_fragment}" - const val androidx_arch_core_testing = "androidx.arch.core:core-testing:2.1.0" + const val androidx_arch_core_testing = "androidx.arch.core:core-testing:2.2.0" const val androidx_work_testing = "androidx.work:work-testing:${Versions.work}" const val androidx_test_core_ktx = "androidx.test:core-ktx:1.5.0" const val androidx_test_rules = "androidx.test:rules:1.5.0" const val androidx_test_espresso_contrib = "androidx.test.espresso:espresso-contrib:${Versions.espresso}" const val androidx_test_espresso_core = "androidx.test.espresso:espresso-core:${Versions.espresso}" const val androidx_test_espresso_intents = "androidx.test.espresso:espresso-intents:${Versions.espresso}" - const val androidx_test_ext_junit = "androidx.test.ext:junit:1.1.4" + const val androidx_test_ext_junit = "androidx.test.ext:junit:1.1.5" const val okhttp3_mockwebserver = "com.squareup.okhttp3:mockwebserver:${Versions.okhttp3}" const val hamcrest = "org.hamcrest:hamcrest:2.2" const val robolectric = "org.robolectric:robolectric:${Versions.robolectric}" diff --git a/buildSrc/src/main/java/dependencies/Versions.kt b/buildSrc/src/main/java/dependencies/Versions.kt index bd411e3923d..212b3448c1b 100644 --- a/buildSrc/src/main/java/dependencies/Versions.kt +++ b/buildSrc/src/main/java/dependencies/Versions.kt @@ -6,13 +6,13 @@ object Versions { const val android_target_sdk = 31 const val androidx_fragment = "1.5.5" - const val dagger = "2.44.2" - const val espresso = "3.5.0" - const val glide = "4.14.2" - const val mockito = "4.10.0" + const val dagger = "2.45" + const val espresso = "3.5.1" + const val glide = "4.15.1" + const val mockito = "5.2.0" const val okhttp3 = "4.10.0" const val robolectric = "4.9" - const val work = "2.7.1" + const val work = "2.8.0" const val lifecycle = "2.5.1" - const val camerax = "1.2.0" + const val camerax = "1.2.1" } From d043bfb295d0ef16b03361b40be57e61873a7fd0 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Thu, 16 Mar 2023 22:50:49 +0100 Subject: [PATCH 03/12] Updated dependencies in the project gradle file --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 437ee52d0ad..74191dad917 100644 --- a/build.gradle +++ b/build.gradle @@ -16,9 +16,9 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.4.0' - classpath 'com.google.gms:google-services:4.3.14' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2' + classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.google.gms:google-services:4.3.15' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21" classpath "org.jlleitschuh.gradle:ktlint-gradle:10.1.0" classpath "com.github.ben-manes:gradle-versions-plugin:0.46.0" From 707e9c6fa0c4b1d16805fbef88285f1f95b10976 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Thu, 16 Mar 2023 22:51:11 +0100 Subject: [PATCH 04/12] Updated gradle --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 902295f3756..410ce7ee1db 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -4,5 +4,5 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists android.enableD8.desugaring=true -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip org.gradle.configureondemand=false From 12d8be7570a42691e0fa722ad3929b8261ea3c04 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Thu, 16 Mar 2023 22:51:48 +0100 Subject: [PATCH 05/12] Updated checkstyle and pmd --- .../android/openrosa/CaseInsensitiveEmptyHeadersTest.java | 2 +- config/quality.gradle | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/collect_app/src/test/java/org/odk/collect/android/openrosa/CaseInsensitiveEmptyHeadersTest.java b/collect_app/src/test/java/org/odk/collect/android/openrosa/CaseInsensitiveEmptyHeadersTest.java index 0faeb68b71b..6ddfff20c2b 100644 --- a/collect_app/src/test/java/org/odk/collect/android/openrosa/CaseInsensitiveEmptyHeadersTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/openrosa/CaseInsensitiveEmptyHeadersTest.java @@ -8,7 +8,7 @@ public class CaseInsensitiveEmptyHeadersTest { @Test public void testGetHeaders() { - Assert.assertTrue(headers.getHeaders().size() == 0); + Assert.assertEquals(0, headers.getHeaders().size()); } @Test diff --git a/config/quality.gradle b/config/quality.gradle index f03be338729..628b4eb67c2 100644 --- a/config/quality.gradle +++ b/config/quality.gradle @@ -5,7 +5,7 @@ def reportsDir = "${project.buildDir}/reports" apply plugin: 'checkstyle' -checkstyle.toolVersion = '10.5.0' +checkstyle.toolVersion = '10.9.0' tasks.register("checkstyle", Checkstyle) { configFile file("$configDir/checkstyle.xml") @@ -24,7 +24,7 @@ tasks.register("checkstyle", Checkstyle) { apply plugin: 'pmd' pmd { - toolVersion = '6.52.0' + toolVersion = '6.55.0' } tasks.register("pmd", Pmd) { @@ -37,12 +37,12 @@ tasks.register("pmd", Pmd) { exclude '**/gen/**' reports { - xml.enabled = false - html.enabled = true xml { + enabled false setDestination new File("$reportsDir/pmd/pmd.xml") } html { + enabled true setDestination new File("$reportsDir/pmd/pmd.html") } } From e9cae9f0bfb9224029bad1fb686df016d5b906f3 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Fri, 17 Mar 2023 00:29:55 +0100 Subject: [PATCH 06/12] Updated kotlin --- build.gradle | 4 ++-- buildSrc/src/main/java/dependencies/Dependencies.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 74191dad917..f651cb01043 100644 --- a/build.gradle +++ b/build.gradle @@ -19,8 +19,8 @@ buildscript { classpath 'com.android.tools.build:gradle:7.4.2' classpath 'com.google.gms:google-services:4.3.15' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21" - classpath "org.jlleitschuh.gradle:ktlint-gradle:10.1.0" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10" + classpath "org.jlleitschuh.gradle:ktlint-gradle:11.3.1" classpath "com.github.ben-manes:gradle-versions-plugin:0.46.0" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3" classpath "com.google.android.gms:oss-licenses-plugin:0.10.6" diff --git a/buildSrc/src/main/java/dependencies/Dependencies.kt b/buildSrc/src/main/java/dependencies/Dependencies.kt index 5f71757b519..4cff9717d92 100644 --- a/buildSrc/src/main/java/dependencies/Dependencies.kt +++ b/buildSrc/src/main/java/dependencies/Dependencies.kt @@ -57,7 +57,7 @@ object Dependencies { const val glide_compiler = "com.github.bumptech.glide:compiler:${Versions.glide}" const val caverock_androidsvg = "com.caverock:androidsvg-aar:1.4" const val mp4parser_muxer = "org.mp4parser:muxer:1.9.41" // Check if https://github.com/getodk/collect/issues/5323 no longer takes place before upgrading - const val kotlin_stdlib = "org.jetbrains.kotlin:kotlin-stdlib:1.7.22" + const val kotlin_stdlib = "org.jetbrains.kotlin:kotlin-stdlib:1.8.10" const val gson = "com.google.code.gson:gson:2.10.1" const val firebase_analytics = "com.google.firebase:firebase-analytics:21.2.0" const val firebase_crashlytics = "com.google.firebase:firebase-crashlytics:18.3.5" From 7bfd3181f811b83fab3e0ce957f4160033cb74e8 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Fri, 17 Mar 2023 22:42:06 +0100 Subject: [PATCH 07/12] Allow adding empty lines in chained method calls --- config/quality.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/quality.gradle b/config/quality.gradle index 628b4eb67c2..97c524a4a9c 100644 --- a/config/quality.gradle +++ b/config/quality.gradle @@ -50,4 +50,8 @@ tasks.register("pmd", Pmd) { //------------------------ktlint------------------------// -apply plugin: "org.jlleitschuh.gradle.ktlint" \ No newline at end of file +apply plugin: "org.jlleitschuh.gradle.ktlint" + +ktlint { + disabledRules.set(["no-blank-lines-in-chained-method-calls"]) +} \ No newline at end of file From e642840e89279d617046dc656c6a61a2921c78c5 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Fri, 17 Mar 2023 22:43:19 +0100 Subject: [PATCH 08/12] Formatted kotlin code --- .../bitmap/ImageCompressorTest.kt | 2 +- .../bitmap/ImageFileUtilsTest.kt | 3 +- .../androidshared/bitmap/ImageFileUtils.kt | 16 ++++++-- .../odk/collect/androidshared/ui/PrefUtils.kt | 6 +-- .../ui/multiclicksafe/MultiClickSafeButton.kt | 3 +- .../MultiClickSafeImageButton.kt | 3 +- .../MultiClickSafeTextInputEditText.kt | 3 +- .../androidshared/ui/ColorPickerDialogTest.kt | 2 +- .../audioclips/AudioClipViewModelTest.kt | 2 +- .../external/InstanceUploadActionTest.kt | 1 - .../support/FakeClickableMapFragment.kt | 2 +- .../android/support/rules/CollectTestRule.kt | 4 +- .../android/support/rules/ResetStateRule.kt | 4 +- .../activities/FormEntryViewModelFactory.kt | 4 +- .../viewmodels/CurrentProjectViewModel.kt | 4 +- .../configure/qr/ShowQRCodeFragment.kt | 3 +- .../android/database/DatabaseObjectMapper.kt | 10 +++-- .../org/odk/collect/android/draw/DrawView.kt | 6 ++- .../android/external/FormUriActivity.kt | 2 +- .../android/formentry/QuitFormDialog.kt | 4 +- .../android/formentry/audit/AuditUtils.kt | 6 ++- .../blankformlist/BlankFormListViewModel.kt | 2 +- .../formmap/FormMapViewModel.kt | 2 +- .../fragments/dialogs/NumberPickerDialog.kt | 3 +- .../config/CollectGeoDependencyModule.kt | 2 +- .../config/CollectOsmDroidDependencyModule.kt | 2 +- ...ormUpdatesDownloadedNotificationBuilder.kt | 22 ++++++---- .../screens/MapsPreferencesFragment.kt | 7 +++- .../ProjectDisplayPreferencesFragment.kt | 26 ++++++++---- .../collect/android/utilities/Appearances.kt | 25 ++++++++---- .../collect/android/utilities/MediaUtils.kt | 7 +++- .../items/SelectOneFromMapDialogFragment.kt | 6 +-- .../utilities/ActivityGeoDataRequester.kt | 34 ++++++++-------- .../widgets/utilities/FileRequester.kt | 11 +++-- .../widgets/utilities/GeoWidgetUtils.kt | 2 +- .../widgets/utilities/StringRequester.kt | 7 +++- .../activities/MainMenuActivityTest.kt | 6 +-- .../qr/QRCodeActivityResultDelegateTest.kt | 3 +- .../configure/qr/QRCodeMenuDelegateTest.kt | 12 ++++-- .../database/DatabaseConnectionTest.kt | 2 +- .../AudioVideoImageTextLabelVisibilityTest.kt | 4 +- .../android/formentry/QuitFormDialogTest.kt | 4 +- .../BlankFormListMenuDelegateTest.kt | 8 ++-- .../BlankFormListViewModelTest.kt | 8 ++-- .../FormDownloadExceptionMapperTest.kt | 8 ++-- .../FormUpdateDownloaderTest.kt | 2 +- .../ServerFormsDetailsFetcherTest.kt | 2 +- .../formmap/FormMapViewModelTest.kt | 2 +- .../ProjectDisplayPreferencesFragmentTest.kt | 2 +- .../preferences/source/SettingsStoreTest.kt | 2 +- .../projects/CurrentProjectProviderTest.kt | 2 +- .../android/projects/ProjectDeleterTest.kt | 2 +- .../projects/ProjectSettingsDialogTest.kt | 2 +- .../QrCodeProjectCreatorDialogTest.kt | 2 +- .../storage/StoragePathProviderTest.kt | 2 +- .../SelectOneFromMapDialogFragmentTest.kt | 3 +- .../items/SelectOneFromMapWidgetTest.kt | 4 +- .../widgets/support/NoOpMapFragment.kt | 4 +- .../ExternalAppRecordingRequesterTest.kt | 2 +- .../odk/collect/crashhandler/CrashHandler.kt | 2 +- .../odk/collect/entities/DatasetsFragment.kt | 2 +- .../odk/collect/entities/EntitiesFragment.kt | 2 +- .../geo/selection/MappableSelectItem.kt | 8 ++-- .../geo/selection/SelectionMapFragment.kt | 4 +- .../geo/geopoint/GeoPointActivityTest.kt | 6 +-- .../LocationTrackerGeoPointViewModelTest.kt | 14 +++---- .../geo/selection/SelectionMapFragmentTest.kt | 10 ++--- .../collect/geo/support/FakeMapFragment.kt | 4 +- .../org/odk/collect/geo/support/Fixtures.kt | 2 +- .../location/LocationClientProviderTest.kt | 2 +- .../java/org/odk/collect/mapbox/MapUtils.kt | 2 +- .../odk/collect/mapbox/MapboxMapFragment.kt | 12 +++--- .../odk/collect/maps/MapFragmentDelegate.kt | 2 +- .../collect/maps/markers/MarkerDescription.kt | 3 +- .../collect/maps/markers/MarkerIconCreator.kt | 2 +- .../permissions/PermissionsDialogCreator.kt | 3 +- .../permissions/PermissionsProvider.kt | 12 ++++-- .../projects/InMemProjectsRepositoryTest.kt | 2 +- .../projects/ProjectsRepositoryTest.kt | 2 +- ...SharedPreferencesProjectsRepositoryTest.kt | 2 +- .../odk/collect/selfiecamera/CameraXCamera.kt | 2 +- .../selfiecamera/CaptureSelfieActivityTest.kt | 2 +- .../importing/SettingsImporterTest.kt | 40 +++++++++++++------ .../odk/collect/shared/strings/StringUtils.kt | 20 +++++++--- 84 files changed, 301 insertions(+), 197 deletions(-) diff --git a/androidshared/src/androidTest/java/org/odk/collect/androidshared/bitmap/ImageCompressorTest.kt b/androidshared/src/androidTest/java/org/odk/collect/androidshared/bitmap/ImageCompressorTest.kt index 866a171d49f..72fee68da20 100644 --- a/androidshared/src/androidTest/java/org/odk/collect/androidshared/bitmap/ImageCompressorTest.kt +++ b/androidshared/src/androidTest/java/org/odk/collect/androidshared/bitmap/ImageCompressorTest.kt @@ -156,7 +156,7 @@ class ImageCompressorTest { // unsupported exif tags ExifInterface.TAG_THUMBNAIL_IMAGE_LENGTH to "5", - ExifInterface.TAG_DNG_VERSION to "100", + ExifInterface.TAG_DNG_VERSION to "100" ) saveTestBitmap(3000, 4000, attributes) diff --git a/androidshared/src/androidTest/java/org/odk/collect/androidshared/bitmap/ImageFileUtilsTest.kt b/androidshared/src/androidTest/java/org/odk/collect/androidshared/bitmap/ImageFileUtilsTest.kt index 749f5bea83a..b7d97c1cc31 100644 --- a/androidshared/src/androidTest/java/org/odk/collect/androidshared/bitmap/ImageFileUtilsTest.kt +++ b/androidshared/src/androidTest/java/org/odk/collect/androidshared/bitmap/ImageFileUtilsTest.kt @@ -180,7 +180,8 @@ class ImageFileUtilsTest { assertEquals( ExifInterface.ORIENTATION_UNDEFINED, exifData.getAttributeInt( - ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED + ExifInterface.TAG_ORIENTATION, + ExifInterface.ORIENTATION_UNDEFINED ) ) } diff --git a/androidshared/src/main/java/org/odk/collect/androidshared/bitmap/ImageFileUtils.kt b/androidshared/src/main/java/org/odk/collect/androidshared/bitmap/ImageFileUtils.kt index fec44ca3478..ad1b8d18310 100644 --- a/androidshared/src/main/java/org/odk/collect/androidshared/bitmap/ImageFileUtils.kt +++ b/androidshared/src/main/java/org/odk/collect/androidshared/bitmap/ImageFileUtils.kt @@ -26,9 +26,11 @@ object ImageFileUtils { @JvmStatic fun saveBitmapToFile(bitmap: Bitmap?, path: String) { val compressFormat = - if (path.lowercase(Locale.getDefault()).endsWith(".png")) + if (path.lowercase(Locale.getDefault()).endsWith(".png")) { CompressFormat.PNG - else CompressFormat.JPEG + } else { + CompressFormat.JPEG + } try { if (bitmap != null) { FileOutputStream(path).use { out -> bitmap.compress(compressFormat, IMAGE_COMPRESS_QUALITY, out) } @@ -101,7 +103,9 @@ object ImageFileUtils { if (bitmap != null) { bitmap = Bitmap.createScaledBitmap( bitmap, - newWidth.toInt(), newHeight.toInt(), false + newWidth.toInt(), + newHeight.toInt(), + false ) } } else { @@ -122,7 +126,11 @@ object ImageFileUtils { if (bitmap != null) { Timber.i( "Screen is %dx%d. Image has been scaled down by %f to %dx%d", - screenHeight, screenWidth, scale, bitmap.height, bitmap.width + screenHeight, + screenWidth, + scale, + bitmap.height, + bitmap.width ) } return bitmap diff --git a/androidshared/src/main/java/org/odk/collect/androidshared/ui/PrefUtils.kt b/androidshared/src/main/java/org/odk/collect/androidshared/ui/PrefUtils.kt index 70359014f8a..1bbc52ebe5e 100644 --- a/androidshared/src/main/java/org/odk/collect/androidshared/ui/PrefUtils.kt +++ b/androidshared/src/main/java/org/odk/collect/androidshared/ui/PrefUtils.kt @@ -13,7 +13,7 @@ object PrefUtils { title: String, labelIds: IntArray, values: Array, - settings: Settings, + settings: Settings ): ListPreference { val labels: Array = labelIds.map { context.getString(it) }.toTypedArray() return createListPref(context, key, title, labels, values, settings) @@ -48,7 +48,7 @@ object PrefUtils { title: String, labels: Array, values: Array, - settings: Settings, + settings: Settings ): ListPreference { ensurePrefHasValidValue(key, values, settings) return ListPreference(context).also { @@ -65,7 +65,7 @@ object PrefUtils { private fun ensurePrefHasValidValue( key: String, validValues: Array, - settings: Settings, + settings: Settings ) { val value = settings.getString(key) if (validValues.indexOf(value) < 0) { diff --git a/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeButton.kt b/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeButton.kt index 743a014da86..8e6898cbd88 100644 --- a/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeButton.kt +++ b/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeButton.kt @@ -9,7 +9,8 @@ class MultiClickSafeButton : MaterialButton { constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet?) : super( - context, attrs + context, + attrs ) override fun performClick(): Boolean { diff --git a/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeImageButton.kt b/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeImageButton.kt index dee75c71808..109c7355cf4 100644 --- a/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeImageButton.kt +++ b/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeImageButton.kt @@ -9,7 +9,8 @@ class MultiClickSafeImageButton : AppCompatImageButton { constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet?) : super( - context, attrs + context, + attrs ) override fun performClick(): Boolean { diff --git a/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeTextInputEditText.kt b/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeTextInputEditText.kt index 3a46eb40210..a1c68f1f8f1 100644 --- a/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeTextInputEditText.kt +++ b/androidshared/src/main/java/org/odk/collect/androidshared/ui/multiclicksafe/MultiClickSafeTextInputEditText.kt @@ -9,7 +9,8 @@ class MultiClickSafeTextInputEditText : TextInputEditText { constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet?) : super( - context, attrs + context, + attrs ) override fun performClick(): Boolean { diff --git a/androidshared/src/test/java/org/odk/collect/androidshared/ui/ColorPickerDialogTest.kt b/androidshared/src/test/java/org/odk/collect/androidshared/ui/ColorPickerDialogTest.kt index 71bc0bba19a..23327a3c15c 100644 --- a/androidshared/src/test/java/org/odk/collect/androidshared/ui/ColorPickerDialogTest.kt +++ b/androidshared/src/test/java/org/odk/collect/androidshared/ui/ColorPickerDialogTest.kt @@ -10,8 +10,8 @@ import androidx.test.espresso.action.ViewActions.pressBack import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.ext.junit.runners.AndroidJUnit4 import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.equalToIgnoringCase +import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.nullValue import org.junit.Rule import org.junit.Test diff --git a/audioclips/src/test/java/org/odk/collect/audioclips/AudioClipViewModelTest.kt b/audioclips/src/test/java/org/odk/collect/audioclips/AudioClipViewModelTest.kt index 0e60a3752e8..638b5d642df 100644 --- a/audioclips/src/test/java/org/odk/collect/audioclips/AudioClipViewModelTest.kt +++ b/audioclips/src/test/java/org/odk/collect/audioclips/AudioClipViewModelTest.kt @@ -8,13 +8,13 @@ import org.junit.Rule import org.junit.Test import org.mockito.ArgumentCaptor import org.mockito.ArgumentMatchers -import org.mockito.Mockito.`when` import org.mockito.Mockito.doThrow import org.mockito.Mockito.inOrder import org.mockito.Mockito.mock import org.mockito.Mockito.never import org.mockito.Mockito.times import org.mockito.Mockito.verify +import org.mockito.Mockito.`when` import org.odk.collect.androidtest.getOrAwaitValue import org.odk.collect.testshared.FakeScheduler import java.io.File diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/feature/external/InstanceUploadActionTest.kt b/collect_app/src/androidTest/java/org/odk/collect/android/feature/external/InstanceUploadActionTest.kt index f1028f9e758..88b04f31f1a 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/feature/external/InstanceUploadActionTest.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/feature/external/InstanceUploadActionTest.kt @@ -24,7 +24,6 @@ class InstanceUploadActionTest { @Test fun whenInstanceDoesNotExist_showsError() { - val instanceIds = longArrayOf(11) instanceUploadAction(instanceIds) diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/FakeClickableMapFragment.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/FakeClickableMapFragment.kt index bb530d730ed..31df3597381 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/FakeClickableMapFragment.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/FakeClickableMapFragment.kt @@ -15,7 +15,7 @@ class FakeClickableMapFragment : Fragment(), MapFragment { override fun init( readyListener: MapFragment.ReadyListener?, - errorListener: MapFragment.ErrorListener?, + errorListener: MapFragment.ErrorListener? ) { readyListener?.onReady(this) } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/rules/CollectTestRule.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/rules/CollectTestRule.kt index 00a4406644d..815825d7adb 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/rules/CollectTestRule.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/rules/CollectTestRule.kt @@ -15,7 +15,7 @@ import org.odk.collect.androidtest.ActivityScenarioLauncherRule import java.util.function.Consumer class CollectTestRule @JvmOverloads constructor( - private val useDemoProject: Boolean = true, + private val useDemoProject: Boolean = true ) : ActivityScenarioLauncherRule() { override fun before() { @@ -58,7 +58,7 @@ class CollectTestRule @JvmOverloads constructor( fun > launchForResult( intent: Intent, destination: T, - actions: Consumer, + actions: Consumer ): Instrumentation.ActivityResult { val scenario = launchForResult(intent) destination.assertOnPage() diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/rules/ResetStateRule.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/rules/ResetStateRule.kt index 1a246d9dc58..4cf7e5abbe2 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/rules/ResetStateRule.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/rules/ResetStateRule.kt @@ -21,7 +21,7 @@ import java.io.IOException private class ResetStateStatement( private val base: Statement, - private val appDependencyModule: AppDependencyModule? = null, + private val appDependencyModule: AppDependencyModule? = null ) : Statement() { override fun evaluate() { @@ -68,7 +68,7 @@ private class ResetStateStatement( } class ResetStateRule @JvmOverloads constructor( - private val appDependencyModule: AppDependencyModule? = null, + private val appDependencyModule: AppDependencyModule? = null ) : TestRule { override fun apply(base: Statement, description: Description): Statement = diff --git a/collect_app/src/main/java/org/odk/collect/android/activities/FormEntryViewModelFactory.kt b/collect_app/src/main/java/org/odk/collect/android/activities/FormEntryViewModelFactory.kt index 3a2e1896484..fea6519fef2 100644 --- a/collect_app/src/main/java/org/odk/collect/android/activities/FormEntryViewModelFactory.kt +++ b/collect_app/src/main/java/org/odk/collect/android/activities/FormEntryViewModelFactory.kt @@ -39,13 +39,13 @@ class FormEntryViewModelFactory( private val settingsProvider: SettingsProvider, private val permissionsChecker: PermissionsChecker, private val fusedLocationClient: LocationClient, - private val permissionsProvider: PermissionsProvider, + private val permissionsProvider: PermissionsProvider ) : AbstractSavedStateViewModelFactory(owner, null) { override fun create( key: String, modelClass: Class, - handle: SavedStateHandle, + handle: SavedStateHandle ): T { return when (modelClass) { FormEntryViewModel::class.java -> FormEntryViewModel( diff --git a/collect_app/src/main/java/org/odk/collect/android/activities/viewmodels/CurrentProjectViewModel.kt b/collect_app/src/main/java/org/odk/collect/android/activities/viewmodels/CurrentProjectViewModel.kt index e0aaf752f7e..0a00014bab4 100644 --- a/collect_app/src/main/java/org/odk/collect/android/activities/viewmodels/CurrentProjectViewModel.kt +++ b/collect_app/src/main/java/org/odk/collect/android/activities/viewmodels/CurrentProjectViewModel.kt @@ -12,7 +12,7 @@ import org.odk.collect.projects.Project class CurrentProjectViewModel( private val currentProjectProvider: CurrentProjectProvider, - private val analyticsInitializer: AnalyticsInitializer, + private val analyticsInitializer: AnalyticsInitializer ) : ViewModel() { private val _currentProject by lazy { MutableNonNullLiveData(currentProjectProvider.getCurrentProject()) } @@ -42,7 +42,7 @@ class CurrentProjectViewModel( open class Factory( private val currentProjectProvider: CurrentProjectProvider, - private val analyticsInitializer: AnalyticsInitializer, + private val analyticsInitializer: AnalyticsInitializer ) : ViewModelProvider.Factory { override fun create(modelClass: Class): T { diff --git a/collect_app/src/main/java/org/odk/collect/android/configure/qr/ShowQRCodeFragment.kt b/collect_app/src/main/java/org/odk/collect/android/configure/qr/ShowQRCodeFragment.kt index 12bdab06f55..459790a17fa 100644 --- a/collect_app/src/main/java/org/odk/collect/android/configure/qr/ShowQRCodeFragment.kt +++ b/collect_app/src/main/java/org/odk/collect/android/configure/qr/ShowQRCodeFragment.kt @@ -137,7 +137,8 @@ class ShowQRCodeFragment : Fragment() { } override fun onChildViewRemoved(view: View, view1: View) {} - }) + } + ) } .show() } diff --git a/collect_app/src/main/java/org/odk/collect/android/database/DatabaseObjectMapper.kt b/collect_app/src/main/java/org/odk/collect/android/database/DatabaseObjectMapper.kt index 95a8c9bec23..b3cc87b1bb8 100644 --- a/collect_app/src/main/java/org/odk/collect/android/database/DatabaseObjectMapper.kt +++ b/collect_app/src/main/java/org/odk/collect/android/database/DatabaseObjectMapper.kt @@ -189,9 +189,13 @@ object DatabaseObjectMapper { .status(cursor.getString(statusColumnIndex)) .lastStatusChangeDate(cursor.getLong(lastStatusChangeDateColumnIndex)) .deletedDate( - if (cursor.isNull(deletedDateColumnIndex)) null else cursor.getLong( - deletedDateColumnIndex - ) + if (cursor.isNull(deletedDateColumnIndex)) { + null + } else { + cursor.getLong( + deletedDateColumnIndex + ) + } ) .geometryType(cursor.getString(geometryTypeColumnIndex)) .geometry(cursor.getString(geometryColumnIndex)) diff --git a/collect_app/src/main/java/org/odk/collect/android/draw/DrawView.kt b/collect_app/src/main/java/org/odk/collect/android/draw/DrawView.kt index 5d28f7e9c02..34f7b252ad1 100644 --- a/collect_app/src/main/java/org/odk/collect/android/draw/DrawView.kt +++ b/collect_app/src/main/java/org/odk/collect/android/draw/DrawView.kt @@ -121,8 +121,10 @@ class DrawView(context: Context?, attrs: AttributeSet?) : View(context, attrs) { private fun touchMove(x: Float, y: Float) { currentPath.quadTo(valueX, valueY, (x + valueX) / 2, (y + valueY) / 2) offscreenPath.quadTo( - valueX - bitmapLeft, valueY - bitmapTop, - (x + valueX) / 2 - bitmapLeft, (y + valueY) / 2 - bitmapTop + valueX - bitmapLeft, + valueY - bitmapTop, + (x + valueX) / 2 - bitmapLeft, + (y + valueY) / 2 - bitmapTop ) valueX = x valueY = y diff --git a/collect_app/src/main/java/org/odk/collect/android/external/FormUriActivity.kt b/collect_app/src/main/java/org/odk/collect/android/external/FormUriActivity.kt index 5879af19fab..67bdc6a86a6 100644 --- a/collect_app/src/main/java/org/odk/collect/android/external/FormUriActivity.kt +++ b/collect_app/src/main/java/org/odk/collect/android/external/FormUriActivity.kt @@ -57,7 +57,7 @@ class FormUriActivity : ComponentActivity() { it.action = intent.action it.data = uri intent.extras?.let { sourceExtras -> it.putExtras(sourceExtras) } - }, + } ) } } else { diff --git a/collect_app/src/main/java/org/odk/collect/android/formentry/QuitFormDialog.kt b/collect_app/src/main/java/org/odk/collect/android/formentry/QuitFormDialog.kt index 916a98d0ce5..62e71e5cfb1 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formentry/QuitFormDialog.kt +++ b/collect_app/src/main/java/org/odk/collect/android/formentry/QuitFormDialog.kt @@ -30,7 +30,7 @@ object QuitFormDialog { formEntryViewModel: FormEntryViewModel, settingsProvider: SettingsProvider, currentProjectProvider: CurrentProjectProvider, - onSaveChangesClicked: Runnable?, + onSaveChangesClicked: Runnable? ): AlertDialog { return create( activity, @@ -50,7 +50,7 @@ object QuitFormDialog { formEntryViewModel: FormEntryViewModel, settingsProvider: SettingsProvider, currentProjectProvider: CurrentProjectProvider, - onSaveChangesClicked: Runnable?, + onSaveChangesClicked: Runnable? ): AlertDialog { val title: String = if (formSaveViewModel.formName == null) activity.resources.getString(R.string.no_form_loaded) else formSaveViewModel.getFormName() diff --git a/collect_app/src/main/java/org/odk/collect/android/formentry/audit/AuditUtils.kt b/collect_app/src/main/java/org/odk/collect/android/formentry/audit/AuditUtils.kt index d62bad4bb30..f63b5bbddc8 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formentry/audit/AuditUtils.kt +++ b/collect_app/src/main/java/org/odk/collect/android/formentry/audit/AuditUtils.kt @@ -18,9 +18,11 @@ object AuditUtils { try { for (question in formController.getQuestionPrompts()) { val answer = - if (question.answerValue != null) + if (question.answerValue != null) { question.answerValue!!.displayText - else null + } else { + null + } auditEventLogger.logEvent( AuditEvent.AuditEventType.QUESTION, diff --git a/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt b/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt index f4778f48f5c..566552ca8a6 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt +++ b/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt @@ -54,7 +54,7 @@ class BlankFormListViewModel( LiveDataUtils.zip3( isFormLoadingRunning, isSyncingWithStorageRunning, - syncRepository.isSyncing(projectId), + syncRepository.isSyncing(projectId) ) ) { (one, two, three) -> one || two || three } diff --git a/collect_app/src/main/java/org/odk/collect/android/formmanagement/formmap/FormMapViewModel.kt b/collect_app/src/main/java/org/odk/collect/android/formmanagement/formmap/FormMapViewModel.kt index e8a58f4c37e..6e4b806c08e 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formmanagement/formmap/FormMapViewModel.kt +++ b/collect_app/src/main/java/org/odk/collect/android/formmanagement/formmap/FormMapViewModel.kt @@ -100,7 +100,7 @@ class FormMapViewModel( private fun createItem( instance: Instance, latitude: Double, - longitude: Double, + longitude: Double ): MappableSelectItem { val instanceLastStatusChangeDate = InstanceProvider.getDisplaySubtext( resources, diff --git a/collect_app/src/main/java/org/odk/collect/android/fragments/dialogs/NumberPickerDialog.kt b/collect_app/src/main/java/org/odk/collect/android/fragments/dialogs/NumberPickerDialog.kt index 623ebcd5ad7..a64b7c9f8f2 100644 --- a/collect_app/src/main/java/org/odk/collect/android/fragments/dialogs/NumberPickerDialog.kt +++ b/collect_app/src/main/java/org/odk/collect/android/fragments/dialogs/NumberPickerDialog.kt @@ -55,7 +55,8 @@ class NumberPickerDialog : DialogFragment() { .setView(view) .setPositiveButton(R.string.ok) { _, _ -> listener?.onNumberPickerValueSelected( - requireArguments().getInt(WIDGET_ID), numberPicker.value + requireArguments().getInt(WIDGET_ID), + numberPicker.value ) } .setNegativeButton(R.string.cancel) { _, _ -> } diff --git a/collect_app/src/main/java/org/odk/collect/android/injection/config/CollectGeoDependencyModule.kt b/collect_app/src/main/java/org/odk/collect/android/injection/config/CollectGeoDependencyModule.kt index e2f6b823dfb..ba7d252f7e4 100644 --- a/collect_app/src/main/java/org/odk/collect/android/injection/config/CollectGeoDependencyModule.kt +++ b/collect_app/src/main/java/org/odk/collect/android/injection/config/CollectGeoDependencyModule.kt @@ -20,7 +20,7 @@ class CollectGeoDependencyModule( private val mapFragmentFactory: MapFragmentFactory, private val locationClient: LocationClient, private val scheduler: Scheduler, - private val permissionChecker: PermissionsChecker, + private val permissionChecker: PermissionsChecker ) : GeoDependencyModule() { override fun providesReferenceLayerSettingsNavigator(): ReferenceLayerSettingsNavigator { diff --git a/collect_app/src/main/java/org/odk/collect/android/injection/config/CollectOsmDroidDependencyModule.kt b/collect_app/src/main/java/org/odk/collect/android/injection/config/CollectOsmDroidDependencyModule.kt index 1d4666fe727..08dfe459ae9 100644 --- a/collect_app/src/main/java/org/odk/collect/android/injection/config/CollectOsmDroidDependencyModule.kt +++ b/collect_app/src/main/java/org/odk/collect/android/injection/config/CollectOsmDroidDependencyModule.kt @@ -11,7 +11,7 @@ import org.odk.collect.settings.keys.ProjectKeys class CollectOsmDroidDependencyModule( private val referenceLayerRepository: ReferenceLayerRepository, private val locationClient: LocationClient, - private val settingsProvider: SettingsProvider, + private val settingsProvider: SettingsProvider ) : OsmDroidDependencyModule() { override fun providesReferenceLayerRepository(): ReferenceLayerRepository { return referenceLayerRepository diff --git a/collect_app/src/main/java/org/odk/collect/android/notifications/builders/FormUpdatesDownloadedNotificationBuilder.kt b/collect_app/src/main/java/org/odk/collect/android/notifications/builders/FormUpdatesDownloadedNotificationBuilder.kt index 6e1d19750e2..a9f1476fd49 100644 --- a/collect_app/src/main/java/org/odk/collect/android/notifications/builders/FormUpdatesDownloadedNotificationBuilder.kt +++ b/collect_app/src/main/java/org/odk/collect/android/notifications/builders/FormUpdatesDownloadedNotificationBuilder.kt @@ -39,16 +39,22 @@ object FormUpdatesDownloadedNotificationBuilder { ) val title = - if (allFormsDownloadedSuccessfully) application.getLocalizedString(R.string.forms_download_succeeded) - else application.getLocalizedString(R.string.forms_download_failed) + if (allFormsDownloadedSuccessfully) { + application.getLocalizedString(R.string.forms_download_succeeded) + } else { + application.getLocalizedString(R.string.forms_download_failed) + } val message = - if (allFormsDownloadedSuccessfully) application.getLocalizedString(R.string.all_downloads_succeeded) - else application.getLocalizedString( - R.string.some_downloads_failed, - FormsDownloadResultInterpreter.getNumberOfFailures(result), - result.size - ) + if (allFormsDownloadedSuccessfully) { + application.getLocalizedString(R.string.all_downloads_succeeded) + } else { + application.getLocalizedString( + R.string.some_downloads_failed, + FormsDownloadResultInterpreter.getNumberOfFailures(result), + result.size + ) + } return NotificationCompat.Builder( application, diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/screens/MapsPreferencesFragment.kt b/collect_app/src/main/java/org/odk/collect/android/preferences/screens/MapsPreferencesFragment.kt index 81a7a07f9d4..67e5700c767 100644 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/screens/MapsPreferencesFragment.kt +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/screens/MapsPreferencesFragment.kt @@ -100,8 +100,11 @@ class MapsPreferencesFragment : BaseProjectPreferencesFragment() { */ private fun initBasemapSourcePref() { basemapSourcePref = PrefUtils.createListPref( - requireContext(), KEY_BASEMAP_SOURCE, getString(R.string.basemap_source), - MapConfiguratorProvider.getLabelIds(), MapConfiguratorProvider.getIds(), + requireContext(), + KEY_BASEMAP_SOURCE, + getString(R.string.basemap_source), + MapConfiguratorProvider.getLabelIds(), + MapConfiguratorProvider.getIds(), settingsProvider.getUnprotectedSettings() ) basemapSourcePref.setIconSpaceReserved(false) diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragment.kt b/collect_app/src/main/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragment.kt index 8ca015127a1..e2827f31ad1 100644 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragment.kt +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragment.kt @@ -53,7 +53,8 @@ class ProjectDisplayPreferencesFragment : projectsRepository.save(Project.Saved(uuid, name, icon, color)) findPreference(PROJECT_COLOR_KEY)!!.summaryProvider = ProjectDetailsSummaryProvider( - PROJECT_COLOR_KEY, currentProjectProvider + PROJECT_COLOR_KEY, + currentProjectProvider ) } ) @@ -66,15 +67,18 @@ class ProjectDisplayPreferencesFragment : findPreference(PROJECT_NAME_KEY)!!.summaryProvider = ProjectDetailsSummaryProvider( - PROJECT_NAME_KEY, currentProjectProvider + PROJECT_NAME_KEY, + currentProjectProvider ) findPreference(PROJECT_ICON_KEY)!!.summaryProvider = ProjectDetailsSummaryProvider( - PROJECT_ICON_KEY, currentProjectProvider + PROJECT_ICON_KEY, + currentProjectProvider ) findPreference(PROJECT_COLOR_KEY)!!.summaryProvider = ProjectDetailsSummaryProvider( - PROJECT_COLOR_KEY, currentProjectProvider + PROJECT_COLOR_KEY, + currentProjectProvider ) findPreference(PROJECT_NAME_KEY)!!.onPreferenceChangeListener = this findPreference(PROJECT_ICON_KEY)!!.onPreferenceChangeListener = this @@ -105,7 +109,9 @@ class ProjectDisplayPreferencesFragment : currentProjectProvider.getCurrentProject().color ) ), - 0, summary.length, 0 + 0, + summary.length, + 0 ) summary } @@ -168,7 +174,10 @@ class ProjectDisplayPreferencesFragment : projectsRepository.save( Project.Saved( - uuid, newValue.toString(), icon, color + uuid, + newValue.toString(), + icon, + color ) ) } @@ -177,7 +186,10 @@ class ProjectDisplayPreferencesFragment : projectsRepository.save( Project.Saved( - uuid, name, newValue.toString(), color + uuid, + name, + newValue.toString(), + color ) ) } diff --git a/collect_app/src/main/java/org/odk/collect/android/utilities/Appearances.kt b/collect_app/src/main/java/org/odk/collect/android/utilities/Appearances.kt index 6055298d586..27c9c6c3ab5 100644 --- a/collect_app/src/main/java/org/odk/collect/android/utilities/Appearances.kt +++ b/collect_app/src/main/java/org/odk/collect/android/utilities/Appearances.kt @@ -34,17 +34,21 @@ object Appearances { const val YEAR = "year" // Select one/multiple appearances - @Deprecated("") const val COMPACT = "compact" + @Deprecated("") + const val COMPACT = "compact" - @Deprecated("") const val COMPACT_N = "compact-" + @Deprecated("") + const val COMPACT_N = "compact-" const val MINIMAL = "minimal" const val COLUMNS = "columns" const val COLUMNS_N = "columns-" const val COLUMNS_PACK = "columns-pack" - @Deprecated("") const val QUICKCOMPACT = "quickcompact" + @Deprecated("") + const val QUICKCOMPACT = "quickcompact" - @Deprecated("") const val SEARCH = "search" + @Deprecated("") + const val SEARCH = "search" const val AUTOCOMPLETE = "autocomplete" const val LIST_NO_LABEL = "list-nolabel" const val LIST = "list" @@ -60,7 +64,8 @@ object Appearances { const val ANNOTATE = "annotate" const val DRAW = "draw" - @Deprecated("") const val SELFIE = "selfie" + @Deprecated("") + const val SELFIE = "selfie" const val NEW_FRONT = "new-front" const val NEW = "new" const val FRONT = "front" @@ -124,9 +129,13 @@ object Appearances { val substringFromNumColumns = appearance.substring(idx + columnsAppearance.length) numColumns = substringFromNumColumns.substring( 0, - if (substringFromNumColumns.contains(" ")) substringFromNumColumns.indexOf( - ' ' - ) else substringFromNumColumns.length + if (substringFromNumColumns.contains(" ")) { + substringFromNumColumns.indexOf( + ' ' + ) + } else { + substringFromNumColumns.length + } ).toInt() if (numColumns < 1) { numColumns = 1 diff --git a/collect_app/src/main/java/org/odk/collect/android/utilities/MediaUtils.kt b/collect_app/src/main/java/org/odk/collect/android/utilities/MediaUtils.kt index a930de5010d..be31cda9916 100644 --- a/collect_app/src/main/java/org/odk/collect/android/utilities/MediaUtils.kt +++ b/collect_app/src/main/java/org/odk/collect/android/utilities/MediaUtils.kt @@ -76,8 +76,11 @@ class MediaUtils(private val intentLauncher: IntentLauncher, private val content } private fun getMimeType(file: File, expectedMimeType: String?) = - if (expectedMimeType == null || expectedMimeType.isEmpty()) FileUtils.getMimeType(file) - else expectedMimeType + if (expectedMimeType == null || expectedMimeType.isEmpty()) { + FileUtils.getMimeType(file) + } else { + expectedMimeType + } fun pickFile(activity: Activity, mimeType: String, requestCode: Int) { val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply { diff --git a/collect_app/src/main/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragment.kt b/collect_app/src/main/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragment.kt index cdfd2552d14..cc8957e4a88 100644 --- a/collect_app/src/main/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragment.kt +++ b/collect_app/src/main/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragment.kt @@ -70,7 +70,7 @@ class SelectOneFromMapDialogFragment(private val viewModelFactory: ViewModelProv override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?, + savedInstanceState: Bundle? ): View { val binding = SelectOneFromMapDialogLayoutBinding.inflate(inflater) return binding.root @@ -107,7 +107,7 @@ internal class SelectChoicesMapData( private val resources: Resources, scheduler: Scheduler, prompt: FormEntryPrompt, - private val selectedIndex: Int?, + private val selectedIndex: Int? ) : SelectionMapData { private val mapTitle = MutableLiveData(prompt.longText) @@ -132,7 +132,7 @@ internal class SelectChoicesMapData( private fun loadItemsFromChoices( selectChoices: MutableList, - prompt: FormEntryPrompt, + prompt: FormEntryPrompt ): List { return selectChoices.foldIndexed(emptyList()) { index, list, selectChoice -> val geometry = selectChoice.getChild("geometry") diff --git a/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/ActivityGeoDataRequester.kt b/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/ActivityGeoDataRequester.kt index d706437ce6b..fe33ae81039 100644 --- a/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/ActivityGeoDataRequester.kt +++ b/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/ActivityGeoDataRequester.kt @@ -20,13 +20,13 @@ import java.lang.Boolean.parseBoolean class ActivityGeoDataRequester( private val permissionsProvider: PermissionsProvider, - private val activity: Activity, + private val activity: Activity ) : GeoDataRequester { override fun requestGeoPoint( prompt: FormEntryPrompt, answerText: String?, - waitingForDataRegistry: WaitingForDataRegistry, + waitingForDataRegistry: WaitingForDataRegistry ) { permissionsProvider.requestEnabledLocationPermissions( activity, @@ -38,7 +38,7 @@ class ActivityGeoDataRequester( if (!answerText.isNullOrEmpty()) { it.putParcelable( GeoPointMapActivity.EXTRA_LOCATION, - GeoWidgetUtils.parseGeometry(answerText)[0], + GeoWidgetUtils.parseGeometry(answerText)[0] ) } @@ -47,18 +47,18 @@ class ActivityGeoDataRequester( val unacceptableAccuracyThreshold = FormEntryPromptUtils.getBodyAttribute( prompt, - "unacceptableAccuracyThreshold", + "unacceptableAccuracyThreshold" ) it.putFloat( GeoPointActivity.EXTRA_ACCURACY_THRESHOLD, - accuracyThreshold?.toFloatOrNull() ?: DEFAULT_ACCURACY_THRESHOLD, + accuracyThreshold?.toFloatOrNull() ?: DEFAULT_ACCURACY_THRESHOLD ) it.putFloat( GeoPointActivity.EXTRA_UNACCEPTABLE_ACCURACY_THRESHOLD, unacceptableAccuracyThreshold?.toFloatOrNull() - ?: DEFAULT_UNACCEPTABLE_ACCURACY_THRESHOLD, + ?: DEFAULT_UNACCEPTABLE_ACCURACY_THRESHOLD ) it.putBoolean(EXTRA_RETAIN_MOCK_ACCURACY, getAllowMockAccuracy(prompt)) @@ -68,24 +68,24 @@ class ActivityGeoDataRequester( val intent = Intent( activity, - if (isMapsAppearance(prompt)) GeoPointMapActivity::class.java else GeoPointActivity::class.java, + if (isMapsAppearance(prompt)) GeoPointMapActivity::class.java else GeoPointActivity::class.java ).also { it.putExtras(bundle) } activity.startActivityForResult( intent, - ApplicationConstants.RequestCodes.LOCATION_CAPTURE, + ApplicationConstants.RequestCodes.LOCATION_CAPTURE ) } - }, + } ) } override fun requestGeoShape( prompt: FormEntryPrompt, answerText: String?, - waitingForDataRegistry: WaitingForDataRegistry, + waitingForDataRegistry: WaitingForDataRegistry ) { permissionsProvider.requestEnabledLocationPermissions( activity, @@ -100,7 +100,7 @@ class ActivityGeoDataRequester( ) it.putExtra( GeoPolyActivity.OUTPUT_MODE_KEY, - GeoPolyActivity.OutputMode.GEOSHAPE, + GeoPolyActivity.OutputMode.GEOSHAPE ) it.putExtra(EXTRA_READ_ONLY, prompt.isReadOnly) it.putExtra(EXTRA_RETAIN_MOCK_ACCURACY, getAllowMockAccuracy(prompt)) @@ -108,17 +108,17 @@ class ActivityGeoDataRequester( activity.startActivityForResult( intent, - ApplicationConstants.RequestCodes.GEOSHAPE_CAPTURE, + ApplicationConstants.RequestCodes.GEOSHAPE_CAPTURE ) } - }, + } ) } override fun requestGeoTrace( prompt: FormEntryPrompt, answerText: String?, - waitingForDataRegistry: WaitingForDataRegistry, + waitingForDataRegistry: WaitingForDataRegistry ) { permissionsProvider.requestEnabledLocationPermissions( activity, @@ -133,7 +133,7 @@ class ActivityGeoDataRequester( ) it.putExtra( GeoPolyActivity.OUTPUT_MODE_KEY, - GeoPolyActivity.OutputMode.GEOTRACE, + GeoPolyActivity.OutputMode.GEOTRACE ) it.putExtra(EXTRA_READ_ONLY, prompt.isReadOnly) it.putExtra(EXTRA_RETAIN_MOCK_ACCURACY, getAllowMockAccuracy(prompt)) @@ -141,10 +141,10 @@ class ActivityGeoDataRequester( activity.startActivityForResult( intent, - ApplicationConstants.RequestCodes.GEOTRACE_CAPTURE, + ApplicationConstants.RequestCodes.GEOTRACE_CAPTURE ) } - }, + } ) } diff --git a/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/FileRequester.kt b/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/FileRequester.kt index 756510f534c..62a5723b3ba 100644 --- a/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/FileRequester.kt +++ b/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/FileRequester.kt @@ -25,15 +25,20 @@ class FileRequesterImpl( val intent = externalAppIntentProvider.getIntentToRunExternalApp(formController, formEntryPrompt) val intentWithoutDefaultCategory = externalAppIntentProvider.getIntentToRunExternalAppWithoutDefaultCategory( - formController, formEntryPrompt, + formController, + formEntryPrompt, activity.packageManager ) intentLauncher.launchForResult( - activity, intent, requestCode + activity, + intent, + requestCode ) { intentLauncher.launchForResult( - activity, intentWithoutDefaultCategory, requestCode + activity, + intentWithoutDefaultCategory, + requestCode ) { showLongToast(activity, getErrorMessage(formEntryPrompt, activity)) } diff --git a/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/GeoWidgetUtils.kt b/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/GeoWidgetUtils.kt index 2f7bd1949e6..4a7eca5e5ca 100644 --- a/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/GeoWidgetUtils.kt +++ b/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/GeoWidgetUtils.kt @@ -83,7 +83,7 @@ object GeoWidgetUtils { fun convertCoordinatesIntoDegreeFormat( context: Context, coordinate: Double, - type: String, + type: String ): String { val coordinateDegrees = Location.convert(abs(coordinate), Location.FORMAT_SECONDS) val coordinateSplit = coordinateDegrees.split(":").toTypedArray() diff --git a/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/StringRequester.kt b/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/StringRequester.kt index 5179fcdcd12..b0e0737ab3d 100644 --- a/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/StringRequester.kt +++ b/collect_app/src/main/java/org/odk/collect/android/widgets/utilities/StringRequester.kt @@ -41,7 +41,8 @@ class StringRequesterImpl( if (intent != null && Intent.ACTION_SENDTO == intent.action) { intentLauncher.launch(activity, intent) { intentLauncher.launch( - activity, intentWithoutDefaultCategory + activity, + intentWithoutDefaultCategory ) { onError(getErrorMessage(formEntryPrompt, activity)) } @@ -49,7 +50,9 @@ class StringRequesterImpl( } else { intentLauncher.launchForResult(activity, intent, requestCode) { intentLauncher.launchForResult( - activity, intentWithoutDefaultCategory, requestCode + activity, + intentWithoutDefaultCategory, + requestCode ) { onError(getErrorMessage(formEntryPrompt, activity)) } diff --git a/collect_app/src/test/java/org/odk/collect/android/activities/MainMenuActivityTest.kt b/collect_app/src/test/java/org/odk/collect/android/activities/MainMenuActivityTest.kt index 5d849b4ad1f..c6a974faa41 100644 --- a/collect_app/src/test/java/org/odk/collect/android/activities/MainMenuActivityTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/activities/MainMenuActivityTest.kt @@ -11,8 +11,8 @@ import androidx.lifecycle.ViewModel import androidx.test.espresso.intent.Intents import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent import androidx.test.ext.junit.runners.AndroidJUnit4 -import org.hamcrest.CoreMatchers.`is` import org.hamcrest.CoreMatchers.equalTo +import org.hamcrest.CoreMatchers.`is` import org.hamcrest.MatcherAssert.assertThat import org.junit.Before import org.junit.Rule @@ -66,7 +66,7 @@ class MainMenuActivityTest { application: Application, settingsProvider: SettingsProvider, instancesAppState: InstancesAppState, - scheduler: Scheduler, + scheduler: Scheduler ): MainMenuViewModel.Factory { return object : MainMenuViewModel.Factory( versionInformation, @@ -85,7 +85,7 @@ class MainMenuActivityTest { currentProjectProvider: CurrentProjectProvider, analyticsInitializer: AnalyticsInitializer, storagePathProvider: StoragePathProvider, - projectsRepository: ProjectsRepository, + projectsRepository: ProjectsRepository ): CurrentProjectViewModel.Factory { return object : CurrentProjectViewModel.Factory( currentProjectProvider, diff --git a/collect_app/src/test/java/org/odk/collect/android/configure/qr/QRCodeActivityResultDelegateTest.kt b/collect_app/src/test/java/org/odk/collect/android/configure/qr/QRCodeActivityResultDelegateTest.kt index ceb01c46e65..f335f3cf5a8 100644 --- a/collect_app/src/test/java/org/odk/collect/android/configure/qr/QRCodeActivityResultDelegateTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/configure/qr/QRCodeActivityResultDelegateTest.kt @@ -129,7 +129,8 @@ class QRCodeActivityResultDelegateTest { val inputStream = ByteArrayInputStream(streamContents.toByteArray()) Shadows.shadowOf(ApplicationProvider.getApplicationContext().contentResolver) .registerInputStream( - Uri.parse("file://qr"), inputStream + Uri.parse("file://qr"), + inputStream ) val data = Intent() data.data = Uri.parse(uri) diff --git a/collect_app/src/test/java/org/odk/collect/android/configure/qr/QRCodeMenuDelegateTest.kt b/collect_app/src/test/java/org/odk/collect/android/configure/qr/QRCodeMenuDelegateTest.kt index 1dab8a32fdd..4589473d1be 100644 --- a/collect_app/src/test/java/org/odk/collect/android/configure/qr/QRCodeMenuDelegateTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/configure/qr/QRCodeMenuDelegateTest.kt @@ -46,8 +46,13 @@ class QRCodeMenuDelegateTest { private fun setupMenuDelegate() { menuDelegate = QRCodeMenuDelegate( - activity, intentLauncher, qrCodeGenerator, - appConfigurationGenerator, fileProvider, getSettingsProvider(), fakeScheduler + activity, + intentLauncher, + qrCodeGenerator, + appConfigurationGenerator, + fileProvider, + getSettingsProvider(), + fakeScheduler ) } @@ -75,7 +80,8 @@ class QRCodeMenuDelegateTest { menuDelegate.onOptionsItemSelected(RoboMenuItem(R.id.menu_item_scan_sd_card)) assertThat( - Shadows.shadowOf(activity).nextStartedActivityForResult, nullValue() + Shadows.shadowOf(activity).nextStartedActivityForResult, + nullValue() ) assertThat(ShadowToast.getLatestToast(), notNullValue()) } diff --git a/collect_app/src/test/java/org/odk/collect/android/database/DatabaseConnectionTest.kt b/collect_app/src/test/java/org/odk/collect/android/database/DatabaseConnectionTest.kt index 0c048aee40e..ba3895c8c03 100644 --- a/collect_app/src/test/java/org/odk/collect/android/database/DatabaseConnectionTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/database/DatabaseConnectionTest.kt @@ -13,8 +13,8 @@ import java.io.File @RunWith(AndroidJUnit4::class) class DatabaseConnectionTest { - @Test // https://github.com/getodk/collect/issues/5042 + @Test fun `database file should be recreated if removed between operations`() { val dbDir = createTempDir() val formsDbPath = dbDir.absolutePath + File.separator + "forms.db" diff --git a/collect_app/src/test/java/org/odk/collect/android/formentry/AudioVideoImageTextLabelVisibilityTest.kt b/collect_app/src/test/java/org/odk/collect/android/formentry/AudioVideoImageTextLabelVisibilityTest.kt index 10f71ebb9de..e77f3200cf5 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formentry/AudioVideoImageTextLabelVisibilityTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formentry/AudioVideoImageTextLabelVisibilityTest.kt @@ -51,7 +51,9 @@ class AudioVideoImageTextLabelVisibilityTest( WidgetTestActivity::class.java ) audioHelper = AudioHelper( - activity, activity.viewLifecycle, mock(), + activity, + activity.viewLifecycle, + mock(), { mock() } diff --git a/collect_app/src/test/java/org/odk/collect/android/formentry/QuitFormDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/formentry/QuitFormDialogTest.kt index 30fbca790f9..54997571431 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formentry/QuitFormDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formentry/QuitFormDialogTest.kt @@ -41,7 +41,7 @@ class QuitFormDialogTest { assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).visibility, equalTo(View.GONE)) assertThat( dialog.getButton(DialogInterface.BUTTON_NEGATIVE).visibility, - equalTo(View.VISIBLE), + equalTo(View.VISIBLE) ) assertThat( dialog.getButton(DialogInterface.BUTTON_NEGATIVE).text, @@ -76,7 +76,7 @@ class QuitFormDialogTest { val dialogTitle = dialog.findViewById(R.id.alertTitle) assertThat( dialogTitle!!.text.toString(), - equalTo(activity.getString(R.string.quit_application, "blah")), + equalTo(activity.getString(R.string.quit_application, "blah")) ) } diff --git a/collect_app/src/test/java/org/odk/collect/android/formlists/blankformlist/BlankFormListMenuDelegateTest.kt b/collect_app/src/test/java/org/odk/collect/android/formlists/blankformlist/BlankFormListMenuDelegateTest.kt index 794f4631e10..f494e76a5bd 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formlists/blankformlist/BlankFormListMenuDelegateTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formlists/blankformlist/BlankFormListMenuDelegateTest.kt @@ -8,8 +8,8 @@ import androidx.core.internal.view.SupportMenu import androidx.fragment.app.FragmentActivity import androidx.lifecycle.MutableLiveData import androidx.test.ext.junit.runners.AndroidJUnit4 -import org.hamcrest.CoreMatchers.`is` import org.hamcrest.CoreMatchers.instanceOf +import org.hamcrest.CoreMatchers.`is` import org.hamcrest.CoreMatchers.nullValue import org.hamcrest.MatcherAssert.assertThat import org.junit.Before @@ -109,7 +109,8 @@ class BlankFormListMenuDelegateTest { menuDelegate.onOptionsItemSelected(RoboMenuItem(R.id.menu_refresh)) assertThat( - ShadowToast.getTextOfLatestToast(), `is`(activity.getString(R.string.form_update_succeeded)) + ShadowToast.getTextOfLatestToast(), + `is`(activity.getString(R.string.form_update_succeeded)) ) } @@ -131,7 +132,8 @@ class BlankFormListMenuDelegateTest { menuDelegate.onOptionsItemSelected(RoboMenuItem(R.id.menu_refresh)) assertThat( - ShadowToast.getTextOfLatestToast(), `is`(activity.getString(R.string.no_connection)) + ShadowToast.getTextOfLatestToast(), + `is`(activity.getString(R.string.no_connection)) ) verify(viewModel, never()).syncWithServer() } diff --git a/collect_app/src/test/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModelTest.kt b/collect_app/src/test/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModelTest.kt index 7b4d23802df..c6f94cd6b1c 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModelTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModelTest.kt @@ -4,8 +4,8 @@ import android.app.Application import androidx.lifecycle.MutableLiveData import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 -import org.hamcrest.CoreMatchers.`is` import org.hamcrest.CoreMatchers.equalTo +import org.hamcrest.CoreMatchers.`is` import org.hamcrest.MatcherAssert.assertThat import org.junit.Test import org.junit.runner.RunWith @@ -336,7 +336,7 @@ class BlankFormListViewModelTest { instance(formId = "3", lastStatusChangeDate = 2L), instance(formId = "5", lastStatusChangeDate = 3L), instance(formId = "4", lastStatusChangeDate = 4L), - instance(formId = "2", lastStatusChangeDate = 5L), + instance(formId = "2", lastStatusChangeDate = 5L) ) createViewModel() @@ -383,7 +383,7 @@ class BlankFormListViewModelTest { saveInstances( instance(formId = "1", lastStatusChangeDate = 1L), - instance(formId = "3", lastStatusChangeDate = 2L), + instance(formId = "3", lastStatusChangeDate = 2L) ) createViewModel() @@ -408,7 +408,7 @@ class BlankFormListViewModelTest { saveInstances( instance(formId = "1", lastStatusChangeDate = 1L, version = "1"), instance(formId = "2", lastStatusChangeDate = 2L), - instance(formId = "1", lastStatusChangeDate = 3L, version = "2"), + instance(formId = "1", lastStatusChangeDate = 3L, version = "2") ) createViewModel(shouldHideOldFormVersions = false) diff --git a/collect_app/src/test/java/org/odk/collect/android/formmanagement/FormDownloadExceptionMapperTest.kt b/collect_app/src/test/java/org/odk/collect/android/formmanagement/FormDownloadExceptionMapperTest.kt index a088dd6abbd..57200ecd4e3 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formmanagement/FormDownloadExceptionMapperTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formmanagement/FormDownloadExceptionMapperTest.kt @@ -24,7 +24,7 @@ class FormDownloadExceptionMapperTest { @Test fun formWithNoHashError_returnsFormWithNoHashErrorMessage() { val expectedString = context.getString( - R.string.form_with_no_hash_error, + R.string.form_with_no_hash_error ) + " " + context.getString(R.string.report_to_project_lead) assertThat( mapper.getMessage(FormDownloadException.FormWithNoHash()), @@ -35,7 +35,7 @@ class FormDownloadExceptionMapperTest { @Test fun formParsingError_returnsFormParsingErrorMessage() { val expectedString = context.getString( - R.string.form_parsing_error, + R.string.form_parsing_error ) + " " + context.getString(R.string.report_to_project_lead) assertThat( mapper.getMessage(FormDownloadException.FormParsingError()), @@ -46,7 +46,7 @@ class FormDownloadExceptionMapperTest { @Test fun formSaveError_returnsFormSaveErrorMessage() { val expectedString = context.getString( - R.string.form_save_disk_error, + R.string.form_save_disk_error ) + " " + context.getString(R.string.report_to_project_lead) assertThat( mapper.getMessage(FormDownloadException.DiskError()), @@ -57,7 +57,7 @@ class FormDownloadExceptionMapperTest { @Test fun formWithInvalidSubmissionError_returnsFormInvalidSubmissionErrorMessage() { val expectedString = context.getString( - R.string.form_with_invalid_submission_error, + R.string.form_with_invalid_submission_error ) + " " + context.getString(R.string.report_to_project_lead) assertThat( mapper.getMessage(FormDownloadException.InvalidSubmission()), diff --git a/collect_app/src/test/java/org/odk/collect/android/formmanagement/FormUpdateDownloaderTest.kt b/collect_app/src/test/java/org/odk/collect/android/formmanagement/FormUpdateDownloaderTest.kt index ff71cd7c047..61deb926234 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formmanagement/FormUpdateDownloaderTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formmanagement/FormUpdateDownloaderTest.kt @@ -1,8 +1,8 @@ package org.odk.collect.android.formmanagement import androidx.test.espresso.matcher.ViewMatchers.assertThat -import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.`is` import org.junit.Test import org.mockito.Mockito.any import org.mockito.Mockito.doAnswer diff --git a/collect_app/src/test/java/org/odk/collect/android/formmanagement/ServerFormsDetailsFetcherTest.kt b/collect_app/src/test/java/org/odk/collect/android/formmanagement/ServerFormsDetailsFetcherTest.kt index 1f40e238a6e..5a18953f035 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formmanagement/ServerFormsDetailsFetcherTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formmanagement/ServerFormsDetailsFetcherTest.kt @@ -1,8 +1,8 @@ package org.odk.collect.android.formmanagement import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.contains +import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.nullValue import org.junit.Test import org.mockito.kotlin.doReturn diff --git a/collect_app/src/test/java/org/odk/collect/android/formmanagement/formmap/FormMapViewModelTest.kt b/collect_app/src/test/java/org/odk/collect/android/formmanagement/formmap/FormMapViewModelTest.kt index ca921e516c3..759c1cb284a 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formmanagement/formmap/FormMapViewModelTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formmanagement/formmap/FormMapViewModelTest.kt @@ -252,7 +252,7 @@ class FormMapViewModelTest { ) ) ), - info = formatDate(R.string.deleted_on_date_at_time, 123L), + info = formatDate(R.string.deleted_on_date_at_time, 123L) ) assertThat(viewModel.getMappableItems().value!![0], equalTo(expectedItem)) } diff --git a/collect_app/src/test/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragmentTest.kt b/collect_app/src/test/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragmentTest.kt index 67cd93c1789..fa4e0623832 100644 --- a/collect_app/src/test/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragmentTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragmentTest.kt @@ -11,8 +11,8 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith -import org.mockito.Mockito.`when` import org.mockito.Mockito.mock +import org.mockito.Mockito.`when` import org.odk.collect.android.R import org.odk.collect.android.application.Collect import org.odk.collect.android.injection.config.AppDependencyModule diff --git a/collect_app/src/test/java/org/odk/collect/android/preferences/source/SettingsStoreTest.kt b/collect_app/src/test/java/org/odk/collect/android/preferences/source/SettingsStoreTest.kt index dcbb4bf5062..442092a0604 100644 --- a/collect_app/src/test/java/org/odk/collect/android/preferences/source/SettingsStoreTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/preferences/source/SettingsStoreTest.kt @@ -4,9 +4,9 @@ import org.hamcrest.CoreMatchers.`is` import org.hamcrest.MatcherAssert.assertThat import org.junit.Before import org.junit.Test -import org.mockito.Mockito.`when` import org.mockito.Mockito.mock import org.mockito.Mockito.verify +import org.mockito.Mockito.`when` import org.odk.collect.shared.settings.Settings class SettingsStoreTest { diff --git a/collect_app/src/test/java/org/odk/collect/android/projects/CurrentProjectProviderTest.kt b/collect_app/src/test/java/org/odk/collect/android/projects/CurrentProjectProviderTest.kt index 69de0e3e121..54e37fff770 100644 --- a/collect_app/src/test/java/org/odk/collect/android/projects/CurrentProjectProviderTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/projects/CurrentProjectProviderTest.kt @@ -1,8 +1,8 @@ package org.odk.collect.android.projects import androidx.test.espresso.matcher.ViewMatchers.assertThat -import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.`is` import org.junit.Test import org.odk.collect.projects.InMemProjectsRepository import org.odk.collect.projects.Project diff --git a/collect_app/src/test/java/org/odk/collect/android/projects/ProjectDeleterTest.kt b/collect_app/src/test/java/org/odk/collect/android/projects/ProjectDeleterTest.kt index ff676f6eaed..fec25612199 100644 --- a/collect_app/src/test/java/org/odk/collect/android/projects/ProjectDeleterTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/projects/ProjectDeleterTest.kt @@ -1,8 +1,8 @@ package org.odk.collect.android.projects import androidx.test.espresso.matcher.ViewMatchers.assertThat -import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.instanceOf +import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.nullValue import org.junit.Before import org.junit.Test diff --git a/collect_app/src/test/java/org/odk/collect/android/projects/ProjectSettingsDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/projects/ProjectSettingsDialogTest.kt index f52b8a6656e..dacb3e62b4e 100644 --- a/collect_app/src/test/java/org/odk/collect/android/projects/ProjectSettingsDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/projects/ProjectSettingsDialogTest.kt @@ -51,7 +51,7 @@ class ProjectSettingsDialogTest { ) } - val projectsRepository = InMemProjectsRepository(UUIDGenerator(),) + val projectsRepository = InMemProjectsRepository(UUIDGenerator()) @get:Rule val launcherRule = diff --git a/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt index 64e6205db11..370ebd17865 100644 --- a/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt @@ -24,8 +24,8 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith -import org.mockito.Mockito.`when` import org.mockito.Mockito.verifyNoInteractions +import org.mockito.Mockito.`when` import org.mockito.kotlin.any import org.mockito.kotlin.mock import org.odk.collect.android.R diff --git a/collect_app/src/test/java/org/odk/collect/android/storage/StoragePathProviderTest.kt b/collect_app/src/test/java/org/odk/collect/android/storage/StoragePathProviderTest.kt index bf5176f71f7..9b36cd0ac4f 100644 --- a/collect_app/src/test/java/org/odk/collect/android/storage/StoragePathProviderTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/storage/StoragePathProviderTest.kt @@ -5,8 +5,8 @@ import org.hamcrest.CoreMatchers.`is` import org.junit.After import org.junit.Before import org.junit.Test -import org.mockito.Mockito.`when` import org.mockito.Mockito.mock +import org.mockito.Mockito.`when` import org.odk.collect.android.projects.CurrentProjectProvider import org.odk.collect.projects.Project import org.odk.collect.projects.ProjectsRepository diff --git a/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragmentTest.kt b/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragmentTest.kt index 347d113ea84..1b5d445c6c9 100644 --- a/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragmentTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragmentTest.kt @@ -193,7 +193,8 @@ class SelectOneFromMapDialogFragmentTest { "A", emptyList(), IconifiedText( - R.drawable.ic_save, application.getString(R.string.select_item) + R.drawable.ic_save, + application.getString(R.string.select_item) ) ), MappableSelectItem.WithAction( diff --git a/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapWidgetTest.kt b/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapWidgetTest.kt index 775a0bcc10d..87ac5786b71 100644 --- a/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapWidgetTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapWidgetTest.kt @@ -96,7 +96,7 @@ class SelectOneFromMapWidgetTest { SelectOneFromMapDialogFragment(object : ViewModelProvider.Factory { override fun create( modelClass: Class, - extras: CreationExtras, + extras: CreationExtras ): T { return formEntryViewModel as T } @@ -271,7 +271,7 @@ class SelectOneFromMapWidgetTest { SelectOneFromMapDialogFragment(object : ViewModelProvider.Factory { override fun create( modelClass: Class, - extras: CreationExtras, + extras: CreationExtras ): T { return formEntryViewModel as T } diff --git a/collect_app/src/test/java/org/odk/collect/android/widgets/support/NoOpMapFragment.kt b/collect_app/src/test/java/org/odk/collect/android/widgets/support/NoOpMapFragment.kt index 3d3f643e13d..a09636c0e6b 100644 --- a/collect_app/src/test/java/org/odk/collect/android/widgets/support/NoOpMapFragment.kt +++ b/collect_app/src/test/java/org/odk/collect/android/widgets/support/NoOpMapFragment.kt @@ -10,7 +10,7 @@ class NoOpMapFragment : Fragment(), MapFragment { override fun init( readyListener: MapFragment.ReadyListener?, - errorListener: MapFragment.ErrorListener?, + errorListener: MapFragment.ErrorListener? ) { } @@ -34,7 +34,7 @@ class NoOpMapFragment : Fragment(), MapFragment { override fun zoomToBoundingBox( points: MutableIterable?, scaleFactor: Double, - animate: Boolean, + animate: Boolean ) { } diff --git a/collect_app/src/test/java/org/odk/collect/android/widgets/utilities/ExternalAppRecordingRequesterTest.kt b/collect_app/src/test/java/org/odk/collect/android/widgets/utilities/ExternalAppRecordingRequesterTest.kt index 3c6b90d2eb0..b3578101a7c 100644 --- a/collect_app/src/test/java/org/odk/collect/android/widgets/utilities/ExternalAppRecordingRequesterTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/widgets/utilities/ExternalAppRecordingRequesterTest.kt @@ -4,8 +4,8 @@ import android.app.Activity import android.provider.MediaStore import androidx.test.espresso.matcher.ViewMatchers.assertThat import androidx.test.ext.junit.runners.AndroidJUnit4 -import org.hamcrest.CoreMatchers.`is` import org.hamcrest.CoreMatchers.equalTo +import org.hamcrest.CoreMatchers.`is` import org.hamcrest.CoreMatchers.nullValue import org.junit.Before import org.junit.Test diff --git a/crash-handler/src/main/java/org/odk/collect/crashhandler/CrashHandler.kt b/crash-handler/src/main/java/org/odk/collect/crashhandler/CrashHandler.kt index c6cc2eb418e..b5eb8e3fe58 100644 --- a/crash-handler/src/main/java/org/odk/collect/crashhandler/CrashHandler.kt +++ b/crash-handler/src/main/java/org/odk/collect/crashhandler/CrashHandler.kt @@ -106,7 +106,7 @@ class CrashHandler(private val processKiller: Runnable = Runnable { exitProcess( private fun wrapUncaughtExceptionHandler( crashHandler: CrashHandler, - context: Context, + context: Context ) { if (originalHandler != null) { throw IllegalStateException("install() should not be called multiple times without uninstall()!") diff --git a/entities/src/main/java/org/odk/collect/entities/DatasetsFragment.kt b/entities/src/main/java/org/odk/collect/entities/DatasetsFragment.kt index a4801fb6b29..ec468b81e8c 100644 --- a/entities/src/main/java/org/odk/collect/entities/DatasetsFragment.kt +++ b/entities/src/main/java/org/odk/collect/entities/DatasetsFragment.kt @@ -24,7 +24,7 @@ class DatasetsFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?, + savedInstanceState: Bundle? ): View { return ListLayoutBinding.inflate(inflater, container, false).root } diff --git a/entities/src/main/java/org/odk/collect/entities/EntitiesFragment.kt b/entities/src/main/java/org/odk/collect/entities/EntitiesFragment.kt index a9b29175db1..b05e37cd405 100644 --- a/entities/src/main/java/org/odk/collect/entities/EntitiesFragment.kt +++ b/entities/src/main/java/org/odk/collect/entities/EntitiesFragment.kt @@ -24,7 +24,7 @@ class EntitiesFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?, + savedInstanceState: Bundle? ): View { return ListLayoutBinding.inflate(inflater, container, false).root } diff --git a/geo/src/main/java/org/odk/collect/geo/selection/MappableSelectItem.kt b/geo/src/main/java/org/odk/collect/geo/selection/MappableSelectItem.kt index 33fe26e95cf..cc57a33f6e3 100644 --- a/geo/src/main/java/org/odk/collect/geo/selection/MappableSelectItem.kt +++ b/geo/src/main/java/org/odk/collect/geo/selection/MappableSelectItem.kt @@ -24,7 +24,7 @@ sealed interface MappableSelectItem { val info: String, override val selected: Boolean = false, override val color: String? = null, - override val symbol: String? = null, + override val symbol: String? = null ) : MappableSelectItem { constructor( @@ -38,7 +38,7 @@ sealed interface MappableSelectItem { info: String, selected: Boolean = false, color: String? = null, - symbol: String? = null, + symbol: String? = null ) : this( id, listOf(MapPoint(latitude, longitude)), @@ -63,7 +63,7 @@ sealed interface MappableSelectItem { val action: IconifiedText, override val selected: Boolean = false, override val color: String? = null, - override val symbol: String? = null, + override val symbol: String? = null ) : MappableSelectItem { constructor( @@ -77,7 +77,7 @@ sealed interface MappableSelectItem { action: IconifiedText, selected: Boolean = false, color: String? = null, - symbol: String? = null, + symbol: String? = null ) : this( id, listOf(MapPoint(latitude, longitude)), diff --git a/geo/src/main/java/org/odk/collect/geo/selection/SelectionMapFragment.kt b/geo/src/main/java/org/odk/collect/geo/selection/SelectionMapFragment.kt index 5832406d4b7..e018db9804f 100644 --- a/geo/src/main/java/org/odk/collect/geo/selection/SelectionMapFragment.kt +++ b/geo/src/main/java/org/odk/collect/geo/selection/SelectionMapFragment.kt @@ -44,7 +44,7 @@ class SelectionMapFragment( val skipSummary: Boolean = false, val zoomToFitItems: Boolean = true, val showNewItemButton: Boolean = true, - val onBackPressedDispatcher: (() -> OnBackPressedDispatcher)? = null, + val onBackPressedDispatcher: (() -> OnBackPressedDispatcher)? = null ) : Fragment() { @Inject @@ -117,7 +117,7 @@ class SelectionMapFragment( override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?, + savedInstanceState: Bundle? ): View { return SelectionMapLayoutBinding.inflate(inflater).root } diff --git a/geo/src/test/java/org/odk/collect/geo/geopoint/GeoPointActivityTest.kt b/geo/src/test/java/org/odk/collect/geo/geopoint/GeoPointActivityTest.kt index 1564d3ca08c..127c48ce12a 100644 --- a/geo/src/test/java/org/odk/collect/geo/geopoint/GeoPointActivityTest.kt +++ b/geo/src/test/java/org/odk/collect/geo/geopoint/GeoPointActivityTest.kt @@ -66,7 +66,7 @@ class GeoPointActivityTest { val intent = Intent(getApplicationContext(), GeoPointActivity::class.java) launcherRule.launch(intent) - verify(viewModel).start(retainMockAccuracy = false,) + verify(viewModel).start(retainMockAccuracy = false) } @Test @@ -112,7 +112,7 @@ class GeoPointActivityTest { intent.putExtra(EXTRA_RETAIN_MOCK_ACCURACY, true) launcherRule.launch(intent) - verify(viewModel).start(retainMockAccuracy = true,) + verify(viewModel).start(retainMockAccuracy = true) } @Test @@ -121,7 +121,7 @@ class GeoPointActivityTest { intent.putExtra(GeoPointActivity.EXTRA_ACCURACY_THRESHOLD, 5.0f) launcherRule.launch(intent) - verify(viewModel).start(retainMockAccuracy = false, accuracyThreshold = 5.0f,) + verify(viewModel).start(retainMockAccuracy = false, accuracyThreshold = 5.0f) } @Test diff --git a/geo/src/test/java/org/odk/collect/geo/geopoint/LocationTrackerGeoPointViewModelTest.kt b/geo/src/test/java/org/odk/collect/geo/geopoint/LocationTrackerGeoPointViewModelTest.kt index ee993d5dc32..794e5f75e12 100644 --- a/geo/src/test/java/org/odk/collect/geo/geopoint/LocationTrackerGeoPointViewModelTest.kt +++ b/geo/src/test/java/org/odk/collect/geo/geopoint/LocationTrackerGeoPointViewModelTest.kt @@ -35,7 +35,7 @@ class LocationTrackerGeoPointViewModelTest { @Test fun `start() starts LocationTracker with with retain mock accuracy value when set`() { val viewModel = createViewModel() - viewModel.start(retainMockAccuracy = true,) + viewModel.start(retainMockAccuracy = true) verify(locationTracker).start(true, 1000L) } @@ -43,7 +43,7 @@ class LocationTrackerGeoPointViewModelTest { @Test fun `acceptedLocation is null when no location`() { val viewModel = createViewModel() - viewModel.start(accuracyThreshold = 0.0f,) + viewModel.start(accuracyThreshold = 0.0f) val location = viewModel.acceptedLocation whenever(locationTracker.getCurrentLocation()).thenReturn(null) @@ -54,7 +54,7 @@ class LocationTrackerGeoPointViewModelTest { @Test fun `acceptedLocation is null when accuracy is higher than threshold value`() { val viewModel = createViewModel() - viewModel.start(accuracyThreshold = 1.0f,) + viewModel.start(accuracyThreshold = 1.0f) val location = viewModel.acceptedLocation whenever(locationTracker.getCurrentLocation()).thenReturn(Location(0.0, 0.0, 0.0, 1.1f)) @@ -65,7 +65,7 @@ class LocationTrackerGeoPointViewModelTest { @Test fun `acceptedLocation is tracker location when accuracy is equal to threshold value`() { val viewModel = createViewModel() - viewModel.start(accuracyThreshold = 1.0f,) + viewModel.start(accuracyThreshold = 1.0f) val location = viewModel.acceptedLocation val locationTrackerLocation = Location(0.0, 0.0, 0.0, 1.0f) @@ -77,7 +77,7 @@ class LocationTrackerGeoPointViewModelTest { @Test fun `acceptedLocation is tracker location when accuracy is lower than threshold value`() { val viewModel = createViewModel() - viewModel.start(accuracyThreshold = 1.0f,) + viewModel.start(accuracyThreshold = 1.0f) val location = viewModel.acceptedLocation val locationTrackerLocation = Location(0.0, 0.0, 0.0, 0.9f) @@ -89,7 +89,7 @@ class LocationTrackerGeoPointViewModelTest { @Test fun `acceptedLocation does not update after it has met the threshold`() { val viewModel = createViewModel() - viewModel.start(accuracyThreshold = 1.0f,) + viewModel.start(accuracyThreshold = 1.0f) val location = viewModel.acceptedLocation val locationTrackerLocation = Location(0.0, 0.0, 0.0, 1.0f) @@ -183,7 +183,7 @@ class LocationTrackerGeoPointViewModelTest { @Test fun `forceLocation() sets acceptedLocation to location tracker location regardless of threshold`() { val viewModel = createViewModel() - viewModel.start(accuracyThreshold = 1.0f,) + viewModel.start(accuracyThreshold = 1.0f) val location = viewModel.acceptedLocation val locationTrackerLocation = Location(0.0, 0.0, 0.0, 2.5f) diff --git a/geo/src/test/java/org/odk/collect/geo/selection/SelectionMapFragmentTest.kt b/geo/src/test/java/org/odk/collect/geo/selection/SelectionMapFragmentTest.kt index 399a4005b18..46b5f7e3c8d 100644 --- a/geo/src/test/java/org/odk/collect/geo/selection/SelectionMapFragmentTest.kt +++ b/geo/src/test/java/org/odk/collect/geo/selection/SelectionMapFragmentTest.kt @@ -450,7 +450,7 @@ class SelectionMapFragmentTest { fun `clicking on item always selects correct item`() { val items = listOf( Fixtures.actionMappableSelectItem().copy(id = 0, points = listOf(MapPoint(40.0, 0.0), MapPoint(41.0, 0.0))), - Fixtures.actionMappableSelectItem().copy(id = 1, points = listOf(MapPoint(45.0, 0.0))), + Fixtures.actionMappableSelectItem().copy(id = 1, points = listOf(MapPoint(45.0, 0.0))) ) whenever(data.getMappableItems()).thenReturn(MutableLiveData(items)) @@ -477,7 +477,7 @@ class SelectionMapFragmentTest { largeIcon = android.R.drawable.ic_lock_idle_alarm, symbol = "B", color = "#000000" - ), + ) ) whenever(data.getMappableItems()).thenReturn(MutableLiveData(items)) @@ -513,7 +513,7 @@ class SelectionMapFragmentTest { largeIcon = android.R.drawable.ic_lock_idle_alarm, symbol = "B", color = "#000000" - ), + ) ) whenever(data.getMappableItems()).thenReturn(MutableLiveData(items)) @@ -538,7 +538,7 @@ class SelectionMapFragmentTest { fun `clicking on item sets item on summary sheet`() { val items = listOf( Fixtures.actionMappableSelectItem().copy(id = 0, name = "Blah1"), - Fixtures.actionMappableSelectItem().copy(id = 1, name = "Blah2"), + Fixtures.actionMappableSelectItem().copy(id = 1, name = "Blah2") ) whenever(data.getMappableItems()).thenReturn(MutableLiveData(items)) @@ -554,7 +554,7 @@ class SelectionMapFragmentTest { fun `clicking on item returns item ID as result when skipSummary is true`() { val items = listOf( Fixtures.actionMappableSelectItem().copy(id = 0), - Fixtures.actionMappableSelectItem().copy(id = 1), + Fixtures.actionMappableSelectItem().copy(id = 1) ) whenever(data.getMappableItems()).thenReturn(MutableLiveData(items)) diff --git a/geo/src/test/java/org/odk/collect/geo/support/FakeMapFragment.kt b/geo/src/test/java/org/odk/collect/geo/support/FakeMapFragment.kt index 53eb7972aa4..094c33b130b 100644 --- a/geo/src/test/java/org/odk/collect/geo/support/FakeMapFragment.kt +++ b/geo/src/test/java/org/odk/collect/geo/support/FakeMapFragment.kt @@ -33,7 +33,7 @@ class FakeMapFragment : Fragment(), MapFragment { override fun init( readyListener: ReadyListener?, - errorListener: MapFragment.ErrorListener?, + errorListener: MapFragment.ErrorListener? ) { this.readyListener = readyListener } @@ -72,7 +72,7 @@ class FakeMapFragment : Fragment(), MapFragment { override fun zoomToBoundingBox( points: Iterable, scaleFactor: Double, - animate: Boolean, + animate: Boolean ) { center = null zoom = 0.0 diff --git a/geo/src/test/java/org/odk/collect/geo/support/Fixtures.kt b/geo/src/test/java/org/odk/collect/geo/support/Fixtures.kt index e4ac47d8419..feaf2f5f639 100644 --- a/geo/src/test/java/org/odk/collect/geo/support/Fixtures.kt +++ b/geo/src/test/java/org/odk/collect/geo/support/Fixtures.kt @@ -13,7 +13,7 @@ object Fixtures { R.drawable.ic_lock_idle_charging, "0", listOf(MappableSelectItem.IconifiedText(R.drawable.ic_lock_idle_charging, "An item")), - MappableSelectItem.IconifiedText(R.drawable.ic_delete, "Action"), + MappableSelectItem.IconifiedText(R.drawable.ic_delete, "Action") ) } diff --git a/location/src/test/java/org/odk/collect/location/LocationClientProviderTest.kt b/location/src/test/java/org/odk/collect/location/LocationClientProviderTest.kt index afd2fb54edb..f7714e2863b 100644 --- a/location/src/test/java/org/odk/collect/location/LocationClientProviderTest.kt +++ b/location/src/test/java/org/odk/collect/location/LocationClientProviderTest.kt @@ -17,8 +17,8 @@ import android.content.Context import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.GoogleApiAvailability import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.instanceOf +import org.hamcrest.Matchers.`is` import org.junit.Test import org.mockito.ArgumentMatchers import org.mockito.Mockito diff --git a/mapbox/src/main/java/org/odk/collect/mapbox/MapUtils.kt b/mapbox/src/main/java/org/odk/collect/mapbox/MapUtils.kt index 075e5f42bf7..06bf7b4b296 100644 --- a/mapbox/src/main/java/org/odk/collect/mapbox/MapUtils.kt +++ b/mapbox/src/main/java/org/odk/collect/mapbox/MapUtils.kt @@ -36,7 +36,7 @@ object MapUtils { fun createPointAnnotations( context: Context, pointAnnotationManager: PointAnnotationManager, - markerFeatures: List, + markerFeatures: List ): List { val pointAnnotationOptionsList = markerFeatures.map { PointAnnotationOptions() diff --git a/mapbox/src/main/java/org/odk/collect/mapbox/MapboxMapFragment.kt b/mapbox/src/main/java/org/odk/collect/mapbox/MapboxMapFragment.kt index 8190d37987a..f714d960707 100644 --- a/mapbox/src/main/java/org/odk/collect/mapbox/MapboxMapFragment.kt +++ b/mapbox/src/main/java/org/odk/collect/mapbox/MapboxMapFragment.kt @@ -142,7 +142,7 @@ class MapboxMapFragment : override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?, + savedInstanceState: Bundle? ): View { mapView = MapView(inflater.context).apply { scalebar.enabled = false @@ -256,7 +256,7 @@ class MapboxMapFragment : override fun zoomToBoundingBox( mapPoints: Iterable?, scaleFactor: Double, - animate: Boolean, + animate: Boolean ) { mapPoints?.let { val points = mapPoints.map { @@ -461,8 +461,10 @@ class MapboxMapFragment : override fun onLocationChanged(location: Location) { lastLocationFix = MapPoint( - location.latitude, location.longitude, - location.altitude, location.accuracy.toDouble() + location.latitude, + location.longitude, + location.altitude, + location.accuracy.toDouble() ) lastLocationProvider = location.provider Timber.i( @@ -504,7 +506,7 @@ class MapboxMapFragment : this.locationPuck = LocationPuck2D( AppCompatResources.getDrawable( requireContext(), - R.drawable.ic_crosshairs, + R.drawable.ic_crosshairs ) ) } diff --git a/maps/src/main/java/org/odk/collect/maps/MapFragmentDelegate.kt b/maps/src/main/java/org/odk/collect/maps/MapFragmentDelegate.kt index 9548ef4fc6d..41e85ef7e0f 100644 --- a/maps/src/main/java/org/odk/collect/maps/MapFragmentDelegate.kt +++ b/maps/src/main/java/org/odk/collect/maps/MapFragmentDelegate.kt @@ -9,7 +9,7 @@ class MapFragmentDelegate( private val mapFragment: MapFragment, configuratorProvider: () -> MapConfigurator, settingsProvider: () -> Settings, - private val onConfigChanged: Consumer, + private val onConfigChanged: Consumer ) : OnSettingChangeListener { private val configurator by lazy { configuratorProvider() } diff --git a/maps/src/main/java/org/odk/collect/maps/markers/MarkerDescription.kt b/maps/src/main/java/org/odk/collect/maps/markers/MarkerDescription.kt index b501430a3cf..d735d5fa320 100644 --- a/maps/src/main/java/org/odk/collect/maps/markers/MarkerDescription.kt +++ b/maps/src/main/java/org/odk/collect/maps/markers/MarkerDescription.kt @@ -6,6 +6,7 @@ import org.odk.collect.maps.MapPoint data class MarkerDescription( val point: MapPoint, val isDraggable: Boolean, - @get:MapFragment.IconAnchor @param:MapFragment.IconAnchor val iconAnchor: String, + @get:MapFragment.IconAnchor @param:MapFragment.IconAnchor + val iconAnchor: String, val iconDescription: MarkerIconDescription ) diff --git a/maps/src/main/java/org/odk/collect/maps/markers/MarkerIconCreator.kt b/maps/src/main/java/org/odk/collect/maps/markers/MarkerIconCreator.kt index 228a0265a7a..316df9a0354 100644 --- a/maps/src/main/java/org/odk/collect/maps/markers/MarkerIconCreator.kt +++ b/maps/src/main/java/org/odk/collect/maps/markers/MarkerIconCreator.kt @@ -46,7 +46,7 @@ object MarkerIconCreator { context: Context, drawableId: Int, color: Int?, - symbol: String?, + symbol: String? ): Bitmap { val drawable = ContextCompat.getDrawable(context, drawableId) if (drawable != null) { diff --git a/permissions/src/main/java/org/odk/collect/permissions/PermissionsDialogCreator.kt b/permissions/src/main/java/org/odk/collect/permissions/PermissionsDialogCreator.kt index d2100b5df08..fa49f4fa4cb 100644 --- a/permissions/src/main/java/org/odk/collect/permissions/PermissionsDialogCreator.kt +++ b/permissions/src/main/java/org/odk/collect/permissions/PermissionsDialogCreator.kt @@ -34,7 +34,8 @@ internal object PermissionsDialogCreatorImpl : PermissionsDialogCreator { activity.getString(R.string.enable_gps) ) { _: DialogInterface?, _: Int -> activity.startActivityForResult( - Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0 + Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), + 0 ) } .setNegativeButton( diff --git a/permissions/src/main/java/org/odk/collect/permissions/PermissionsProvider.kt b/permissions/src/main/java/org/odk/collect/permissions/PermissionsProvider.kt index 6462e0269c3..5d1c992c7c3 100644 --- a/permissions/src/main/java/org/odk/collect/permissions/PermissionsProvider.kt +++ b/permissions/src/main/java/org/odk/collect/permissions/PermissionsProvider.kt @@ -103,7 +103,8 @@ open class PermissionsProvider internal constructor( ) } }, - Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.ACCESS_COARSE_LOCATION ) } @@ -151,7 +152,8 @@ open class PermissionsProvider internal constructor( ) } }, - Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO + Manifest.permission.CAMERA, + Manifest.permission.RECORD_AUDIO ) } @@ -247,8 +249,10 @@ open class PermissionsProvider internal constructor( override fun denied() { permissionsDialogCreator.showAdditionalExplanation( - activity, R.string.storage_runtime_permission_denied_title, - R.string.storage_runtime_permission_denied_desc, R.drawable.sd, + activity, + R.string.storage_runtime_permission_denied_title, + R.string.storage_runtime_permission_denied_desc, + R.drawable.sd, listener ) } diff --git a/projects/src/test/java/org/odk/collect/projects/InMemProjectsRepositoryTest.kt b/projects/src/test/java/org/odk/collect/projects/InMemProjectsRepositoryTest.kt index efa97fa2969..d5f2c1b4e80 100644 --- a/projects/src/test/java/org/odk/collect/projects/InMemProjectsRepositoryTest.kt +++ b/projects/src/test/java/org/odk/collect/projects/InMemProjectsRepositoryTest.kt @@ -5,7 +5,7 @@ import java.util.function.Supplier class InMemProjectsRepositoryTest : ProjectsRepositoryTest() { override fun buildSubject(): ProjectsRepository { - return InMemProjectsRepository(UUIDGenerator(),) + return InMemProjectsRepository(UUIDGenerator()) } override fun buildSubject(clock: Supplier): ProjectsRepository { diff --git a/projects/src/test/java/org/odk/collect/projects/ProjectsRepositoryTest.kt b/projects/src/test/java/org/odk/collect/projects/ProjectsRepositoryTest.kt index 81e96601a99..8b121177927 100644 --- a/projects/src/test/java/org/odk/collect/projects/ProjectsRepositoryTest.kt +++ b/projects/src/test/java/org/odk/collect/projects/ProjectsRepositoryTest.kt @@ -7,8 +7,8 @@ import org.hamcrest.Matchers.not import org.hamcrest.Matchers.notNullValue import org.junit.Before import org.junit.Test -import org.mockito.Mockito.`when` import org.mockito.Mockito.mock +import org.mockito.Mockito.`when` import java.util.function.Supplier abstract class ProjectsRepositoryTest { diff --git a/projects/src/test/java/org/odk/collect/projects/SharedPreferencesProjectsRepositoryTest.kt b/projects/src/test/java/org/odk/collect/projects/SharedPreferencesProjectsRepositoryTest.kt index 8593bfc3c20..2a58d862aa4 100644 --- a/projects/src/test/java/org/odk/collect/projects/SharedPreferencesProjectsRepositoryTest.kt +++ b/projects/src/test/java/org/odk/collect/projects/SharedPreferencesProjectsRepositoryTest.kt @@ -14,7 +14,7 @@ class SharedPreferencesProjectsRepositoryTest : ProjectsRepositoryTest() { UUIDGenerator(), Gson(), InMemSettings(), - "test", + "test" ) } diff --git a/selfie-camera/src/main/java/org/odk/collect/selfiecamera/CameraXCamera.kt b/selfie-camera/src/main/java/org/odk/collect/selfiecamera/CameraXCamera.kt index fa77c81574e..9d3080747c0 100644 --- a/selfie-camera/src/main/java/org/odk/collect/selfiecamera/CameraXCamera.kt +++ b/selfie-camera/src/main/java/org/odk/collect/selfiecamera/CameraXCamera.kt @@ -54,7 +54,7 @@ internal class CameraXCamera : Camera { override fun takePicture( imagePath: String, onImageSaved: () -> Unit, - onImageSaveError: () -> Unit, + onImageSaveError: () -> Unit ) { Pair(imageCapture, activity).let { (i, a) -> if (i == null || a == null) { diff --git a/selfie-camera/src/test/java/org/odk/collect/selfiecamera/CaptureSelfieActivityTest.kt b/selfie-camera/src/test/java/org/odk/collect/selfiecamera/CaptureSelfieActivityTest.kt index cf0e41db952..7f5f27c112d 100644 --- a/selfie-camera/src/test/java/org/odk/collect/selfiecamera/CaptureSelfieActivityTest.kt +++ b/selfie-camera/src/test/java/org/odk/collect/selfiecamera/CaptureSelfieActivityTest.kt @@ -157,7 +157,7 @@ private class FakeCamera : Camera { override fun takePicture( imagePath: String, onImageSaved: () -> Unit, - onImageSaveError: () -> Unit, + onImageSaveError: () -> Unit ) { if (state.value == Camera.State.UNINITIALIZED) { throw IllegalStateException() diff --git a/settings/src/test/java/org/odk/collect/settings/importing/SettingsImporterTest.kt b/settings/src/test/java/org/odk/collect/settings/importing/SettingsImporterTest.kt index 24aef318005..2c816abf6f8 100644 --- a/settings/src/test/java/org/odk/collect/settings/importing/SettingsImporterTest.kt +++ b/settings/src/test/java/org/odk/collect/settings/importing/SettingsImporterTest.kt @@ -120,7 +120,9 @@ class SettingsImporterTest { assertThat( importer.fromJSON( - json.toString(), currentProject, deviceUnsupportedSettings + json.toString(), + currentProject, + deviceUnsupportedSettings ), `is`(true) ) @@ -136,12 +138,15 @@ class SettingsImporterTest { assertThat(importer.fromJSON(emptySettings(), currentProject, JSONObject()), `is`(true)) assertSettings( generalSettings, - "key1", "default", - "key2", true + "key1", + "default", + "key2", + true ) assertSettings( adminSettings, - "key1", 5 + "key1", + 5 ) } @@ -163,12 +168,15 @@ class SettingsImporterTest { assertThat(importer.fromJSON(json.toString(), currentProject, JSONObject()), `is`(true)) assertSettings( generalSettings, - "key1", "default", - "key2", true + "key1", + "default", + "key2", + true ) assertSettings( adminSettings, - "key1", 5 + "key1", + 5 ) } @@ -176,22 +184,28 @@ class SettingsImporterTest { fun whenKeysAlreadyExistInPrefs_overridesWithDefaults() { initSettings( generalSettings, - "key1", "existing", - "key2", false + "key1", + "existing", + "key2", + false ) initSettings( adminSettings, - "key1", 0 + "key1", + 0 ) assertThat(importer.fromJSON(emptySettings(), currentProject, JSONObject()), `is`(true)) assertSettings( generalSettings, - "key1", "default", - "key2", true + "key1", + "default", + "key2", + true ) assertSettings( adminSettings, - "key1", 5 + "key1", + 5 ) } diff --git a/shared/src/main/java/org/odk/collect/shared/strings/StringUtils.kt b/shared/src/main/java/org/odk/collect/shared/strings/StringUtils.kt index f80b87ee0c9..584b483050e 100644 --- a/shared/src/main/java/org/odk/collect/shared/strings/StringUtils.kt +++ b/shared/src/main/java/org/odk/collect/shared/strings/StringUtils.kt @@ -19,10 +19,14 @@ object StringUtils { @JvmStatic fun ellipsizeBeginning(text: String): String { - return if (text.length <= 100) text else "..." + text.substring( - text.length - 97, - text.length - ) + return if (text.length <= 100) { + text + } else { + "..." + text.substring( + text.length - 97, + text.length + ) + } } /** @@ -81,7 +85,9 @@ object StringUtils { } return if (end >= start) { text.subSequence(start, end + 1) - } else text + } else { + text + } } @JvmStatic @@ -91,6 +97,8 @@ object StringUtils { } return if (str.endsWith(remove)) { str.substring(0, str.length - remove.length) - } else str + } else { + str + } } } From 83e435733bbef5667e99094c67569e6269d6a109 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Sat, 18 Mar 2023 17:38:35 +0100 Subject: [PATCH 09/12] Fixed setting java version in kotlin --- analytics/build.gradle | 4 +--- androidshared/build.gradle | 4 ---- audiorecorder/build.gradle | 4 ---- build.gradle | 1 + collect_app/build.gradle | 4 ---- crash-handler/build.gradle.kts | 4 ---- entities/build.gradle.kts | 4 ---- errors/build.gradle | 4 ---- externalapp/build.gradle | 4 ---- fragmentstest/build.gradle | 4 +--- geo/build.gradle | 4 ---- imageloader/build.gradle | 4 +--- location/build.gradle | 4 ---- mapbox/build.gradle | 4 ---- maps/build.gradle | 4 ---- osmdroid/build.gradle | 3 --- permissions/build.gradle | 4 ---- projects/build.gradle | 4 ---- qr-code/build.gradle.kts | 4 ---- selfie-camera/build.gradle.kts | 4 ---- settings/build.gradle | 3 --- shadows/build.gradle.kts | 4 ---- upgrade/build.gradle | 4 ---- 23 files changed, 4 insertions(+), 83 deletions(-) diff --git a/analytics/build.gradle b/analytics/build.gradle index 803957aa825..c8cc8bfa378 100644 --- a/analytics/build.gradle +++ b/analytics/build.gradle @@ -29,9 +29,7 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } + namespace 'org.odk.collect.analytics' } diff --git a/androidshared/build.gradle b/androidshared/build.gradle index e420bcb0a0c..fe03e18cf2c 100644 --- a/androidshared/build.gradle +++ b/androidshared/build.gradle @@ -36,10 +36,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions { unitTests { includeAndroidResources = true diff --git a/audiorecorder/build.gradle b/audiorecorder/build.gradle index b78c7c0f1b9..8d9d465252a 100644 --- a/audiorecorder/build.gradle +++ b/audiorecorder/build.gradle @@ -28,10 +28,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions { unitTests.includeAndroidResources = true } diff --git a/build.gradle b/build.gradle index f651cb01043..0884afdeef8 100644 --- a/build.gradle +++ b/build.gradle @@ -64,6 +64,7 @@ allprojects { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { freeCompilerArgs = ['-Xjvm-default=all'] + jvmTarget = '1.8' } } } diff --git a/collect_app/build.gradle b/collect_app/build.gradle index a295ab8fcc8..66082c40ce1 100644 --- a/collect_app/build.gradle +++ b/collect_app/build.gradle @@ -186,10 +186,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() - } - testOptions { unitTests { includeAndroidResources = true diff --git a/crash-handler/build.gradle.kts b/crash-handler/build.gradle.kts index 7422f54d5cf..31fab61cb97 100644 --- a/crash-handler/build.gradle.kts +++ b/crash-handler/build.gradle.kts @@ -32,10 +32,6 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = "1.8" - } - testOptions { unitTests { isIncludeAndroidResources = true diff --git a/entities/build.gradle.kts b/entities/build.gradle.kts index 5fe59605694..5e850180feb 100644 --- a/entities/build.gradle.kts +++ b/entities/build.gradle.kts @@ -33,10 +33,6 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = "1.8" - } - testOptions { unitTests { isIncludeAndroidResources = true diff --git a/errors/build.gradle b/errors/build.gradle index f08c05e0fe7..dc497674753 100644 --- a/errors/build.gradle +++ b/errors/build.gradle @@ -30,10 +30,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions { unitTests { includeAndroidResources = true diff --git a/externalapp/build.gradle b/externalapp/build.gradle index bf5b4e5de1a..a26baba029a 100644 --- a/externalapp/build.gradle +++ b/externalapp/build.gradle @@ -31,10 +31,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions { unitTests { includeAndroidResources = true diff --git a/fragmentstest/build.gradle b/fragmentstest/build.gradle index 57dd6fa67f6..87de150b1b9 100644 --- a/fragmentstest/build.gradle +++ b/fragmentstest/build.gradle @@ -28,9 +28,7 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } + namespace 'org.odk.collect.fragmentstest' } diff --git a/geo/build.gradle b/geo/build.gradle index d8d3ab46b4c..ebe62995a74 100644 --- a/geo/build.gradle +++ b/geo/build.gradle @@ -32,10 +32,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions { unitTests { includeAndroidResources = true diff --git a/imageloader/build.gradle b/imageloader/build.gradle index c7fc971ba0d..3bd87443198 100644 --- a/imageloader/build.gradle +++ b/imageloader/build.gradle @@ -29,9 +29,7 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } + namespace 'org.odk.collect.imageloader' } diff --git a/location/build.gradle b/location/build.gradle index ce92288ac9c..51a4306df9b 100644 --- a/location/build.gradle +++ b/location/build.gradle @@ -31,10 +31,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions { unitTests { includeAndroidResources = true diff --git a/mapbox/build.gradle b/mapbox/build.gradle index e7ca2ca7b28..1d1557113e4 100644 --- a/mapbox/build.gradle +++ b/mapbox/build.gradle @@ -32,10 +32,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - namespace 'org.odk.collect.mapbox' } diff --git a/maps/build.gradle b/maps/build.gradle index 56ac3e0ae97..35ac770b95c 100644 --- a/maps/build.gradle +++ b/maps/build.gradle @@ -33,10 +33,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions { unitTests { includeAndroidResources = true diff --git a/osmdroid/build.gradle b/osmdroid/build.gradle index 428aeb84a6c..116f2860d83 100644 --- a/osmdroid/build.gradle +++ b/osmdroid/build.gradle @@ -32,9 +32,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } namespace 'org.odk.collect.osmdroid' } diff --git a/permissions/build.gradle b/permissions/build.gradle index b91c48759ca..dfcbde77a1f 100644 --- a/permissions/build.gradle +++ b/permissions/build.gradle @@ -30,10 +30,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions { unitTests { includeAndroidResources = true diff --git a/projects/build.gradle b/projects/build.gradle index 1b2f70ac611..449fa9e66ff 100644 --- a/projects/build.gradle +++ b/projects/build.gradle @@ -32,10 +32,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { viewBinding true } diff --git a/qr-code/build.gradle.kts b/qr-code/build.gradle.kts index 174beee156c..9f573eff45d 100644 --- a/qr-code/build.gradle.kts +++ b/qr-code/build.gradle.kts @@ -32,10 +32,6 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = "1.8" - } - testOptions { unitTests { isIncludeAndroidResources = true diff --git a/selfie-camera/build.gradle.kts b/selfie-camera/build.gradle.kts index 096850590a6..ca8be652a87 100644 --- a/selfie-camera/build.gradle.kts +++ b/selfie-camera/build.gradle.kts @@ -33,10 +33,6 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = "1.8" - } - testOptions { unitTests { isIncludeAndroidResources = true diff --git a/settings/build.gradle b/settings/build.gradle index 0dad842a0bf..2a3a449ba62 100644 --- a/settings/build.gradle +++ b/settings/build.gradle @@ -31,9 +31,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } packagingOptions { resources { // These library licenses will be referenced in-app diff --git a/shadows/build.gradle.kts b/shadows/build.gradle.kts index 4786f7670d6..5dd999b1337 100644 --- a/shadows/build.gradle.kts +++ b/shadows/build.gradle.kts @@ -31,10 +31,6 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = "1.8" - } - testOptions { unitTests { isIncludeAndroidResources = true diff --git a/upgrade/build.gradle b/upgrade/build.gradle index 7da09527243..48cc14f7efa 100644 --- a/upgrade/build.gradle +++ b/upgrade/build.gradle @@ -31,10 +31,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions { unitTests { includeAndroidResources = true From 7422c48dd1e04e09f14593735c3dbe48040cfc9a Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Mon, 20 Mar 2023 19:07:50 +0100 Subject: [PATCH 10/12] Updated androidx.lifecycle --- .../collect/androidtest/FakeLifecycleOwner.kt | 9 +++----- .../collect/androidtest/LiveDataTestUtils.kt | 2 +- .../collect/audioclips/AudioClipViewModel.kt | 4 ++-- .../src/main/java/dependencies/Versions.kt | 2 +- collect_app/build.gradle | 1 + .../blankformlist/BlankFormListViewModel.kt | 22 +++++++------------ .../utilities/ControllableLifecyleOwner.kt | 10 ++++----- geo/build.gradle | 1 + .../collect/geo/geopoint/GeoPointViewModel.kt | 4 ++-- osmdroid/build.gradle | 4 +++- 10 files changed, 26 insertions(+), 33 deletions(-) diff --git a/androidtest/src/main/java/org/odk/collect/androidtest/FakeLifecycleOwner.kt b/androidtest/src/main/java/org/odk/collect/androidtest/FakeLifecycleOwner.kt index 79747af8fca..e4a216793e4 100644 --- a/androidtest/src/main/java/org/odk/collect/androidtest/FakeLifecycleOwner.kt +++ b/androidtest/src/main/java/org/odk/collect/androidtest/FakeLifecycleOwner.kt @@ -5,18 +5,15 @@ import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry class FakeLifecycleOwner : LifecycleOwner { - - private val lifecycle: LifecycleRegistry by lazy { + private val lifecycleRegistry: LifecycleRegistry by lazy { LifecycleRegistry(this).also { it.handleLifecycleEvent(Lifecycle.Event.ON_RESUME) } } + override val lifecycle: LifecycleRegistry = lifecycleRegistry + fun destroy() { lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY) } - - override fun getLifecycle(): Lifecycle { - return lifecycle - } } diff --git a/androidtest/src/main/java/org/odk/collect/androidtest/LiveDataTestUtils.kt b/androidtest/src/main/java/org/odk/collect/androidtest/LiveDataTestUtils.kt index 9fc9df1e710..52979d0db24 100644 --- a/androidtest/src/main/java/org/odk/collect/androidtest/LiveDataTestUtils.kt +++ b/androidtest/src/main/java/org/odk/collect/androidtest/LiveDataTestUtils.kt @@ -23,7 +23,7 @@ fun LiveData.getOrAwaitValue( var data: T? = null val latch = CountDownLatch(1) val observer = object : Observer { - override fun onChanged(o: T?) { + override fun onChanged(o: T) { data = o latch.countDown() this@getOrAwaitValue.removeObserver(this) diff --git a/audioclips/src/main/java/org/odk/collect/audioclips/AudioClipViewModel.kt b/audioclips/src/main/java/org/odk/collect/audioclips/AudioClipViewModel.kt index a549887addd..a3e9422e641 100644 --- a/audioclips/src/main/java/org/odk/collect/audioclips/AudioClipViewModel.kt +++ b/audioclips/src/main/java/org/odk/collect/audioclips/AudioClipViewModel.kt @@ -3,9 +3,9 @@ package org.odk.collect.audioclips import android.media.MediaPlayer import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.map import org.odk.collect.async.Cancellable import org.odk.collect.async.Scheduler import java.io.File @@ -57,7 +57,7 @@ class AudioClipViewModel(private val mediaPlayerFactory: Supplier, } fun isPlaying(clipID: String): LiveData { - return Transformations.map(currentlyPlaying) { value -> + return currentlyPlaying.map { value -> if (isCurrentPlayingClip(clipID, value)) { !value!!.isPaused } else { diff --git a/buildSrc/src/main/java/dependencies/Versions.kt b/buildSrc/src/main/java/dependencies/Versions.kt index 212b3448c1b..de59260250a 100644 --- a/buildSrc/src/main/java/dependencies/Versions.kt +++ b/buildSrc/src/main/java/dependencies/Versions.kt @@ -13,6 +13,6 @@ object Versions { const val okhttp3 = "4.10.0" const val robolectric = "4.9" const val work = "2.8.0" - const val lifecycle = "2.5.1" + const val lifecycle = "2.6.0" const val camerax = "1.2.1" } diff --git a/collect_app/build.gradle b/collect_app/build.gradle index 66082c40ce1..faafcb2f15e 100644 --- a/collect_app/build.gradle +++ b/collect_app/build.gradle @@ -337,6 +337,7 @@ dependencies { // Android Architecture Components: implementation Dependencies.androidx_lifecycle_runtime_ktx + implementation Dependencies.androidx_lifecycle_livedata_ktx implementation Dependencies.androidx_viewpager2 // Dagger: diff --git a/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt b/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt index 566552ca8a6..b89ee1802cd 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt +++ b/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt @@ -5,9 +5,9 @@ import android.net.Uri import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Observer -import androidx.lifecycle.Transformations import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.map import org.odk.collect.android.formmanagement.FormsUpdater import org.odk.collect.android.formmanagement.matchexactly.SyncStatusAppState import org.odk.collect.android.preferences.utilities.FormUpdateMode @@ -50,13 +50,11 @@ class BlankFormListViewModel( private val isFormLoadingRunning = MutableNonNullLiveData(false) private val isSyncingWithStorageRunning = MutableNonNullLiveData(false) - val isLoading: LiveData = Transformations.map( - LiveDataUtils.zip3( - isFormLoadingRunning, - isSyncingWithStorageRunning, - syncRepository.isSyncing(projectId) - ) - ) { (one, two, three) -> one || two || three } + val isLoading: LiveData = LiveDataUtils.zip3( + isFormLoadingRunning, + isSyncingWithStorageRunning, + syncRepository.isSyncing(projectId) + ).map { (one, two, three) -> one || two || three } var sortingOrder: Int = generalSettings.getInt("formChooserListSortingOrder") get() { return generalSettings.getInt("formChooserListSortingOrder") } @@ -171,17 +169,13 @@ class BlankFormListViewModel( } fun isOutOfSyncWithServer(): LiveData { - return Transformations.map( - syncRepository.getSyncError(projectId) - ) { obj: FormSourceException? -> + return syncRepository.getSyncError(projectId).map { obj: FormSourceException? -> obj != null } } fun isAuthenticationRequired(): LiveData { - return Transformations.map( - syncRepository.getSyncError(projectId) - ) { error: FormSourceException? -> + return syncRepository.getSyncError(projectId).map { error: FormSourceException? -> if (error != null) { error is AuthRequired } else { diff --git a/collect_app/src/main/java/org/odk/collect/android/utilities/ControllableLifecyleOwner.kt b/collect_app/src/main/java/org/odk/collect/android/utilities/ControllableLifecyleOwner.kt index 1a54aa800f8..8fd0130d91d 100644 --- a/collect_app/src/main/java/org/odk/collect/android/utilities/ControllableLifecyleOwner.kt +++ b/collect_app/src/main/java/org/odk/collect/android/utilities/ControllableLifecyleOwner.kt @@ -9,15 +9,13 @@ class ControllableLifecyleOwner : LifecycleOwner { this.handleLifecycleEvent(Lifecycle.Event.ON_CREATE) } + override val lifecycle: LifecycleRegistry = lifecycleRegistry + fun start() { - lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME) + lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME) } fun destroy() { - lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY) - } - - override fun getLifecycle(): Lifecycle { - return lifecycleRegistry + lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY) } } diff --git a/geo/build.gradle b/geo/build.gradle index ebe62995a74..f0b605aab5f 100644 --- a/geo/build.gradle +++ b/geo/build.gradle @@ -49,6 +49,7 @@ dependencies { implementation Dependencies.kotlin_stdlib implementation Dependencies.androidx_appcompat + implementation Dependencies.androidx_lifecycle_livedata_ktx implementation Dependencies.android_material implementation Dependencies.timber implementation Dependencies.play_services_location diff --git a/geo/src/main/java/org/odk/collect/geo/geopoint/GeoPointViewModel.kt b/geo/src/main/java/org/odk/collect/geo/geopoint/GeoPointViewModel.kt index 3dee2280403..2ddf43f19d7 100644 --- a/geo/src/main/java/org/odk/collect/geo/geopoint/GeoPointViewModel.kt +++ b/geo/src/main/java/org/odk/collect/geo/geopoint/GeoPointViewModel.kt @@ -2,9 +2,9 @@ package org.odk.collect.geo.geopoint import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.map import org.odk.collect.analytics.Analytics.Companion.log import org.odk.collect.androidshared.livedata.MutableNonNullLiveData import org.odk.collect.androidshared.livedata.NonNullLiveData @@ -56,7 +56,7 @@ internal class LocationTrackerGeoPointViewModel( private val trackerLocation = MutableLiveData(null) override val acceptedLocation: MutableLiveData = MutableLiveData(null) - override val currentAccuracy = Transformations.map(trackerLocation) { + override val currentAccuracy = trackerLocation.map { if (it != null) { when { it.accuracy > unacceptableAccuracyThreshold -> GeoPointAccuracy.Unacceptable(it.accuracy) diff --git a/osmdroid/build.gradle b/osmdroid/build.gradle index 116f2860d83..2e4e85c04b1 100644 --- a/osmdroid/build.gradle +++ b/osmdroid/build.gradle @@ -39,7 +39,9 @@ dependencies { coreLibraryDesugaring Dependencies.desugar implementation project(':shared') - implementation project(':androidshared') + implementation(project(':androidshared')) { + exclude group: 'androidx.lifecycle' + } implementation project(':icons') implementation project(':maps') implementation project(':location') From e10cc469559fb4df87868c13601707fc85954a02 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Mon, 20 Mar 2023 21:47:17 +0100 Subject: [PATCH 11/12] Removed unused method --- .../formlists/blankformlist/BlankFormListViewModel.kt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt b/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt index b89ee1802cd..9a7e034378c 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt +++ b/collect_app/src/main/java/org/odk/collect/android/formlists/blankformlist/BlankFormListViewModel.kt @@ -1,7 +1,6 @@ package org.odk.collect.android.formlists.blankformlist import android.app.Application -import android.net.Uri import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Observer @@ -24,8 +23,6 @@ import org.odk.collect.forms.FormsRepository import org.odk.collect.forms.instances.InstancesRepository import org.odk.collect.settings.keys.ProjectKeys import org.odk.collect.shared.settings.Settings -import org.odk.collect.shared.strings.Md5.getMd5Hash -import java.io.ByteArrayInputStream class BlankFormListViewModel( private val formsRepository: FormsRepository, @@ -149,7 +146,6 @@ class BlankFormListViewModel( } fun syncWithServer(): LiveData { - logManualSyncWithServer() val result = MutableLiveData() scheduler.immediate( { formsUpdater.matchFormsWithServer(projectId) }, @@ -184,12 +180,6 @@ class BlankFormListViewModel( } } - private fun logManualSyncWithServer() { - val uri = Uri.parse(generalSettings.getString(ProjectKeys.KEY_SERVER_URL)) - val host = if (uri.host != null) uri.host else "" - val urlHash = getMd5Hash(ByteArrayInputStream(host!!.toByteArray())) ?: "" - } - private fun sortAndFilter() { _formsToDisplay.value = when (sortingOrder) { 0 -> _allForms.value.sortedBy { it.formName.lowercase() } From a39b629e87883ea8b57e9d0f9e9385c4feff0b4c Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Wed, 22 Mar 2023 20:38:10 +0100 Subject: [PATCH 12/12] Added a comment --- osmdroid/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osmdroid/build.gradle b/osmdroid/build.gradle index 2e4e85c04b1..bdaca965524 100644 --- a/osmdroid/build.gradle +++ b/osmdroid/build.gradle @@ -40,6 +40,8 @@ dependencies { implementation project(':shared') implementation(project(':androidshared')) { + // Without this the build fails with 'Corrupt serialized resolution result'. + // It looks like a Gradle issue. Hopefully we can get rid of it in the future. exclude group: 'androidx.lifecycle' } implementation project(':icons')