Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package app.k9mail.provider

import app.k9mail.core.android.common.provider.NotificationIconResourceProvider
import app.k9mail.core.ui.legacy.theme2.k9mail.R

class K9AppNotificationIconProvider : NotificationIconResourceProvider {
override val pushNotificationIcon: Int

get() = R.drawable.ic_logo_k9_white
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.k9mail.provider

import app.k9mail.core.android.common.provider.NotificationIconResourceProvider
import com.fsck.k9.preferences.FilePrefixProvider
import net.thunderbird.core.common.provider.AppNameProvider
import net.thunderbird.core.common.provider.BrandNameProvider
Expand All @@ -17,4 +18,8 @@ internal val providerModule = module {
single<ThemeProvider> { K9ThemeProvider() }

single<FeatureThemeProvider> { K9FeatureThemeProvider() }

single<NotificationIconResourceProvider> {
K9AppNotificationIconProvider()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package app.k9mail

import app.k9mail.provider.K9AppNotificationIconProvider
import assertk.assertThat
import assertk.assertions.isEqualTo
import kotlin.test.Test

class K9AppNotificationIconProviderTest {
@Test
fun `provides correct K9 notification icon`() {
val provider = K9AppNotificationIconProvider()
val icon = provider.pushNotificationIcon

assertThat(icon)
.isEqualTo(app.k9mail.core.ui.legacy.theme2.k9mail.R.drawable.ic_logo_k9_white)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.thunderbird.android.provider

import app.k9mail.core.android.common.provider.NotificationIconResourceProvider
import com.fsck.k9.preferences.FilePrefixProvider
import net.thunderbird.core.common.provider.AppNameProvider
import net.thunderbird.core.common.provider.BrandNameProvider
Expand All @@ -17,4 +18,8 @@ internal val providerModule = module {
single<ThemeProvider> { TbThemeProvider() }

single<FeatureThemeProvider> { TbFeatureThemeProvider() }

single<NotificationIconResourceProvider> {
TbAppIconNotificationProvider()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package net.thunderbird.android.provider

import app.k9mail.core.android.common.provider.NotificationIconResourceProvider

class TbAppIconNotificationProvider : NotificationIconResourceProvider {
override val pushNotificationIcon: Int
get() = app.k9mail.core.ui.legacy.theme2.thunderbird.R.drawable.ic_logo_thunderbird_white
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.thunderbird.android

import assertk.assertThat
import assertk.assertions.isEqualTo
import net.thunderbird.android.provider.TbAppIconNotificationProvider
import org.junit.Test

class TbAppIconNotificationProviderTest {
@Test
fun `provides correct Thunderbird notification icon`() {
val provider = TbAppIconNotificationProvider()
val icon = provider.pushNotificationIcon

assertThat(icon)
.isEqualTo(app.k9mail.core.ui.legacy.theme2.thunderbird.R.drawable.ic_logo_thunderbird_white)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package app.k9mail.core.android.common.provider

interface NotificationIconResourceProvider {
val pushNotificationIcon: Int
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
android:viewportWidth="24"
android:viewportHeight="24"
android:width="24dp"
android:height="24dp">
<group>
<clip-path
android:pathData="M0 0H24V24H0V0Z" />
<path
android:pathData="M3.25781 14.7656V16.4063L6.75893 21.6018C7.04193 22.0924 7.5705 22.4221 8.17984 22.4221H15.8363C16.4457 22.4221 16.9742 22.0924 17.2572 21.6018H17.2588L20.7583 16.4063V14.7656H3.25781Z"
android:strokeColor="#FFFFFF"
android:strokeWidth="0.508942" />
<path
android:pathData="M8.7266 2.73438H7.63281V4.92194H8.7266V2.73438Z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M16.3868 2.73438H15.293V4.92194H16.3868V2.73438Z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M9.82422 1.91412V0.820337C9.82422 0.367277 9.45694 0 9.00388 0L5.72253 0C5.26947 0 4.9022 0.367277 4.9022 0.820337V1.91412C4.9022 2.36718 5.26947 2.73446 5.72253 2.73446L9.00388 2.73446C9.45694 2.73446 9.82422 2.36718 9.82422 1.91412Z"
android:fillColor="#FFFFFF"
android:strokeColor="#FFFFFF"
android:strokeWidth="0.508942"
android:strokeLineCap="round" />
<path
android:pathData="M19.1172 1.91412V0.820337C19.1172 0.367277 18.7499 0 18.2969 0L15.0155 0C14.5624 0 14.1952 0.367277 14.1952 0.820337V1.91412C14.1952 2.36718 14.5624 2.73446 15.0155 2.73446L18.2969 2.73446C18.7499 2.73446 19.1172 2.36718 19.1172 1.91412Z"
android:fillColor="#FFFFFF"
android:strokeColor="#FFFFFF"
android:strokeWidth="0.508942"
android:strokeLineCap="round" />
<path
android:pathData="M3.2615 3.82812C2.35257 3.82812 1.62053 4.55934 1.62053 5.46827V14.7658C1.62053 15.6747 2.35257 16.4067 3.2615 16.4067H20.7614C21.6703 16.4067 22.4023 15.6747 22.4023 14.7658V5.46827C22.4023 4.55934 21.6703 3.82812 20.7614 3.82812H3.2615ZM3.68893 5.62317C3.79298 5.59159 3.9053 5.60262 4.00122 5.65382L12.0114 9.92566L20.0216 5.65382C20.0692 5.62847 20.1212 5.61273 20.1749 5.6075C20.2285 5.60227 20.2826 5.60766 20.3342 5.62335C20.3857 5.63904 20.4336 5.66473 20.4752 5.69896C20.5168 5.73318 20.5513 5.77527 20.5766 5.82281C20.602 5.87035 20.6177 5.92241 20.623 5.97603C20.6282 6.02965 20.6228 6.08378 20.6071 6.13531C20.5914 6.18685 20.5657 6.2348 20.5315 6.2764C20.4973 6.31801 20.4552 6.35247 20.4077 6.37781L12.0114 10.8551L3.61521 6.37781C3.56767 6.35247 3.52558 6.31801 3.49136 6.2764C3.45713 6.2348 3.43144 6.18685 3.41575 6.13531C3.40006 6.08378 3.39467 6.02965 3.3999 5.97603C3.40513 5.92241 3.42087 5.87035 3.44622 5.82281C3.47157 5.77521 3.50605 5.73308 3.5477 5.69883C3.58935 5.66457 3.63734 5.63886 3.68893 5.62317Z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M13.6562 22.1485V20.5078C13.6562 20.0548 13.289 19.6875 12.8359 19.6875H11.1952C10.7422 19.6875 10.3749 20.0548 10.3749 20.5078V22.1485C10.3749 22.6016 10.7422 22.9689 11.1952 22.9689H12.8359C13.289 22.9689 13.6562 22.6016 13.6562 22.1485Z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M12.0118 24.0636C12.9179 24.0636 13.6524 23.329 13.6524 22.4229C13.6524 21.5168 12.9179 20.7822 12.0118 20.7822C11.1056 20.7822 10.3711 21.5168 10.3711 22.4229C10.3711 23.329 11.1056 24.0636 12.0118 24.0636Z"
android:fillColor="#FFFFFF" />
</group>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="1024"
android:viewportHeight="1024"
>

<path
android:fillColor="#fff"
android:fillType="evenOdd"
android:pathData="M452,306.5h0.2c22,-77 118,-114.7 216,-114.7 67.5,0 128.3,21.5 169.9,55.4a249.8,249.8 0,0 0,-72.8 14.5,211.7 211.7,0 0,1 84,55.5 258.7,258.7 0,0 0,-49 -3.7A350,350 0,0 1,512 862c-190.3,0 -350,-159.4 -350,-350 0,-30.1 4,-61.2 11.8,-90.4 2,-6 4.8,-12 8.6,-14.1 4.7,-2.7 9,5.3 9.7,8 5.2,19.2 12,37.8 20.6,55.7 -0.7,-40 16.3,-76.4 39.8,-107.9 15.7,-21 30.2,-40.4 36.9,-96.6 0.4,-3.7 4,-6.4 7.6,-5.3 51,16.7 78.2,101.6 74,172.6h0.2a123.4,123.4 0,0 0,-31.3 82.6c0,138.6 146.5,218.4 271.4,206.3l-2.2,-0.2c-14.2,-1.4 -68.1,-6.7 -105.3,-48.7 -3.5,-4 -9.7,-11 -7,-15.6 2.4,-3.9 8.3,-3.7 12.8,-3.5h2.4c95,0 172.1,-62.8 172.1,-140.4 0,-77.6 -77,-140.4 -172.1,-140.4 -39.1,0 -80.6,12.3 -113,35v-0.5c-9,-27.7 -3,-79.1 53,-102.1ZM553,279.8s1.6,18.2 -16.9,24c-21,6.6 -30.3,-11 -30.3,-11s2.6,-12.2 19.7,-17.9c18.2,-6 27.5,4.9 27.5,4.9Z"
/>

<path
android:fillColor="#fff"
android:fillType="evenOdd"
android:pathData="M492.2,551.9a24,24 0,0 0,33.6 0l113.6,-77.3 -96.9,94.5a48,48 0,0 1,-67 0l-96.9,-94.5 113.6,77.3Z"
/>

</vector>
1 change: 1 addition & 0 deletions feature/debug-settings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ dependencies {
implementation(projects.core.outcome)
implementation(projects.feature.mail.account.api)
implementation(projects.feature.notification.api)
implementation(projects.core.android.common)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.PreviewLightDark
import app.k9mail.core.android.common.provider.NotificationIconResourceProvider
import app.k9mail.core.ui.compose.common.koin.koinPreview
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemesLightDark
import kotlinx.coroutines.flow.Flow
Expand All @@ -29,6 +30,11 @@ private fun SecretDebugSettingsScreenPreview() {
override val notifications: StateFlow<Set<InAppNotification>> = MutableStateFlow(emptySet())
}
}
single<NotificationIconResourceProvider> {
object : NotificationIconResourceProvider {
override val pushNotificationIcon: Int = 0
}
}
single<DebugNotificationSectionViewModel> {
DebugNotificationSectionViewModel(
stringsResourceManager = object : StringsResourceManager {
Expand All @@ -55,6 +61,7 @@ private fun SecretDebugSettingsScreenPreview() {
error("not implemented")
},
inAppNotificationStream = get(),
notificationIconResourceProvider = get(),
)
}
} WithContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ val featureDebugSettingsModule = module {
accountManager = get(),
notificationSender = get(),
inAppNotificationStream = get(),
notificationIconResourceProvider = get(),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.thunderbird.feature.debug.settings.notification

import androidx.lifecycle.viewModelScope
import app.k9mail.core.android.common.provider.NotificationIconResourceProvider
import app.k9mail.core.ui.compose.common.mvi.BaseViewModel
import kotlin.reflect.KClass
import kotlinx.collections.immutable.ImmutableList
Expand Down Expand Up @@ -37,6 +38,7 @@ internal class DebugNotificationSectionViewModel(
private val accountManager: AccountManager<BaseAccount>,
private val notificationSender: NotificationSender,
private val inAppNotificationStream: InAppNotificationStream,
private val notificationIconResourceProvider: NotificationIconResourceProvider,
private val mainDispatcher: CoroutineDispatcher = Dispatchers.Main,
ioDispatcher: CoroutineDispatcher = Dispatchers.IO,
) : BaseViewModel<State, Event, Effect>(initialState = State()), DebugNotificationSectionContract.ViewModel {
Expand All @@ -60,6 +62,7 @@ internal class DebugNotificationSectionViewModel(
add(PushServiceNotification.Listening::class)
add(PushServiceNotification.WaitBackgroundSync::class)
add(PushServiceNotification.WaitNetwork::class)
add(PushIconTestNotification::class)
}.toPersistentList()

val inAppNotificationTypes = buildList {
Expand Down Expand Up @@ -281,6 +284,10 @@ internal class DebugNotificationSectionViewModel(

PushServiceNotification.WaitNetwork::class -> PushServiceNotification.WaitNetwork()

PushIconTestNotification::class -> PushIconTestNotification(
pushIcon = notificationIconResourceProvider.pushNotificationIcon,
)

else -> null
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.thunderbird.feature.debug.settings.notification

import net.thunderbird.feature.notification.api.NotificationChannel
import net.thunderbird.feature.notification.api.NotificationSeverity
import net.thunderbird.feature.notification.api.content.AppNotification
import net.thunderbird.feature.notification.api.content.SystemNotification
import net.thunderbird.feature.notification.api.ui.icon.NotificationIcon

class PushIconTestNotification(
pushIcon: Int,
override val accountUuid: String? = null,
) : AppNotification(), SystemNotification {
override val title: String = "Push Icon Test"
override val contentText: String = "Verifying NotificationIconResourceProvider"
override val severity: NotificationSeverity = NotificationSeverity.Information
override val channel: NotificationChannel = NotificationChannel.PushService
override val icon: NotificationIcon = NotificationIcon(systemNotificationIcon = pushIcon)
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ class FakeCoreResourceProvider : CoreResourceProvider {
throw UnsupportedOperationException("not implemented")
}

override val iconPushNotification: Int
get() = throw UnsupportedOperationException("not implemented")

override fun pushNotificationText(notificationState: PushNotificationState): String {
throw UnsupportedOperationException("not implemented")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.fsck.k9.resources

import android.content.Context
import app.k9mail.core.ui.legacy.designsystem.atom.icon.Icons
import com.fsck.k9.CoreResourceProvider
import com.fsck.k9.notification.PushNotificationState
import com.fsck.k9.ui.R
Expand Down Expand Up @@ -35,8 +34,6 @@ class K9CoreResourceProvider(
override fun searchUnifiedFoldersTitle(): String = context.getString(R.string.integrated_inbox_title)
override fun searchUnifiedFoldersDetail(): String = context.getString(R.string.integrated_inbox_detail)

override val iconPushNotification: Int = Icons.Outlined.Notifications

override fun pushNotificationText(notificationState: PushNotificationState): String {
val resId = when (notificationState) {
PushNotificationState.INITIALIZING -> R.string.push_notification_state_initializing
Expand Down
2 changes: 1 addition & 1 deletion legacy/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies {
testImplementation(projects.backend.imap)
testImplementation(projects.mail.protocols.smtp)
testImplementation(projects.legacy.storage)

testImplementation(projects.core.android.common)
testImplementation(libs.kotlin.test)
testImplementation(libs.kotlin.reflect)
testImplementation(libs.robolectric)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ interface CoreResourceProvider {

fun searchUnifiedFoldersTitle(): String
fun searchUnifiedFoldersDetail(): String

val iconPushNotification: Int
fun pushNotificationText(notificationState: PushNotificationState): String
fun pushNotificationInfoText(): String
fun pushNotificationGrantAlarmPermissionText(): String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ val coreNotificationModule = module {
actionBuilder = get(),
resourceProvider = get(),
outboxFolderManager = get(),
iconResourceProvider = get(),
)
}
single {
Expand Down Expand Up @@ -127,6 +128,7 @@ val coreNotificationModule = module {
resourceProvider = get(),
notificationChannelManager = get(),
notificationManager = get(),
iconResourceProvider = get(),
)
}
single {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.fsck.k9.notification

import android.app.Notification
import android.app.PendingIntent
import android.content.Context
Expand All @@ -10,13 +9,15 @@ import android.provider.Settings
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.PendingIntentCompat
import app.k9mail.core.android.common.provider.NotificationIconResourceProvider
import com.fsck.k9.CoreResourceProvider

private const val PUSH_INFO_ACTION = "app.k9mail.action.PUSH_INFO"

internal class PushNotificationManager(
private val context: Context,
private val resourceProvider: CoreResourceProvider,
private val iconResourceProvider: NotificationIconResourceProvider,
private val notificationChannelManager: NotificationChannelManager,
private val notificationManager: NotificationManagerCompat,
) {
Expand Down Expand Up @@ -53,7 +54,7 @@ internal class PushNotificationManager(

private fun createNotification(): Notification {
return NotificationCompat.Builder(context, notificationChannelManager.pushChannelId)
.setSmallIcon(resourceProvider.iconPushNotification)
.setSmallIcon(iconResourceProvider.pushNotificationIcon)
.setContentTitle(resourceProvider.pushNotificationText(notificationState))
.setContentText(getContentText())
.setContentIntent(getContentIntent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.fsck.k9.notification
import android.app.Notification
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import app.k9mail.core.android.common.provider.NotificationIconResourceProvider
import com.fsck.k9.mailstore.LocalFolder
import net.thunderbird.core.android.account.LegacyAccountDto
import net.thunderbird.feature.mail.folder.api.OutboxFolderManager
Expand All @@ -12,6 +13,7 @@ internal class SyncNotificationController(
private val actionBuilder: NotificationActionCreator,
private val resourceProvider: NotificationResourceProvider,
private val outboxFolderManager: OutboxFolderManager,
private val iconResourceProvider: NotificationIconResourceProvider,
) {
fun showSendingNotification(account: LegacyAccountDto) {
val accountName = account.displayName
Expand Down Expand Up @@ -60,7 +62,7 @@ internal class SyncNotificationController(

val notificationBuilder = notificationHelper
.createNotificationBuilder(account, NotificationChannelManager.ChannelType.MISCELLANEOUS)
.setSmallIcon(resourceProvider.iconCheckingMail)
.setSmallIcon(iconResourceProvider.pushNotificationIcon)
.setColor(account.chipColor)
.setWhen(System.currentTimeMillis())
.setOngoing(true)
Expand All @@ -70,7 +72,6 @@ internal class SyncNotificationController(
.setContentIntent(showMessageListPendingIntent)
.setPublicVersion(createFetchingMailLockScreenNotification(account))
.setCategory(NotificationCompat.CATEGORY_SERVICE)

notificationManager.notify(notificationId, notificationBuilder.build())
}

Expand All @@ -81,7 +82,7 @@ internal class SyncNotificationController(

val notificationBuilder = notificationHelper
.createNotificationBuilder(account, NotificationChannelManager.ChannelType.MISCELLANEOUS)
.setSmallIcon(resourceProvider.iconCheckingMail)
.setSmallIcon(iconResourceProvider.pushNotificationIcon)
.setColor(account.chipColor)
.setWhen(System.currentTimeMillis())
.setOngoing(true)
Expand Down
Loading
Loading