sort Barcode.data keys alphabetically on Android; add missing bounding box for Android
Showing
1 changed file
with
26 additions
and
6 deletions
| @@ -28,12 +28,22 @@ fun Image.toByteArray(): ByteArray { | @@ -28,12 +28,22 @@ fun Image.toByteArray(): ByteArray { | ||
| 28 | 28 | ||
| 29 | val Barcode.data: Map<String, Any?> | 29 | val Barcode.data: Map<String, Any?> |
| 30 | get() = mapOf( | 30 | get() = mapOf( |
| 31 | - "corners" to cornerPoints?.map { corner -> corner.data }, "format" to format, | ||
| 32 | - "rawBytes" to rawBytes, "rawValue" to rawValue, "type" to valueType, | ||
| 33 | - "calendarEvent" to calendarEvent?.data, "contactInfo" to contactInfo?.data, | ||
| 34 | - "driverLicense" to driverLicense?.data, "email" to email?.data, | ||
| 35 | - "geoPoint" to geoPoint?.data, "phone" to phone?.data, "sms" to sms?.data, | ||
| 36 | - "url" to url?.data, "wifi" to wifi?.data, "displayValue" to displayValue | 31 | + "calendarEvent" to calendarEvent?.data, |
| 32 | + "contactInfo" to contactInfo?.data, | ||
| 33 | + "corners" to cornerPoints?.map { corner -> corner.data }, | ||
| 34 | + "displayValue" to displayValue, | ||
| 35 | + "driverLicense" to driverLicense?.data, | ||
| 36 | + "email" to email?.data, | ||
| 37 | + "format" to format, | ||
| 38 | + "geoPoint" to geoPoint?.data, | ||
| 39 | + "phone" to phone?.data, | ||
| 40 | + "rawBytes" to rawBytes, | ||
| 41 | + "rawValue" to rawValue, | ||
| 42 | + "size" to boundingBox?.size, | ||
| 43 | + "sms" to sms?.data, | ||
| 44 | + "type" to valueType, | ||
| 45 | + "url" to url?.data, | ||
| 46 | + "wifi" to wifi?.data, | ||
| 37 | ) | 47 | ) |
| 38 | 48 | ||
| 39 | private val Point.data: Map<String, Double> | 49 | private val Point.data: Map<String, Double> |
| @@ -93,3 +103,13 @@ private val Barcode.UrlBookmark.data: Map<String, Any?> | @@ -93,3 +103,13 @@ private val Barcode.UrlBookmark.data: Map<String, Any?> | ||
| 93 | 103 | ||
| 94 | private val Barcode.WiFi.data: Map<String, Any?> | 104 | private val Barcode.WiFi.data: Map<String, Any?> |
| 95 | get() = mapOf("encryptionType" to encryptionType, "password" to password, "ssid" to ssid) | 105 | get() = mapOf("encryptionType" to encryptionType, "password" to password, "ssid" to ssid) |
| 106 | + | ||
| 107 | +private val Rect.size: Map<String, Any?> | ||
| 108 | + get() { | ||
| 109 | + // Rect.isValid can't be accessed for some reason, so just do the check manually. | ||
| 110 | + if (left <= right && top <= bottom) { | ||
| 111 | + return mapOf("width" to width().toDouble(), "height" to height().toDouble()) | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + return emptyMap() | ||
| 115 | + } |
-
Please register or login to post a comment