Skip to content

Commit 7722526

Browse files
committed
Use attachment mime type utils to check if element is a calendar event instead
1 parent c7ba463 commit 7722526

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/src/main/java/com/infomaniak/mail/data/models/Attachment.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Infomaniak Mail - Android
3-
* Copyright (C) 2022-2023 Infomaniak Network SA
3+
* Copyright (C) 2022-2024 Infomaniak Network SA
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -60,7 +60,7 @@ class Attachment : EmbeddedRealmObject {
6060
var uploadLocalUri: String? = null
6161
//endregion
6262

63-
val isCalendarEvent: Boolean get() = mimeType == "application/ics" || mimeType == "text/calendar"
63+
val isCalendarEvent: Boolean get() = AttachmentMimeTypeUtils.calendarMatches.contains(mimeType)
6464

6565
val disposition: AttachmentDisposition?
6666
get() = enumValueOfOrNull<AttachmentDisposition>(_disposition)

app/src/main/java/com/infomaniak/mail/utils/AttachmentMimeTypeUtils.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Infomaniak Mail - Android
3-
* Copyright (C) 2023 Infomaniak Network SA
3+
* Copyright (C) 2023-2024 Infomaniak Network SA
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@ object AttachmentMimeTypeUtils {
2828
"application/x-pdf"
2929
)
3030

31-
private val calendarMatches = mimeTypeSetOf(
31+
val calendarMatches = mimeTypeSetOf(
3232
"application/ics",
3333
"text/calendar"
3434
)
@@ -136,7 +136,7 @@ object AttachmentMimeTypeUtils {
136136

137137
private fun mimeTypeSetOf(vararg mimeTypes: String) = MimeTypeSet(mimeTypes.toSet())
138138

139-
private class MimeTypeSet(private val mimeTypes: Set<String>) : Set<String> by mimeTypes {
139+
class MimeTypeSet(private val mimeTypes: Set<String>) : Set<String> by mimeTypes {
140140
override fun contains(element: String): Boolean = mimeTypes.any { mimeType -> element.startsWith(mimeType) }
141141
}
142142
}

0 commit comments

Comments
 (0)