5
5
6
6
package com.flowcrypt.email.providers
7
7
8
- import android.content.res.AssetFileDescriptor
9
8
import android.database.Cursor
10
9
import android.database.MatrixCursor
11
10
import android.net.Uri
12
- import android.os.Bundle
13
11
import android.os.CancellationSignal
14
12
import android.os.ParcelFileDescriptor
15
13
import android.provider.DocumentsContract
16
14
import android.provider.DocumentsProvider
17
- import android.util.Log
18
- import android.widget.Toast
19
15
import com.flowcrypt.email.BuildConfig
20
16
import com.flowcrypt.email.api.email.model.AttachmentInfo
21
17
import com.flowcrypt.email.extensions.java.lang.printStackTraceIfDebugOnly
@@ -39,33 +35,7 @@ class EmbeddedAttachmentsProvider : DocumentsProvider() {
39
35
}
40
36
41
37
override fun queryDocument (documentId : String? , projection : Array <String >? ): Cursor {
42
- val finalProjection = projection ? : DEFAULT_DOCUMENT_PROJECTION
43
- return MatrixCursor (finalProjection).apply {
44
- documentId?.let { id ->
45
- getAttachmentByDocumentId(id)?.let { attachmentInfo ->
46
- newRow().apply {
47
- if (DocumentsContract .Document .COLUMN_DOCUMENT_ID in finalProjection) {
48
- add(DocumentsContract .Document .COLUMN_DOCUMENT_ID , id)
49
- }
50
- if (DocumentsContract .Document .COLUMN_DISPLAY_NAME in finalProjection) {
51
- add(DocumentsContract .Document .COLUMN_DISPLAY_NAME , attachmentInfo.getSafeName())
52
- }
53
- if (DocumentsContract .Document .COLUMN_MIME_TYPE in finalProjection) {
54
- add(DocumentsContract .Document .COLUMN_MIME_TYPE , attachmentInfo.getAndroidMimeType())
55
- }
56
- if (DocumentsContract .Document .COLUMN_FLAGS in finalProjection) {
57
- add(DocumentsContract .Document .COLUMN_FLAGS , 0 )
58
- }
59
- if (DocumentsContract .Document .COLUMN_SIZE in finalProjection) {
60
- add(DocumentsContract .Document .COLUMN_SIZE , attachmentInfo.rawData?.size ? : 0 )
61
- }
62
- if (DocumentsContract .Document .COLUMN_LAST_MODIFIED in finalProjection) {
63
- add(DocumentsContract .Document .COLUMN_LAST_MODIFIED , null )
64
- }
65
- }
66
- }
67
- }
68
- }
38
+ return MatrixCursor (emptyArray())
69
39
}
70
40
71
41
override fun queryChildDocuments (
@@ -80,6 +50,10 @@ class EmbeddedAttachmentsProvider : DocumentsProvider() {
80
50
mode : String ,
81
51
signal : CancellationSignal ?
82
52
): ParcelFileDescriptor ? {
53
+ if (mode.contains(" w" )) {
54
+ throw IllegalStateException (" Modification is not allowed" )
55
+ }
56
+
83
57
return getFileDescriptor(getBytesForDocumentId(documentId))
84
58
}
85
59
@@ -185,15 +159,4 @@ class EmbeddedAttachmentsProvider : DocumentsProvider() {
185
159
}
186
160
}
187
161
}
188
-
189
- companion object {
190
- private val DEFAULT_DOCUMENT_PROJECTION = arrayOf(
191
- DocumentsContract .Document .COLUMN_DOCUMENT_ID ,
192
- DocumentsContract .Document .COLUMN_MIME_TYPE ,
193
- DocumentsContract .Document .COLUMN_DISPLAY_NAME ,
194
- DocumentsContract .Document .COLUMN_LAST_MODIFIED ,
195
- DocumentsContract .Document .COLUMN_FLAGS ,
196
- DocumentsContract .Document .COLUMN_SIZE
197
- )
198
- }
199
162
}
0 commit comments