diff --git a/app/src/main/java/org/tasks/compose/CheckBox.kt b/app/src/main/java/org/tasks/compose/CheckBox.kt index 86d9005dc..889e4562d 100644 --- a/app/src/main/java/org/tasks/compose/CheckBox.kt +++ b/app/src/main/java/org/tasks/compose/CheckBox.kt @@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import org.tasks.data.entity.Task -import org.tasks.themes.ColorProvider +import org.tasks.kmp.org.tasks.themes.ColorProvider.priorityColor import org.tasks.ui.CheckBoxProvider.Companion.getCheckboxRes @Composable @@ -22,7 +22,7 @@ fun CheckBox( Icon( painter = painterResource(id = task.getCheckboxRes()), tint = Color( - ColorProvider.priorityColor( + priorityColor( priority = task.priority, isDarkMode = isSystemInDarkTheme(), desaturate = desaturate, diff --git a/app/src/main/java/org/tasks/compose/edit/PriorityRow.kt b/app/src/main/java/org/tasks/compose/edit/PriorityRow.kt index 06b296613..434fa6087 100644 --- a/app/src/main/java/org/tasks/compose/edit/PriorityRow.kt +++ b/app/src/main/java/org/tasks/compose/edit/PriorityRow.kt @@ -28,7 +28,7 @@ import androidx.compose.ui.unit.dp import org.tasks.R import org.tasks.compose.TaskEditRow import org.tasks.data.entity.Task -import org.tasks.themes.ColorProvider.Companion.priorityColor +import org.tasks.kmp.org.tasks.themes.ColorProvider.priorityColor import org.tasks.themes.TasksTheme @Composable diff --git a/app/src/main/java/org/tasks/compose/edit/TagsRow.kt b/app/src/main/java/org/tasks/compose/edit/TagsRow.kt index 7e00e9228..bdfb3a19f 100644 --- a/app/src/main/java/org/tasks/compose/edit/TagsRow.kt +++ b/app/src/main/java/org/tasks/compose/edit/TagsRow.kt @@ -13,7 +13,7 @@ import org.tasks.compose.ChipGroup import org.tasks.compose.DisabledText import org.tasks.compose.TaskEditRow import org.tasks.data.entity.TagData -import org.tasks.themes.ColorProvider +import org.tasks.kmp.org.tasks.themes.ColorProvider.BLUE_500 import org.tasks.themes.TasksIcons import org.tasks.themes.TasksTheme @@ -74,7 +74,7 @@ fun SingleTag() { TagData( name = "Home", icon = "home", - color = ColorProvider.BLUE_500 + color = BLUE_500 ) ), colorProvider = { it }, @@ -112,7 +112,7 @@ fun TagWithReallyLongName() { TagData( name = "This is a tag with a really really long name", icon = "home", - color = ColorProvider.BLUE_500 + color = BLUE_500 ) ), colorProvider = { it }, diff --git a/app/src/main/java/org/tasks/preferences/Preferences.kt b/app/src/main/java/org/tasks/preferences/Preferences.kt index 7fdb192c4..bd5b2f489 100644 --- a/app/src/main/java/org/tasks/preferences/Preferences.kt +++ b/app/src/main/java/org/tasks/preferences/Preferences.kt @@ -25,7 +25,7 @@ import org.tasks.data.entity.Task.Companion.NOTIFY_AFTER_DEADLINE import org.tasks.data.entity.Task.Companion.NOTIFY_AT_DEADLINE import org.tasks.data.entity.TaskAttachment import org.tasks.extensions.Context.getResourceUri -import org.tasks.themes.ColorProvider +import org.tasks.kmp.org.tasks.themes.ColorProvider.BLUE_500 import org.tasks.themes.ThemeBase import org.tasks.time.DateTime import org.tasks.time.DateTimeUtils2.currentTimeMillis @@ -558,7 +558,7 @@ class Preferences @JvmOverloads constructor( } val defaultThemeColor: Int - get() = getInt(R.string.p_theme_color, ColorProvider.BLUE_500) + get() = getInt(R.string.p_theme_color, BLUE_500) val markdown: Boolean get() = getBoolean(R.string.p_markdown, false) diff --git a/app/src/main/java/org/tasks/themes/ColorProvider.kt b/app/src/main/java/org/tasks/themes/ColorProvider.kt index a2b45a11a..6bd883961 100644 --- a/app/src/main/java/org/tasks/themes/ColorProvider.kt +++ b/app/src/main/java/org/tasks/themes/ColorProvider.kt @@ -2,9 +2,10 @@ package org.tasks.themes import android.content.Context import androidx.annotation.ColorInt -import org.tasks.data.entity.Task import dagger.hilt.android.qualifiers.ApplicationContext import org.tasks.R +import org.tasks.kmp.org.tasks.themes.ColorProvider.priorityColor +import org.tasks.kmp.org.tasks.themes.ColorProvider.saturated import org.tasks.preferences.Preferences import javax.inject.Inject @@ -13,79 +14,6 @@ class ColorProvider @Inject constructor( preferences: Preferences ) { - companion object { - const val BLUE_500 = -14575885 - private const val RED_500 = -769226 - private const val AMBER_500 = -16121 - private const val GREY_500 = -6381922 - private const val WHITE = -1 - private const val BLACK = -16777216 - - private val saturated: Map = hashMapOf( - // 2014 material design palette - -10453621 to -7297874, // blue_grey - RED_500 to -1739917, // red - -1499549 to -1023342, // pink - -6543440 to -4560696, // purple - -10011977 to -6982195, // deep purple -// -12627531 to -8812853, // indigo - BLUE_500 to -10177034, // blue - -16537100 to -11549705, // light blue - -16728876 to -11677471, // cyan -// -16738680 to -11684180, // teal - -11751600 to -8271996, // green - -7617718 to -5319295, // light green - -3285959 to -2300043, // lime - -5317 to -3722, // yellow - AMBER_500 to -10929, // amber - -26624 to -18611, // orange - -43230 to -30107, // deep orange -// -8825528 to -6190977, // brown - GREY_500 to -2039584, // grey - WHITE to BLACK, - - // 2019 google calendar - -2818048 to -3397335, // tomato - -765666 to -2136512, // tangerine - -1086464 to -2459092, // pumpkin - -1010944 to -2254804, // mango - -606426 to -2050234, // banana - -1784767 to -2769834, // citron - -4142541 to -4274613, // avocado - -8604862 to -7817131, // pistachio - -16023485 to -14116514, // basil - -16738680 to -14571622, // eucalyptus - -13388167 to -11879802, // sage - -16540699 to -13787178, // peacock - -12417548 to -10974241, // cobalt - -12627531 to -11312199, // blueberry - -8812853 to -8615738, // lavender - -5005861 to -5597744, // wisteria - -6395473 to -5934410, // amethyst - -7461718 to -6668365, // grape - -5434281 to -4967572, // radicchio - -2614432 to -3261327, // cherry blossom - -1672077 to -2654344, // flamingo - -8825528 to -6984611, // cocoa - -10395295 to -7895161, // graphite - -5792882 to -5135210 // birch - ) - - fun priorityColor(priority: Int, isDarkMode: Boolean = false, desaturate: Boolean = false): Int { - val color = when (priority) { - in Int.MIN_VALUE..Task.Priority.HIGH -> RED_500 - Task.Priority.MEDIUM -> AMBER_500 - Task.Priority.LOW -> BLUE_500 - else -> GREY_500 - } - return if (isDarkMode && desaturate) { - saturated[color] ?: color - } else { - color - } - } - } - private val isDark = context.resources.getBoolean(R.bool.is_dark) private val desaturate = preferences.desaturateDarkMode diff --git a/app/src/main/java/org/tasks/widget/TasksWidgetViewFactory.kt b/app/src/main/java/org/tasks/widget/TasksWidgetViewFactory.kt index 1af5c5b71..8a5b80945 100644 --- a/app/src/main/java/org/tasks/widget/TasksWidgetViewFactory.kt +++ b/app/src/main/java/org/tasks/widget/TasksWidgetViewFactory.kt @@ -25,11 +25,11 @@ import org.tasks.extensions.setTextSize import org.tasks.extensions.strikethrough import org.tasks.filters.AstridOrderingFilter import org.tasks.filters.Filter +import org.tasks.kmp.org.tasks.themes.ColorProvider.priorityColor import org.tasks.markdown.Markdown import org.tasks.tasklist.HeaderFormatter import org.tasks.tasklist.SectionedDataSource import org.tasks.tasklist.headerColor -import org.tasks.themes.ColorProvider.Companion.priorityColor import org.tasks.time.DateTimeUtils2.currentTimeMillis import org.tasks.time.startOfDay import org.tasks.ui.CheckBoxProvider.Companion.getCheckboxRes diff --git a/kmp/src/commonMain/kotlin/org/tasks/themes/ColorProvider.kt b/kmp/src/commonMain/kotlin/org/tasks/themes/ColorProvider.kt new file mode 100644 index 000000000..fb2961a38 --- /dev/null +++ b/kmp/src/commonMain/kotlin/org/tasks/themes/ColorProvider.kt @@ -0,0 +1,76 @@ +package org.tasks.kmp.org.tasks.themes + +import org.tasks.data.entity.Task + +object ColorProvider { + const val BLUE_500 = -14575885 + private const val RED_500 = -769226 + private const val AMBER_500 = -16121 + private const val GREY_500 = -6381922 + private const val WHITE = -1 + private const val BLACK = -16777216 + + val saturated: Map = hashMapOf( + // 2014 material design palette + -10453621 to -7297874, // blue_grey + RED_500 to -1739917, // red + -1499549 to -1023342, // pink + -6543440 to -4560696, // purple + -10011977 to -6982195, // deep purple +// -12627531 to -8812853, // indigo + BLUE_500 to -10177034, // blue + -16537100 to -11549705, // light blue + -16728876 to -11677471, // cyan +// -16738680 to -11684180, // teal + -11751600 to -8271996, // green + -7617718 to -5319295, // light green + -3285959 to -2300043, // lime + -5317 to -3722, // yellow + AMBER_500 to -10929, // amber + -26624 to -18611, // orange + -43230 to -30107, // deep orange +// -8825528 to -6190977, // brown + GREY_500 to -2039584, // grey + WHITE to BLACK, + + // 2019 google calendar + -2818048 to -3397335, // tomato + -765666 to -2136512, // tangerine + -1086464 to -2459092, // pumpkin + -1010944 to -2254804, // mango + -606426 to -2050234, // banana + -1784767 to -2769834, // citron + -4142541 to -4274613, // avocado + -8604862 to -7817131, // pistachio + -16023485 to -14116514, // basil + -16738680 to -14571622, // eucalyptus + -13388167 to -11879802, // sage + -16540699 to -13787178, // peacock + -12417548 to -10974241, // cobalt + -12627531 to -11312199, // blueberry + -8812853 to -8615738, // lavender + -5005861 to -5597744, // wisteria + -6395473 to -5934410, // amethyst + -7461718 to -6668365, // grape + -5434281 to -4967572, // radicchio + -2614432 to -3261327, // cherry blossom + -1672077 to -2654344, // flamingo + -8825528 to -6984611, // cocoa + -10395295 to -7895161, // graphite + -5792882 to -5135210 // birch + ) + + fun priorityColor(priority: Int, isDarkMode: Boolean = false, desaturate: Boolean = false): Int { + val color = when (priority) { + in Int.MIN_VALUE..Task.Priority.HIGH -> RED_500 + Task.Priority.MEDIUM -> AMBER_500 + Task.Priority.LOW -> BLUE_500 + else -> GREY_500 + } + return if (isDarkMode && desaturate) { + saturated[color] ?: color + } else { + color + } + } +}