Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Allow MonetMode and ThemingMode to be used without compose dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sadellie committed Jan 16, 2024
1 parent 9dc7b6c commit 17c27e5
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 19 deletions.
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[versions]
version = "1.3.0"
androidGradlePlugin = "8.2.1"
kotlin = "1.9.22"
androidxCoreCoreKts = "1.12.0"
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ dependencyResolutionManagement {
rootProject.name = "Themmo"
include(":themmo")
include(":themmosample")
include(":themmo-core")
1 change: 1 addition & 0 deletions themmo-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
62 changes: 62 additions & 0 deletions themmo-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("maven-publish")
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = "io.github.sadellie"
artifactId = "themmo-core"
version = libs.versions.version.get().toString()

afterEvaluate {
from(components["release"])
}
}
}
}

android {
namespace = "io.github.sadellie.themmo.core"
compileSdk = 34

defaultConfig {
minSdk = 21

aarMetadata {
minCompileSdk = 29
}

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

publishing {
singleVariant("release") {
withSourcesJar()
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(libs.androidx.core.core.ktx)
}
Empty file added themmo-core/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions themmo-core/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions themmo-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.github.sadellie.themmo.core

enum class MonetMode {
TonalSpot,
Neutral,
Vibrant,
Expressive,
Rainbow,
FruitSalad,
Monochrome,
Fidelity,
Content
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.sadellie.themmo
package io.github.sadellie.themmo.core

enum class ThemingMode {
/**
Expand Down
3 changes: 2 additions & 1 deletion themmo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publishing {
register<MavenPublication>("release") {
groupId = "io.github.sadellie"
artifactId = "themmo"
version = "1.2.0"
version = libs.versions.version.get().toString()

afterEvaluate {
from(components["release"])
Expand Down Expand Up @@ -83,4 +83,5 @@ dependencies {
implementation(libs.androidx.compose.ui)
implementation(libs.com.github.kyant0.m3color)
implementation(libs.androidx.compose.material3)
api(project(":themmo-core"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.material3.lightColorScheme
import androidx.compose.ui.graphics.Color
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.github.sadellie.themmo.core.ThemingMode

import org.junit.Test
import org.junit.runner.RunWith
Expand Down
12 changes: 1 addition & 11 deletions themmo/src/main/java/io/github/sadellie/themmo/DynamicColors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.kyant.m3color.scheme.SchemeNeutral
import com.kyant.m3color.scheme.SchemeRainbow
import com.kyant.m3color.scheme.SchemeTonalSpot
import com.kyant.m3color.scheme.SchemeVibrant
import io.github.sadellie.themmo.core.MonetMode

/**
* Extract primary color from device wallpaper.
Expand Down Expand Up @@ -92,14 +93,3 @@ internal fun dynamicColorScheme(
)
}

enum class MonetMode {
TonalSpot,
Neutral,
Vibrant,
Expressive,
Rainbow,
FruitSalad,
Monochrome,
Fidelity,
Content
}
2 changes: 0 additions & 2 deletions themmo/src/main/java/io/github/sadellie/themmo/Themmo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package io.github.sadellie.themmo

import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.Easing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.ColorScheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.isSpecified
import androidx.compose.ui.res.colorResource
import io.github.sadellie.themmo.core.MonetMode
import io.github.sadellie.themmo.core.ThemingMode

// Constants for Saver
private const val AMOLED_ENABLED = "AMOLED_ENABLED"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.dp
import androidx.core.graphics.toColorInt
import io.github.sadellie.themmo.MonetMode
import io.github.sadellie.themmo.ThemingMode
import io.github.sadellie.themmo.core.MonetMode
import io.github.sadellie.themmo.Themmo
import io.github.sadellie.themmo.ThemmoController
import io.github.sadellie.themmo.core.ThemingMode

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -104,7 +104,7 @@ fun ExampleSettingScreen(themmoController: ThemmoController) {

Text("Current theme: ${themmoController.currentThemingMode}")

ThemingMode.values().forEach {
ThemingMode.entries.forEach {
Button(onClick = { themmoController.setThemingMode(it) }) { Text(it.name) }
}

Expand Down Expand Up @@ -143,7 +143,7 @@ fun ExampleSettingScreen(themmoController: ThemmoController) {
)

Text("Current mode: ${themmoController.currentMonetMode}")
MonetMode.values().forEach {
MonetMode.entries.forEach {
Button(onClick = { themmoController.setMonetMode(it) }) { Text(it.name) }
}

Expand Down

0 comments on commit 17c27e5

Please sign in to comment.