Loading library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ class ReadFileRemoteOperationIT : AbstractIT() { testOnlyOnServer(NextcloudVersion.nextcloud_27) @Suppress("Detekt.MagicNumber") assertEquals(GeoLocation(49.99679166666667, 8.67198611111111), remoteFile.geoLocation) assertEquals(GeoLocation(49.996791666667, 8.6719861111111), remoteFile.geoLocation) } @Test Loading library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt +26 −4 Original line number Diff line number Diff line Loading @@ -31,8 +31,6 @@ 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.files.model.parseGeoLocation import com.owncloud.android.lib.resources.files.model.parseImageDimensions import com.owncloud.android.lib.resources.shares.ShareType import com.owncloud.android.lib.resources.shares.ShareeUser import org.apache.jackrabbit.webdav.MultiStatusResponse Loading Loading @@ -426,7 +424,19 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { prop = propSet[EXTENDED_PROPERTY_METADATA_SIZE, ncNamespace] gson.fromDavProperty<ImageDimension>(prop) } else { parseImageDimensions(prop.value.toString()) val xmlData = prop.value as ArrayList<*> var width = 0f var height = 0f xmlData.forEach { val element = it as Element if (element.tagName == "width") { width = element.firstChild.textContent.toFloat() } else if (element.tagName == "height") { height = element.firstChild.textContent.toFloat() } } ImageDimension(width, height) } // NC metadata gps property <nc:file-metadata-gps> Loading @@ -436,7 +446,19 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { prop = propSet[EXTENDED_PROPERTY_METADATA_GPS, ncNamespace] gson.fromDavProperty<GeoLocation>(prop) } else { parseGeoLocation(prop.value.toString()) val xmlData = prop.value as ArrayList<*> var latitude = 0.0 var longitude = 0.0 xmlData.forEach { val element = it as Element if (element.tagName == "latitude") { latitude = element.firstChild.textContent.toDouble() } else if (element.tagName == "longitude") { longitude = element.firstChild.textContent.toDouble() } } GeoLocation(latitude, longitude) } parseLockProperties(ncNamespace, propSet) Loading library/src/main/java/com/owncloud/android/lib/resources/files/model/GeoLocation.kt +0 −26 Original line number Diff line number Diff line Loading @@ -27,30 +27,4 @@ package com.owncloud.android.lib.resources.files.model import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParserFactory data class GeoLocation(var latitude: Double = -1.0, var longitude: Double = -1.0) fun parseGeoLocation(xmlString: String): GeoLocation { val xmlPullParserFactory = XmlPullParserFactory.newInstance() xmlPullParserFactory.isNamespaceAware = true val parser = xmlPullParserFactory.newPullParser() parser.setInput(xmlString.reader()) var eventType = parser.eventType val geoLocation = GeoLocation() while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && parser.name == "Location") { val latitude = parser.getAttributeValue(null, "latitude")?.toDoubleOrNull() ?: -1.0 val longitude = parser.getAttributeValue(null, "longitude")?.toDoubleOrNull() ?: -1.0 geoLocation.latitude = latitude geoLocation.longitude = longitude break } eventType = parser.next() } return geoLocation } library/src/main/java/com/owncloud/android/lib/resources/files/model/ImageDimension.kt +0 −25 Original line number Diff line number Diff line Loading @@ -27,29 +27,4 @@ package com.owncloud.android.lib.resources.files.model import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParserFactory data class ImageDimension(var width: Float = -1f, var height: Float = -1f) fun parseImageDimensions(xmlString: String): ImageDimension { val xmlPullParserFactory = XmlPullParserFactory.newInstance() val parser = xmlPullParserFactory.newPullParser() parser.setInput(xmlString.reader()) var eventType = parser.eventType val imageDimension = ImageDimension() while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && parser.name == "Dimension") { val width = parser.getAttributeValue(null, "width")?.toFloatOrNull() ?: -1f val height = parser.getAttributeValue(null, "height")?.toFloatOrNull() ?: -1f imageDimension.width = width imageDimension.height = height break } eventType = parser.next() } return imageDimension } Loading
library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ class ReadFileRemoteOperationIT : AbstractIT() { testOnlyOnServer(NextcloudVersion.nextcloud_27) @Suppress("Detekt.MagicNumber") assertEquals(GeoLocation(49.99679166666667, 8.67198611111111), remoteFile.geoLocation) assertEquals(GeoLocation(49.996791666667, 8.6719861111111), remoteFile.geoLocation) } @Test Loading
library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt +26 −4 Original line number Diff line number Diff line Loading @@ -31,8 +31,6 @@ 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.files.model.parseGeoLocation import com.owncloud.android.lib.resources.files.model.parseImageDimensions import com.owncloud.android.lib.resources.shares.ShareType import com.owncloud.android.lib.resources.shares.ShareeUser import org.apache.jackrabbit.webdav.MultiStatusResponse Loading Loading @@ -426,7 +424,19 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { prop = propSet[EXTENDED_PROPERTY_METADATA_SIZE, ncNamespace] gson.fromDavProperty<ImageDimension>(prop) } else { parseImageDimensions(prop.value.toString()) val xmlData = prop.value as ArrayList<*> var width = 0f var height = 0f xmlData.forEach { val element = it as Element if (element.tagName == "width") { width = element.firstChild.textContent.toFloat() } else if (element.tagName == "height") { height = element.firstChild.textContent.toFloat() } } ImageDimension(width, height) } // NC metadata gps property <nc:file-metadata-gps> Loading @@ -436,7 +446,19 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { prop = propSet[EXTENDED_PROPERTY_METADATA_GPS, ncNamespace] gson.fromDavProperty<GeoLocation>(prop) } else { parseGeoLocation(prop.value.toString()) val xmlData = prop.value as ArrayList<*> var latitude = 0.0 var longitude = 0.0 xmlData.forEach { val element = it as Element if (element.tagName == "latitude") { latitude = element.firstChild.textContent.toDouble() } else if (element.tagName == "longitude") { longitude = element.firstChild.textContent.toDouble() } } GeoLocation(latitude, longitude) } parseLockProperties(ncNamespace, propSet) Loading
library/src/main/java/com/owncloud/android/lib/resources/files/model/GeoLocation.kt +0 −26 Original line number Diff line number Diff line Loading @@ -27,30 +27,4 @@ package com.owncloud.android.lib.resources.files.model import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParserFactory data class GeoLocation(var latitude: Double = -1.0, var longitude: Double = -1.0) fun parseGeoLocation(xmlString: String): GeoLocation { val xmlPullParserFactory = XmlPullParserFactory.newInstance() xmlPullParserFactory.isNamespaceAware = true val parser = xmlPullParserFactory.newPullParser() parser.setInput(xmlString.reader()) var eventType = parser.eventType val geoLocation = GeoLocation() while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && parser.name == "Location") { val latitude = parser.getAttributeValue(null, "latitude")?.toDoubleOrNull() ?: -1.0 val longitude = parser.getAttributeValue(null, "longitude")?.toDoubleOrNull() ?: -1.0 geoLocation.latitude = latitude geoLocation.longitude = longitude break } eventType = parser.next() } return geoLocation }
library/src/main/java/com/owncloud/android/lib/resources/files/model/ImageDimension.kt +0 −25 Original line number Diff line number Diff line Loading @@ -27,29 +27,4 @@ package com.owncloud.android.lib.resources.files.model import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParserFactory data class ImageDimension(var width: Float = -1f, var height: Float = -1f) fun parseImageDimensions(xmlString: String): ImageDimension { val xmlPullParserFactory = XmlPullParserFactory.newInstance() val parser = xmlPullParserFactory.newPullParser() parser.setInput(xmlString.reader()) var eventType = parser.eventType val imageDimension = ImageDimension() while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && parser.name == "Dimension") { val width = parser.getAttributeValue(null, "width")?.toFloatOrNull() ?: -1f val height = parser.getAttributeValue(null, "height")?.toFloatOrNull() ?: -1f imageDimension.width = width imageDimension.height = height break } eventType = parser.next() } return imageDimension }