Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class FileListAdapter(
// Set file icon depending on its mimetype. Ask for thumbnail later.
fileIcon.setImageResource(MimetypeIconUtil.getFileTypeIconId(file.mimeType, file.fileName))

if (file.isImage) {
if (file.hasPreview || file.isImage) {
account?.let { acc ->
fileIcon.load(ThumbnailsRequester.getPreviewUriForFile(fileWithSyncInfo, acc),
ThumbnailsRequester.getContentAddressedImageLoader(acc)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import at.bitfire.dav4jvm.property.OCPrivatelink
import at.bitfire.dav4jvm.property.OCSize
import at.bitfire.dav4jvm.property.ResourceType
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCChecksums
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCHasPreview
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCShareTypes

object DavUtils {
Expand All @@ -55,6 +56,7 @@ object DavUtils {
OCPrivatelink.NAME,
OCShareTypes.NAME,
OCChecksums.NAME,
OCHasPreview.NAME,
)

val quotaPropSet: Array<Property.Name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* openCloud Android Library is available under MIT license
* Copyright (C) 2026 OpenCloud GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package eu.opencloud.android.lib.common.http.methods.webdav.properties

import at.bitfire.dav4jvm.Property
import at.bitfire.dav4jvm.PropertyFactory
import at.bitfire.dav4jvm.XmlUtils
import org.xmlpull.v1.XmlPullParser

/**
* Parses `<oc:has-preview>` from a PROPFIND response: "1" when the server can render a thumbnail
* for this resource, "0" otherwise. Mirrors what the Web UI uses to decide whether to show a
* preview, so the file list can request thumbnails only where one actually exists.
*
* @author Markus Goetz
*/
data class OCHasPreview(val hasPreview: Boolean) : Property {
class Factory : PropertyFactory {
override fun getName() = NAME

override fun create(parser: XmlPullParser): OCHasPreview? {
XmlUtils.readText(parser)?.let {
return OCHasPreview(it == "1")
}
return null
}
}

companion object {
@JvmField
val NAME = Property.Name(XmlUtils.NS_OWNCLOUD, "has-preview")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import eu.opencloud.android.lib.common.http.methods.webdav.DavConstants.DEPTH_0
import eu.opencloud.android.lib.common.http.methods.webdav.DavUtils
import eu.opencloud.android.lib.common.http.methods.webdav.PropfindMethod
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCChecksums
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCHasPreview
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCShareTypes
import eu.opencloud.android.lib.common.network.WebdavUtils
import eu.opencloud.android.lib.common.operations.RemoteOperation
Expand Down Expand Up @@ -67,6 +68,7 @@ class ReadRemoteFileOperation(
}
PropertyRegistry.register(OCShareTypes.Factory())
PropertyRegistry.register(OCChecksums.Factory())
PropertyRegistry.register(OCHasPreview.Factory())

val propFind = PropfindMethod(
url = getFinalWebDavUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import eu.opencloud.android.lib.common.http.methods.webdav.DavConstants
import eu.opencloud.android.lib.common.http.methods.webdav.DavUtils
import eu.opencloud.android.lib.common.http.methods.webdav.PropfindMethod
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCChecksums
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCHasPreview
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCShareTypes
import eu.opencloud.android.lib.common.network.WebdavUtils
import eu.opencloud.android.lib.common.operations.RemoteOperation
Expand Down Expand Up @@ -62,6 +63,7 @@ class ReadRemoteFolderOperation(
try {
PropertyRegistry.register(OCShareTypes.Factory())
PropertyRegistry.register(OCChecksums.Factory())
PropertyRegistry.register(OCHasPreview.Factory())

val propfindMethod = PropfindMethod(
getFinalWebDavUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import at.bitfire.dav4jvm.property.OCPrivatelink
import at.bitfire.dav4jvm.property.OCSize
import eu.opencloud.android.lib.common.http.HttpConstants
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCChecksums
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCHasPreview
import eu.opencloud.android.lib.common.http.methods.webdav.properties.OCShareTypes
import eu.opencloud.android.lib.common.utils.isOneOf
import eu.opencloud.android.lib.resources.shares.ShareType
Expand Down Expand Up @@ -76,6 +77,8 @@ data class RemoteFile(
var sharedWithSharee: Boolean = false,
/** Server-reported checksums as raw "ALGORITHM:value" strings (e.g. "SHA1:1c68ea…"). */
var checksums: List<String> = emptyList(),
/** Whether the server can render a thumbnail for this file (from `<oc:has-preview>`). */
var hasPreview: Boolean = false,
) : Parcelable {

// To do: Quotas not used. Use or remove them.
Expand Down Expand Up @@ -140,6 +143,9 @@ data class RemoteFile(
is OCChecksums -> {
remoteFile.checksums = property.checksums
}
is OCHasPreview -> {
remoteFile.hasPreview = property.hasPreview
}
is OCShareTypes -> {
val list = property.shareTypes
for (i in list.indices) {
Expand Down
Loading
Loading