Rename LockScreenNotifications to LockScreenNotificationCreator
This commit is contained in:
parent
ad5b9a300b
commit
13f64bd0d7
7 changed files with 28 additions and 28 deletions
|
@ -34,7 +34,7 @@ val coreNotificationModule = module {
|
|||
single { NotificationContentCreator(get(), get()) }
|
||||
single { SingleMessageNotifications(get(), get(), get(), get()) }
|
||||
single { MessageSummaryNotifications(get(), get(), get(), get(), get()) }
|
||||
single { LockScreenNotification(get(), get()) }
|
||||
single { LockScreenNotificationCreator(get(), get()) }
|
||||
single {
|
||||
PushNotificationManager(
|
||||
context = get(),
|
||||
|
|
|
@ -5,7 +5,7 @@ import androidx.core.app.NotificationCompat
|
|||
import com.fsck.k9.K9
|
||||
import com.fsck.k9.K9.LockScreenNotificationVisibility
|
||||
|
||||
internal class LockScreenNotification(
|
||||
internal class LockScreenNotificationCreator(
|
||||
private val notificationHelper: NotificationHelper,
|
||||
private val resourceProvider: NotificationResourceProvider
|
||||
) {
|
|
@ -12,7 +12,7 @@ import com.fsck.k9.notification.NotificationIds.getNewMailSummaryNotificationId
|
|||
internal open class MessageSummaryNotifications(
|
||||
private val notificationHelper: NotificationHelper,
|
||||
private val actionCreator: NotificationActionCreator,
|
||||
private val lockScreenNotification: LockScreenNotification,
|
||||
private val lockScreenNotificationCreator: LockScreenNotificationCreator,
|
||||
private val singleMessageNotifications: SingleMessageNotifications,
|
||||
private val resourceProvider: NotificationResourceProvider
|
||||
) {
|
||||
|
@ -36,7 +36,7 @@ internal open class MessageSummaryNotifications(
|
|||
val deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent(account, notificationId)
|
||||
builder.setDeleteIntent(deletePendingIntent)
|
||||
|
||||
lockScreenNotification.configureLockScreenNotification(builder, notificationData)
|
||||
lockScreenNotificationCreator.configureLockScreenNotification(builder, notificationData)
|
||||
|
||||
val notificationSetting = account.notificationSetting
|
||||
notificationHelper.configureNotification(
|
||||
|
|
|
@ -10,7 +10,7 @@ internal open class SingleMessageNotifications(
|
|||
private val notificationHelper: NotificationHelper,
|
||||
private val actionCreator: NotificationActionCreator,
|
||||
private val resourceProvider: NotificationResourceProvider,
|
||||
private val lockScreenNotification: LockScreenNotification,
|
||||
private val lockScreenNotificationCreator: LockScreenNotificationCreator,
|
||||
) {
|
||||
|
||||
fun buildSingleMessageNotification(account: Account, holder: NotificationHolder): Notification {
|
||||
|
@ -29,7 +29,7 @@ internal open class SingleMessageNotifications(
|
|||
return createSingleMessageNotificationBuilder(account, holder, notificationId)
|
||||
.setNotificationSilent()
|
||||
.apply {
|
||||
lockScreenNotification.configureLockScreenNotification(this, notificationData)
|
||||
lockScreenNotificationCreator.configureLockScreenNotification(this, notificationData)
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ import org.mockito.kotlin.stubbing
|
|||
private const val ACCOUNT_NAME = "Hugo"
|
||||
private const val NEW_MESSAGE_COUNT = 3
|
||||
|
||||
class LockScreenNotificationTest : RobolectricTest() {
|
||||
class LockScreenNotificationCreatorTest : RobolectricTest() {
|
||||
private val resourceProvider = TestNotificationResourceProvider()
|
||||
private val builder = createFakeNotificationBuilder()
|
||||
private val publicBuilder = createFakeNotificationBuilder()
|
||||
private var notificationData = createFakeNotificationData()
|
||||
private var lockScreenNotification = LockScreenNotification(
|
||||
private var notificationCreator = LockScreenNotificationCreator(
|
||||
notificationHelper = createFakeNotificationHelper(publicBuilder),
|
||||
resourceProvider = resourceProvider
|
||||
)
|
||||
|
@ -33,7 +33,7 @@ class LockScreenNotificationTest : RobolectricTest() {
|
|||
fun configureLockScreenNotification_NOTHING() {
|
||||
K9.lockScreenNotificationVisibility = LockScreenNotificationVisibility.NOTHING
|
||||
|
||||
lockScreenNotification.configureLockScreenNotification(builder, notificationData)
|
||||
notificationCreator.configureLockScreenNotification(builder, notificationData)
|
||||
|
||||
verify(builder).setVisibility(NotificationCompat.VISIBILITY_SECRET)
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class LockScreenNotificationTest : RobolectricTest() {
|
|||
fun configureLockScreenNotification_APP_NAME() {
|
||||
K9.lockScreenNotificationVisibility = LockScreenNotificationVisibility.APP_NAME
|
||||
|
||||
lockScreenNotification.configureLockScreenNotification(builder, notificationData)
|
||||
notificationCreator.configureLockScreenNotification(builder, notificationData)
|
||||
|
||||
verify(builder).setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class LockScreenNotificationTest : RobolectricTest() {
|
|||
fun configureLockScreenNotification_EVERYTHING() {
|
||||
K9.lockScreenNotificationVisibility = LockScreenNotificationVisibility.EVERYTHING
|
||||
|
||||
lockScreenNotification.configureLockScreenNotification(builder, notificationData)
|
||||
notificationCreator.configureLockScreenNotification(builder, notificationData)
|
||||
|
||||
verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class LockScreenNotificationTest : RobolectricTest() {
|
|||
on { holderForLatestNotification } doReturn holder
|
||||
}
|
||||
|
||||
lockScreenNotification.configureLockScreenNotification(builder, notificationData)
|
||||
notificationCreator.configureLockScreenNotification(builder, notificationData)
|
||||
|
||||
verify(publicBuilder).setSmallIcon(resourceProvider.iconNewMail)
|
||||
verify(publicBuilder).setNumber(1)
|
||||
|
@ -88,7 +88,7 @@ class LockScreenNotificationTest : RobolectricTest() {
|
|||
on { getContentForSummaryNotification() } doReturn listOf(content1, content2, content3)
|
||||
}
|
||||
|
||||
lockScreenNotification.configureLockScreenNotification(builder, notificationData)
|
||||
notificationCreator.configureLockScreenNotification(builder, notificationData)
|
||||
|
||||
verify(publicBuilder).setSmallIcon(resourceProvider.iconNewMail)
|
||||
verify(publicBuilder).setNumber(NEW_MESSAGE_COUNT)
|
||||
|
@ -103,7 +103,7 @@ class LockScreenNotificationTest : RobolectricTest() {
|
|||
fun configureLockScreenNotification_SENDERS_makeSureWeGetEnoughSenderNames() {
|
||||
assertThat(
|
||||
NotificationData.MAX_NUMBER_OF_MESSAGES_FOR_SUMMARY_NOTIFICATION >=
|
||||
LockScreenNotification.MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION
|
||||
LockScreenNotificationCreator.MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION
|
||||
).isTrue()
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class LockScreenNotificationTest : RobolectricTest() {
|
|||
val content5 = createNotificationContent("ed@example.com")
|
||||
val content6 = createNotificationContent("fiona@example.com")
|
||||
|
||||
val result = lockScreenNotification.createCommaSeparatedListOfSenders(
|
||||
val result = notificationCreator.createCommaSeparatedListOfSenders(
|
||||
listOf(content1, content2, content3, content4, content5, content6)
|
||||
)
|
||||
|
||||
|
@ -132,7 +132,7 @@ class LockScreenNotificationTest : RobolectricTest() {
|
|||
on { newMessagesCount } doReturn NEW_MESSAGE_COUNT
|
||||
}
|
||||
|
||||
lockScreenNotification.configureLockScreenNotification(builder, notificationData)
|
||||
notificationCreator.configureLockScreenNotification(builder, notificationData)
|
||||
|
||||
verify(publicBuilder).setSmallIcon(resourceProvider.iconNewMail)
|
||||
verify(publicBuilder).setNumber(NEW_MESSAGE_COUNT)
|
|
@ -35,7 +35,7 @@ class SingleMessageNotificationsTest : RobolectricTest() {
|
|||
notificationHelper = createNotificationHelper(builder),
|
||||
actionCreator = actionCreator,
|
||||
resourceProvider = resourceProvider,
|
||||
lockScreenNotification = mock()
|
||||
lockScreenNotificationCreator = mock()
|
||||
)
|
||||
|
||||
@Test
|
||||
|
|
|
@ -41,8 +41,8 @@ class SummaryNotificationsTest : RobolectricTest() {
|
|||
private val notificationData = createFakeNotificationData(account)
|
||||
private val builder = createFakeNotificationBuilder()
|
||||
private val builder2 = createFakeNotificationBuilder()
|
||||
private val lockScreenNotification = mock<LockScreenNotification>()
|
||||
private val notifications = createSummaryNotifications(builder, lockScreenNotification)
|
||||
private val lockScreenNotificationCreator = mock<LockScreenNotificationCreator>()
|
||||
private val notifications = createSummaryNotifications(builder, lockScreenNotificationCreator)
|
||||
|
||||
@Test
|
||||
fun buildSummaryNotification_withSingleMessageNotification() {
|
||||
|
@ -64,7 +64,7 @@ class SummaryNotificationsTest : RobolectricTest() {
|
|||
verify(builder).addAction(resourceProvider.iconReply, "Reply", null)
|
||||
verify(builder).addAction(resourceProvider.iconMarkAsRead, "Mark Read", null)
|
||||
verify(builder).addAction(resourceProvider.iconDelete, "Delete", null)
|
||||
verify(lockScreenNotification).configureLockScreenNotification(builder, notificationData)
|
||||
verify(lockScreenNotificationCreator).configureLockScreenNotification(builder, notificationData)
|
||||
assertThat(result).isEqualTo(notification)
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ class SummaryNotificationsTest : RobolectricTest() {
|
|||
verify(notifications.inboxStyle).addLine(SUMMARY_2)
|
||||
verify(builder).addAction(resourceProvider.iconMarkAsRead, "Mark Read", null)
|
||||
verify(builder).addAction(resourceProvider.iconDelete, "Delete", null)
|
||||
verify(lockScreenNotification).configureLockScreenNotification(builder, notificationData)
|
||||
verify(lockScreenNotificationCreator).configureLockScreenNotification(builder, notificationData)
|
||||
assertThat(result).isEqualTo(notification)
|
||||
}
|
||||
|
||||
|
@ -165,20 +165,20 @@ class SummaryNotificationsTest : RobolectricTest() {
|
|||
|
||||
private fun createSummaryNotifications(
|
||||
builder: NotificationCompat.Builder,
|
||||
lockScreenNotification: LockScreenNotification
|
||||
lockScreenNotificationCreator: LockScreenNotificationCreator
|
||||
): TestMessageSummaryNotifications {
|
||||
val notificationHelper = createFakeNotificationHelper(builder)
|
||||
val singleMessageNotifications = TestSingleMessageNotifications(
|
||||
notificationHelper = notificationHelper,
|
||||
actionCreator = mock(),
|
||||
resourceProvider = resourceProvider,
|
||||
lockScreenNotification = mock()
|
||||
lockScreenNotificationCreator = mock()
|
||||
)
|
||||
|
||||
return TestMessageSummaryNotifications(
|
||||
notificationHelper = notificationHelper,
|
||||
actionCreator = mock(),
|
||||
lockScreenNotification = lockScreenNotification,
|
||||
lockScreenNotificationCreator = lockScreenNotificationCreator,
|
||||
singleMessageNotifications = singleMessageNotifications,
|
||||
resourceProvider = resourceProvider
|
||||
)
|
||||
|
@ -197,13 +197,13 @@ class SummaryNotificationsTest : RobolectricTest() {
|
|||
internal class TestMessageSummaryNotifications(
|
||||
notificationHelper: NotificationHelper,
|
||||
actionCreator: NotificationActionCreator,
|
||||
lockScreenNotification: LockScreenNotification,
|
||||
lockScreenNotificationCreator: LockScreenNotificationCreator,
|
||||
singleMessageNotifications: SingleMessageNotifications,
|
||||
resourceProvider: NotificationResourceProvider
|
||||
) : MessageSummaryNotifications(
|
||||
notificationHelper,
|
||||
actionCreator,
|
||||
lockScreenNotification,
|
||||
lockScreenNotificationCreator,
|
||||
singleMessageNotifications,
|
||||
resourceProvider
|
||||
) {
|
||||
|
@ -218,12 +218,12 @@ class SummaryNotificationsTest : RobolectricTest() {
|
|||
notificationHelper: NotificationHelper,
|
||||
actionCreator: NotificationActionCreator,
|
||||
resourceProvider: NotificationResourceProvider,
|
||||
lockScreenNotification: LockScreenNotification
|
||||
lockScreenNotificationCreator: LockScreenNotificationCreator
|
||||
) : SingleMessageNotifications(
|
||||
notificationHelper,
|
||||
actionCreator,
|
||||
resourceProvider,
|
||||
lockScreenNotification
|
||||
lockScreenNotificationCreator
|
||||
) {
|
||||
override fun createBigTextStyle(builder: NotificationCompat.Builder?): NotificationCompat.BigTextStyle {
|
||||
return bigTextStyle
|
||||
|
|
Loading…
Reference in a new issue