From 9789052011f611c4e8f25d1eed304df4468e708d Mon Sep 17 00:00:00 2001 From: bhanu-dev82 Date: Sat, 21 Nov 2026 17:30:01 +0530 Subject: [PATCH 1/3] feat: point the Compose theme at the shared Scribe colors (#782) --- CHANGELOG.md | 1 + app/src/main/java/be/scri/ui/theme/Colors.kt | 100 ++++++++++++------ .../main/java/be/scri/ui/theme/ScribeTheme.kt | 47 +------- .../be/scri/ui/theme/ScribeColorSchemeTest.kt | 41 +++++++ 4 files changed, 113 insertions(+), 76 deletions(-) create mode 100644 app/src/test/kotlin/be/scri/ui/theme/ScribeColorSchemeTest.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index dde049ac9..c3368e005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/). ### 🎨 Design +- Compose theme colors now come from the shared `scribe_*` resources. Dark mode button text stays orange on orange. The dark caption uses the named token `#CAC4D0`, the same grey this slot already used ([#782](https://github.com/scribe-org/Scribe-Android/issues/782)). - Named `scribe_*` color tokens record the light and dark hexes the app already uses. No screen color changes ([#781](https://github.com/scribe-org/Scribe-Android/issues/781)). - The Scribe key and command bar where Scribe commands are triggered ([#16](https://github.com/scribe-org/Scribe-Android/issues/16)). - 3x2 and other conjugation tables from which conjugations can be selected in the Conjugate command ([#267](https://github.com/scribe-org/Scribe-Android/issues/267), [#270](https://github.com/scribe-org/Scribe-Android/issues/270), [#496](https://github.com/scribe-org/Scribe-Android/issues/496), [#523](https://github.com/scribe-org/Scribe-Android/issues/523)). diff --git a/app/src/main/java/be/scri/ui/theme/Colors.kt b/app/src/main/java/be/scri/ui/theme/Colors.kt index 86c72bfe0..5624a6f03 100644 --- a/app/src/main/java/be/scri/ui/theme/Colors.kt +++ b/app/src/main/java/be/scri/ui/theme/Colors.kt @@ -2,42 +2,76 @@ package be.scri.ui.theme +import android.content.Context +import android.content.res.Configuration +import androidx.compose.material3.ColorScheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme import androidx.compose.ui.graphics.Color - -val theme_light_card_view_color = Color(color = 0xFFFFFFFF) -val theme_light_button_color = Color(color = 0xFFFDAD0D) -val theme_light_button_text_color = Color(color = 0xFF000000) -val theme_light_background = Color(color = 0xFF5EB5E8) -val theme_light_text_color = Color(color = 0xFF000000) -val theme_light_selected_button_color = Color(color = 0xFF235270) -val theme_light_switch_container_color = Color(color = 0xFFAAAAAA) -val theme_light_switch_selector_color = Color(color = 0xFFFEDE9E) -val theme_light_unchecked_switch_selector_color = Color(color = 0xFFEEEEEE) -val theme_light_corner_button_color = Color(color = 0xFFFDAD0D) -val theme_light_success_color = Color(color = 0xFF9BC53D) -val theme_light_caption_color = Color(color = 0xE558564B) - -val theme_dark_card_view_color = Color(color = 0xFF000000) -val theme_dark_button_color = Color(color = 0xFFD17B0F) -val theme_dark_button_text_color = Color(color = 0xFFD17B0F) -val theme_dark_background = Color(color = 0xFF235270) -val theme_dark_text_color = Color(color = 0xFFFFFFFF) -val theme_dark_button_outline_color = Color(color = 0xFFD17B0F) -val theme_dark_selected_button_color = Color(color = 0xFF5EB5E8) -val theme_dark_switch_container_color = Color(color = 0xFFAAAAAA) -val theme_dark_switch_selector_color = Color(color = 0xFF2A1903) -val theme_dark_unchecked_switch_selector_color = Color(color = 0xFF2D2D2D) -val theme_dark_corner_button_color = Color(color = 0xFF2A1903) -val theme_dark_success_color = Color(color = 0xFF08A045) +import androidx.core.content.ContextCompat +import be.scri.R /** - * Custom colors for use throughout the application. + * Compose color scheme from the shared `scribe_*` resources. + * [dark] follows the app theme argument, not the device night mode. */ -@Suppress("MagicNumber") -val BlueSky = Color(0xFF4478a9) +fun Context.scribeColorScheme(dark: Boolean): ColorScheme { + val themed = configurationContext(dark) + val button = themed.scribeColor(R.color.scribe_button) + val onButton = themed.scribeColor(R.color.scribe_on_button) + val background = themed.scribeColor(R.color.scribe_background) + val text = themed.scribeColor(R.color.scribe_text) + val surface = themed.scribeColor(R.color.scribe_surface) + val outline = themed.scribeColor(R.color.scribe_outline) + val selected = themed.scribeColor(R.color.scribe_selected) + val switchThumb = themed.scribeColor(R.color.scribe_switch_thumb) + val switchTrack = themed.scribeColor(R.color.scribe_switch_track) + val switchThumbOff = themed.scribeColor(R.color.scribe_switch_thumb_off) + val cornerButton = themed.scribeColor(R.color.scribe_corner_button) + val success = themed.scribeColor(R.color.scribe_success) + val caption = themed.scribeColor(R.color.scribe_caption) + return if (dark) { + darkColorScheme( + primary = button, + onPrimary = onButton, + background = background, + onBackground = text, + surface = surface, + onSurface = text, + outline = outline, + secondary = selected, + tertiary = switchThumb, + tertiaryContainer = switchTrack, + outlineVariant = switchThumbOff, + surfaceContainer = cornerButton, + surfaceVariant = success, + onSurfaceVariant = caption, + ) + } else { + lightColorScheme( + primary = button, + onPrimary = onButton, + background = background, + onBackground = text, + surface = surface, + onSurface = text, + outline = outline, + secondary = selected, + tertiary = switchThumb, + tertiaryContainer = switchTrack, + outlineVariant = switchThumbOff, + surfaceContainer = cornerButton, + surfaceVariant = success, + onSurfaceVariant = caption, + ) + } +} -@Suppress("MagicNumber") -val NightSky = Color(0xFF333333) +private fun Context.configurationContext(dark: Boolean): Context { + val nightMode = if (dark) Configuration.UI_MODE_NIGHT_YES else Configuration.UI_MODE_NIGHT_NO + val config = Configuration(resources.configuration) + config.uiMode = (config.uiMode and Configuration.UI_MODE_NIGHT_MASK.inv()) or nightMode + return createConfigurationContext(config) +} -@Suppress("MagicNumber") -val BorderColor = Color(0x40000000) +private fun Context.scribeColor(id: Int): Color = Color(color = ContextCompat.getColor(this, id)) diff --git a/app/src/main/java/be/scri/ui/theme/ScribeTheme.kt b/app/src/main/java/be/scri/ui/theme/ScribeTheme.kt index 644648cbb..2114b2fdf 100644 --- a/app/src/main/java/be/scri/ui/theme/ScribeTheme.kt +++ b/app/src/main/java/be/scri/ui/theme/ScribeTheme.kt @@ -3,44 +3,9 @@ package be.scri.ui.theme import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.darkColorScheme -import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable - -private val LightColors = - lightColorScheme( - primary = theme_light_button_color, - onPrimary = theme_light_button_text_color, - background = theme_light_background, - onBackground = theme_light_text_color, - surface = theme_light_card_view_color, - onSurface = theme_light_text_color, - outline = theme_light_button_color, - secondary = theme_light_selected_button_color, - tertiary = theme_light_switch_selector_color, - tertiaryContainer = theme_light_switch_container_color, - outlineVariant = theme_light_unchecked_switch_selector_color, - surfaceContainer = theme_light_corner_button_color, - surfaceVariant = theme_light_success_color, - onSurfaceVariant = theme_light_caption_color, - ) - -private val DarkColors = - darkColorScheme( - primary = theme_dark_button_color, - onPrimary = theme_dark_button_text_color, - background = theme_dark_background, - onBackground = theme_dark_text_color, - surface = theme_dark_card_view_color, - onSurface = theme_dark_text_color, - outline = theme_dark_button_outline_color, - secondary = theme_dark_selected_button_color, - tertiary = theme_dark_switch_selector_color, - tertiaryContainer = theme_dark_switch_container_color, - outlineVariant = theme_dark_unchecked_switch_selector_color, - surfaceContainer = theme_dark_corner_button_color, - surfaceVariant = theme_dark_success_color, - ) +import androidx.compose.runtime.remember +import androidx.compose.ui.platform.LocalContext /** * Light and dark mode themes for the application. @@ -52,12 +17,8 @@ fun ScribeTheme( @Suppress("ktlint:standard:annotation") content: @Composable() () -> Unit, ) { - val colors = - if (!useDarkTheme) { - LightColors - } else { - DarkColors - } + val context = LocalContext.current + val colors = remember(context, useDarkTheme) { context.scribeColorScheme(useDarkTheme) } val typography = if (isIncreaseTextSize) createTypography(1.25f) else ScribeTypography diff --git a/app/src/test/kotlin/be/scri/ui/theme/ScribeColorSchemeTest.kt b/app/src/test/kotlin/be/scri/ui/theme/ScribeColorSchemeTest.kt new file mode 100644 index 000000000..92aff4052 --- /dev/null +++ b/app/src/test/kotlin/be/scri/ui/theme/ScribeColorSchemeTest.kt @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package be.scri.ui.theme + +import android.content.Context +import androidx.compose.ui.graphics.toArgb +import androidx.test.core.app.ApplicationProvider +import org.junit.Assert.assertEquals +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [34]) +class ScribeColorSchemeTest { + @Test + @Config(qualifiers = "night") + fun lightSchemeFollowsTheArgumentWhenTheDeviceIsNight() { + val context = ApplicationProvider.getApplicationContext() + val scheme = context.scribeColorScheme(dark = false) + assertEquals(0xFF5EB5E8.toInt(), scheme.background.toArgb()) + assertEquals(0xFF000000.toInt(), scheme.onPrimary.toArgb()) + assertEquals(0xFFFDAD0D.toInt(), scheme.primary.toArgb()) + assertEquals(0xE558564B.toInt(), scheme.onSurfaceVariant.toArgb()) + assertEquals(0xFFFEDE9E.toInt(), scheme.tertiary.toArgb()) + assertEquals(0xFF9BC53D.toInt(), scheme.surfaceVariant.toArgb()) + } + + @Test + fun darkSchemeFollowsTheArgumentWhenTheDeviceIsDay() { + val context = ApplicationProvider.getApplicationContext() + val scheme = context.scribeColorScheme(dark = true) + assertEquals(0xFF235270.toInt(), scheme.background.toArgb()) + assertEquals(0xFFD17B0F.toInt(), scheme.onPrimary.toArgb()) + assertEquals(0xFFD17B0F.toInt(), scheme.primary.toArgb()) + assertEquals(0xFFCAC4D0.toInt(), scheme.onSurfaceVariant.toArgb()) + assertEquals(0xFF2A1903.toInt(), scheme.tertiary.toArgb()) + assertEquals(0xFF08A045.toInt(), scheme.surfaceVariant.toArgb()) + } +} From ae26ac7041d2f09684b3ddecacfbd3310cd9d74a Mon Sep 17 00:00:00 2001 From: bhanu-dev82 Date: Wed, 25 Nov 2026 10:41:38 +0530 Subject: [PATCH 2/3] test: assert all 14 color slots in ScribeColorSchemeTest ScribeColorSchemeTest now checks every slot set in Colors.kt for both light and dark schemes, not only the previous six per mode. --- .../be/scri/ui/theme/ScribeColorSchemeTest.kt | 69 +++++++++++++++---- 1 file changed, 57 insertions(+), 12 deletions(-) diff --git a/app/src/test/kotlin/be/scri/ui/theme/ScribeColorSchemeTest.kt b/app/src/test/kotlin/be/scri/ui/theme/ScribeColorSchemeTest.kt index 92aff4052..f17449950 100644 --- a/app/src/test/kotlin/be/scri/ui/theme/ScribeColorSchemeTest.kt +++ b/app/src/test/kotlin/be/scri/ui/theme/ScribeColorSchemeTest.kt @@ -3,6 +3,7 @@ package be.scri.ui.theme import android.content.Context +import androidx.compose.material3.ColorScheme import androidx.compose.ui.graphics.toArgb import androidx.test.core.app.ApplicationProvider import org.junit.Assert.assertEquals @@ -19,23 +20,67 @@ class ScribeColorSchemeTest { fun lightSchemeFollowsTheArgumentWhenTheDeviceIsNight() { val context = ApplicationProvider.getApplicationContext() val scheme = context.scribeColorScheme(dark = false) - assertEquals(0xFF5EB5E8.toInt(), scheme.background.toArgb()) - assertEquals(0xFF000000.toInt(), scheme.onPrimary.toArgb()) - assertEquals(0xFFFDAD0D.toInt(), scheme.primary.toArgb()) - assertEquals(0xE558564B.toInt(), scheme.onSurfaceVariant.toArgb()) - assertEquals(0xFFFEDE9E.toInt(), scheme.tertiary.toArgb()) - assertEquals(0xFF9BC53D.toInt(), scheme.surfaceVariant.toArgb()) + // All 14 slots set in Colors.kt, from the light scribe_* resources. + scheme.assertSlots( + "primary" to 0xFFFDAD0D.toInt(), + "onPrimary" to 0xFF000000.toInt(), + "background" to 0xFF5EB5E8.toInt(), + "onBackground" to 0xFF000000.toInt(), + "surface" to 0xFFFFFFFF.toInt(), + "onSurface" to 0xFF000000.toInt(), + "outline" to 0xFFFDAD0D.toInt(), + "secondary" to 0xFF235270.toInt(), + "tertiary" to 0xFFFEDE9E.toInt(), + "tertiaryContainer" to 0xFFAAAAAA.toInt(), + "outlineVariant" to 0xFFEEEEEE.toInt(), + "surfaceContainer" to 0xFFFDAD0D.toInt(), + "surfaceVariant" to 0xFF9BC53D.toInt(), + "onSurfaceVariant" to 0xE558564B.toInt(), + ) } @Test fun darkSchemeFollowsTheArgumentWhenTheDeviceIsDay() { val context = ApplicationProvider.getApplicationContext() val scheme = context.scribeColorScheme(dark = true) - assertEquals(0xFF235270.toInt(), scheme.background.toArgb()) - assertEquals(0xFFD17B0F.toInt(), scheme.onPrimary.toArgb()) - assertEquals(0xFFD17B0F.toInt(), scheme.primary.toArgb()) - assertEquals(0xFFCAC4D0.toInt(), scheme.onSurfaceVariant.toArgb()) - assertEquals(0xFF2A1903.toInt(), scheme.tertiary.toArgb()) - assertEquals(0xFF08A045.toInt(), scheme.surfaceVariant.toArgb()) + // All 14 slots set in Colors.kt, from the night scribe_* resources. + scheme.assertSlots( + "primary" to 0xFFD17B0F.toInt(), + "onPrimary" to 0xFFD17B0F.toInt(), + "background" to 0xFF235270.toInt(), + "onBackground" to 0xFFFFFFFF.toInt(), + "surface" to 0xFF000000.toInt(), + "onSurface" to 0xFFFFFFFF.toInt(), + "outline" to 0xFFD17B0F.toInt(), + "secondary" to 0xFF5EB5E8.toInt(), + "tertiary" to 0xFF2A1903.toInt(), + "tertiaryContainer" to 0xFFAAAAAA.toInt(), + "outlineVariant" to 0xFF2D2D2D.toInt(), + "surfaceContainer" to 0xFF2A1903.toInt(), + "surfaceVariant" to 0xFF08A045.toInt(), + "onSurfaceVariant" to 0xFFCAC4D0.toInt(), + ) } } + +private fun ColorScheme.assertSlots(vararg expected: Pair) { + val actual = + listOf( + "primary" to primary.toArgb(), + "onPrimary" to onPrimary.toArgb(), + "background" to background.toArgb(), + "onBackground" to onBackground.toArgb(), + "surface" to surface.toArgb(), + "onSurface" to onSurface.toArgb(), + "outline" to outline.toArgb(), + "secondary" to secondary.toArgb(), + "tertiary" to tertiary.toArgb(), + "tertiaryContainer" to tertiaryContainer.toArgb(), + "outlineVariant" to outlineVariant.toArgb(), + "surfaceContainer" to surfaceContainer.toArgb(), + "surfaceVariant" to surfaceVariant.toArgb(), + "onSurfaceVariant" to onSurfaceVariant.toArgb(), + ) + assertEquals(14, actual.size) + assertEquals(expected.toList(), actual) +} From 7801942c4cecafec35aacade53dbd5ded5c45909 Mon Sep 17 00:00:00 2001 From: Andrew Tavis McAllister Date: Wed, 25 Nov 2026 23:38:00 +0100 Subject: [PATCH 3/3] Move changlog entry to next release --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60090320e..1a0fc7583 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/). ## [Upcoming] Scribe-Android v1.X.Y +### 🎨 Design + +- Compose theme colors now come from the shared `scribe_*` resources. Dark mode button text stays orange on orange. The dark caption uses the named token `#CAC4D0`, the same grey this slot already used ([#782](https://github.com/scribe-org/Scribe-Android/issues/782)). + ### 🔒 Security - The unused `WRITE_EXTERNAL_STORAGE` permission was removed so the app requests only network access ([#791](https://github.com/scribe-org/Scribe-Android/issues/791)). @@ -75,7 +79,6 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/). ### 🎨 Design -- Compose theme colors now come from the shared `scribe_*` resources. Dark mode button text stays orange on orange. The dark caption uses the named token `#CAC4D0`, the same grey this slot already used ([#782](https://github.com/scribe-org/Scribe-Android/issues/782)). - Named `scribe_*` color tokens record the light and dark hexes the app already uses. No screen color changes ([#781](https://github.com/scribe-org/Scribe-Android/issues/781)). - The Scribe key and command bar where Scribe commands are triggered ([#16](https://github.com/scribe-org/Scribe-Android/issues/16)). - 3x2 and other conjugation tables from which conjugations can be selected in the Conjugate command ([#267](https://github.com/scribe-org/Scribe-Android/issues/267), [#270](https://github.com/scribe-org/Scribe-Android/issues/270), [#496](https://github.com/scribe-org/Scribe-Android/issues/496), [#523](https://github.com/scribe-org/Scribe-Android/issues/523)).