From c8ad7980cf6f4ebbbf6271313cb376b4bb3f9326 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 4 Dec 2023 10:54:55 +0100 Subject: [PATCH] reformat kt code for ktlin check compliance Signed-off-by: Andy Scherzinger --- .../talk/activities/MainActivityTest.kt | 41 +++++++------- .../com/nextcloud/talk/utils/ShareUtilsIT.kt | 16 +++--- .../com/nextcloud/talk/utils/UriUtilsIT.kt | 53 +++++++++---------- .../talk/utils/VibrationUtilsTest.kt | 10 ++-- .../talk/jobs/GetFirebasePushTokenWorker.kt | 11 ++-- .../firebase/NCFirebaseMessagingService.kt | 23 ++++---- .../talk/utils/ClosedInterfaceImpl.kt | 33 ++++++------ 7 files changed, 98 insertions(+), 89 deletions(-) diff --git a/app/src/androidTest/java/com/nextcloud/talk/activities/MainActivityTest.kt b/app/src/androidTest/java/com/nextcloud/talk/activities/MainActivityTest.kt index 258e7a35625..6cb1ed8f8a0 100644 --- a/app/src/androidTest/java/com/nextcloud/talk/activities/MainActivityTest.kt +++ b/app/src/androidTest/java/com/nextcloud/talk/activities/MainActivityTest.kt @@ -8,31 +8,32 @@ import org.junit.Test class MainActivityTest { @get:Rule - val activityRule: IntentsTestRule = IntentsTestRule( - MainActivity::class.java, - true, - false - ) + val activityRule: IntentsTestRule = + IntentsTestRule(MainActivity::class.java, true, false) @Test fun login() { val sut = activityRule.launchActivity(null) - val user = sut.userManager.storeProfile( - "test", - UserManager.UserAttributes( - null, - serverUrl = "http://server/nc", - currentUser = true, - userId = "test", - token = "test", - displayName = "Test Name", - pushConfigurationState = null, - capabilities = null, - certificateAlias = null, - externalSignalingServer = null - ) - ).blockingGet() + val user = + sut + .userManager + .storeProfile( + "test", + UserManager.UserAttributes( + null, + serverUrl = "http://server/nc", + currentUser = true, + userId = "test", + token = "test", + displayName = "Test Name", + pushConfigurationState = null, + capabilities = null, + certificateAlias = null, + externalSignalingServer = null, + ), + ) + .blockingGet() assertNotNull("Error creating user", user) } diff --git a/app/src/androidTest/java/com/nextcloud/talk/utils/ShareUtilsIT.kt b/app/src/androidTest/java/com/nextcloud/talk/utils/ShareUtilsIT.kt index eeef9ea8da6..0d2c9de55a6 100644 --- a/app/src/androidTest/java/com/nextcloud/talk/utils/ShareUtilsIT.kt +++ b/app/src/androidTest/java/com/nextcloud/talk/utils/ShareUtilsIT.kt @@ -18,11 +18,15 @@ class ShareUtilsIT { private fun parseDate2(dateStr: String): Date { return DateUtils.parseDate( - dateStr, Locale.US, + dateStr, + Locale.US, HttpUtils.httpDateFormatStr, - "EEE, dd MMM yyyy HH:mm:ss zzz", // RFC 822, updated by RFC 1123 with any TZ - "EEEE, dd-MMM-yy HH:mm:ss zzz", // RFC 850, obsoleted by RFC 1036 with any TZ. - "EEE MMM d HH:mm:ss yyyy", // ANSI C's asctime() format + // RFC 822, updated by RFC 1123 with any TZ + "EEE, dd MMM yyyy HH:mm:ss zzz", + // RFC 850, obsoleted by RFC 1036 with any TZ. + "EEEE, dd-MMM-yy HH:mm:ss zzz", + // ANSI C's asctime() format + "EEE MMM d HH:mm:ss yyyy", // Alternative formats. "EEE, dd-MMM-yyyy HH:mm:ss z", "EEE, dd-MMM-yyyy HH-mm-ss z", @@ -34,9 +38,9 @@ class ShareUtilsIT { "EEE dd MMM yy HH:mm:ss z", "EEE,dd-MMM-yy HH:mm:ss z", "EEE,dd-MMM-yyyy HH:mm:ss z", + // RI bug 6641315 claims a cookie of this format was once served by www.yahoo.com "EEE, dd-MM-yyyy HH:mm:ss z", - /* RI bug 6641315 claims a cookie of this format was once served by www.yahoo.com */ - "EEE MMM d yyyy HH:mm:ss z" + "EEE MMM d yyyy HH:mm:ss z", ) } diff --git a/app/src/androidTest/java/com/nextcloud/talk/utils/UriUtilsIT.kt b/app/src/androidTest/java/com/nextcloud/talk/utils/UriUtilsIT.kt index 0312b166d54..a59b8b35458 100644 --- a/app/src/androidTest/java/com/nextcloud/talk/utils/UriUtilsIT.kt +++ b/app/src/androidTest/java/com/nextcloud/talk/utils/UriUtilsIT.kt @@ -25,7 +25,6 @@ import junit.framework.TestCase.assertTrue import org.junit.Test class UriUtilsIT { - @Test fun testHasHttpProtocolPrefixed() { val uriHttp = "http://www.example.com" @@ -46,8 +45,8 @@ class UriUtilsIT { assertEquals( "42", UriUtils.extractInstanceInternalFileFileId( - "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=42" - ) + "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=42", + ), ) } @@ -55,7 +54,7 @@ class UriUtilsIT { fun testExtractInstanceInternalFileShareFileId() { assertEquals( "42", - UriUtils.extractInstanceInternalFileShareFileId("https://cloud.nextcloud.com/f/42") + UriUtils.extractInstanceInternalFileShareFileId("https://cloud.nextcloud.com/f/42"), ) } @@ -64,29 +63,29 @@ class UriUtilsIT { assertTrue( UriUtils.isInstanceInternalFileShareUrl( "https://cloud.nextcloud.com", - "https://cloud.nextcloud.com/f/42" - ) + "https://cloud.nextcloud.com/f/42", + ), ) assertFalse( UriUtils.isInstanceInternalFileShareUrl( "https://nextcloud.nextcloud.com", - "https://cloud.nextcloud.com/f/42" - ) + "https://cloud.nextcloud.com/f/42", + ), ) assertFalse( UriUtils.isInstanceInternalFileShareUrl( "https://nextcloud.nextcloud.com", - "https://cloud.nextcloud.com/f/" - ) + "https://cloud.nextcloud.com/f/", + ), ) assertFalse( UriUtils.isInstanceInternalFileShareUrl( "https://nextcloud.nextcloud.com", - "https://cloud.nextcloud.com/f/test123" - ) + "https://cloud.nextcloud.com/f/test123", + ), ) } @@ -95,36 +94,36 @@ class UriUtilsIT { assertTrue( UriUtils.isInstanceInternalFileUrl( "https://cloud.nextcloud.com", - "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=41" - ) + "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=41", + ), ) assertFalse( UriUtils.isInstanceInternalFileUrl( "https://nextcloud.nextcloud.com", - "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=41" - ) + "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=41", + ), ) assertFalse( UriUtils.isInstanceInternalFileUrl( "https://nextcloud.nextcloud.com", - "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=test123" - ) + "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=test123", + ), ) assertFalse( UriUtils.isInstanceInternalFileUrl( "https://nextcloud.nextcloud.com", - "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=" - ) + "https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=", + ), ) assertFalse( UriUtils.isInstanceInternalFileUrl( "https://cloud.nextcloud.com", - "https://cloud.nextcloud.com/apps/files/?dir=/Engineering" - ) + "https://cloud.nextcloud.com/apps/files/?dir=/Engineering", + ), ) } @@ -133,15 +132,15 @@ class UriUtilsIT { assertTrue( UriUtils.isInstanceInternalFileUrlNew( "https://cloud.nextcloud.com", - "https://cloud.nextcloud.com/apps/files/files/41?dir=/" - ) + "https://cloud.nextcloud.com/apps/files/files/41?dir=/", + ), ) assertFalse( UriUtils.isInstanceInternalFileUrlNew( "https://nextcloud.nextcloud.com", - "https://cloud.nextcloud.com/apps/files/files/41?dir=/" - ) + "https://cloud.nextcloud.com/apps/files/files/41?dir=/", + ), ) } @@ -149,7 +148,7 @@ class UriUtilsIT { fun testExtractInstanceInternalFileFileIdNew() { assertEquals( "42", - UriUtils.extractInstanceInternalFileFileIdNew("https://cloud.nextcloud.com/apps/files/files/42?dir=/") + UriUtils.extractInstanceInternalFileFileIdNew("https://cloud.nextcloud.com/apps/files/files/42?dir=/"), ) } } diff --git a/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt b/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt index 02f5e2ed5b9..877145cd34d 100644 --- a/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt +++ b/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt @@ -32,7 +32,6 @@ import org.mockito.junit.MockitoJUnitRunner @RunWith(MockitoJUnitRunner::class) class VibrationUtilsTest { - @Mock private lateinit var mockContext: Context @@ -49,13 +48,10 @@ class VibrationUtilsTest { VibrationUtils.vibrateShort(mockContext) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - Mockito.verify(mockVibrator) + Mockito + .verify(mockVibrator) .vibrate( - VibrationEffect - .createOneShot( - VibrationUtils.SHORT_VIBRATE, - VibrationEffect.DEFAULT_AMPLITUDE - ) + VibrationEffect.createOneShot(VibrationUtils.SHORT_VIBRATE, VibrationEffect.DEFAULT_AMPLITUDE), ) } else { Mockito.verify(mockVibrator).vibrate(VibrationUtils.SHORT_VIBRATE) diff --git a/app/src/gplay/java/com/nextcloud/talk/jobs/GetFirebasePushTokenWorker.kt b/app/src/gplay/java/com/nextcloud/talk/jobs/GetFirebasePushTokenWorker.kt index a2320217e51..e1d3e3044d5 100644 --- a/app/src/gplay/java/com/nextcloud/talk/jobs/GetFirebasePushTokenWorker.kt +++ b/app/src/gplay/java/com/nextcloud/talk/jobs/GetFirebasePushTokenWorker.kt @@ -38,7 +38,6 @@ import javax.inject.Inject @AutoInjector(NextcloudTalkApplication::class) class GetFirebasePushTokenWorker(val context: Context, workerParameters: WorkerParameters) : Worker(context, workerParameters) { - @Inject lateinit var appPreferences: AppPreferences @@ -60,11 +59,13 @@ class GetFirebasePushTokenWorker(val context: Context, workerParameters: WorkerP val data: Data = Data.Builder().putString(PushRegistrationWorker.ORIGIN, "GetFirebasePushTokenWorker").build() - val pushRegistrationWork = OneTimeWorkRequest.Builder(PushRegistrationWorker::class.java) - .setInputData(data) - .build() + val pushRegistrationWork = + OneTimeWorkRequest + .Builder(PushRegistrationWorker::class.java) + .setInputData(data) + .build() WorkManager.getInstance(context).enqueue(pushRegistrationWork) - } + }, ) return Result.success() diff --git a/app/src/gplay/java/com/nextcloud/talk/services/firebase/NCFirebaseMessagingService.kt b/app/src/gplay/java/com/nextcloud/talk/services/firebase/NCFirebaseMessagingService.kt index 413b2e79702..37dd0df16ef 100644 --- a/app/src/gplay/java/com/nextcloud/talk/services/firebase/NCFirebaseMessagingService.kt +++ b/app/src/gplay/java/com/nextcloud/talk/services/firebase/NCFirebaseMessagingService.kt @@ -40,7 +40,6 @@ import javax.inject.Inject @AutoInjector(NextcloudTalkApplication::class) class NCFirebaseMessagingService : FirebaseMessagingService() { - @Inject lateinit var appPreferences: AppPreferences @@ -62,12 +61,16 @@ class NCFirebaseMessagingService : FirebaseMessagingService() { val signature = data[KEY_NOTIFICATION_SIGNATURE] if (!subject.isNullOrEmpty() && !signature.isNullOrEmpty()) { - val messageData = Data.Builder() - .putString(BundleKeys.KEY_NOTIFICATION_SUBJECT, subject) - .putString(BundleKeys.KEY_NOTIFICATION_SIGNATURE, signature) - .build() + val messageData = + Data + .Builder() + .putString(BundleKeys.KEY_NOTIFICATION_SUBJECT, subject) + .putString(BundleKeys.KEY_NOTIFICATION_SIGNATURE, signature) + .build() val notificationWork = - OneTimeWorkRequest.Builder(NotificationWorker::class.java).setInputData(messageData) + OneTimeWorkRequest + .Builder(NotificationWorker::class.java) + .setInputData(messageData) .build() WorkManager.getInstance().enqueue(notificationWork) } @@ -81,9 +84,11 @@ class NCFirebaseMessagingService : FirebaseMessagingService() { val data: Data = Data.Builder().putString(PushRegistrationWorker.ORIGIN, "NCFirebaseMessagingService#onNewToken").build() - val pushRegistrationWork = OneTimeWorkRequest.Builder(PushRegistrationWorker::class.java) - .setInputData(data) - .build() + val pushRegistrationWork = + OneTimeWorkRequest + .Builder(PushRegistrationWorker::class.java) + .setInputData(data) + .build() WorkManager.getInstance().enqueue(pushRegistrationWork) } diff --git a/app/src/gplay/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.kt b/app/src/gplay/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.kt index f7562336d75..3fc103f3f68 100644 --- a/app/src/gplay/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.kt +++ b/app/src/gplay/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.kt @@ -40,15 +40,11 @@ import java.util.concurrent.TimeUnit @AutoInjector(NextcloudTalkApplication::class) class ClosedInterfaceImpl : ClosedInterface, ProviderInstaller.ProviderInstallListener { - override val isGooglePlayServicesAvailable: Boolean = isGPlayServicesAvailable() override fun providerInstallerInstallIfNeededAsync() { NextcloudTalkApplication.sharedApplication?.let { - ProviderInstaller.installIfNeededAsync( - it.applicationContext, - this - ) + ProviderInstaller.installIfNeededAsync(it.applicationContext, this) } } @@ -56,7 +52,10 @@ class ClosedInterfaceImpl : ClosedInterface, ProviderInstaller.ProviderInstallLi // unused atm } - override fun onProviderInstallFailed(p0: Int, p1: Intent?) { + override fun onProviderInstallFailed( + p0: Int, + p1: Intent?, + ) { // unused atm } @@ -82,19 +81,23 @@ class ClosedInterfaceImpl : ClosedInterface, ProviderInstaller.ProviderInstallLi } private fun setUpPeriodicTokenRefreshFromFCM() { - val periodicTokenRefreshFromFCM = PeriodicWorkRequest.Builder( - GetFirebasePushTokenWorker::class.java, - DAILY, - TimeUnit.HOURS, - FLEX_INTERVAL, - TimeUnit.HOURS - ).build() + val periodicTokenRefreshFromFCM = + PeriodicWorkRequest + .Builder( + GetFirebasePushTokenWorker::class.java, + DAILY, + TimeUnit.HOURS, + FLEX_INTERVAL, + TimeUnit.HOURS, + ) + .build() - WorkManager.getInstance() + WorkManager + .getInstance() .enqueueUniquePeriodicWork( "periodicTokenRefreshFromFCM", ExistingPeriodicWorkPolicy.UPDATE, - periodicTokenRefreshFromFCM + periodicTokenRefreshFromFCM, ) }