From 40d45bcb7a9e6c0afa936533d089df1583dc2e27 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 27 Jun 2024 19:46:41 +0200 Subject: [PATCH] fix: ktlint compliant kotlin formatting/code Signed-off-by: Andy Scherzinger --- .editorconfig | 2 + .../providers/DocumentsProviderUtils.kt | 45 ++++++++-------- .../android/ui/fragment/AvatarTestFragment.kt | 10 ++-- .../fragment/FileDetailSharingFragmentIT.kt | 10 +--- .../android/ui/trashbin/TrashbinActivityIT.kt | 4 +- .../ui/trashbin/TrashbinLocalRepository.kt | 18 ++++--- .../android/utils/EncryptionUtilsV2IT.kt | 3 +- .../appReview/InAppReviewHelperImpl.kt | 6 +-- .../client/assistant/AssistantViewModel.kt | 13 ++--- .../client/assistant/AsssistantScreen.kt | 6 +-- .../repository/AssistantRepository.kt | 5 +- .../repository/AssistantRepositoryType.kt | 5 +- .../client/assistant/task/TaskView.kt | 5 +- .../taskDetail/TaskDetailBottomSheet.kt | 25 ++++----- .../client/database/NextcloudDatabase.kt | 8 +-- .../migrations/DatabaseMigrationUtil.kt | 12 +---- .../nextcloud/client/di/FragmentInjector.kt | 6 +-- .../documentscan/DocumentPageListAdapter.kt | 6 +-- .../client/documentscan/GeneratePDFUseCase.kt | 10 +--- .../documentscan/GeneratePdfFromImagesWork.kt | 3 +- .../client/etm/pages/EtmAccountsFragment.kt | 2 +- .../client/etm/pages/EtmMigrations.kt | 2 +- .../etm/pages/EtmPreferencesFragment.kt | 2 +- .../client/integrations/deck/DeckApi.kt | 5 +- .../client/jobs/BackgroundJobFactory.kt | 10 +--- .../client/jobs/BackgroundJobManagerImpl.kt | 4 +- .../nextcloud/client/jobs/FilesSyncWork.kt | 3 +- .../client/jobs/download/FileDownloadError.kt | 3 +- .../jobs/download/FileDownloadHelper.kt | 6 +-- .../jobs/download/FileDownloadIntents.kt | 5 +- .../jobs/download/FileDownloadWorker.kt | 5 +- .../client/jobs/upload/FileUploadHelper.kt | 10 +--- .../client/jobs/upload/FileUploadWorker.kt | 5 +- .../preferences/AppPreferencesImpl.java | 4 +- .../client/preferences/SubFolderRule.kt | 4 +- .../com/nextcloud/client/utils/IntentUtil.kt | 29 +++++------ .../ui/ChooseAccountDialogFragment.kt | 12 ++--- .../com/nextcloud/ui/ImageDetailFragment.kt | 3 +- .../bottomSheet/MoreActionsBottomSheet.kt | 6 +-- .../ui/fileactions/FileActionsBottomSheet.kt | 10 ++-- .../ui/fileactions/FileActionsViewModel.kt | 15 ++---- .../utils/extensions/BundleExtensions.kt | 6 +-- .../utils/extensions/IntentExtensions.kt | 6 +-- ...nDataTransferProgressListenerExtensions.kt | 6 +-- .../nextcloud/utils/view/FastScrollUtils.kt | 5 +- .../authentication/DeepLinkLoginActivity.kt | 3 +- .../datamodel/ForegroundServiceType.kt | 3 +- .../android/datamodel/MediaFolderType.kt | 4 +- .../owncloud/android/datamodel/Template.kt | 5 +- .../android/media/MediaControlView.kt | 16 ++++-- .../ui/activity/ConflictsResolveActivity.kt | 8 +-- .../ui/activity/FolderPickerActivity.kt | 5 +- .../ui/activity/NotificationsActivity.kt | 6 +-- .../ui/activity/SyncedFoldersActivity.kt | 6 +-- .../ui/adapter/TrashbinListAdapter.java | 2 +- .../ui/adapter/UnifiedSearchItemViewHolder.kt | 5 +- .../android/ui/dialog/AccountRemovalDialog.kt | 2 +- .../ui/dialog/ChooseTemplateDialogFragment.kt | 6 ++- .../android/ui/dialog/SendFilesDialog.kt | 9 ++-- .../android/ui/dialog/SendShareDialog.kt | 3 +- .../ui/dialog/SortingOrderDialogFragment.kt | 14 ++--- .../dialog/StoragePermissionDialogFragment.kt | 4 +- .../SyncedFolderPreferencesDialogFragment.kt | 14 ++--- .../FileDetailsSharingProcessFragment.kt | 8 ++- .../ui/fragment/ProfileBottomSheetDialog.kt | 2 +- .../ui/fragment/UnifiedSearchFragment.kt | 2 +- .../android/ui/helpers/UriUploader.kt | 15 ++++-- .../ui/preview/pdf/PreviewPdfFragment.kt | 5 +- .../ui/preview/pdf/PreviewPdfViewModel.kt | 2 +- .../android/ui/trashbin/TrashbinActivity.kt | 8 +-- .../owncloud/android/utils/DisplayUtils.java | 24 ++++----- .../android/utils/EncryptionUtilsV2.kt | 17 +++--- .../owncloud/android/utils/FileExportUtils.kt | 8 +-- .../owncloud/android/utils/FileSortOrder.kt | 52 ++++++++++--------- .../theme/FilesSpecificViewThemeUtils.kt | 4 +- .../nextcloud/client/utils/OCFileSortTest.kt | 2 +- 76 files changed, 272 insertions(+), 362 deletions(-) diff --git a/.editorconfig b/.editorconfig index 3c00f0cce0..67e5fa3c2e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -42,8 +42,10 @@ trim_trailing_whitespace=false indent_size=2 [*.{kt,kts}] +ktlint_code_style = android_studio # IDE does not follow this Ktlint rule strictly, but the default ordering is pretty good anyway, so let's ditch it ktlint_standard_import-ordering = disabled ktlint_standard_no-consecutive-comments = disabled +ktlint_function_naming_ignore_when_annotated_with = Composable ij_kotlin_allow_trailing_comma = false ij_kotlin_allow_trailing_comma_on_call_site = false diff --git a/app/src/androidTest/java/com/owncloud/android/providers/DocumentsProviderUtils.kt b/app/src/androidTest/java/com/owncloud/android/providers/DocumentsProviderUtils.kt index 16be9df183..0cc2705e76 100644 --- a/app/src/androidTest/java/com/owncloud/android/providers/DocumentsProviderUtils.kt +++ b/app/src/androidTest/java/com/owncloud/android/providers/DocumentsProviderUtils.kt @@ -177,31 +177,30 @@ object DocumentsProviderUtils { */ @Suppress("EXPERIMENTAL_API_USAGE") @VisibleForTesting - internal suspend fun getLoadedCursor(timeout: Long = 15_000, query: () -> Cursor?) = - withTimeout(timeout) { - suspendCancellableCoroutine { cont -> - val cursor = query() ?: throw IOException("Initial query returned no results") - cont.invokeOnCancellation { cursor.close() } - val loading = cursor.extras.getBoolean(EXTRA_LOADING, false) - if (loading) { - Log_OC.e("TEST", "Cursor was loading, wait for update...") - cursor.registerContentObserver( - object : ContentObserver(null) { - override fun onChange(selfChange: Boolean, uri: Uri?) { - cursor.close() - val newCursor = query() - if (newCursor == null) { - cont.cancel(IOException("Re-query returned no results")) - } else { - cont.resume(newCursor) - } + internal suspend fun getLoadedCursor(timeout: Long = 15_000, query: () -> Cursor?) = withTimeout(timeout) { + suspendCancellableCoroutine { cont -> + val cursor = query() ?: throw IOException("Initial query returned no results") + cont.invokeOnCancellation { cursor.close() } + val loading = cursor.extras.getBoolean(EXTRA_LOADING, false) + if (loading) { + Log_OC.e("TEST", "Cursor was loading, wait for update...") + cursor.registerContentObserver( + object : ContentObserver(null) { + override fun onChange(selfChange: Boolean, uri: Uri?) { + cursor.close() + val newCursor = query() + if (newCursor == null) { + cont.cancel(IOException("Re-query returned no results")) + } else { + cont.resume(newCursor) } } - ) - } else { - // not loading, return cursor right away - cont.resume(cursor) - } + } + ) + } else { + // not loading, return cursor right away + cont.resume(cursor) } } + } } diff --git a/app/src/androidTest/java/com/owncloud/android/ui/fragment/AvatarTestFragment.kt b/app/src/androidTest/java/com/owncloud/android/ui/fragment/AvatarTestFragment.kt index 02d4f87585..6d21bf1239 100644 --- a/app/src/androidTest/java/com/owncloud/android/ui/fragment/AvatarTestFragment.kt +++ b/app/src/androidTest/java/com/owncloud/android/ui/fragment/AvatarTestFragment.kt @@ -21,8 +21,8 @@ import com.owncloud.android.R import com.owncloud.android.ui.TextDrawable internal class AvatarTestFragment : Fragment() { - lateinit var list1: LinearLayout - lateinit var list2: LinearLayout + private lateinit var list1: LinearLayout + private lateinit var list2: LinearLayout override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view: View = inflater.inflate(R.layout.avatar_fragment, null) @@ -34,7 +34,7 @@ internal class AvatarTestFragment : Fragment() { } fun addAvatar(name: String, avatarRadius: Float, width: Int, targetContext: Context) { - val margin = padding + val margin = PADDING val imageView = ImageView(targetContext) imageView.setImageDrawable(TextDrawable.createNamedAvatar(name, avatarRadius)) @@ -47,7 +47,7 @@ internal class AvatarTestFragment : Fragment() { } fun addBitmap(bitmap: Bitmap, width: Int, list: Int, targetContext: Context) { - val margin = padding + val margin = PADDING val imageView = ImageView(targetContext) imageView.setImageBitmap(bitmap) @@ -64,6 +64,6 @@ internal class AvatarTestFragment : Fragment() { } companion object { - private const val padding = 10 + private const val PADDING = 10 } } diff --git a/app/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailSharingFragmentIT.kt b/app/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailSharingFragmentIT.kt index 433e6c6b7b..d4c5de954a 100644 --- a/app/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailSharingFragmentIT.kt +++ b/app/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailSharingFragmentIT.kt @@ -672,10 +672,7 @@ class FileDetailSharingFragmentIT : AbstractIT() { } // open bottom sheet with actions - private fun openAdvancedPermissions( - sut: FileDetailSharingFragment, - userShare: OCShare - ) { + private fun openAdvancedPermissions(sut: FileDetailSharingFragment, userShare: OCShare) { activity.handler.post { sut.showSharingMenuActionSheet(userShare) } @@ -723,10 +720,7 @@ class FileDetailSharingFragmentIT : AbstractIT() { /** * verify send new email note text */ - private fun verifySendNewEmail( - sut: FileDetailSharingFragment, - userShare: OCShare - ) { + private fun verifySendNewEmail(sut: FileDetailSharingFragment, userShare: OCShare) { activity.runOnUiThread { sut.showSharingMenuActionSheet(userShare) } waitForIdleSync() diff --git a/app/src/androidTest/java/com/owncloud/android/ui/trashbin/TrashbinActivityIT.kt b/app/src/androidTest/java/com/owncloud/android/ui/trashbin/TrashbinActivityIT.kt index 943cae11b3..42e69169b4 100644 --- a/app/src/androidTest/java/com/owncloud/android/ui/trashbin/TrashbinActivityIT.kt +++ b/app/src/androidTest/java/com/owncloud/android/ui/trashbin/TrashbinActivityIT.kt @@ -20,7 +20,9 @@ import org.junit.Test class TrashbinActivityIT : AbstractIT() { enum class TestCase { - ERROR, EMPTY, FILES + ERROR, + EMPTY, + FILES } @get:Rule diff --git a/app/src/androidTest/java/com/owncloud/android/ui/trashbin/TrashbinLocalRepository.kt b/app/src/androidTest/java/com/owncloud/android/ui/trashbin/TrashbinLocalRepository.kt index e0fdecc272..ebf5244951 100644 --- a/app/src/androidTest/java/com/owncloud/android/ui/trashbin/TrashbinLocalRepository.kt +++ b/app/src/androidTest/java/com/owncloud/android/ui/trashbin/TrashbinLocalRepository.kt @@ -36,8 +36,10 @@ class TrashbinLocalRepository(private val testCase: TrashbinActivityIT.TestCase) "image/png", "/trashbin/test.png", "subFolder/test.png", - 1395847838, // random date - 1395847908 // random date + // random date + 1395847838, + // random date + 1395847908 ) ) files.add( @@ -46,8 +48,10 @@ class TrashbinLocalRepository(private val testCase: TrashbinActivityIT.TestCase) "image/jpeg", "/trashbin/image.jpg", "image.jpg", - 1395841858, // random date - 1395837858 // random date + // random date + 1395841858, + // random date + 1395837858 ) ) files.add( @@ -56,8 +60,10 @@ class TrashbinLocalRepository(private val testCase: TrashbinActivityIT.TestCase) "DIR", "/trashbin/folder/", "folder", - 1395347858, // random date - 1395849858 // random date + // random date + 1395347858, + // random date + 1395849858 ) ) diff --git a/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2IT.kt b/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2IT.kt index f41ccbfa60..a5be7eaba1 100644 --- a/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2IT.kt +++ b/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2IT.kt @@ -290,7 +290,8 @@ class EncryptionUtilsV2IT : EncryptionIT() { mimeType = MimeType.JPEG }, EncryptionUtils.generateIV(), - EncryptionUtils.generateUid(), // random string, not real tag + // random string, not real tag + EncryptionUtils.generateUid(), EncryptionUtils.generateKey(), metadataFile, storageManager diff --git a/app/src/gplay/java/com/nextcloud/android/appReview/InAppReviewHelperImpl.kt b/app/src/gplay/java/com/nextcloud/android/appReview/InAppReviewHelperImpl.kt index 77d6113e49..01208c9a7a 100644 --- a/app/src/gplay/java/com/nextcloud/android/appReview/InAppReviewHelperImpl.kt +++ b/app/src/gplay/java/com/nextcloud/android/appReview/InAppReviewHelperImpl.kt @@ -85,11 +85,7 @@ class InAppReviewHelperImpl(val appPreferences: AppPreferences) : InAppReviewHel } } - private fun launchAppReviewFlow( - manager: ReviewManager, - activity: AppCompatActivity, - reviewInfo: ReviewInfo - ) { + private fun launchAppReviewFlow(manager: ReviewManager, activity: AppCompatActivity, reviewInfo: ReviewInfo) { val flow = manager.launchReviewFlow(activity, reviewInfo) flow.addOnCompleteListener { _ -> // The flow has finished. The API does not indicate whether the user diff --git a/app/src/main/java/com/nextcloud/client/assistant/AssistantViewModel.kt b/app/src/main/java/com/nextcloud/client/assistant/AssistantViewModel.kt index 360285db8a..ffc3d11ab0 100644 --- a/app/src/main/java/com/nextcloud/client/assistant/AssistantViewModel.kt +++ b/app/src/main/java/com/nextcloud/client/assistant/AssistantViewModel.kt @@ -44,7 +44,7 @@ class AssistantViewModel( private val _taskTypes = MutableStateFlow?>(null) val taskTypes: StateFlow?> = _taskTypes - private var _taskList: List? = null + private var taskList: List? = null private val _filteredTaskList = MutableStateFlow?>(null) val filteredTaskList: StateFlow?> = _filteredTaskList @@ -55,10 +55,7 @@ class AssistantViewModel( } @Suppress("MagicNumber") - fun createTask( - input: String, - type: String - ) { + fun createTask(input: String, type: String) { viewModelScope.launch(Dispatchers.IO) { val result = repository.createTask(input, type) @@ -111,7 +108,7 @@ class AssistantViewModel( viewModelScope.launch(Dispatchers.IO) { val result = repository.getTaskList(appId) if (result.isSuccess) { - _taskList = result.resultData.tasks + taskList = result.resultData.tasks filterTaskList(_selectedTaskType.value?.id) @@ -157,11 +154,11 @@ class AssistantViewModel( private fun filterTaskList(taskTypeId: String?) { if (taskTypeId == null) { _filteredTaskList.update { - _taskList + taskList } } else { _filteredTaskList.update { - _taskList?.filter { it.type == taskTypeId } + taskList?.filter { it.type == taskTypeId } } } diff --git a/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt b/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt index 8295cc5146..7d6cc6968f 100644 --- a/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt +++ b/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt @@ -151,11 +151,7 @@ fun AssistantScreen(viewModel: AssistantViewModel, activity: Activity) { } @Composable -private fun ScreenState( - state: AssistantViewModel.State, - activity: Activity, - viewModel: AssistantViewModel -) { +private fun ScreenState(state: AssistantViewModel.State, activity: Activity, viewModel: AssistantViewModel) { val messageId: Int? = when (state) { is AssistantViewModel.State.Error -> { state.messageId diff --git a/app/src/main/java/com/nextcloud/client/assistant/repository/AssistantRepository.kt b/app/src/main/java/com/nextcloud/client/assistant/repository/AssistantRepository.kt index bdd1f24126..1cb32ff43c 100644 --- a/app/src/main/java/com/nextcloud/client/assistant/repository/AssistantRepository.kt +++ b/app/src/main/java/com/nextcloud/client/assistant/repository/AssistantRepository.kt @@ -22,10 +22,7 @@ class AssistantRepository(private val client: NextcloudClient) : AssistantReposi return GetTaskTypesRemoteOperation().execute(client) } - override fun createTask( - input: String, - type: String - ): RemoteOperationResult { + override fun createTask(input: String, type: String): RemoteOperationResult { return CreateTaskRemoteOperation(input, type).execute(client) } diff --git a/app/src/main/java/com/nextcloud/client/assistant/repository/AssistantRepositoryType.kt b/app/src/main/java/com/nextcloud/client/assistant/repository/AssistantRepositoryType.kt index 58acaf4d09..8bb9808863 100644 --- a/app/src/main/java/com/nextcloud/client/assistant/repository/AssistantRepositoryType.kt +++ b/app/src/main/java/com/nextcloud/client/assistant/repository/AssistantRepositoryType.kt @@ -14,10 +14,7 @@ import com.owncloud.android.lib.resources.assistant.model.TaskTypes interface AssistantRepositoryType { fun getTaskTypes(): RemoteOperationResult - fun createTask( - input: String, - type: String - ): RemoteOperationResult + fun createTask(input: String, type: String): RemoteOperationResult fun getTaskList(appId: String): RemoteOperationResult diff --git a/app/src/main/java/com/nextcloud/client/assistant/task/TaskView.kt b/app/src/main/java/com/nextcloud/client/assistant/task/TaskView.kt index acdc298aa1..cdc5c28476 100644 --- a/app/src/main/java/com/nextcloud/client/assistant/task/TaskView.kt +++ b/app/src/main/java/com/nextcloud/client/assistant/task/TaskView.kt @@ -41,10 +41,7 @@ import com.owncloud.android.lib.resources.assistant.model.Task @OptIn(ExperimentalFoundationApi::class) @Suppress("LongMethod", "MagicNumber") @Composable -fun TaskView( - task: Task, - showDeleteTaskAlertDialog: (Long) -> Unit -) { +fun TaskView(task: Task, showDeleteTaskAlertDialog: (Long) -> Unit) { var showTaskDetailBottomSheet by remember { mutableStateOf(false) } var showMoreActionsBottomSheet by remember { mutableStateOf(false) } diff --git a/app/src/main/java/com/nextcloud/client/assistant/taskDetail/TaskDetailBottomSheet.kt b/app/src/main/java/com/nextcloud/client/assistant/taskDetail/TaskDetailBottomSheet.kt index d73fae9371..4bc84bb239 100644 --- a/app/src/main/java/com/nextcloud/client/assistant/taskDetail/TaskDetailBottomSheet.kt +++ b/app/src/main/java/com/nextcloud/client/assistant/taskDetail/TaskDetailBottomSheet.kt @@ -55,21 +55,16 @@ fun TaskDetailBottomSheet(task: Task, dismiss: () -> Unit) { ModalBottomSheet( modifier = Modifier.padding(top = 32.dp), containerColor = Color.White, - onDismissRequest = { - dismiss() - }, + onDismissRequest = { dismiss() }, sheetState = sheetState ) { - LazyColumn( - modifier = Modifier - .fillMaxSize() - .padding(16.dp) - ) { + LazyColumn(modifier = Modifier.fillMaxSize().padding(16.dp)) { stickyHeader { Row( - modifier = Modifier - .fillMaxWidth() - .background(color = colorResource(id = R.color.light_grey), shape = RoundedCornerShape(8.dp)) + modifier = Modifier.fillMaxWidth().background( + color = colorResource(id = R.color.light_grey), + shape = RoundedCornerShape(8.dp) + ) ) { TextInputSelectButton( Modifier.weight(1f), @@ -95,10 +90,10 @@ fun TaskDetailBottomSheet(task: Task, dismiss: () -> Unit) { Spacer(modifier = Modifier.height(16.dp)) Column( - modifier = Modifier - .fillMaxSize() - .background(color = colorResource(id = R.color.light_grey), shape = RoundedCornerShape(8.dp)) - .padding(16.dp) + modifier = Modifier.fillMaxSize().background( + color = colorResource(id = R.color.light_grey), + shape = RoundedCornerShape(8.dp) + ).padding(16.dp) ) { Text( text = if (showInput) { diff --git a/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt b/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt index 8b80435e6b..1c9ec8c7de 100644 --- a/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt +++ b/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt @@ -71,7 +71,7 @@ abstract class NextcloudDatabase : RoomDatabase() { companion object { const val FIRST_ROOM_DB_VERSION = 65 - private var INSTANCE: NextcloudDatabase? = null + private var instance: NextcloudDatabase? = null @JvmStatic @Suppress("DeprecatedCallableAddReplaceWith") @@ -82,8 +82,8 @@ abstract class NextcloudDatabase : RoomDatabase() { @JvmStatic fun getInstance(context: Context, clock: Clock): NextcloudDatabase { - if (INSTANCE == null) { - INSTANCE = Room + if (instance == null) { + instance = Room .databaseBuilder(context, NextcloudDatabase::class.java, ProviderMeta.DB_NAME) .allowMainThreadQueries() .addLegacyMigrations(clock, context) @@ -92,7 +92,7 @@ abstract class NextcloudDatabase : RoomDatabase() { .fallbackToDestructiveMigration() .build() } - return INSTANCE!! + return instance!! } } } diff --git a/app/src/main/java/com/nextcloud/client/database/migrations/DatabaseMigrationUtil.kt b/app/src/main/java/com/nextcloud/client/database/migrations/DatabaseMigrationUtil.kt index ca4475ceea..eb1dcb6cd7 100644 --- a/app/src/main/java/com/nextcloud/client/database/migrations/DatabaseMigrationUtil.kt +++ b/app/src/main/java/com/nextcloud/client/database/migrations/DatabaseMigrationUtil.kt @@ -46,11 +46,7 @@ object DatabaseMigrationUtil { /** * Utility method to create a new table with the given columns */ - private fun createNewTable( - database: SupportSQLiteDatabase, - newTableName: String, - columns: Map - ) { + private fun createNewTable(database: SupportSQLiteDatabase, newTableName: String, columns: Map) { val columnsString = columns.entries.joinToString(",") { "${it.key} ${it.value}" } database.execSQL("CREATE TABLE $newTableName ($columnsString)") } @@ -80,11 +76,7 @@ object DatabaseMigrationUtil { /** * Utility method to replace an old table with a new one, essentially deleting the old one and renaming the new one */ - private fun replaceTable( - database: SupportSQLiteDatabase, - tableName: String, - newTableTempName: String - ) { + private fun replaceTable(database: SupportSQLiteDatabase, tableName: String, newTableTempName: String) { database.execSQL("DROP TABLE $tableName") database.execSQL("ALTER TABLE $newTableTempName RENAME TO $tableName") } diff --git a/app/src/main/java/com/nextcloud/client/di/FragmentInjector.kt b/app/src/main/java/com/nextcloud/client/di/FragmentInjector.kt index 164466d5f2..5d76e732ae 100644 --- a/app/src/main/java/com/nextcloud/client/di/FragmentInjector.kt +++ b/app/src/main/java/com/nextcloud/client/di/FragmentInjector.kt @@ -12,11 +12,7 @@ import androidx.fragment.app.FragmentManager import dagger.android.support.AndroidSupportInjection internal class FragmentInjector : FragmentManager.FragmentLifecycleCallbacks() { - override fun onFragmentPreAttached( - fragmentManager: FragmentManager, - fragment: Fragment, - context: Context - ) { + override fun onFragmentPreAttached(fragmentManager: FragmentManager, fragment: Fragment, context: Context) { super.onFragmentPreAttached(fragmentManager, fragment, context) if (fragment is Injectable) { try { diff --git a/app/src/main/java/com/nextcloud/client/documentscan/DocumentPageListAdapter.kt b/app/src/main/java/com/nextcloud/client/documentscan/DocumentPageListAdapter.kt index 16a39f1509..f0340766ec 100644 --- a/app/src/main/java/com/nextcloud/client/documentscan/DocumentPageListAdapter.kt +++ b/app/src/main/java/com/nextcloud/client/documentscan/DocumentPageListAdapter.kt @@ -39,10 +39,8 @@ class DocumentPageListAdapter : } private class DiffItemCallback : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: String, newItem: String) = - oldItem == newItem + override fun areItemsTheSame(oldItem: String, newItem: String) = oldItem == newItem - override fun areContentsTheSame(oldItem: String, newItem: String) = - oldItem == newItem + override fun areContentsTheSame(oldItem: String, newItem: String) = oldItem == newItem } } diff --git a/app/src/main/java/com/nextcloud/client/documentscan/GeneratePDFUseCase.kt b/app/src/main/java/com/nextcloud/client/documentscan/GeneratePDFUseCase.kt index 8f231a5444..4cb87527dd 100644 --- a/app/src/main/java/com/nextcloud/client/documentscan/GeneratePDFUseCase.kt +++ b/app/src/main/java/com/nextcloud/client/documentscan/GeneratePDFUseCase.kt @@ -36,10 +36,7 @@ class GeneratePDFUseCase @Inject constructor(private val logger: Logger) { /** * @return `true` if the PDF was generated successfully, `false` otherwise */ - private fun writePdfToFile( - filePath: String, - document: PdfDocument - ): Boolean { + private fun writePdfToFile(filePath: String, document: PdfDocument): Boolean { return try { val fileOutputStream = FileOutputStream(filePath) document.writeTo(fileOutputStream) @@ -52,10 +49,7 @@ class GeneratePDFUseCase @Inject constructor(private val logger: Logger) { } } - private fun fillDocumentPages( - document: PdfDocument, - imagePaths: List - ) { + private fun fillDocumentPages(document: PdfDocument, imagePaths: List) { imagePaths.forEach { path -> val bitmap = BitmapFactory.decodeFile(path) val pageInfo = PdfDocument.PageInfo.Builder(bitmap.width, bitmap.height, 1).create() diff --git a/app/src/main/java/com/nextcloud/client/documentscan/GeneratePdfFromImagesWork.kt b/app/src/main/java/com/nextcloud/client/documentscan/GeneratePdfFromImagesWork.kt index 11d44e24fb..c1115de62e 100644 --- a/app/src/main/java/com/nextcloud/client/documentscan/GeneratePdfFromImagesWork.kt +++ b/app/src/main/java/com/nextcloud/client/documentscan/GeneratePdfFromImagesWork.kt @@ -112,7 +112,8 @@ class GeneratePdfFromImagesWork( user, arrayOf(pdfPath), arrayOf(uploadPath), - FileUploadWorker.LOCAL_BEHAVIOUR_DELETE, // MIME type will be detected from file name + // MIME type will be detected from file name + FileUploadWorker.LOCAL_BEHAVIOUR_DELETE, true, UploadFileOperation.CREATED_BY_USER, false, diff --git a/app/src/main/java/com/nextcloud/client/etm/pages/EtmAccountsFragment.kt b/app/src/main/java/com/nextcloud/client/etm/pages/EtmAccountsFragment.kt index dccc22f73a..e406bf9747 100644 --- a/app/src/main/java/com/nextcloud/client/etm/pages/EtmAccountsFragment.kt +++ b/app/src/main/java/com/nextcloud/client/etm/pages/EtmAccountsFragment.kt @@ -20,7 +20,7 @@ import com.owncloud.android.databinding.FragmentEtmAccountsBinding class EtmAccountsFragment : EtmBaseFragment() { private var _binding: FragmentEtmAccountsBinding? = null - private val binding get() = _binding!! + val binding get() = _binding!! override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/com/nextcloud/client/etm/pages/EtmMigrations.kt b/app/src/main/java/com/nextcloud/client/etm/pages/EtmMigrations.kt index f1efb30b2e..8f93432865 100644 --- a/app/src/main/java/com/nextcloud/client/etm/pages/EtmMigrations.kt +++ b/app/src/main/java/com/nextcloud/client/etm/pages/EtmMigrations.kt @@ -20,7 +20,7 @@ import java.util.Locale class EtmMigrations : EtmBaseFragment() { private var _binding: FragmentEtmMigrationsBinding? = null - private val binding get() = _binding!! + val binding get() = _binding!! override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/com/nextcloud/client/etm/pages/EtmPreferencesFragment.kt b/app/src/main/java/com/nextcloud/client/etm/pages/EtmPreferencesFragment.kt index f5a40c5590..395bf484a9 100644 --- a/app/src/main/java/com/nextcloud/client/etm/pages/EtmPreferencesFragment.kt +++ b/app/src/main/java/com/nextcloud/client/etm/pages/EtmPreferencesFragment.kt @@ -20,7 +20,7 @@ import com.owncloud.android.databinding.FragmentEtmPreferencesBinding class EtmPreferencesFragment : EtmBaseFragment() { private var _binding: FragmentEtmPreferencesBinding? = null - private val binding get() = _binding!! + val binding get() = _binding!! override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/com/nextcloud/client/integrations/deck/DeckApi.kt b/app/src/main/java/com/nextcloud/client/integrations/deck/DeckApi.kt index 1880ce8c58..b956e4cf6c 100644 --- a/app/src/main/java/com/nextcloud/client/integrations/deck/DeckApi.kt +++ b/app/src/main/java/com/nextcloud/client/integrations/deck/DeckApi.kt @@ -25,8 +25,5 @@ interface DeckApi { * value otherwise * @see [Deck Server App](https://apps.nextcloud.com/apps/deck) */ - fun createForwardToDeckActionIntent( - notification: Notification, - user: User - ): Optional + fun createForwardToDeckActionIntent(notification: Notification, user: User): Optional } diff --git a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobFactory.kt b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobFactory.kt index e10207a1f4..8bfc81c030 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobFactory.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobFactory.kt @@ -100,10 +100,7 @@ class BackgroundJobFactory @Inject constructor( } } - private fun createFilesExportWork( - context: Context, - params: WorkerParameters - ): ListenableWorker { + private fun createFilesExportWork(context: Context, params: WorkerParameters): ListenableWorker { return FilesExportWork( context, accountManager.user, @@ -113,10 +110,7 @@ class BackgroundJobFactory @Inject constructor( ) } - private fun createContentObserverJob( - context: Context, - workerParameters: WorkerParameters - ): ListenableWorker { + private fun createContentObserverJob(context: Context, workerParameters: WorkerParameters): ListenableWorker { return ContentObserverWork( context, workerParameters, diff --git a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt index 716440c36b..76a9b836b8 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt @@ -409,9 +409,7 @@ internal class BackgroundJobManagerImpl( workManager.isWorkRunning(JOB_IMMEDIATE_FILES_SYNC + "_" + syncedFolderID) } - override fun schedulePeriodicFilesSyncJob( - syncedFolderID: Long - ) { + override fun schedulePeriodicFilesSyncJob(syncedFolderID: Long) { val arguments = Data.Builder() .putLong(FilesSyncWork.SYNCED_FOLDER_ID, syncedFolderID) .build() diff --git a/app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt b/app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt index c3bbfd4c2b..277f5cef52 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt @@ -250,7 +250,8 @@ class FilesSyncWork( localPaths, remotePaths, uploadAction!!, - true, // create parent folder if not existent + // create parent folder if not existent + true, UploadFileOperation.CREATED_AS_INSTANT_PICTURE, needsWifi, needsCharging, diff --git a/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadError.kt b/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadError.kt index c69eea3e94..cb027e9ae0 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadError.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadError.kt @@ -8,5 +8,6 @@ package com.nextcloud.client.jobs.download enum class FileDownloadError { - Failed, Cancelled + Failed, + Cancelled } diff --git a/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadHelper.kt b/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadHelper.kt index fb42ecbe2b..e1ad4662e0 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadHelper.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadHelper.kt @@ -81,11 +81,7 @@ class FileDownloadHelper { backgroundJobManager.cancelFilesDownloadJob(currentUser, currentFile.fileId) } - fun saveFile( - file: OCFile, - currentDownload: DownloadFileOperation?, - storageManager: FileDataStorageManager? - ) { + fun saveFile(file: OCFile, currentDownload: DownloadFileOperation?, storageManager: FileDataStorageManager?) { val syncDate = System.currentTimeMillis() file.apply { diff --git a/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadIntents.kt b/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadIntents.kt index bbedd28058..56ab82e359 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadIntents.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadIntents.kt @@ -22,10 +22,7 @@ import com.owncloud.android.ui.preview.PreviewImageFragment class FileDownloadIntents(private val context: Context) { - fun newDownloadIntent( - download: DownloadFileOperation, - linkedToRemotePath: String - ): Intent { + fun newDownloadIntent(download: DownloadFileOperation, linkedToRemotePath: String): Intent { return Intent(FileDownloadWorker.getDownloadAddedMessage()).apply { putExtra(FileDownloadWorker.EXTRA_ACCOUNT_NAME, download.user.accountName) putExtra(FileDownloadWorker.EXTRA_REMOTE_PATH, download.remotePath) diff --git a/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadWorker.kt b/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadWorker.kt index 379d44dd3f..089a094c6d 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/download/FileDownloadWorker.kt @@ -369,10 +369,7 @@ class FileDownloadWorker( notificationManager.showNewNotification(text) } - private fun notifyDownloadResult( - download: DownloadFileOperation, - downloadResult: RemoteOperationResult<*> - ) { + private fun notifyDownloadResult(download: DownloadFileOperation, downloadResult: RemoteOperationResult<*>) { if (downloadResult.isCancelled) { return } diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt index 67ba4834df..283cc0fbab 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt @@ -282,17 +282,11 @@ class FileUploadHelper { cancelAndRestartUploadJob(accountManager.getUser(accountName).get()) } - fun addUploadTransferProgressListener( - listener: OnDatatransferProgressListener, - targetKey: String - ) { + fun addUploadTransferProgressListener(listener: OnDatatransferProgressListener, targetKey: String) { mBoundListeners[targetKey] = listener } - fun removeUploadTransferProgressListener( - listener: OnDatatransferProgressListener, - targetKey: String - ) { + fun removeUploadTransferProgressListener(listener: OnDatatransferProgressListener, targetKey: String) { if (mBoundListeners[targetKey] === listener) { mBoundListeners.remove(targetKey) } diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt index d684d2f8eb..dba505bf52 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt @@ -269,7 +269,10 @@ class FileUploadWorker( // Only notify if it is not same file on remote that causes conflict if (uploadResult.code == ResultCode.SYNC_CONFLICT && FileUploadHelper().isSameFileOnRemote( - uploadFileOperation.user, File(uploadFileOperation.storagePath), uploadFileOperation.remotePath, context + uploadFileOperation.user, + File(uploadFileOperation.storagePath), + uploadFileOperation.remotePath, + context ) ) { context.showToast(R.string.file_upload_worker_same_file_already_exists) diff --git a/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java b/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java index 3bfb6afc39..0801d91027 100644 --- a/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java +++ b/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java @@ -329,7 +329,7 @@ public final class AppPreferencesImpl implements AppPreferences { userAccountManager.getUser(), PREF__FOLDER_SORT_ORDER, folder, - FileSortOrder.sort_a_to_z.name)); + FileSortOrder.SORT_A_TO_Z.name)); } @Override @@ -343,7 +343,7 @@ public final class AppPreferencesImpl implements AppPreferences { @Override public FileSortOrder getSortOrderByType(FileSortOrder.Type type) { - return getSortOrderByType(type, FileSortOrder.sort_a_to_z); + return getSortOrderByType(type, FileSortOrder.SORT_A_TO_Z); } @Override diff --git a/app/src/main/java/com/nextcloud/client/preferences/SubFolderRule.kt b/app/src/main/java/com/nextcloud/client/preferences/SubFolderRule.kt index c4c7ed0227..85412031e7 100644 --- a/app/src/main/java/com/nextcloud/client/preferences/SubFolderRule.kt +++ b/app/src/main/java/com/nextcloud/client/preferences/SubFolderRule.kt @@ -11,5 +11,7 @@ package com.nextcloud.client.preferences enum class SubFolderRule { - YEAR_MONTH, YEAR, YEAR_MONTH_DAY + YEAR_MONTH, + YEAR, + YEAR_MONTH_DAY } diff --git a/app/src/main/java/com/nextcloud/client/utils/IntentUtil.kt b/app/src/main/java/com/nextcloud/client/utils/IntentUtil.kt index a537da6f5f..1f3dfa2f21 100644 --- a/app/src/main/java/com/nextcloud/client/utils/IntentUtil.kt +++ b/app/src/main/java/com/nextcloud/client/utils/IntentUtil.kt @@ -15,25 +15,22 @@ import com.owncloud.android.datamodel.OCFile object IntentUtil { @JvmStatic - public fun createSendIntent(context: Context, file: OCFile): Intent = - createBaseSendFileIntent().apply { - action = Intent.ACTION_SEND - type = file.mimeType - putExtra(Intent.EXTRA_STREAM, file.getExposedFileUri(context)) - } + public fun createSendIntent(context: Context, file: OCFile): Intent = createBaseSendFileIntent().apply { + action = Intent.ACTION_SEND + type = file.mimeType + putExtra(Intent.EXTRA_STREAM, file.getExposedFileUri(context)) + } @JvmStatic - public fun createSendIntent(context: Context, files: Array): Intent = - createBaseSendFileIntent().apply { - action = Intent.ACTION_SEND_MULTIPLE - type = getUniqueMimetype(files) - putParcelableArrayListExtra(Intent.EXTRA_STREAM, getExposedFileUris(context, files)) - } + public fun createSendIntent(context: Context, files: Array): Intent = createBaseSendFileIntent().apply { + action = Intent.ACTION_SEND_MULTIPLE + type = getUniqueMimetype(files) + putParcelableArrayListExtra(Intent.EXTRA_STREAM, getExposedFileUris(context, files)) + } - private fun createBaseSendFileIntent(): Intent = - Intent().apply { - addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) - } + private fun createBaseSendFileIntent(): Intent = Intent().apply { + addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + } private fun getUniqueMimetype(files: Array): String? = when { files.distinctBy { it.mimeType }.size > 1 -> "*/*" diff --git a/app/src/main/java/com/nextcloud/ui/ChooseAccountDialogFragment.kt b/app/src/main/java/com/nextcloud/ui/ChooseAccountDialogFragment.kt index d7d5d4de41..27e3fc4276 100644 --- a/app/src/main/java/com/nextcloud/ui/ChooseAccountDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/ui/ChooseAccountDialogFragment.kt @@ -6,7 +6,6 @@ * * SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only */ - package com.nextcloud.ui import android.annotation.SuppressLint @@ -55,7 +54,7 @@ class ChooseAccountDialogFragment : private var currentStatus: Status? = null private var _binding: DialogChooseAccountBinding? = null - private val binding get() = _binding!! + val binding get() = _binding!! @Inject lateinit var clientFactory: ClientFactory @@ -187,12 +186,11 @@ class ChooseAccountDialogFragment : */ companion object { @JvmStatic - fun newInstance(user: User) = - ChooseAccountDialogFragment().apply { - arguments = Bundle().apply { - putParcelable(ARG_CURRENT_USER_PARAM, user) - } + fun newInstance(user: User) = ChooseAccountDialogFragment().apply { + arguments = Bundle().apply { + putParcelable(ARG_CURRENT_USER_PARAM, user) } + } } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { diff --git a/app/src/main/java/com/nextcloud/ui/ImageDetailFragment.kt b/app/src/main/java/com/nextcloud/ui/ImageDetailFragment.kt index 473bf19428..8fc7af18de 100644 --- a/app/src/main/java/com/nextcloud/ui/ImageDetailFragment.kt +++ b/app/src/main/java/com/nextcloud/ui/ImageDetailFragment.kt @@ -93,7 +93,8 @@ class ImageDetailFragment : Fragment(), Injectable { } nominatimClient = NominatimClient( - getString(R.string.osm_geocoder_url), getString(R.string.osm_geocoder_contact) + getString(R.string.osm_geocoder_url), + getString(R.string.osm_geocoder_contact) ) return binding.root diff --git a/app/src/main/java/com/nextcloud/ui/composeComponents/bottomSheet/MoreActionsBottomSheet.kt b/app/src/main/java/com/nextcloud/ui/composeComponents/bottomSheet/MoreActionsBottomSheet.kt index 408f6c6d33..16131db380 100644 --- a/app/src/main/java/com/nextcloud/ui/composeComponents/bottomSheet/MoreActionsBottomSheet.kt +++ b/app/src/main/java/com/nextcloud/ui/composeComponents/bottomSheet/MoreActionsBottomSheet.kt @@ -37,11 +37,7 @@ import kotlinx.coroutines.launch @SuppressLint("ResourceAsColor") @OptIn(ExperimentalMaterial3Api::class) @Composable -fun MoreActionsBottomSheet( - title: String? = null, - actions: List Unit>>, - dismiss: () -> Unit -) { +fun MoreActionsBottomSheet(title: String? = null, actions: List Unit>>, dismiss: () -> Unit) { val sheetState = rememberModalBottomSheetState() val scope = rememberCoroutineScope() diff --git a/app/src/main/java/com/nextcloud/ui/fileactions/FileActionsBottomSheet.kt b/app/src/main/java/com/nextcloud/ui/fileactions/FileActionsBottomSheet.kt index dc1bfbb23a..1269459f2a 100644 --- a/app/src/main/java/com/nextcloud/ui/fileactions/FileActionsBottomSheet.kt +++ b/app/src/main/java/com/nextcloud/ui/fileactions/FileActionsBottomSheet.kt @@ -67,7 +67,7 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable { private lateinit var viewModel: FileActionsViewModel private var _binding: FileActionsBottomSheetBinding? = null - private val binding + val binding get() = _binding!! private lateinit var componentsGetter: ComponentsGetter @@ -99,9 +99,7 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable { return binding.root } - private fun handleState( - state: FileActionsViewModel.UiState - ) { + private fun handleState(state: FileActionsViewModel.UiState) { toggleLoadingOrContent(state) when (state) { is FileActionsViewModel.UiState.LoadedForSingleFile -> { @@ -192,9 +190,7 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable { } } - private fun displayActions( - actions: List - ) { + private fun displayActions(actions: List) { if (binding.fileActionsList.isEmpty()) { actions.forEach { action -> val view = inflateActionView(action) diff --git a/app/src/main/java/com/nextcloud/ui/fileactions/FileActionsViewModel.kt b/app/src/main/java/com/nextcloud/ui/fileactions/FileActionsViewModel.kt index f66d028e15..e45a61fbf2 100644 --- a/app/src/main/java/com/nextcloud/ui/fileactions/FileActionsViewModel.kt +++ b/app/src/main/java/com/nextcloud/ui/fileactions/FileActionsViewModel.kt @@ -54,10 +54,7 @@ class FileActionsViewModel @Inject constructor( @IdRes get() = _clickActionId - fun load( - arguments: Bundle, - componentsGetter: ComponentsGetter - ) { + fun load(arguments: Bundle, componentsGetter: ComponentsGetter) { val files: List? = arguments.getParcelableArrayList(ARG_FILES) val numberOfAllFiles: Int = arguments.getInt(ARG_ALL_FILES_COUNT, 1) val isOverflow = arguments.getBoolean(ARG_IS_OVERFLOW, false) @@ -104,17 +101,11 @@ class FileActionsViewModel @Inject constructor( .getToHide(inSingleFileFragment) } - private fun getActionsToShow( - additionalFilter: IntArray?, - toHide: List - ) = FileAction.SORTED_VALUES + private fun getActionsToShow(additionalFilter: IntArray?, toHide: List) = FileAction.SORTED_VALUES .filter { additionalFilter == null || it.id !in additionalFilter } .filter { it.id !in toHide } - private fun updateStateLoaded( - files: Collection, - availableActions: List - ) { + private fun updateStateLoaded(files: Collection, availableActions: List) { val state: UiState = when (files.size) { 1 -> { val file = files.first() diff --git a/app/src/main/java/com/nextcloud/utils/extensions/BundleExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/BundleExtensions.kt index 228a76df1c..5b341c76b3 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/BundleExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/BundleExtensions.kt @@ -14,7 +14,7 @@ import com.owncloud.android.lib.common.utils.Log_OC import java.io.Serializable @Suppress("TopLevelPropertyNaming") -private const val tag = "BundleExtension" +private const val TAG = "BundleExtension" fun Bundle?.getSerializableArgument(key: String, type: Class): T? { if (this == null) { @@ -33,7 +33,7 @@ fun Bundle?.getSerializableArgument(key: String, type: Class } } } catch (e: ClassCastException) { - Log_OC.e(tag, e.localizedMessage) + Log_OC.e(TAG, e.localizedMessage) null } } @@ -51,7 +51,7 @@ fun Bundle?.getParcelableArgument(key: String, type: Class) this.getParcelable(key) } } catch (e: ClassCastException) { - Log_OC.e(tag, e.localizedMessage) + Log_OC.e(TAG, e.localizedMessage) e.printStackTrace() null } diff --git a/app/src/main/java/com/nextcloud/utils/extensions/IntentExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/IntentExtensions.kt index b286d65295..9a41e870b9 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/IntentExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/IntentExtensions.kt @@ -14,7 +14,7 @@ import com.owncloud.android.lib.common.utils.Log_OC import java.io.Serializable @Suppress("TopLevelPropertyNaming") -private const val tag = "IntentExtension" +private const val TAG = "IntentExtension" fun Intent?.getSerializableArgument(key: String, type: Class): T? { if (this == null) { @@ -33,7 +33,7 @@ fun Intent?.getSerializableArgument(key: String, type: Class } } } catch (e: ClassCastException) { - Log_OC.e(tag, e.localizedMessage) + Log_OC.e(TAG, e.localizedMessage) null } } @@ -51,7 +51,7 @@ fun Intent?.getParcelableArgument(key: String, type: Class) this.getParcelableExtra(key) } } catch (e: ClassCastException) { - Log_OC.e(tag, e.localizedMessage) + Log_OC.e(TAG, e.localizedMessage) null } } diff --git a/app/src/main/java/com/nextcloud/utils/extensions/OnDataTransferProgressListenerExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/OnDataTransferProgressListenerExtensions.kt index e0ab2cbc0b..f6fed6fb4f 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/OnDataTransferProgressListenerExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/OnDataTransferProgressListenerExtensions.kt @@ -10,7 +10,5 @@ package com.nextcloud.utils.extensions import com.owncloud.android.lib.common.network.OnDatatransferProgressListener @Suppress("MagicNumber") -fun OnDatatransferProgressListener.getPercent( - totalTransferredSoFar: Long, - totalToTransfer: Long -): Int = ((100.0 * totalTransferredSoFar.toDouble() / totalToTransfer.toDouble()).toInt()).coerceAtMost(100) +fun OnDatatransferProgressListener.getPercent(totalTransferredSoFar: Long, totalToTransfer: Long): Int = + ((100.0 * totalTransferredSoFar.toDouble() / totalToTransfer.toDouble()).toInt()).coerceAtMost(100) diff --git a/app/src/main/java/com/nextcloud/utils/view/FastScrollUtils.kt b/app/src/main/java/com/nextcloud/utils/view/FastScrollUtils.kt index d9ee026707..807d4b3de7 100644 --- a/app/src/main/java/com/nextcloud/utils/view/FastScrollUtils.kt +++ b/app/src/main/java/com/nextcloud/utils/view/FastScrollUtils.kt @@ -17,10 +17,7 @@ import javax.inject.Inject class FastScrollUtils @Inject constructor(private val viewThemeUtils: ViewThemeUtils) { @JvmOverloads - fun applyFastScroll( - recyclerView: RecyclerView, - viewHelper: FastScroller.ViewHelper? = null - ) { + fun applyFastScroll(recyclerView: RecyclerView, viewHelper: FastScroller.ViewHelper? = null) { val builder = FastScrollerBuilder(recyclerView).let { viewThemeUtils.files.themeFastScrollerBuilder( diff --git a/app/src/main/java/com/owncloud/android/authentication/DeepLinkLoginActivity.kt b/app/src/main/java/com/owncloud/android/authentication/DeepLinkLoginActivity.kt index 141b64fafb..25283adcbc 100644 --- a/app/src/main/java/com/owncloud/android/authentication/DeepLinkLoginActivity.kt +++ b/app/src/main/java/com/owncloud/android/authentication/DeepLinkLoginActivity.kt @@ -33,7 +33,8 @@ class DeepLinkLoginActivity : AuthenticatorActivity(), Injectable { val loginUrlInfo = parseLoginDataUrl(prefix, it.toString()) val loginText = findViewById(R.id.loginInfo) loginText.text = String.format( - getString(R.string.direct_login_text), loginUrlInfo.username, + getString(R.string.direct_login_text), + loginUrlInfo.username, loginUrlInfo.serverAddress ) } catch (e: IllegalArgumentException) { diff --git a/app/src/main/java/com/owncloud/android/datamodel/ForegroundServiceType.kt b/app/src/main/java/com/owncloud/android/datamodel/ForegroundServiceType.kt index 9da4705f62..e5f3926ef6 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/ForegroundServiceType.kt +++ b/app/src/main/java/com/owncloud/android/datamodel/ForegroundServiceType.kt @@ -18,7 +18,8 @@ import androidx.annotation.RequiresApi * This wrapper is designed for compatibility on those versions. */ enum class ForegroundServiceType { - DataSync, MediaPlayback; + DataSync, + MediaPlayback; @RequiresApi(Build.VERSION_CODES.Q) fun getId(): Int { diff --git a/app/src/main/java/com/owncloud/android/datamodel/MediaFolderType.kt b/app/src/main/java/com/owncloud/android/datamodel/MediaFolderType.kt index c2326c76fe..8b6639f4a6 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/MediaFolderType.kt +++ b/app/src/main/java/com/owncloud/android/datamodel/MediaFolderType.kt @@ -12,7 +12,9 @@ import android.util.SparseArray * Types of media folder. */ enum class MediaFolderType(@JvmField val id: Int) { - CUSTOM(0), IMAGE(1), VIDEO(2); + CUSTOM(0), + IMAGE(1), + VIDEO(2); companion object { private val reverseMap = SparseArray(3) diff --git a/app/src/main/java/com/owncloud/android/datamodel/Template.kt b/app/src/main/java/com/owncloud/android/datamodel/Template.kt index 08d5e4f32c..a393525746 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/Template.kt +++ b/app/src/main/java/com/owncloud/android/datamodel/Template.kt @@ -22,7 +22,10 @@ data class Template( val extension: String ) : Parcelable { enum class Type { - DOCUMENT, SPREADSHEET, PRESENTATION, UNKNOWN; + DOCUMENT, + SPREADSHEET, + PRESENTATION, + UNKNOWN; companion object { @JvmStatic diff --git a/app/src/main/java/com/owncloud/android/media/MediaControlView.kt b/app/src/main/java/com/owncloud/android/media/MediaControlView.kt index 1335d289ac..25747c3f1b 100644 --- a/app/src/main/java/com/owncloud/android/media/MediaControlView.kt +++ b/app/src/main/java/com/owncloud/android/media/MediaControlView.kt @@ -227,10 +227,20 @@ class MediaControlView(context: Context, attrs: AttributeSet?) : context, if (playerControl?.isPlaying == true) { R.drawable.ic_pause - } else { R.drawable.ic_play } + } else { + R.drawable.ic_play + } ) - binding.forwardBtn.visibility = if (playerControl?.canSeekForward() == true) { VISIBLE } else { INVISIBLE } - binding.rewindBtn.visibility = if (playerControl?.canSeekBackward() == true) { VISIBLE } else { INVISIBLE } + binding.forwardBtn.visibility = if (playerControl?.canSeekForward() == true) { + VISIBLE + } else { + INVISIBLE + } + binding.rewindBtn.visibility = if (playerControl?.canSeekBackward() == true) { + VISIBLE + } else { + INVISIBLE + } } private fun doPauseResume() { diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt index f3a71e7a21..7b8710d4f1 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt @@ -254,13 +254,7 @@ class ConflictsResolveActivity : FileActivity(), OnConflictDecisionMadeListener private val TAG = ConflictsResolveActivity::class.java.simpleName @JvmStatic - fun createIntent( - file: OCFile?, - user: User?, - conflictUploadId: Long, - flag: Int?, - context: Context? - ): Intent { + fun createIntent(file: OCFile?, user: User?, conflictUploadId: Long, flag: Int?, context: Context?): Intent { val intent = Intent(context, ConflictsResolveActivity::class.java) if (flag != null) { intent.flags = intent.flags or flag diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt index f8fbc5c1ef..ed9574f1fb 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt @@ -475,10 +475,7 @@ open class FolderPickerActivity : * @param operation Creation operation performed. * @param result Result of the creation. */ - private fun onCreateFolderOperationFinish( - operation: CreateFolderOperation, - result: RemoteOperationResult<*> - ) { + private fun onCreateFolderOperationFinish(operation: CreateFolderOperation, result: RemoteOperationResult<*>) { if (result.isSuccess) { val fileListFragment = listOfFilesFragment fileListFragment?.onItemClicked(storageManager.getFileByPath(operation.remotePath)) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt index 471390356e..671efe8492 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt @@ -343,11 +343,7 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View { } } - override fun onActionCallback( - isSuccess: Boolean, - notification: Notification, - holder: NotificationViewHolder - ) { + override fun onActionCallback(isSuccess: Boolean, notification: Notification, holder: NotificationViewHolder) { if (isSuccess) { adapter?.removeNotification(holder) } else { diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt index ed301b3075..53758c329d 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt @@ -801,11 +801,7 @@ class SyncedFoldersActivity : item.setExcludeHidden(excludeHidden) } - override fun onRequestPermissionsResult( - requestCode: Int, - permissions: Array, - grantResults: IntArray - ) { + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { when (requestCode) { PermissionUtil.PERMISSIONS_EXTERNAL_STORAGE -> { // If request is cancelled, result arrays are empty. diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/TrashbinListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/TrashbinListAdapter.java index c8a12dae3d..8d3ebfecd9 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/TrashbinListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/TrashbinListAdapter.java @@ -83,7 +83,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalDialog.kt b/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalDialog.kt index c27f5282dd..e42f1b7c62 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalDialog.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalDialog.kt @@ -40,7 +40,7 @@ class AccountRemovalDialog : DialogFragment(), AvatarGenerationListener, Injecta private var user: User? = null private lateinit var alertDialog: AlertDialog private var _binding: AccountRemovalDialogBinding? = null - private val binding get() = _binding!! + val binding get() = _binding!! override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.kt index 8f3bfeab0c..9f461f7aa0 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.kt @@ -80,11 +80,13 @@ class ChooseTemplateDialogFragment : DialogFragment(), View.OnClickListener, Tem private var creator: Creator? = null enum class Type { - DOCUMENT, SPREADSHEET, PRESENTATION + DOCUMENT, + SPREADSHEET, + PRESENTATION } private var _binding: ChooseTemplateBinding? = null - private val binding get() = _binding!! + val binding get() = _binding!! override fun onStart() { super.onStart() diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/SendFilesDialog.kt b/app/src/main/java/com/owncloud/android/ui/dialog/SendFilesDialog.kt index cc407ce2a6..4f851b3d99 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/SendFilesDialog.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/SendFilesDialog.kt @@ -52,11 +52,7 @@ class SendFilesDialog : BottomSheetDialogFragment(R.layout.send_files_fragment), } } - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { binding = SendFilesFragmentBinding.inflate(inflater, container, false) setupSendButtonRecyclerView() @@ -102,7 +98,8 @@ class SendFilesDialog : BottomSheetDialogFragment(R.layout.send_files_fragment), icon = match.loadIcon(requireActivity().packageManager) label = match.loadLabel(requireActivity().packageManager) sendButtonData = SendButtonData( - icon, label, + icon, + label, match.activityInfo.packageName, match.activityInfo.name ) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/SendShareDialog.kt b/app/src/main/java/com/owncloud/android/ui/dialog/SendShareDialog.kt index 90d60838be..3a569c0d4b 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/SendShareDialog.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/SendShareDialog.kt @@ -200,7 +200,8 @@ class SendShareDialog : BottomSheetDialogFragment(R.layout.send_share_fragment), icon = match.loadIcon(requireActivity().packageManager) label = match.loadLabel(requireActivity().packageManager) sendButtonData = SendButtonData( - icon, label, + icon, + label, match.activityInfo.packageName, match.activityInfo.name ) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/SortingOrderDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/SortingOrderDialogFragment.kt index d702fb97ca..8a593cabf5 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/SortingOrderDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/SortingOrderDialogFragment.kt @@ -41,7 +41,7 @@ class SortingOrderDialogFragment : DialogFragment(), Injectable { retainInstance = true binding = null - currentSortOrderName = requireArguments().getString(KEY_SORT_ORDER, FileSortOrder.sort_a_to_z.name) + currentSortOrderName = requireArguments().getString(KEY_SORT_ORDER, FileSortOrder.SORT_A_TO_Z.name) } /** @@ -51,12 +51,12 @@ class SortingOrderDialogFragment : DialogFragment(), Injectable { */ private fun setupDialogElements(binding: SortingOrderFragmentBinding) { val bindings = listOf( - binding.sortByNameAscending to FileSortOrder.sort_a_to_z, - binding.sortByNameDescending to FileSortOrder.sort_z_to_a, - binding.sortByModificationDateAscending to FileSortOrder.sort_old_to_new, - binding.sortByModificationDateDescending to FileSortOrder.sort_new_to_old, - binding.sortBySizeAscending to FileSortOrder.sort_small_to_big, - binding.sortBySizeDescending to FileSortOrder.sort_big_to_small + binding.sortByNameAscending to FileSortOrder.SORT_A_TO_Z, + binding.sortByNameDescending to FileSortOrder.SORT_Z_TO_A, + binding.sortByModificationDateAscending to FileSortOrder.SORT_OLD_TO_NEW, + binding.sortByModificationDateDescending to FileSortOrder.SORT_NEW_TO_OLD, + binding.sortBySizeAscending to FileSortOrder.SORT_SMALL_TO_BIG, + binding.sortBySizeDescending to FileSortOrder.SORT_BIG_TO_SMALL ) bindings.forEach { (view, sortOrder) -> diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/StoragePermissionDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/StoragePermissionDialogFragment.kt index 0d2984c163..337ee99b41 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/StoragePermissionDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/StoragePermissionDialogFragment.kt @@ -97,7 +97,9 @@ class StoragePermissionDialogFragment : DialogFragment(), Injectable { @Parcelize enum class Result : Parcelable { - CANCEL, FULL_ACCESS, MEDIA_READ_ONLY + CANCEL, + FULL_ACCESS, + MEDIA_READ_ONLY } companion object { diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.kt index f57c7b61c5..aba0d565d8 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.kt @@ -274,17 +274,17 @@ class SyncedFolderPreferencesDialogFragment : DialogFragment(), Injectable { private fun checkWritableFolder() { if (!syncedFolder!!.isEnabled) { binding?.settingInstantBehaviourContainer?.isEnabled = false - binding?.settingInstantBehaviourContainer?.alpha = alphaDisabled + binding?.settingInstantBehaviourContainer?.alpha = ALPHA_DISABLED return } if (syncedFolder!!.localPath != null && File(syncedFolder!!.localPath).canWrite()) { binding?.settingInstantBehaviourContainer?.isEnabled = true - binding?.settingInstantBehaviourContainer?.alpha = alphaEnabled + binding?.settingInstantBehaviourContainer?.alpha = ALPHA_ENABLED binding?.settingInstantBehaviourSummary?.text = uploadBehaviorItemStrings[syncedFolder!!.uploadActionInteger] } else { binding?.settingInstantBehaviourContainer?.isEnabled = false - binding?.settingInstantBehaviourContainer?.alpha = alphaDisabled + binding?.settingInstantBehaviourContainer?.alpha = ALPHA_DISABLED syncedFolder?.setUploadAction( resources.getTextArray(R.array.pref_behaviour_entryValues)[0].toString() ) @@ -294,9 +294,9 @@ class SyncedFolderPreferencesDialogFragment : DialogFragment(), Injectable { private fun setupViews(optionalBinding: SyncedFoldersSettingsLayoutBinding?, enable: Boolean) { val alpha: Float = if (enable) { - alphaEnabled + ALPHA_ENABLED } else { - alphaDisabled + ALPHA_DISABLED } optionalBinding?.let { binding -> @@ -518,8 +518,8 @@ class SyncedFolderPreferencesDialogFragment : DialogFragment(), Injectable { private val TAG = SyncedFolderPreferencesDialogFragment::class.java.simpleName private const val BEHAVIOUR_DIALOG_STATE = "BEHAVIOUR_DIALOG_STATE" private const val NAME_COLLISION_POLICY_DIALOG_STATE = "NAME_COLLISION_POLICY_DIALOG_STATE" - private const val alphaEnabled = 1.0f - private const val alphaDisabled = 0.7f + private const val ALPHA_ENABLED = 1.0f + private const val ALPHA_DISABLED = 0.7f @JvmStatic fun newInstance(syncedFolder: SyncedFolderDisplayItem?, section: Int): SyncedFolderPreferencesDialogFragment? { diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt index 119d4e68be..fc806d4ab8 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt @@ -91,8 +91,12 @@ class FileDetailsSharingProcessFragment : * fragment instance to be called while modifying existing share information */ @JvmStatic - fun newInstance(share: OCShare, screenType: Int, isReshareShown: Boolean, isExpirationDateShown: Boolean): - FileDetailsSharingProcessFragment { + fun newInstance( + share: OCShare, + screenType: Int, + isReshareShown: Boolean, + isExpirationDateShown: Boolean + ): FileDetailsSharingProcessFragment { val args = Bundle() args.putParcelable(ARG_OCSHARE, share) args.putInt(ARG_SCREEN_TYPE, screenType) diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/ProfileBottomSheetDialog.kt b/app/src/main/java/com/owncloud/android/ui/fragment/ProfileBottomSheetDialog.kt index 6ead47ba2a..292818ec3d 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/ProfileBottomSheetDialog.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/ProfileBottomSheetDialog.kt @@ -40,7 +40,7 @@ class ProfileBottomSheetDialog( private var _binding: ProfileBottomSheetFragmentBinding? = null // This property is only valid between onCreateView and onDestroyView. - private val binding get() = _binding!! + val binding get() = _binding!! override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt b/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt index adfb06b305..234e49995f 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt @@ -59,7 +59,7 @@ class UnifiedSearchFragment : UnifiedSearchItemViewHolder.FilesAction { private lateinit var adapter: UnifiedSearchListAdapter private var _binding: ListFragmentBinding? = null - private val binding get() = _binding!! + val binding get() = _binding!! private var searchView: SearchView? = null lateinit var vm: IUnifiedSearchViewModel diff --git a/app/src/main/java/com/owncloud/android/ui/helpers/UriUploader.kt b/app/src/main/java/com/owncloud/android/ui/helpers/UriUploader.kt index 6429d625bd..3db05a6805 100644 --- a/app/src/main/java/com/owncloud/android/ui/helpers/UriUploader.kt +++ b/app/src/main/java/com/owncloud/android/ui/helpers/UriUploader.kt @@ -53,7 +53,11 @@ class UriUploader( ) { enum class UriUploaderResultCode { - OK, ERROR_UNKNOWN, ERROR_NO_FILE_TO_UPLOAD, ERROR_READ_PERMISSION_NOT_GRANTED, ERROR_SENSITIVE_PATH + OK, + ERROR_UNKNOWN, + ERROR_NO_FILE_TO_UPLOAD, + ERROR_READ_PERMISSION_NOT_GRANTED, + ERROR_SENSITIVE_PATH } fun uploadUris(): UriUploaderResultCode { @@ -121,11 +125,12 @@ class UriUploader( arrayOf(localPath ?: ""), arrayOf(remotePath), mBehaviour, - false, // do not create parent folder if not existent + // do not create parent folder if not existent + false, UploadFileOperation.CREATED_BY_USER, - false, - false, - NameCollisionPolicy.ASK_USER + requiresWifi = false, + requiresCharging = false, + nameCollisionPolicy = NameCollisionPolicy.ASK_USER ) } diff --git a/app/src/main/java/com/owncloud/android/ui/preview/pdf/PreviewPdfFragment.kt b/app/src/main/java/com/owncloud/android/ui/preview/pdf/PreviewPdfFragment.kt index 3fd5f9be87..b8ac22d08e 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/pdf/PreviewPdfFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/pdf/PreviewPdfFragment.kt @@ -86,7 +86,7 @@ class PreviewPdfFragment : Fragment(), Injectable { requireContext().startActivity(intent) } } - viewModel.shouldShowZoomTip.observe(viewLifecycleOwner) { shouldShow -> + viewModel.showZoomTip.observe(viewLifecycleOwner) { shouldShow -> if (shouldShow) { snack = DisplayUtils.showSnackMessage(binding.root, R.string.pdf_zoom_tip) viewModel.onZoomTipShown() @@ -100,8 +100,7 @@ class PreviewPdfFragment : Fragment(), Injectable { setHasOptionsMenu(true) } - private fun getScreenWidth(): Int = - requireContext().resources.displayMetrics.widthPixels + private fun getScreenWidth(): Int = requireContext().resources.displayMetrics.widthPixels override fun onPrepareOptionsMenu(menu: Menu) { super.onPrepareOptionsMenu(menu) diff --git a/app/src/main/java/com/owncloud/android/ui/preview/pdf/PreviewPdfViewModel.kt b/app/src/main/java/com/owncloud/android/ui/preview/pdf/PreviewPdfViewModel.kt index 78ca628193..2280016c7f 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/pdf/PreviewPdfViewModel.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/pdf/PreviewPdfViewModel.kt @@ -36,7 +36,7 @@ class PreviewPdfViewModel @Inject constructor(val appPreferences: AppPreferences get() = _previewImagePath private var _showZoomTip = MutableLiveData() - val shouldShowZoomTip: LiveData + val showZoomTip: LiveData get() = _showZoomTip override fun onCleared() { diff --git a/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.kt b/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.kt index 1e25961b04..fefa493ef3 100644 --- a/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.kt @@ -159,7 +159,7 @@ class TrashbinActivity : supportFragmentManager, preferences?.getSortOrderByType( FileSortOrder.Type.trashBinView, - FileSortOrder.sort_new_to_old + FileSortOrder.SORT_NEW_TO_OLD ) ) } @@ -247,10 +247,10 @@ class TrashbinActivity : onBackPressedCallback.isEnabled = !isRoot } - override fun onSortingOrderChosen(sortOrder: FileSortOrder?) { + override fun onSortingOrderChosen(selection: FileSortOrder?) { val sortButton = findViewById(R.id.sort_button) - sortButton.setText(DisplayUtils.getSortOrderStringId(sortOrder)) - trashbinListAdapter?.setSortOrder(sortOrder) + sortButton.setText(DisplayUtils.getSortOrderStringId(selection)) + trashbinListAdapter?.setSortOrder(selection) } override fun showTrashbinFolder(trashbinFiles: List?) { diff --git a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java index 66892aa05e..6a8d207ae8 100644 --- a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -110,12 +110,12 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import static com.owncloud.android.ui.dialog.SortingOrderDialogFragment.SORTING_ORDER_FRAGMENT; -import static com.owncloud.android.utils.FileSortOrder.sort_a_to_z_id; -import static com.owncloud.android.utils.FileSortOrder.sort_big_to_small_id; -import static com.owncloud.android.utils.FileSortOrder.sort_new_to_old_id; -import static com.owncloud.android.utils.FileSortOrder.sort_old_to_new_id; -import static com.owncloud.android.utils.FileSortOrder.sort_small_to_big_id; -import static com.owncloud.android.utils.FileSortOrder.sort_z_to_a_id; +import static com.owncloud.android.utils.FileSortOrder.SORT_A_TO_Z_ID; +import static com.owncloud.android.utils.FileSortOrder.SORT_BIG_TO_SMALL_ID; +import static com.owncloud.android.utils.FileSortOrder.SORT_NEW_TO_OLD_ID; +import static com.owncloud.android.utils.FileSortOrder.SORT_OLD_TO_NEW_ID; +import static com.owncloud.android.utils.FileSortOrder.SORT_SMALL_TO_BIG_ID; +import static com.owncloud.android.utils.FileSortOrder.SORT_Z_TO_A_ID; /** * A helper class for UI/display related operations. @@ -819,17 +819,17 @@ public final class DisplayUtils { public static @StringRes int getSortOrderStringId(FileSortOrder sortOrder) { switch (sortOrder.name) { - case sort_z_to_a_id: + case SORT_Z_TO_A_ID: return R.string.menu_item_sort_by_name_z_a; - case sort_new_to_old_id: + case SORT_NEW_TO_OLD_ID: return R.string.menu_item_sort_by_date_newest_first; - case sort_old_to_new_id: + case SORT_OLD_TO_NEW_ID: return R.string.menu_item_sort_by_date_oldest_first; - case sort_big_to_small_id: + case SORT_BIG_TO_SMALL_ID: return R.string.menu_item_sort_by_size_biggest_first; - case sort_small_to_big_id: + case SORT_SMALL_TO_BIG_ID: return R.string.menu_item_sort_by_size_smallest_first; - case sort_a_to_z_id: + case SORT_A_TO_Z_ID: default: return R.string.menu_item_sort_by_name_a_z; } diff --git a/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt b/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt index 9adf94e4eb..042f4251fa 100644 --- a/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt +++ b/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt @@ -196,7 +196,8 @@ class EncryptionUtilsV2 { DecryptedFolderMetadataFile( decryptedMetadata, - mutableListOf(), // subfolder do not store user array + // subfolder do not store user array + mutableListOf(), mutableMapOf() ) } else { @@ -530,20 +531,13 @@ class EncryptionUtilsV2 { } @Throws(IllegalStateException::class) - fun removeFileFromMetadata( - fileName: String, - metadata: DecryptedFolderMetadataFile - ) { + fun removeFileFromMetadata(fileName: String, metadata: DecryptedFolderMetadataFile) { metadata.metadata.files.remove(fileName) ?: throw IllegalStateException("File $fileName not found in metadata!") } @Throws(IllegalStateException::class) - fun renameFile( - key: String, - newName: String, - metadataFile: DecryptedFolderMetadataFile - ) { + fun renameFile(key: String, newName: String, metadataFile: DecryptedFolderMetadataFile) { if (!metadataFile.metadata.files.containsKey(key)) { throw IllegalStateException("File with key $key not found in metadata!") } @@ -956,7 +950,8 @@ class EncryptionUtilsV2 { encryptedFolderMetadataFile: EncryptedFolderMetadataFile, decryptedFolderMetadataFile: DecryptedFolderMetadataFile, oldCounter: Long, - ans: String // base 64 encoded BER + // base 64 encoded BER + ans: String ) { // check counter if (decryptedFolderMetadataFile.metadata.counter < oldCounter) { diff --git a/app/src/main/java/com/owncloud/android/utils/FileExportUtils.kt b/app/src/main/java/com/owncloud/android/utils/FileExportUtils.kt index 54404fce9e..b13936b946 100644 --- a/app/src/main/java/com/owncloud/android/utils/FileExportUtils.kt +++ b/app/src/main/java/com/owncloud/android/utils/FileExportUtils.kt @@ -25,13 +25,7 @@ import java.io.InputStream class FileExportUtils { @Throws(IllegalStateException::class) - fun exportFile( - fileName: String, - mimeType: String, - contentResolver: ContentResolver, - ocFile: OCFile?, - file: File? - ) { + fun exportFile(fileName: String, mimeType: String, contentResolver: ContentResolver, ocFile: OCFile?, file: File?) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { exportFileAndroid10AndAbove( fileName, diff --git a/app/src/main/java/com/owncloud/android/utils/FileSortOrder.kt b/app/src/main/java/com/owncloud/android/utils/FileSortOrder.kt index c6e0f9e483..a62aeec668 100644 --- a/app/src/main/java/com/owncloud/android/utils/FileSortOrder.kt +++ b/app/src/main/java/com/owncloud/android/utils/FileSortOrder.kt @@ -29,44 +29,46 @@ open class FileSortOrder(@JvmField var name: String, var isAscending: Boolean) { } enum class SortType { - SIZE, ALPHABET, DATE + SIZE, + ALPHABET, + DATE } companion object { - const val sort_a_to_z_id = "sort_a_to_z" - const val sort_z_to_a_id = "sort_z_to_a" - const val sort_old_to_new_id = "sort_old_to_new" - const val sort_new_to_old_id = "sort_new_to_old" - const val sort_small_to_big_id = "sort_small_to_big" - const val sort_big_to_small_id = "sort_big_to_small" + const val SORT_A_TO_Z_ID = "sort_a_to_z" + const val SORT_Z_TO_A_ID = "sort_z_to_a" + const val SORT_OLD_TO_NEW_ID = "sort_old_to_new" + const val SORT_NEW_TO_OLD_ID = "sort_new_to_old" + const val SORT_SMALL_TO_BIG_ID = "sort_small_to_big" + const val SORT_BIG_TO_SMALL_ID = "sort_big_to_small" @JvmField - val sort_a_to_z: FileSortOrder = FileSortOrderByName(sort_a_to_z_id, true) + val SORT_A_TO_Z: FileSortOrder = FileSortOrderByName(SORT_A_TO_Z_ID, true) @JvmField - val sort_z_to_a: FileSortOrder = FileSortOrderByName(sort_z_to_a_id, false) + val SORT_Z_TO_A: FileSortOrder = FileSortOrderByName(SORT_Z_TO_A_ID, false) @JvmField - val sort_old_to_new: FileSortOrder = FileSortOrderByDate(sort_old_to_new_id, true) + val SORT_OLD_TO_NEW: FileSortOrder = FileSortOrderByDate(SORT_OLD_TO_NEW_ID, true) @JvmField - val sort_new_to_old: FileSortOrder = FileSortOrderByDate(sort_new_to_old_id, false) + val SORT_NEW_TO_OLD: FileSortOrder = FileSortOrderByDate(SORT_NEW_TO_OLD_ID, false) @JvmField - val sort_small_to_big: FileSortOrder = FileSortOrderBySize(sort_small_to_big_id, true) + val SORT_SMALL_TO_BIG: FileSortOrder = FileSortOrderBySize(SORT_SMALL_TO_BIG_ID, true) @JvmField - val sort_big_to_small: FileSortOrder = FileSortOrderBySize(sort_big_to_small_id, false) + val SORT_BIG_TO_SMALL: FileSortOrder = FileSortOrderBySize(SORT_BIG_TO_SMALL_ID, false) @JvmField val sortOrders: Map = Collections.unmodifiableMap( mapOf( - sort_a_to_z.name to sort_a_to_z, - sort_z_to_a.name to sort_z_to_a, - sort_old_to_new.name to sort_old_to_new, - sort_new_to_old.name to sort_new_to_old, - sort_small_to_big.name to sort_small_to_big, - sort_big_to_small.name to sort_big_to_small + SORT_A_TO_Z.name to SORT_A_TO_Z, + SORT_Z_TO_A.name to SORT_Z_TO_A, + SORT_OLD_TO_NEW.name to SORT_OLD_TO_NEW, + SORT_NEW_TO_OLD.name to SORT_NEW_TO_OLD, + SORT_SMALL_TO_BIG.name to SORT_SMALL_TO_BIG, + SORT_BIG_TO_SMALL.name to SORT_BIG_TO_SMALL ) ) @@ -103,14 +105,14 @@ open class FileSortOrder(@JvmField var name: String, var isAscending: Boolean) { open fun getType(): SortType { return when (name) { - sort_z_to_a_id, - sort_a_to_z_id -> SortType.ALPHABET + SORT_Z_TO_A_ID, + SORT_A_TO_Z_ID -> SortType.ALPHABET - sort_small_to_big_id, - sort_big_to_small_id -> SortType.SIZE + SORT_SMALL_TO_BIG_ID, + SORT_BIG_TO_SMALL_ID -> SortType.SIZE - sort_new_to_old_id, - sort_old_to_new_id -> SortType.DATE + SORT_NEW_TO_OLD_ID, + SORT_OLD_TO_NEW_ID -> SortType.DATE else -> SortType.ALPHABET } diff --git a/app/src/main/java/com/owncloud/android/utils/theme/FilesSpecificViewThemeUtils.kt b/app/src/main/java/com/owncloud/android/utils/theme/FilesSpecificViewThemeUtils.kt index f9d75d16c5..41f13b3715 100644 --- a/app/src/main/java/com/owncloud/android/utils/theme/FilesSpecificViewThemeUtils.kt +++ b/app/src/main/java/com/owncloud/android/utils/theme/FilesSpecificViewThemeUtils.kt @@ -108,9 +108,7 @@ class FilesSpecificViewThemeUtils @Inject constructor( } } - private fun getThumbDrawable( - context: Context - ): Drawable { + private fun getThumbDrawable(context: Context): Drawable { val thumbDrawable = ResourcesCompat.getDrawable( context.resources, diff --git a/app/src/test/java/com/nextcloud/client/utils/OCFileSortTest.kt b/app/src/test/java/com/nextcloud/client/utils/OCFileSortTest.kt index 9ead6a05ff..be292100d2 100644 --- a/app/src/test/java/com/nextcloud/client/utils/OCFileSortTest.kt +++ b/app/src/test/java/com/nextcloud/client/utils/OCFileSortTest.kt @@ -33,7 +33,7 @@ class OCFileSortTest { fun testFileSortOrder() { val toSort = getShuffledList() - FileSortOrder.sort_a_to_z.sortCloudFiles(toSort) + FileSortOrder.SORT_A_TO_Z.sortCloudFiles(toSort) verifySort(toSort) }