diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index ed0a13e1d..dc4e9da27 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -167,6 +167,8 @@ LongMethod:SrvServiceDiscoveryTest.kt$SrvServiceDiscoveryTest$@Test fun discover_withRequiredServices_shouldCorrectlyPrioritize() LongMethod:TextBodyBuilderTest.kt$TextBodyBuilderTest.Companion$@JvmStatic @Parameterized.Parameters(name = "{index}: {0}") fun data(): Collection<TestData> LongMethod:ThreadMessageOperationsTest.kt$ThreadMessageOperationsTest$@Test fun `merge two existing threads`() + LongParameterList:Colors.kt$( primary: Color = MaterialColor.deep_purple_200, primaryVariant: Color = MaterialColor.deep_purple_50, secondary: Color = MaterialColor.cyan_300, secondaryVariant: Color = MaterialColor.cyan_100, background: Color = MaterialColor.gray_800, surface: Color = MaterialColor.gray_900, error: Color = MaterialColor.red_300, onPrimary: Color = Color.Black, onSecondary: Color = Color.Black, onBackground: Color = Color.White, onSurface: Color = Color.White, onError: Color = Color.Black, ) + LongParameterList:Colors.kt$( primary: Color = MaterialColor.deep_purple_600, primaryVariant: Color = MaterialColor.deep_purple_900, secondary: Color = MaterialColor.cyan_600, secondaryVariant: Color = MaterialColor.cyan_800, background: Color = MaterialColor.gray_200, surface: Color = Color.White, error: Color = MaterialColor.red_600, onPrimary: Color = Color.White, onSecondary: Color = Color.Black, onBackground: Color = Color.Black, onSurface: Color = Color.Black, onError: Color = Color.White, ) LongParameterList:CopyMessageOperations.kt$DatabaseMessagePart$( val id: Long, val type: Int, val root: Long, val parent: Long, val seq: Int, val mimeType: String?, val decodedBodySize: Long?, val displayName: String?, val header: ByteArray?, val encoding: String?, val charset: String?, val dataLocation: Int, val data: ByteArray?, val preamble: ByteArray?, val epilogue: ByteArray?, val boundary: String?, val contentId: String?, val serverExtra: String?, ) LongParameterList:FolderHelpers.kt$( name: String = "irrelevant", type: String = "regular", serverId: String? = null, isLocalOnly: Boolean = true, integrate: Boolean = false, inTopGroup: Boolean = false, displayClass: String = "NO_CLASS", syncClass: String? = "INHERITED", notifyClass: String? = "INHERITED", pushClass: String? = "SECOND_CLASS", lastUpdated: Long = 0L, unreadCount: Int = 0, visibleLimit: Int = 25, status: String? = null, flaggedCount: Int = 0, moreMessages: String = "unknown", ) LongParameterList:ImapSync.kt$ImapSync$( remoteFolder: ImapFolder, backendFolder: BackendFolder, largeMessages: List<ImapMessage>, progress: AtomicInteger, downloadedMessageCount: AtomicInteger, todo: Int, highestKnownUid: Long?, listener: SyncListener, maxDownloadSize: Int, ) diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml index 51bbf1d39..8b0694aeb 100644 --- a/config/detekt/detekt.yml +++ b/config/detekt/detekt.yml @@ -729,7 +729,7 @@ style: Compose: CompositionLocalAllowlist: active: true - allowedCompositionLocals: [LocalElevations, LocalImages, LocalSizes, LocalSpacings] + allowedCompositionLocals: [LocalColors, LocalElevations, LocalImages, LocalSizes, LocalSpacings] ContentEmitterReturningValues: active: true # You can optionally add your own composables here diff --git a/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/Colors.kt b/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/Colors.kt new file mode 100644 index 000000000..6c9712fe1 --- /dev/null +++ b/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/Colors.kt @@ -0,0 +1,101 @@ +package app.k9mail.core.ui.compose.theme + +import androidx.compose.runtime.Immutable +import androidx.compose.runtime.staticCompositionLocalOf +import androidx.compose.ui.graphics.Color +import androidx.compose.material.Colors as MaterialColors + +@Immutable +data class Colors( + val primary: Color, + val primaryVariant: Color, + val secondary: Color, + val secondaryVariant: Color, + val background: Color, + val surface: Color, + val error: Color, + val onPrimary: Color, + val onSecondary: Color, + val onBackground: Color, + val onSurface: Color, + val onError: Color, + val isLight: Boolean, +) + +fun lightColors( + primary: Color = Color(0xFF6200EE), + primaryVariant: Color = Color(0xFF3700B3), + secondary: Color = Color(0xFF03DAC6), + secondaryVariant: Color = Color(0xFF018786), + background: Color = Color.White, + surface: Color = Color.White, + error: Color = Color(0xFFB00020), + onPrimary: Color = Color.White, + onSecondary: Color = Color.Black, + onBackground: Color = Color.Black, + onSurface: Color = Color.Black, + onError: Color = Color.White, +) = Colors( + primary = primary, + primaryVariant = primaryVariant, + secondary = secondary, + secondaryVariant = secondaryVariant, + background = background, + surface = surface, + error = error, + onPrimary = onPrimary, + onSecondary = onSecondary, + onBackground = onBackground, + onSurface = onSurface, + onError = onError, + isLight = true, +) + +fun darkColors( + primary: Color = Color(0xFFBB86FC), + primaryVariant: Color = Color(0xFF3700B3), + secondary: Color = Color(0xFF03DAC6), + secondaryVariant: Color = secondary, + background: Color = Color(0xFF121212), + surface: Color = Color(0xFF121212), + error: Color = Color(0xFFCF6679), + onPrimary: Color = Color.Black, + onSecondary: Color = Color.Black, + onBackground: Color = Color.White, + onSurface: Color = Color.White, + onError: Color = Color.Black, +) = Colors( + primary = primary, + primaryVariant = primaryVariant, + secondary = secondary, + secondaryVariant = secondaryVariant, + background = background, + surface = surface, + error = error, + onPrimary = onPrimary, + onSecondary = onSecondary, + onBackground = onBackground, + onSurface = onSurface, + onError = onError, + isLight = false, +) + +internal fun Colors.toMaterialColors(): MaterialColors { + return MaterialColors( + primary = primary, + primaryVariant = primaryVariant, + secondary = secondary, + secondaryVariant = secondaryVariant, + background = background, + surface = surface, + error = error, + onPrimary = onPrimary, + onSecondary = onSecondary, + onBackground = onBackground, + onSurface = onSurface, + onError = onError, + isLight = isLight, + ) +} + +internal val LocalColors = staticCompositionLocalOf { lightColors() } diff --git a/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/K9Theme.kt b/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/K9Theme.kt index 9583b0de6..cddd2c28d 100644 --- a/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/K9Theme.kt +++ b/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/K9Theme.kt @@ -1,8 +1,6 @@ package app.k9mail.core.ui.compose.theme import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors import androidx.compose.runtime.Composable private val k9LightColorPalette = lightColors( diff --git a/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/MainTheme.kt b/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/MainTheme.kt index 7510b9ad0..cc92190a4 100644 --- a/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/MainTheme.kt +++ b/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/MainTheme.kt @@ -1,7 +1,6 @@ package app.k9mail.core.ui.compose.theme import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.Colors import androidx.compose.material.MaterialTheme import androidx.compose.material.Shapes import androidx.compose.material.Typography @@ -30,13 +29,14 @@ fun MainTheme( } CompositionLocalProvider( + LocalColors provides colors, LocalElevations provides Elevations(), LocalImages provides images, LocalSizes provides Sizes(), LocalSpacings provides Spacings(), ) { MaterialTheme( - colors = colors, + colors = colors.toMaterialColors(), typography = typography, shapes = shapes, content = content, @@ -48,7 +48,7 @@ object MainTheme { val colors: Colors @Composable @ReadOnlyComposable - get() = MaterialTheme.colors + get() = LocalColors.current val typography: Typography @Composable diff --git a/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/ThunderbirdTheme.kt b/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/ThunderbirdTheme.kt index 65f98ba71..33b2845cb 100644 --- a/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/ThunderbirdTheme.kt +++ b/core/ui/compose/theme/src/main/java/app/k9mail/core/ui/compose/theme/ThunderbirdTheme.kt @@ -1,8 +1,6 @@ package app.k9mail.core.ui.compose.theme import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors import androidx.compose.runtime.Composable private val thunderbirdLightColorPalette = lightColors(