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
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId = "dev.typetype.android"
minSdk = 23
targetSdk = 37
versionCode = 10702
versionName = "1.7.0-beta.3"
versionCode = 10703
versionName = "1.7.0-beta.4"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
resValue("string", "app_name", "TypeType")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,59 @@ class AppearanceSchemeTest {
assertEquals(Color.Black, scheme.background)
assertEquals(Color.Black, scheme.surface)
}

@Test
fun mangaPaperKeepsTextContrastWhenColorModeDiffers() {
val accent = accentColors(AccentColor.Blue)
val dayPaperInDarkMode = mangaScheme(
paper = MangaPaper.Day,
theme = AppearanceTheme.TypeType,
accent = accent.first,
accentSoft = accent.second,
amoled = false,
isDark = true,
)
val nightPaperInLightMode = mangaScheme(
paper = MangaPaper.Night,
theme = AppearanceTheme.TypeType,
accent = accent.first,
accentSoft = accent.second,
amoled = false,
isDark = false,
)

assertEquals(Color(0xFFF5F3EA), dayPaperInDarkMode.onBackground)
assertEquals(Color(0xFF211F1A), dayPaperInDarkMode.background)
assertEquals(Color(0xFFF5F3EA), nightPaperInLightMode.onBackground)
}

@Test
fun everyMangaPaperKeepsItsInkContrastAcrossColorModes() {
val accent = accentColors(AccentColor.Blue)
val paperThemes = listOf(AppearanceTheme.TypeType, AppearanceTheme.Dynamic)
val modes = listOf(false, true)

paperThemes.forEach { theme ->
MangaPaper.entries.forEach { paper ->
modes.forEach { isDark ->
val scheme = mangaScheme(
paper = paper,
theme = theme,
accent = accent.first,
accentSoft = accent.second,
amoled = false,
isDark = isDark,
)
val expectedInk = if (paper == MangaPaper.Day && !isDark) {
Color(0xFF171717)
} else {
Color(0xFFF5F3EA)
}

assertEquals(expectedInk, scheme.onBackground)
assertEquals(expectedInk, scheme.onSurface)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,14 @@ internal fun mangaScheme(
amoled: Boolean,
isDark: Boolean,
): ColorScheme {
val dark = isDark || amoled
val usesPaperSurfaces = theme == AppearanceTheme.TypeType || theme == AppearanceTheme.Dynamic
val darkMode = isDark || amoled
val darkSurface = if (usesPaperSurfaces) darkMode || paper != MangaPaper.Day else darkMode
val background = if (amoled) {
Color.Black
} else {
when (paper) {
MangaPaper.Day -> Color(0xFFFFFDF5)
MangaPaper.Day -> if (darkMode) Color(0xFF211F1A) else Color(0xFFFFFDF5)
MangaPaper.Night -> Color.Black
MangaPaper.Nord -> Color(0xFF2E3440)
}
Expand All @@ -183,18 +185,17 @@ internal fun mangaScheme(
Color.Black
} else {
when (paper) {
MangaPaper.Day -> Color(0xFFFFFAE8)
MangaPaper.Day -> if (darkMode) Color(0xFF302B23) else Color(0xFFFFFAE8)
MangaPaper.Night -> Color(0xFF121212)
MangaPaper.Nord -> Color(0xFF3B4252)
}
}
val ink = if (dark) Color(0xFFF5F3EA) else Color(0xFF171717)
val base = if (dark) {
val ink = if (darkSurface) Color(0xFFF5F3EA) else Color(0xFF171717)
val base = if (darkSurface) {
themedDarkScheme(theme, accent, accentSoft, amoled = false)
} else {
themedLightScheme(theme, accent, accentSoft)
}
val usesPaperSurfaces = theme == AppearanceTheme.TypeType || theme == AppearanceTheme.Dynamic
val activeBackground = if (amoled) Color.Black
else if (usesPaperSurfaces) background else base.background
val activeSurface = if (amoled) Color.Black
Expand Down Expand Up @@ -222,7 +223,7 @@ internal fun mangaScheme(
surfaceBright = activeSurface,
outline = ink,
outlineVariant = ink.copy(alpha = 0.42f),
error = if (dark) Red300 else Red600,
onError = if (dark) Color.Black else White,
error = if (darkSurface) Red300 else Red600,
onError = if (darkSurface) Color.Black else White,
)
}