Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 867a12b9 authored by alperozturk's avatar alperozturk
Browse files

parse tags

parent b341d8d3
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -393,23 +393,20 @@ class WebdavEntry constructor(
            }

            prop = propSet[EXTENDED_PROPERTY_SYSTEM_TAGS, ncNamespace]
            if (prop != null && prop.value != null) {
                if (prop.value is ArrayList<*>) {
                    val list = prop.value as ArrayList<*>
                    val tempList: MutableList<String> = ArrayList(list.size)
                    for (i in list.indices) {
                        val element = list[i] as Element
                        tempList.add(element.firstChild.textContent)
                    }
                    tags = tempList.toTypedArray()
                } else {
                    // single item or empty
                    val element = prop.value as Element
                    val value = element.firstChild.textContent
            if (prop?.value != null) {
                tags = when (prop.value) {
                    is ArrayList<*> -> (prop.value as ArrayList<*>)
                        .filterIsInstance<Element>()
                        .map { parseTag(it) }
                        .toTypedArray()

                    if (value != null) {
                        tags = arrayOf(value)
                    is Element -> {
                        val element = (prop.value as Element)
                        val tag = parseTag(element)
                        arrayOf(tag)
                    }

                    else -> emptyArray()
                }
            }

@@ -485,6 +482,12 @@ class WebdavEntry constructor(
        }
    }

    private fun parseTag(element: Element): Tag {
        val name = element.firstChild.textContent
        val color = element.getAttribute("nc:color")
        return Tag(name, color)
    }

    private fun parseLockProperties(
        ncNamespace: Namespace,
        propSet: DavPropertySet
+2 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ package com.owncloud.android.lib.resources.files.model

import android.os.Parcel
import android.os.Parcelable
import com.owncloud.android.lib.common.network.Tag
import com.nextcloud.android.lib.resources.files.FileDownloadLimit
import com.owncloud.android.lib.common.network.WebdavEntry
import com.owncloud.android.lib.common.network.WebdavEntry.MountType
@@ -53,7 +54,7 @@ class RemoteFile :
    var lockOwnerEditor: String? = null
    var lockTimeout: Long = 0
    var lockToken: String? = null
    var tags: Array<String?>? = null
    var tags: Array<Tag?>? = null
    var imageDimension: ImageDimension? = null
    var geoLocation: GeoLocation? = null
    var hidden = false