Remove legacy notification intents handling

ET-5800
This commit is contained in:
Niccolò Forlini
2026-01-30 12:23:44 +01:00
parent 999ebdf6fd
commit 7298481784
7 changed files with 9 additions and 142 deletions
-40
View File
@@ -267,14 +267,6 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="notification"
android:scheme="proton" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
@@ -318,14 +310,6 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="notification"
android:scheme="proton" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
@@ -369,14 +353,6 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="notification"
android:scheme="proton" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
@@ -420,14 +396,6 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="notification"
android:scheme="proton" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
@@ -471,14 +439,6 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="notification"
android:scheme="proton" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
@@ -21,7 +21,6 @@ import android.content.Intent
import ch.protonmail.android.mailcommon.data.file.getShareInfo
import ch.protonmail.android.mailcommon.data.file.isMailToIntent
import ch.protonmail.android.mailcommon.domain.model.isNotEmpty
import ch.protonmail.android.mailnotifications.domain.NotificationsDeepLinkHelper
import ch.protonmail.android.navigation.model.HomeNavigationEvent
import javax.inject.Inject
@@ -29,13 +28,6 @@ class IntentMapper @Inject constructor() {
fun map(intent: Intent): HomeNavigationEvent {
return when {
intent.isNotificationIntent() && intent.data != null -> {
HomeNavigationEvent.NotificationIntentReceived(
intent = intent,
uri = intent.data!!
)
}
intent.isLauncherIntent() -> {
HomeNavigationEvent.LauncherIntentReceived(intent)
}
@@ -68,8 +60,6 @@ class IntentMapper @Inject constructor() {
}
}
private fun Intent.isNotificationIntent(): Boolean = data?.host == NotificationsDeepLinkHelper.NotificationHost
private fun Intent.isLauncherIntent(): Boolean = action == Intent.ACTION_MAIN &&
categories?.contains(Intent.CATEGORY_LAUNCHER) == true ||
categories?.contains(Intent.CATEGORY_DEFAULT) == true
@@ -19,17 +19,11 @@
package ch.protonmail.android.navigation.model
import android.content.Intent
import android.net.Uri
import ch.protonmail.android.mailcommon.domain.model.IntentShareInfo
sealed interface HomeNavigationEvent {
val intent: Intent
data class NotificationIntentReceived(
override val intent: Intent,
val uri: Uri
) : HomeNavigationEvent
data class LauncherIntentReceived(
override val intent: Intent
) : HomeNavigationEvent
@@ -19,23 +19,20 @@
package ch.protonmail.android.navigation.reducer
import java.net.URLEncoder
import ch.protonmail.android.mailcommon.presentation.Effect
import ch.protonmail.android.navigation.model.HomeNavigationEvent
import ch.protonmail.android.navigation.model.HomeState
import timber.log.Timber
import javax.inject.Inject
import ch.protonmail.android.mailcommon.domain.model.encode
import ch.protonmail.android.mailcommon.presentation.Effect
import ch.protonmail.android.mailmessage.domain.model.DraftAction
import ch.protonmail.android.navigation.model.Destination
import ch.protonmail.android.navigation.model.HomeNavigationEvent
import ch.protonmail.android.navigation.model.HomeState
import ch.protonmail.android.navigation.model.NavigationEffect
import timber.log.Timber
import javax.inject.Inject
class HomeNavigationEventsReducer @Inject constructor() {
fun reduce(state: HomeState, event: HomeNavigationEvent): HomeState {
return when (event) {
is HomeNavigationEvent.NotificationIntentReceived ->
handleNotificationIntentReceived(state, event)
is HomeNavigationEvent.LauncherIntentReceived ->
handleLauncherIntentReceived(state)
@@ -50,6 +47,7 @@ class HomeNavigationEventsReducer @Inject constructor() {
is HomeNavigationEvent.InvalidShareIntentReceived ->
handleInvalidShareIntentReceived(state)
is HomeNavigationEvent.UnknownIntentReceived ->
handleUnknownIntentReceived(state)
}
@@ -65,16 +63,6 @@ class HomeNavigationEventsReducer @Inject constructor() {
return state.copy(startedFromLauncher = true)
}
private fun handleNotificationIntentReceived(
state: HomeState,
event: HomeNavigationEvent.NotificationIntentReceived
): HomeState {
Timber.tag("intent-navigation").d("Received notification intent: ${event.uri}")
val navigation = NavigationEffect.NavigateToUri(event.uri)
return state.copy(navigateToEffect = Effect.of(navigation))
}
private fun handleExternalShareIntentReceived(
state: HomeState,
intent: HomeNavigationEvent.ExternalShareIntentReceived
@@ -101,27 +101,6 @@ class HomeNavigationEventsReducerTest {
assertSame(initialState, result)
}
@Test
fun `reduce NotificationIntentReceived sets NavigateToUri effect`() {
// Given
val initialState = HomeState.Initial
val uri = mockk<Uri>()
val event = HomeNavigationEvent.NotificationIntentReceived(
intent = Intent(Intent.ACTION_VIEW, uri),
uri = uri
)
// When
val result = reducer.reduce(initialState, event)
// Then
val expectedNavigation = NavigationEffect.NavigateToUri(uri)
val expectedEffect = Effect.of(expectedNavigation)
assertEquals(expectedEffect, result.navigateToEffect)
assertEquals(initialState.startedFromLauncher, result.startedFromLauncher)
}
@Test
fun `navigate to composer when external share intent is received`() {
// Given
@@ -43,7 +43,6 @@ import ch.protonmail.android.mailmailbox.domain.usecase.RecordMailboxScreenView
import ch.protonmail.android.mailmessage.domain.model.PreviousScheduleSendTime
import ch.protonmail.android.mailmessage.domain.sample.MessageIdSample
import ch.protonmail.android.mailmessage.domain.usecase.CancelScheduleSendMessage
import ch.protonmail.android.mailnotifications.domain.NotificationsDeepLinkHelper
import ch.protonmail.android.mailpinlock.domain.usecase.ShouldPresentPinInsertionScreen
import ch.protonmail.android.mailsession.domain.eventloop.EventLoopErrorSignal
import ch.protonmail.android.mailsession.domain.usecase.ObservePrimaryUserId
@@ -420,28 +419,6 @@ class HomeViewModelTest {
}
}
@Test
fun `should emit a new state with navigation effect when a notification intent is received`() = runTest {
// Given
val uri = mockk<Uri> {
every { this@mockk.host } returns NotificationsDeepLinkHelper.NotificationHost
}
val shareIntent = mockIntent(
action = Intent.ACTION_VIEW,
data = uri,
externalBoolean = true
)
every { newIntentObserver() } returns flowOf(shareIntent)
// When + Then
homeViewModel.state.test {
val effect = awaitItem().navigateToEffect.consume()
assertTrue { effect is NavigationEffect.NavigateToUri }
}
}
@Test
fun `should discard draft when discard draft is called`() = runTest {
// Given
@@ -20,16 +20,15 @@ package ch.protonmail.android.navigation
import android.content.ClipData
import android.content.Intent
import ch.protonmail.android.mailcommon.domain.model.IntentShareInfo
import ch.protonmail.android.navigation.mapper.IntentMapper
import android.net.Uri
import ch.protonmail.android.mailcommon.data.file.IntentExtraKeys
import ch.protonmail.android.mailnotifications.domain.NotificationsDeepLinkHelper
import ch.protonmail.android.mailcommon.domain.model.IntentShareInfo
import ch.protonmail.android.navigation.mapper.IntentMapper
import ch.protonmail.android.navigation.model.HomeNavigationEvent
import io.mockk.every
import io.mockk.mockk
import kotlin.test.assertEquals
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.test.assertTrue
@@ -49,26 +48,6 @@ class IntentMapperTest {
)
private val sampleShareInfoInternal = sampleShareInfoExternal.copy(isExternal = false)
@Test
fun `map notification intent`() {
// Given
val uri = mockk<Uri>()
every { uri.host } returns NotificationsDeepLinkHelper.NotificationHost
val intent = mockIntent(
action = Intent.ACTION_VIEW,
data = uri,
externalBoolean = false
)
// When
val result = mapper.map(intent)
// Then
assertTrue(result is HomeNavigationEvent.NotificationIntentReceived)
assertEquals(uri, result.uri)
}
@Test
fun `map launcher intent with category launcher`() {
// Given