diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/adapters/filelist/FileListAdapter.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/adapters/filelist/FileListAdapter.kt index 352a838cc23..b002171f6f2 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/adapters/filelist/FileListAdapter.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/adapters/filelist/FileListAdapter.kt @@ -28,6 +28,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout +import android.widget.TextView import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.recyclerview.widget.DiffUtil @@ -39,6 +40,7 @@ import com.owncloud.android.databinding.GridItemBinding import com.owncloud.android.databinding.ItemFileListBinding import com.owncloud.android.databinding.ListFooterBinding import com.owncloud.android.datamodel.ThumbnailsCacheManager +import com.owncloud.android.domain.files.model.FileListOption import com.owncloud.android.domain.files.model.OCFile import com.owncloud.android.domain.files.model.OCFooterFile import com.owncloud.android.presentation.diffutils.FileListDiffCallback @@ -55,8 +57,9 @@ class FileListAdapter( var files = mutableListOf() private var account: Account? = AccountUtils.getCurrentOwnCloudAccount(context) + private var fileListOption: FileListOption = FileListOption.ALL_FILES - fun updateFileList(filesToAdd: List) { + fun updateFileList(filesToAdd: List, fileListOption: FileListOption) { val listWithFooter = mutableListOf() listWithFooter.addAll(filesToAdd) @@ -64,11 +67,17 @@ class FileListAdapter( listWithFooter.add(OCFooterFile(manageListOfFilesAndGenerateText(filesToAdd))) } - val diffUtilCallback = FileListDiffCallback(oldList = files, newList = listWithFooter) + val diffUtilCallback = FileListDiffCallback( + oldList = files, + newList = listWithFooter, + oldFileListOption = this.fileListOption, + newFileListOption = fileListOption, + ) val diffResult = DiffUtil.calculateDiff(diffUtilCallback) files.clear() files.addAll(listWithFooter) + this.fileListOption = fileListOption diffResult.dispatchUpdatesTo(this) } @@ -249,6 +258,11 @@ class FileListAdapter( } checkBoxV.isVisible = getCheckedItems().isNotEmpty() + holder.itemView.findViewById(R.id.file_list_path).apply { + text = file.remotePath + isVisible = !fileListOption.isAllFiles() + } + if (file.isFolder) { // Folder fileIcon.setImageResource( diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/diffutils/FileListDiffCallback.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/diffutils/FileListDiffCallback.kt index 810fe82d6c3..aaea4e64744 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/diffutils/FileListDiffCallback.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/diffutils/FileListDiffCallback.kt @@ -21,10 +21,16 @@ package com.owncloud.android.presentation.diffutils import androidx.recyclerview.widget.DiffUtil +import com.owncloud.android.domain.files.model.FileListOption import com.owncloud.android.domain.files.model.OCFile import com.owncloud.android.domain.files.model.OCFooterFile -class FileListDiffCallback(private val oldList: List, private val newList: List) : DiffUtil.Callback() { +class FileListDiffCallback( + private val oldList: List, + private val newList: List, + private val oldFileListOption: FileListOption, + private val newFileListOption: FileListOption, +) : DiffUtil.Callback() { override fun getOldListSize(): Int = oldList.size @@ -54,5 +60,5 @@ class FileListDiffCallback(private val oldList: List, private val newList: } override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = - oldList[oldItemPosition] == newList[newItemPosition] + oldList[oldItemPosition] == newList[newItemPosition] && oldFileListOption == newFileListOption } diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/files/filelist/MainFileListFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/files/filelist/MainFileListFragment.kt index c1f9ae43ed1..6cf63a738d2 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/files/filelist/MainFileListFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/files/filelist/MainFileListFragment.kt @@ -207,7 +207,7 @@ class MainFileListFragment : Fragment(), collectLatestLifecycleFlow(mainFileListViewModel.fileListUiState) { fileListUiState -> if (fileListUiState !is MainFileListViewModel.FileListUiState.Success) return@collectLatestLifecycleFlow - updateFileListData(fileListUiState.folderContent) + updateFileListData(fileListUiState.folderContent, fileListUiState.fileListOption) } mainFileListViewModel.syncFolder.observe(viewLifecycleOwner, Event.EventObserver { @@ -222,8 +222,8 @@ class MainFileListFragment : Fragment(), }) } - private fun updateFileListData(filesList: List) { - fileListAdapter.updateFileList(filesToAdd = filesList) + private fun updateFileListData(filesList: List, fileListOption: FileListOption) { + fileListAdapter.updateFileList(filesToAdd = filesList, fileListOption = fileListOption) showOrHideEmptyView(filesList) } diff --git a/owncloudApp/src/main/res/layout/item_file_list.xml b/owncloudApp/src/main/res/layout/item_file_list.xml index 8390ae4678a..cfe6217ba56 100644 --- a/owncloudApp/src/main/res/layout/item_file_list.xml +++ b/owncloudApp/src/main/res/layout/item_file_list.xml @@ -106,7 +106,8 @@ android:visibility="gone" app:layout_constraintStart_toStartOf="@+id/Filename" app:layout_constraintTop_toBottomOf="@+id/file_list_size" - tools:text="/path/to/file" /> + tools:text="/path/to/file" + tools:visibility="visible"/> - \ No newline at end of file +