Skip to content

Commit

Permalink
Show remote path in av offline and shared by link shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgardep committed Aug 17, 2022
1 parent 90a1a6d commit 0967173
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -55,20 +57,27 @@ class FileListAdapter(

var files = mutableListOf<Any>()
private var account: Account? = AccountUtils.getCurrentOwnCloudAccount(context)
private var fileListOption: FileListOption = FileListOption.ALL_FILES

fun updateFileList(filesToAdd: List<OCFile>) {
fun updateFileList(filesToAdd: List<OCFile>, fileListOption: FileListOption) {
val listWithFooter = mutableListOf<Any>()
listWithFooter.addAll(filesToAdd)

if (listWithFooter.isNotEmpty()) {
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)
}
Expand Down Expand Up @@ -249,6 +258,11 @@ class FileListAdapter(
}
checkBoxV.isVisible = getCheckedItems().isNotEmpty()

holder.itemView.findViewById<TextView>(R.id.file_list_path).apply {
text = file.remotePath
isVisible = !fileListOption.isAllFiles()
}

if (file.isFolder) {
// Folder
fileIcon.setImageResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Any>, private val newList: List<Any>) : DiffUtil.Callback() {
class FileListDiffCallback(
private val oldList: List<Any>,
private val newList: List<Any>,
private val oldFileListOption: FileListOption,
private val newFileListOption: FileListOption,
) : DiffUtil.Callback() {

override fun getOldListSize(): Int = oldList.size

Expand Down Expand Up @@ -54,5 +60,5 @@ class FileListDiffCallback(private val oldList: List<Any>, private val newList:
}

override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
oldList[oldItemPosition] == newList[newItemPosition]
oldList[oldItemPosition] == newList[newItemPosition] && oldFileListOption == newFileListOption
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -222,8 +222,8 @@ class MainFileListFragment : Fragment(),
})
}

private fun updateFileListData(filesList: List<OCFile>) {
fileListAdapter.updateFileList(filesToAdd = filesList)
private fun updateFileListData(filesList: List<OCFile>, fileListOption: FileListOption) {
fileListAdapter.updateFileList(filesToAdd = filesList, fileListOption = fileListOption)
showOrHideEmptyView(filesList)
}

Expand Down
5 changes: 3 additions & 2 deletions owncloudApp/src/main/res/layout/item_file_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -145,4 +146,4 @@

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 0967173

Please sign in to comment.