diff --git a/library/src/androidTest/assets/gps.jpg b/library/src/androidTest/assets/gps.jpg new file mode 100644 index 000000000..4e55827b5 Binary files /dev/null and b/library/src/androidTest/assets/gps.jpg differ diff --git a/library/src/androidTest/java/com/owncloud/android/AbstractIT.java b/library/src/androidTest/java/com/owncloud/android/AbstractIT.java index 83a4869d9..f8c2d6141 100644 --- a/library/src/androidTest/java/com/owncloud/android/AbstractIT.java +++ b/library/src/androidTest/java/com/owncloud/android/AbstractIT.java @@ -279,8 +279,8 @@ public static File extractAsset(String fileName, Context context) throws IOExcep @After public void after() { - removeOnClient(client); - removeOnClient(client2); +// removeOnClient(client); +// removeOnClient(client2); } private void removeOnClient(OwnCloudClient client) { diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt index 72343c1f0..e95232497 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt @@ -23,6 +23,8 @@ package com.owncloud.android.lib.resources.files import com.owncloud.android.AbstractIT import com.owncloud.android.lib.common.OwnCloudClientManagerFactory import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation +import com.owncloud.android.lib.resources.files.model.GeoLocation +import com.owncloud.android.lib.resources.files.model.ImageDimension import com.owncloud.android.lib.resources.files.model.RemoteFile import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse @@ -58,6 +60,27 @@ class ReadFileRemoteOperationIT : AbstractIT() { assertEquals(remotePath, (result.data[0] as RemoteFile).remotePath) } + @Test + fun testMetadata() { + val filePath = getFile("gps.jpg").absolutePath + val remotePath = "/gps.jpg" + + assertTrue( + UploadFileRemoteOperation(filePath, remotePath, "image/jpg", RANDOM_MTIME) + .execute(client).isSuccess + ) + + val result = ReadFileRemoteOperation(remotePath).execute(client) + + assertTrue(result.isSuccess) + val remoteFile = result.data[0] as RemoteFile + + @Suppress("Detekt.MagicNumber") + assertEquals(ImageDimension(451f, 529f), remoteFile.imageDimension) + @Suppress("Detekt.MagicNumber") + assertEquals(GeoLocation(49.99679166666667, 8.67198611111111), remoteFile.geoLocation) + } + @Test fun readEncryptedState() { val remotePath = "/testEncryptedFolder/" diff --git a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt index e4f430e21..b6dcaa38b 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt +++ b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt @@ -24,9 +24,12 @@ package com.owncloud.android.lib.common.network import android.net.Uri +import com.google.gson.Gson import com.owncloud.android.lib.common.utils.Log_OC import com.owncloud.android.lib.resources.files.model.FileLockType import com.owncloud.android.lib.resources.files.model.FileLockType.Companion.fromValue +import com.owncloud.android.lib.resources.files.model.GeoLocation +import com.owncloud.android.lib.resources.files.model.ImageDimension import com.owncloud.android.lib.resources.shares.ShareType import com.owncloud.android.lib.resources.shares.ShareeUser import org.apache.jackrabbit.webdav.MultiStatusResponse @@ -96,6 +99,8 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { var lockToken: String? = null private set var tags = arrayOfNulls(0) + var imageDimension: ImageDimension? = null + var geoLocation: GeoLocation? = null enum class MountType { INTERNAL, EXTERNAL, GROUP @@ -395,6 +400,18 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { } } + // NC metadata size property + prop = propSet[EXTENDED_PROPERTY_METADATA_SIZE, ncNamespace] + if (prop != null && prop.value != null) { + imageDimension = Gson().fromJson(prop.value.toString(), ImageDimension::class.java) + } + + // NC metadata gps property + prop = propSet[EXTENDED_PROPERTY_METADATA_GPS, ncNamespace] + if (prop != null && prop.value != null) { + geoLocation = Gson().fromJson(prop.value.toString(), GeoLocation::class.java) + } + parseLockProperties(ncNamespace, propSet) } else { Log_OC.e("WebdavEntry", "General error, no status for webdav response") @@ -542,6 +559,8 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { const val EXTENDED_PROPERTY_LOCK_TIMEOUT = "lock-timeout" const val EXTENDED_PROPERTY_LOCK_TOKEN = "lock-token" const val EXTENDED_PROPERTY_SYSTEM_TAGS = "system-tags" + const val EXTENDED_PROPERTY_METADATA_SIZE = "file-metadata-size" + const val EXTENDED_PROPERTY_METADATA_GPS = "file-metadata-gps" const val TRASHBIN_FILENAME = "trashbin-filename" const val TRASHBIN_ORIGINAL_LOCATION = "trashbin-original-location" const val TRASHBIN_DELETION_TIME = "trashbin-deletion-time" diff --git a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java index cf0911116..1aa6b9f79 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java +++ b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java @@ -126,6 +126,8 @@ public static DavPropertyNameSet getAllPropSet() { propSet.add(WebdavEntry.EXTENDED_PROPERTY_LOCK_TIMEOUT, ncNamespace); propSet.add(WebdavEntry.EXTENDED_PROPERTY_LOCK_TOKEN, ncNamespace); propSet.add(WebdavEntry.EXTENDED_PROPERTY_SYSTEM_TAGS, ncNamespace); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_METADATA_SIZE, ncNamespace); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_METADATA_GPS, ncNamespace); return propSet; } @@ -165,6 +167,8 @@ public static DavPropertyNameSet getFilePropSet() { propSet.add(WebdavEntry.EXTENDED_PROPERTY_LOCK_TOKEN, ncNamespace); propSet.add(WebdavEntry.EXTENDED_PROPERTY_IS_ENCRYPTED, ncNamespace); propSet.add(WebdavEntry.EXTENDED_PROPERTY_SYSTEM_TAGS, ncNamespace); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_METADATA_SIZE, ncNamespace); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_METADATA_GPS, ncNamespace); return propSet; } diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/model/GeoLocation.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/model/GeoLocation.kt new file mode 100644 index 000000000..c8af99637 --- /dev/null +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/model/GeoLocation.kt @@ -0,0 +1,30 @@ +/* Nextcloud Android Library is available under MIT license + * + * @author Tobias Kaminsky + * Copyright (C) 2023 Tobias Kaminsky + * Copyright (C) 2023 Nextcloud 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 com.owncloud.android.lib.resources.files.model + +data class GeoLocation(var latitude: Double = -1.0, var longitude: Double = -1.0) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/model/ImageDimension.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/model/ImageDimension.kt new file mode 100644 index 000000000..e3fa7ab52 --- /dev/null +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/model/ImageDimension.kt @@ -0,0 +1,30 @@ +/* Nextcloud Android Library is available under MIT license + * + * @author Tobias Kaminsky + * Copyright (C) 2023 Tobias Kaminsky + * Copyright (C) 2023 Nextcloud 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 com.owncloud.android.lib.resources.files.model + +data class ImageDimension(var width: Float = -1f, var height: Float = -1f) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/model/RemoteFile.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/model/RemoteFile.kt index 8a52a1d55..12d460333 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/files/model/RemoteFile.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/model/RemoteFile.kt @@ -68,6 +68,8 @@ class RemoteFile : Parcelable, Serializable { var lockTimeout: Long = 0 var lockToken: String? = null var tags: Array? = null + var imageDimension: ImageDimension? = null + var geoLocation: GeoLocation? = null constructor() { resetData() @@ -119,6 +121,8 @@ class RemoteFile : Parcelable, Serializable { lockTimeout = we.lockTimeout lockToken = we.lockToken tags = we.tags + imageDimension = we.imageDimension + geoLocation = we.geoLocation } /**