mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Do not open the room again when the app is resumed from the recents list (#7436)
MainActivity is a singleTask activity that declares the elementx://open deep link, so tapping a notification makes that deep link the base intent of the task. When the user later brings the app back from the recents list, the system replays that base intent with FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, the resolver turns it into a navigation again and the user is pushed back into the room they had already left. Ignore any intent the system replayed from the history, the same way the launcher intent is already ignored.
This commit is contained in:
@@ -76,6 +76,7 @@ class IntentResolver(
|
||||
}
|
||||
|
||||
private fun Intent.canBeIgnored(): Boolean {
|
||||
if (flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY != 0) return true
|
||||
return action == Intent.ACTION_MAIN &&
|
||||
categories?.contains(Intent.CATEGORY_LAUNCHER) == true
|
||||
}
|
||||
|
||||
@@ -45,6 +45,24 @@ class IntentResolverTest : RobolectricTest() {
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `resolve intent replayed from the history should return null`() {
|
||||
val sut = createIntentResolver(
|
||||
deeplinkParserResult = DeeplinkData.Room(
|
||||
sessionId = A_SESSION_ID,
|
||||
roomId = A_ROOM_ID,
|
||||
threadId = null,
|
||||
eventId = null,
|
||||
)
|
||||
)
|
||||
val intent = Intent(RuntimeEnvironment.getApplication(), Activity::class.java).apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)
|
||||
}
|
||||
val result = sut.resolve(intent)
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test resolve navigation intent root`() {
|
||||
val sut = createIntentResolver(
|
||||
|
||||
Reference in New Issue
Block a user