17
17
18
18
package im.vector.app.features.home.room.detail.composer
19
19
20
- import android.content.ClipData
21
20
import android.content.Context
22
21
import android.net.Uri
23
22
import android.os.Build
@@ -27,12 +26,12 @@ import android.view.inputmethod.EditorInfo
27
26
import android.view.inputmethod.InputConnection
28
27
import androidx.annotation.RequiresApi
29
28
import androidx.appcompat.widget.AppCompatEditText
30
- import androidx.core.view.OnReceiveContentListener
31
29
import androidx.core.view.ViewCompat
32
30
import androidx.core.view.inputmethod.EditorInfoCompat
33
31
import androidx.core.view.inputmethod.InputConnectionCompat
34
32
import im.vector.app.core.extensions.ooi
35
33
import im.vector.app.core.platform.SimpleTextWatcher
34
+ import im.vector.app.features.home.room.detail.composer.images.UriContentListener
36
35
import im.vector.app.features.html.PillImageSpan
37
36
import timber.log.Timber
38
37
@@ -56,27 +55,11 @@ class ComposerEditText @JvmOverloads constructor(
56
55
EditorInfoCompat .setContentMimeTypes(editorInfo, mimeTypes)
57
56
ic = InputConnectionCompat .createWrapper(this , ic, editorInfo)
58
57
59
- val onReceiveContentListener = OnReceiveContentListener { _, payload ->
60
- val split = payload.partition { item -> item.uri != null }
61
- val uriContent = split.first
62
- val remaining = split.second
63
-
64
- if (uriContent != null ) {
65
- val clip: ClipData = uriContent.clip
66
- for (i in 0 until clip.itemCount) {
67
- val uri = clip.getItemAt(i).uri
68
- // ... app-specific logic to handle the URI ...
69
- callback?.onRichContentSelected(uri)
70
- }
71
- }
72
- // Return anything that we didn't handle ourselves. This preserves the default platform
73
- // behavior for text and anything else for which we are not implementing custom handling.
74
- // Return anything that we didn't handle ourselves. This preserves the default platform
75
- // behavior for text and anything else for which we are not implementing custom handling.
76
- remaining
77
- }
78
-
79
- ViewCompat .setOnReceiveContentListener(this , mimeTypes, onReceiveContentListener)
58
+ ViewCompat .setOnReceiveContentListener(
59
+ this ,
60
+ mimeTypes,
61
+ UriContentListener { callback?.onRichContentSelected(it) }
62
+ )
80
63
81
64
return ic
82
65
}
0 commit comments