mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 01:19:33 +00:00
Ignore Launcher intent (was printing a warning).
This commit is contained in:
@@ -34,6 +34,8 @@ class IntentResolver @Inject constructor(
|
|||||||
private val oidcIntentResolver: OidcIntentResolver
|
private val oidcIntentResolver: OidcIntentResolver
|
||||||
) {
|
) {
|
||||||
fun resolve(intent: Intent): ResolvedIntent? {
|
fun resolve(intent: Intent): ResolvedIntent? {
|
||||||
|
if (intent.canBeIgnored()) return null
|
||||||
|
|
||||||
val deepLinkData = deeplinkParser.getFromIntent(intent)
|
val deepLinkData = deeplinkParser.getFromIntent(intent)
|
||||||
if (deepLinkData != null) return ResolvedIntent.Navigation(deepLinkData)
|
if (deepLinkData != null) return ResolvedIntent.Navigation(deepLinkData)
|
||||||
|
|
||||||
@@ -45,3 +47,8 @@ class IntentResolver @Inject constructor(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Intent.canBeIgnored(): Boolean {
|
||||||
|
return action == Intent.ACTION_MAIN &&
|
||||||
|
categories?.contains(Intent.CATEGORY_LAUNCHER) == true
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ import org.robolectric.RuntimeEnvironment
|
|||||||
|
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
class IntentResolverTest {
|
class IntentResolverTest {
|
||||||
|
@Test
|
||||||
|
fun `resolve launcher intent should return null`() {
|
||||||
|
val sut = createIntentResolver()
|
||||||
|
val intent = Intent(RuntimeEnvironment.getApplication(), Activity::class.java).apply {
|
||||||
|
action = Intent.ACTION_MAIN
|
||||||
|
addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
|
}
|
||||||
|
val result = sut.resolve(intent)
|
||||||
|
assertThat(result).isNull()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test resolve navigation intent root`() {
|
fun `test resolve navigation intent root`() {
|
||||||
val sut = createIntentResolver()
|
val sut = createIntentResolver()
|
||||||
|
|||||||
Reference in New Issue
Block a user