From b0d7d2a4870f1615094d932a328a91862825560e Mon Sep 17 00:00:00 2001 From: ShiftHackZ Date: Wed, 20 Dec 2023 22:35:18 +0200 Subject: [PATCH] Legacy module --- README.md | 55 +++++- app/build.gradle.kts | 2 + gradle/libs.versions.toml | 3 +- palette-legacy/.gitignore | 1 + palette-legacy/build.gradle.kts | 54 ++++++ palette-legacy/consumer-rules.pro | 0 palette-legacy/proguard-rules.pro | 21 +++ palette-legacy/src/main/AndroidManifest.xml | 2 + .../palette/legacy/CatppuccinLegacy.kt | 168 ++++++++++++++++++ .../palette/legacy/CatppuccinLegacyPalette.kt | 40 +++++ .../src/main/res/values/catppuccin-mocha.xml | 29 +++ .../src/main/res/values/colors-frappe.xml | 29 +++ .../src/main/res/values/colors-latte.xml | 29 +++ .../src/main/res/values/colors-macchiato.xml | 29 +++ settings.gradle.kts | 1 + 15 files changed, 460 insertions(+), 3 deletions(-) create mode 100644 palette-legacy/.gitignore create mode 100644 palette-legacy/build.gradle.kts create mode 100644 palette-legacy/consumer-rules.pro create mode 100644 palette-legacy/proguard-rules.pro create mode 100644 palette-legacy/src/main/AndroidManifest.xml create mode 100644 palette-legacy/src/main/java/com/shifthackz/catppuccin/palette/legacy/CatppuccinLegacy.kt create mode 100644 palette-legacy/src/main/java/com/shifthackz/catppuccin/palette/legacy/CatppuccinLegacyPalette.kt create mode 100644 palette-legacy/src/main/res/values/catppuccin-mocha.xml create mode 100644 palette-legacy/src/main/res/values/colors-frappe.xml create mode 100644 palette-legacy/src/main/res/values/colors-latte.xml create mode 100644 palette-legacy/src/main/res/values/colors-macchiato.xml diff --git a/README.md b/README.md index 78f538a..b7ef696 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Then add all or only needed library module dependencies to your module level bui ``` dependencies { implementation 'com.github.ShiftHackZ.Catppuccin-Android-Library:palette:' + implementation 'com.github.ShiftHackZ.Catppuccin-Android-Library:palette-legacy:' implementation 'com.github.ShiftHackZ.Catppuccin-Android-Library:compose:' implementation 'com.github.ShiftHackZ.Catppuccin-Android-Library:splashscreen:' } @@ -52,12 +53,30 @@ dependencies { ### Palette -Implements Catppuccin color palette: Catppuccin.Latte, Catppuccin.Frappe, Catppuccin.Macchiato, Catppuccin.Mocha. +Implements Catppuccin color compose palette: +- Catppuccin.Latte +- Catppuccin.Frappe +- Catppuccin.Macchiato +- Catppuccin.Mocha ``` implementation 'com.github.ShiftHackZ.Catppuccin-Android-Library:palette:' ``` +### Palette Legacy + +**Available since version 0.1.1** + +Implements Catppuccin color palette as xml resources and static colors that can be accessed without context: +- CatppuccinLegacy.Latte +- CatppuccinLegacy.Frappe +- CatppuccinLegacy.Macchiato +- CatppuccinLegacy.Mocha + +``` +implementation 'com.github.ShiftHackZ.Catppuccin-Android-Library:palette-legacy:' +``` + ### Compose Implements Android Jetpack Compose Catppuccin material themes. @@ -95,6 +114,40 @@ fun RedText(text: String) { } ``` +### Palette Legacy + +To access a color in XML or programatically with context, use `catppuccin__`: + +```xml + +``` + +```xml + +``` + +Or you can access it with context like this: + +```kotlin +import com.shifthackz.catppuccin.palette.legacy.R as CatppuccinRes + +... +val color = ContextCompat.getColor(context, CatppuccinRes.catppuccin_frappe_red) +... + +``` + +In case you need a color represented as Int value (or simply don't want to use context) +you can access the color by call `CatppuccinLegacy..`: + +```kotlin +val color = CatppuccinLegacy.Frappe.red +``` + ### Compose material themes #### Themes overview diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c2def39..b76a2cc 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -49,6 +49,8 @@ android { } dependencies { + implementation(project(":palette")) + implementation(project(":palette-legacy")) implementation(project(":compose")) implementation(project(":splashscreen")) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7bac22f..5198365 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -catppuccin = "0.1.0" +catppuccin = "0.1.1" activityCompose = "1.8.2" androidGradlePlugin = "8.2.0" kotlin = "1.9.10" @@ -12,7 +12,6 @@ lifecycleRuntimeKtx = "2.6.2" lifecycleCompose = "2.6.2" material3 = "1.1.2" - [libraries] androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCoreKtx" } diff --git a/palette-legacy/.gitignore b/palette-legacy/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/palette-legacy/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/palette-legacy/build.gradle.kts b/palette-legacy/build.gradle.kts new file mode 100644 index 0000000..a788b60 --- /dev/null +++ b/palette-legacy/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.org.jetbrains.kotlin.android) + `maven-publish` +} + +android { + namespace = "com.shifthackz.catppuccin.palette.legacy" + compileSdk = 34 + + defaultConfig { + minSdk = 21 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + publishing { + singleVariant("release") { + withSourcesJar() + withJavadocJar() + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } +} + +afterEvaluate { + publishing { + publications { + create("release") { + groupId = "com.shifthackz.catppuccin" + artifactId = "palette-legacy" + version = libs.versions.catppuccin.get() + + from(components["release"]) + } + } + } +} diff --git a/palette-legacy/consumer-rules.pro b/palette-legacy/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/palette-legacy/proguard-rules.pro b/palette-legacy/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/palette-legacy/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/palette-legacy/src/main/AndroidManifest.xml b/palette-legacy/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8072ee0 --- /dev/null +++ b/palette-legacy/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/palette-legacy/src/main/java/com/shifthackz/catppuccin/palette/legacy/CatppuccinLegacy.kt b/palette-legacy/src/main/java/com/shifthackz/catppuccin/palette/legacy/CatppuccinLegacy.kt new file mode 100644 index 0000000..d4bd152 --- /dev/null +++ b/palette-legacy/src/main/java/com/shifthackz/catppuccin/palette/legacy/CatppuccinLegacy.kt @@ -0,0 +1,168 @@ +@file:Suppress("unused") + +package com.shifthackz.catppuccin.palette.legacy + +import android.graphics.Color + +/** + * **Catppuccin** is a community-driven pastel theme that aims to be the middle ground between low + * and high contrast themes. + * + * This is a legacy contract where every color is represented as [Int] and can be accessed without + * android context. + * + * @see Catppuccin + * + * @author ShiftHackZ + * @since 0.1.1 + */ +object CatppuccinLegacy { + + /** + * **Catppuccin Latte** legacy flavor color palette. + * + * @see Catppuccin Palette + * + * @author ShiftHackZ + * @since 0.1.1 + */ + object Latte : CatppuccinLegacyPalette { + override val rosewater: Int = Color.parseColor("#dc8a78") + override val flamingo: Int = Color.parseColor("#dd7878") + override val pink: Int = Color.parseColor("#ea76cb") + override val mauve: Int = Color.parseColor("#8839ef") + override val red: Int = Color.parseColor("#d20f39") + override val maroon: Int = Color.parseColor("#e64553") + override val peach: Int = Color.parseColor("#fe640b") + override val yellow: Int = Color.parseColor("#df8e1d") + override val green: Int = Color.parseColor("#40a02b") + override val teal: Int = Color.parseColor("#179299") + override val sky: Int = Color.parseColor("#04a5e5") + override val sapphire: Int = Color.parseColor("#209fb5") + override val blue: Int = Color.parseColor("#1e66f5") + override val lavender: Int = Color.parseColor("#7287fd") + override val text: Int = Color.parseColor("#4c4f69") + override val subtext1: Int = Color.parseColor("#5c5f77") + override val subtext0: Int = Color.parseColor("#6c6f85") + override val overlay2: Int = Color.parseColor("#7c7f93") + override val overlay1: Int = Color.parseColor("#8c8fa1") + override val overlay0: Int = Color.parseColor("#9ca0b0") + override val surface2: Int = Color.parseColor("#acb0be") + override val surface1: Int = Color.parseColor("#bcc0cc") + override val surface0: Int = Color.parseColor("#ccd0da") + override val base: Int = Color.parseColor("#eff1f5") + override val mantle: Int = Color.parseColor("#e6e9ef") + override val crust: Int = Color.parseColor("#dce0e8") + } + + /** + * **Catppuccin Frappe** legacy flavor color palette. + * + * @see Catppuccin Palette + * + * @author ShiftHackZ + * @since 0.1.1 + */ + object Frappe : CatppuccinLegacyPalette { + override val rosewater: Int = Color.parseColor("#f2d5cf") + override val flamingo: Int = Color.parseColor("#eebebe") + override val pink: Int = Color.parseColor("#f4b8e4") + override val mauve: Int = Color.parseColor("#ca9ee6") + override val red: Int = Color.parseColor("#e78284") + override val maroon: Int = Color.parseColor("#ea999c") + override val peach: Int = Color.parseColor("#ef9f76") + override val yellow: Int = Color.parseColor("#e5c890") + override val green: Int = Color.parseColor("#a6d189") + override val teal: Int = Color.parseColor("#81c8be") + override val sky: Int = Color.parseColor("#99d1db") + override val sapphire: Int = Color.parseColor("#85c1dc") + override val blue: Int = Color.parseColor("#8caaee") + override val lavender: Int = Color.parseColor("#babbf1") + override val text: Int = Color.parseColor("#c6d0f5") + override val subtext1: Int = Color.parseColor("#b5bfe2") + override val subtext0: Int = Color.parseColor("#a5adce") + override val overlay2: Int = Color.parseColor("#949cbb") + override val overlay1: Int = Color.parseColor("#838ba7") + override val overlay0: Int = Color.parseColor("#737994") + override val surface2: Int = Color.parseColor("#626880") + override val surface1: Int = Color.parseColor("#51576d") + override val surface0: Int = Color.parseColor("#414559") + override val base: Int = Color.parseColor("#303446") + override val mantle: Int = Color.parseColor("#292c3c") + override val crust: Int = Color.parseColor("#232634") + } + + /** + * **Catppuccin Macchiato** legacy flavor color palette. + * + * @see Catppuccin Palette + * + * @author ShiftHackZ + * @since 0.1.1 + */ + object Macchiato : CatppuccinLegacyPalette { + override val rosewater: Int = Color.parseColor("#f4dbd6") + override val flamingo: Int = Color.parseColor("#f0c6c6") + override val pink: Int = Color.parseColor("#f5bde6") + override val mauve: Int = Color.parseColor("#c6a0f6") + override val red: Int = Color.parseColor("#ed8796") + override val maroon: Int = Color.parseColor("#ee99a0") + override val peach: Int = Color.parseColor("#f5a97f") + override val yellow: Int = Color.parseColor("#eed49f") + override val green: Int = Color.parseColor("#a6da95") + override val teal: Int = Color.parseColor("#8bd5ca") + override val sky: Int = Color.parseColor("#91d7e3") + override val sapphire: Int = Color.parseColor("#7dc4e4") + override val blue: Int = Color.parseColor("#8aadf4") + override val lavender: Int = Color.parseColor("#b7bdf8") + override val text: Int = Color.parseColor("#cad3f5") + override val subtext1: Int = Color.parseColor("#b8c0e0") + override val subtext0: Int = Color.parseColor("#a5adcb") + override val overlay2: Int = Color.parseColor("#939ab7") + override val overlay1: Int = Color.parseColor("#8087a2") + override val overlay0: Int = Color.parseColor("#6e738d") + override val surface2: Int = Color.parseColor("#5b6078") + override val surface1: Int = Color.parseColor("#494d64") + override val surface0: Int = Color.parseColor("#363a4f") + override val base: Int = Color.parseColor("#24273a") + override val mantle: Int = Color.parseColor("#1e2030") + override val crust: Int = Color.parseColor("#181926") + } + + /** + * **Catppuccin Mocha** legacy flavor color palette. + * + * @see Catppuccin Palette + * + * @author ShiftHackZ + * @since 0.1.1 + */ + object Mocha : CatppuccinLegacyPalette { + override val rosewater: Int = Color.parseColor("#f5e0dc") + override val flamingo: Int = Color.parseColor("#f2cdcd") + override val pink: Int = Color.parseColor("#f5c2e7") + override val mauve: Int = Color.parseColor("#cba6f7") + override val red: Int = Color.parseColor("#f38ba8") + override val maroon: Int = Color.parseColor("#eba0ac") + override val peach: Int = Color.parseColor("#fab387") + override val yellow: Int = Color.parseColor("#f9e2af") + override val green: Int = Color.parseColor("#a6e3a1") + override val teal: Int = Color.parseColor("#94e2d5") + override val sky: Int = Color.parseColor("#89dceb") + override val sapphire: Int = Color.parseColor("#74c7ec") + override val blue: Int = Color.parseColor("#89b4fa") + override val lavender: Int = Color.parseColor("#b4befe") + override val text: Int = Color.parseColor("#cdd6f4") + override val subtext1: Int = Color.parseColor("#bac2de") + override val subtext0: Int = Color.parseColor("#a6adc8") + override val overlay2: Int = Color.parseColor("#9399b2") + override val overlay1: Int = Color.parseColor("#7f849c") + override val overlay0: Int = Color.parseColor("#6c7086") + override val surface2: Int = Color.parseColor("#585b70") + override val surface1: Int = Color.parseColor("#45475a") + override val surface0: Int = Color.parseColor("#313244") + override val base: Int = Color.parseColor("#1e1e2e") + override val mantle: Int = Color.parseColor("#181825") + override val crust: Int = Color.parseColor("#11111b") + } +} diff --git a/palette-legacy/src/main/java/com/shifthackz/catppuccin/palette/legacy/CatppuccinLegacyPalette.kt b/palette-legacy/src/main/java/com/shifthackz/catppuccin/palette/legacy/CatppuccinLegacyPalette.kt new file mode 100644 index 0000000..a6d2c49 --- /dev/null +++ b/palette-legacy/src/main/java/com/shifthackz/catppuccin/palette/legacy/CatppuccinLegacyPalette.kt @@ -0,0 +1,40 @@ +package com.shifthackz.catppuccin.palette.legacy + +/** + * Interface contract that determines all available **Catppuccin** legacy color labels. + * + * This is a legacy contract where every color is represented as [Int]. + * + * @see Catppuccin Palette + * + * @author ShiftHackZ + * @since 0.1.1 + */ +interface CatppuccinLegacyPalette { + val rosewater: Int + val flamingo: Int + val pink: Int + val mauve: Int + val red: Int + val maroon: Int + val peach: Int + val yellow: Int + val green: Int + val teal: Int + val sky: Int + val sapphire: Int + val blue: Int + val lavender: Int + val text: Int + val subtext1: Int + val subtext0: Int + val overlay2: Int + val overlay1: Int + val overlay0: Int + val surface2: Int + val surface1: Int + val surface0: Int + val base: Int + val mantle: Int + val crust: Int +} diff --git a/palette-legacy/src/main/res/values/catppuccin-mocha.xml b/palette-legacy/src/main/res/values/catppuccin-mocha.xml new file mode 100644 index 0000000..2270e5e --- /dev/null +++ b/palette-legacy/src/main/res/values/catppuccin-mocha.xml @@ -0,0 +1,29 @@ + + + #f5e0dc + #f2cdcd + #f5c2e7 + #cba6f7 + #f38ba8 + #eba0ac + #fab387 + #f9e2af + #a6e3a1 + #94e2d5 + #89dceb + #74c7ec + #89b4fa + #b4befe + #cdd6f4 + #bac2de + #a6adc8 + #9399b2 + #7f849c + #6c7086 + #585b70 + #45475a + #313244 + #1e1e2e + #181825 + #11111b + diff --git a/palette-legacy/src/main/res/values/colors-frappe.xml b/palette-legacy/src/main/res/values/colors-frappe.xml new file mode 100644 index 0000000..ad7135c --- /dev/null +++ b/palette-legacy/src/main/res/values/colors-frappe.xml @@ -0,0 +1,29 @@ + + + #f2d5cf + #eebebe + #f4b8e4 + #ca9ee6 + #e78284 + #ea999c + #ef9f76 + #e5c890 + #a6d189 + #81c8be + #99d1db + #85c1dc + #8caaee + #babbf1 + #c6d0f5 + #b5bfe2 + #a5adce + #949cbb + #838ba7 + #737994 + #626880 + #51576d + #414559 + #303446 + #292c3c + #232634 + diff --git a/palette-legacy/src/main/res/values/colors-latte.xml b/palette-legacy/src/main/res/values/colors-latte.xml new file mode 100644 index 0000000..5c80e7a --- /dev/null +++ b/palette-legacy/src/main/res/values/colors-latte.xml @@ -0,0 +1,29 @@ + + + #dc8a78 + #dd7878 + #ea76cb + #8839ef + #d20f39 + #e64553 + #fe640b + #df8e1d + #40a02b + #179299 + #04a5e5 + #209fb5 + #1e66f5 + #7287fd + #4c4f69 + #5c5f77 + #6c6f85 + #7c7f93 + #8c8fa1 + #9ca0b0 + #acb0be + #bcc0cc + #ccd0da + #eff1f5 + #e6e9ef + #dce0e8 + diff --git a/palette-legacy/src/main/res/values/colors-macchiato.xml b/palette-legacy/src/main/res/values/colors-macchiato.xml new file mode 100644 index 0000000..7065c39 --- /dev/null +++ b/palette-legacy/src/main/res/values/colors-macchiato.xml @@ -0,0 +1,29 @@ + + + #f4dbd6 + #f0c6c6 + #f5bde6 + #c6a0f6 + #ed8796 + #ee99a0 + #f5a97f + #eed49f + #a6da95 + #8bd5ca + #91d7e3 + #7dc4e4 + #8aadf4 + #b7bdf8 + #cad3f5 + #b8c0e0 + #a5adcb + #939ab7 + #8087a2 + #6e738d + #5b6078 + #494d64 + #363a4f + #24273a + #1e2030 + #181926 + diff --git a/settings.gradle.kts b/settings.gradle.kts index dad34a4..ed20f25 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,3 +19,4 @@ include(":app") include(":compose") include(":palette") include(":splashscreen") +include(":palette-legacy")