-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathUploadItem.kt
More file actions
65 lines (58 loc) · 2.02 KB
/
UploadItem.kt
File metadata and controls
65 lines (58 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package fr.free.nrw.commons.upload
import android.net.Uri
import fr.free.nrw.commons.filepicker.MimeTypeMapWrapper.Companion.getExtensionFromMimeType
import fr.free.nrw.commons.nearby.Place
import fr.free.nrw.commons.utils.ImageUtils
import fr.free.nrw.commons.utils.fixExtension
class UploadItem(
var mediaUri: Uri?,
val mimeType: String?,
var gpsCoords: ImageCoordinates?,
var place: Place?,
val createdTimestamp: Long?,
val createdTimestampSource: String?,
/**
* Uri of uploadItem
* Uri points to image location or name, eg content://media/external/images/camera/10495 (Android 10)
*/
var contentUri: Uri?,
//according to EXIF data
val fileCreatedDateString: String?,
val hasUnsupportedFormat: Boolean = false
) {
var imageQuality: Int = ImageUtils.IMAGE_WAIT
var uploadMediaDetails: MutableList<UploadMediaDetail> = mutableListOf(UploadMediaDetail())
var hasInvalidLocation = false
var isWLMUpload = false
var countryCode: String? = null
/**
* Choose a filename for the media. Currently, the caption is used as a filename. If several
* languages have been entered, the first language is used.
*/
val filename: String
get() = fixExtension(
uploadMediaDetails[0].captionText,
getExtensionFromMimeType(mimeType)
)
fun hasInvalidLocation(): Boolean = hasInvalidLocation
/**
* Sets both the contentUri and mediaUri to the specified Uri.
* This method allows you to assign the same Uri to both the contentUri and mediaUri
* properties.
*
* @param uri The Uri to be set as both the contentUri and mediaUri.
*/
fun setContentAndMediaUri(uri: Uri) {
contentUri = uri
mediaUri = uri
}
override fun equals(other: Any?): Boolean {
if (other !is UploadItem) {
return false
}
return mediaUri.toString().contains((other).mediaUri.toString())
}
override fun hashCode(): Int {
return mediaUri.hashCode()
}
}