mirror of
https://github.com/ProtonMail/android-mail.git
synced 2026-05-15 09:50:40 +00:00
Fix launcher intent detection for share intents
Problem: Share intents with CATEGORY_DEFAULT were incorrectly treated as launcher intents ET-6136
This commit is contained in:
@@ -61,8 +61,10 @@ class IntentMapper @Inject constructor() {
|
||||
}
|
||||
|
||||
private fun Intent.isLauncherIntent(): Boolean = action == Intent.ACTION_MAIN &&
|
||||
categories?.contains(Intent.CATEGORY_LAUNCHER) == true ||
|
||||
categories?.contains(Intent.CATEGORY_DEFAULT) == true
|
||||
(
|
||||
categories?.contains(Intent.CATEGORY_LAUNCHER) == true ||
|
||||
categories?.contains(Intent.CATEGORY_DEFAULT) == true
|
||||
)
|
||||
|
||||
private fun Intent.isShareIntent(): Boolean = action == Intent.ACTION_SEND ||
|
||||
action == Intent.ACTION_SEND_MULTIPLE ||
|
||||
|
||||
@@ -181,6 +181,33 @@ class IntentMapperTest {
|
||||
assertTrue(result is HomeNavigationEvent.UnknownIntentReceived)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `map external image share intent with category default`() {
|
||||
// Given
|
||||
val streamUri = mockk<Uri> {
|
||||
every { scheme } returns "content"
|
||||
}
|
||||
every { streamUri.toString() } returns "content://media/1"
|
||||
|
||||
val intent = mockIntent(
|
||||
action = Intent.ACTION_SEND,
|
||||
type = "image/jpeg",
|
||||
data = null,
|
||||
externalBoolean = true,
|
||||
categories = setOf(Intent.CATEGORY_DEFAULT),
|
||||
extraSubject = sampleShareInfoExternal.emailSubject,
|
||||
extraRecipientTo = sampleShareInfoExternal.emailRecipientTo.toTypedArray(),
|
||||
extraText = sampleShareInfoExternal.emailBody,
|
||||
extraStreamUri = streamUri
|
||||
)
|
||||
|
||||
// When
|
||||
val result = mapper.map(intent)
|
||||
|
||||
// Then
|
||||
assertIs<HomeNavigationEvent.ExternalShareIntentReceived>(result)
|
||||
assertEquals(sampleShareInfoExternal, result.shareInfo)
|
||||
}
|
||||
|
||||
private fun mockIntent(
|
||||
action: String = "",
|
||||
|
||||
Reference in New Issue
Block a user