Skip to content

Commit 59ef8e1

Browse files
committed
injecting the context directly to the handler
1 parent d19346b commit 59ef8e1

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

vector/src/main/java/im/vector/app/features/attachments/ShareIntentHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ import javax.inject.Inject
2323

2424
class ShareIntentHandler @Inject constructor(
2525
private val multiPickerIncomingFiles: MultiPickerIncomingFiles,
26+
private val context: Context,
2627
) {
2728

2829
/**
2930
* This methods aims to handle incoming share intents.
3031
*
3132
* @return true if it can handle the intent data, false otherwise
3233
*/
33-
fun handleIncomingShareIntent(context: Context, intent: Intent, onFile: (List<ContentAttachmentData>) -> Unit, onPlainText: (String) -> Unit): Boolean {
34+
fun handleIncomingShareIntent(intent: Intent, onFile: (List<ContentAttachmentData>) -> Unit, onPlainText: (String) -> Unit): Boolean {
3435
val type = intent.resolveType(context) ?: return false
3536
return when {
3637
type == "text/plain" -> handlePlainText(intent, onPlainText)

vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ class TimelineFragment @Inject constructor(
16191619

16201620
private fun sendUri(uri: Uri): Boolean {
16211621
val shareIntent = Intent(Intent.ACTION_SEND, uri)
1622-
val isHandled = shareIntentHandler.handleIncomingShareIntent(requireContext(), shareIntent, ::onContentAttachmentsReady, onPlainText = {
1622+
val isHandled = shareIntentHandler.handleIncomingShareIntent(shareIntent, ::onContentAttachmentsReady, onPlainText = {
16231623
fatalError("Should not happen as we're generating a File based share Intent", vectorPreferences.failFast())
16241624
})
16251625
if (!isHandled) {

vector/src/main/java/im/vector/app/features/share/IncomingShareFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class IncomingShareFragment @Inject constructor(
116116
}
117117

118118
private fun handleIncomingShareIntent(intent: Intent) = shareIntentHandler.handleIncomingShareIntent(
119-
requireContext(),
120119
intent,
121120
onFile = {
122121
val sharedData = SharedData.Attachments(it)

vector/src/test/java/im/vector/app/features/attachments/ShareIntentHandlerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ShareIntentHandlerTest {
3636
private val onFile = FakeFunction1<List<ContentAttachmentData>>()
3737
private val onPlainText = FakeFunction1<String>()
3838

39-
private val shareIntentHandler = ShareIntentHandler(fakeMultiPickerIncomingFiles.instance)
39+
private val shareIntentHandler = ShareIntentHandler(fakeMultiPickerIncomingFiles.instance, A_CONTEXT)
4040

4141
@Test
4242
fun `given an unhandled sharing intent type, when handling intent, then is not handled`() {
@@ -161,6 +161,6 @@ class ShareIntentHandlerTest {
161161
}
162162

163163
private fun handleIncomingShareIntent(intent: FakeIntent): Boolean {
164-
return shareIntentHandler.handleIncomingShareIntent(A_CONTEXT, intent.instance, onFile.capture, onPlainText.capture)
164+
return shareIntentHandler.handleIncomingShareIntent(intent.instance, onFile.capture, onPlainText.capture)
165165
}
166166
}

0 commit comments

Comments
 (0)