Refactor notifications (#4883)

Also fixes https://github.com/tuskyapp/Tusky/issues/4858.
But apart from that there should be no functional change.
This commit is contained in:
UlrichKu 2025-01-22 21:16:33 +01:00 committed by GitHub
commit 3a3e056572
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 1072 additions and 1217 deletions

View file

@ -14,7 +14,7 @@ import androidx.work.testing.WorkManagerTestInitHelper
import at.connyduck.calladapter.networkresult.NetworkResult
import com.keylesspalace.tusky.appstore.EventHub
import com.keylesspalace.tusky.components.accountlist.AccountListActivity
import com.keylesspalace.tusky.components.systemnotifications.NotificationHelper
import com.keylesspalace.tusky.components.systemnotifications.NotificationService
import com.keylesspalace.tusky.db.AccountManager
import com.keylesspalace.tusky.db.entity.AccountEntity
import com.keylesspalace.tusky.entity.Account
@ -100,12 +100,19 @@ class MainActivityTest {
val notificationManager = context.getSystemService(NotificationManager::class.java)
val shadowNotificationManager = shadowOf(notificationManager)
NotificationHelper.createNotificationChannelsForAccount(accountEntity, context)
val notificationService = NotificationService(
notificationManager,
mock {
on { areNotificationsEnabled() } doReturn true
},
mock(),
context,
)
notificationService.createNotificationChannelsForAccount(accountEntity)
runInBackground {
val notification = NotificationHelper.makeBaseNotification(
context,
notificationManager,
val notification = notificationService.createBaseNotification(
Notification(
type = type,
id = "id",
@ -161,7 +168,8 @@ class MainActivityTest {
api = api,
eventHub = eventHub,
accountManager = accountManager,
shareShortcutHelper = mock()
shareShortcutHelper = mock(),
notificationService = mock(),
)
val testViewModelFactory = viewModelFactory {
initializer { viewModel }