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

Commit

Permalink
Version 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sadellie committed Jan 11, 2024
1 parent ccb3b84 commit 9dc7b6c
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 76 deletions.
16 changes: 4 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.1.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.build.gradle.kts files
}
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.android.gradlePlugin) apply false
alias(libs.plugins.kotlin.jvm) apply false
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
Expand Down
26 changes: 26 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[versions]
androidGradlePlugin = "8.2.1"
kotlin = "1.9.22"
androidxCoreCoreKts = "1.12.0"
junitJunit = "4.13.2"
androidxCompose = "1.6.0-rc01"
androidxComposeMaterial3 = "1.2.0-beta02"
androidxComposeCompiler = "1.5.8"
comGithubKyant0m3color = "2024.1"
androidxTestExtJunitKtx = "1.1.5"
androidxActivityActivityCompose = "1.8.2"

[libraries]
androidx-core-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCoreCoreKts" }
junit-junit = { group = "junit", name = "junit", version.ref = "junitJunit" }
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "androidxCompose" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidxComposeMaterial3" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui", version.ref = "androidxCompose" }
com-github-kyant0-m3color = { group = "com.github.Kyant0", name = "m3color", version.ref = "comGithubKyant0m3color" }
androidx-test-ext-junit-ktx = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "androidxTestExtJunitKtx" }
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview", version.ref = "androidxCompose" }
androidx-activity-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivityActivityCompose" }

[plugins]
android-gradlePlugin = { id = "com.android.application", version.ref = "androidGradlePlugin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Wed Sep 13 10:24:10 MSK 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 4 additions & 3 deletions settings.gradle → settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ pluginManagement {
mavenCentral()
}
}
@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven(url = "https://jitpack.io")
}
}
rootProject.name = "Themmo"
include ':themmo'
include ':themmosample'
include(":themmo")
include(":themmosample")
21 changes: 10 additions & 11 deletions themmo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ publishing {
publications {
register<MavenPublication>("release") {
groupId = "io.github.sadellie"
artifactId = "themmo13"
version = "1.1.0"
artifactId = "themmo"
version = "1.2.0"

afterEvaluate {
from(components["release"])
Expand All @@ -18,7 +18,6 @@ publishing {
}
}

@Suppress("UnstableApiUsage")
android {
namespace = "io.github.sadellie.themmo"
compileSdk = 34
Expand Down Expand Up @@ -67,9 +66,9 @@ android {
buildConfig = false
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.4"
kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get().toString()
}
packagingOptions {
packaging {
jniLibs.excludes.add("META-INF/licenses/**")
resources.excludes.add("META-INF/licenses/**")
resources.excludes.add("META-INF/AL2.0")
Expand All @@ -78,10 +77,10 @@ android {
}

dependencies {
implementation("androidx.core:core-ktx:1.12.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
implementation("androidx.compose.ui:ui:1.6.0-alpha06")
implementation("androidx.compose.material3:material3:1.2.0-alpha08")
implementation("com.github.Kyant0:m3color:2023.8.1")
implementation(libs.androidx.core.core.ktx)
testImplementation(libs.junit.junit)
androidTestImplementation(libs.androidx.test.ext.junit.ktx)
implementation(libs.androidx.compose.ui)
implementation(libs.com.github.kyant0.m3color)
implementation(libs.androidx.compose.material3)
}
12 changes: 10 additions & 2 deletions themmo/src/main/java/io/github/sadellie/themmo/DynamicColors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ import com.kyant.m3color.scheme.SchemeVibrant
* @return Primary color of current wallpaper image.
*/
@RequiresApi(Build.VERSION_CODES.O_MR1)
internal fun extractWallpaperPrimary(context: Context): WallpaperColors? {
return WallpaperManager.getInstance(context).getWallpaperColors(WallpaperManager.FLAG_SYSTEM)
internal fun extractWallpaperPrimary(context: Context): Color? {
val wallpaperColors: WallpaperColors = WallpaperManager
.getInstance(context)
.getWallpaperColors(WallpaperManager.FLAG_SYSTEM) ?: return null

return Color(
red = wallpaperColors.primaryColor.red(),
green = wallpaperColors.primaryColor.green(),
blue = wallpaperColors.primaryColor.blue()
)
}

internal fun dynamicColorScheme(
Expand Down
86 changes: 51 additions & 35 deletions themmo/src/main/java/io/github/sadellie/themmo/ThemmoController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -102,27 +104,34 @@ class ThemmoController(
private fun provideLightColorScheme(context: Context): ColorScheme {
return when {
isDynamicThemeEnabled -> {
val keyColor = when {
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> {
dynamicLightColorScheme(context)
}
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
colorResource(id = android.R.color.system_accent1_500)
val keyColor = colorResource(android.R.color.system_accent1_500)

dynamicColorScheme(
keyColor = keyColor,
isDark = false,
style = currentMonetMode,
)
}
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 -> {
val wallpaperColors = extractWallpaperPrimary(context)
?: return lightColorScheme
Color(
red = wallpaperColors.primaryColor.red(),
green = wallpaperColors.primaryColor.green(),
blue = wallpaperColors.primaryColor.blue()
)
val keyColor = extractWallpaperPrimary(context)

if (keyColor == null) {
lightColorScheme
} else {
dynamicColorScheme(
keyColor = keyColor,
isDark = false,
style = currentMonetMode,
)
}
}
else -> return lightColorScheme
else -> lightColorScheme
}

dynamicColorScheme(
keyColor = keyColor,
isDark = false,
style = currentMonetMode,
)
}
!isDynamicThemeEnabled and currentCustomColor.isSpecified -> {
dynamicColorScheme(
Expand All @@ -137,29 +146,36 @@ class ThemmoController(

@Composable
private fun provideDarkColorScheme(context: Context): ColorScheme {
val dark = when {
val darkColorScheme: ColorScheme = when {
isDynamicThemeEnabled -> {
val keyColor = when {
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> {
dynamicDarkColorScheme(context)
}
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
colorResource(id = android.R.color.system_accent1_500)
val keyColor = colorResource(android.R.color.system_accent1_500)

dynamicColorScheme(
keyColor = keyColor,
isDark = true,
style = currentMonetMode,
)
}
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 -> {
val wallpaperColors = extractWallpaperPrimary(context)
?: return darkColorScheme
Color(
red = wallpaperColors.primaryColor.red(),
green = wallpaperColors.primaryColor.green(),
blue = wallpaperColors.primaryColor.blue()
)
val keyColor = extractWallpaperPrimary(context)

if (keyColor == null) {
darkColorScheme
} else {
dynamicColorScheme(
keyColor = keyColor,
isDark = true,
style = currentMonetMode,
)
}
}
else -> return darkColorScheme
else -> darkColorScheme
}

dynamicColorScheme(
keyColor = keyColor,
isDark = true,
style = currentMonetMode,
)
}
!isDynamicThemeEnabled and currentCustomColor.isSpecified -> {
dynamicColorScheme(
Expand All @@ -173,9 +189,9 @@ class ThemmoController(

// Turning into amoled if needed
return if (isAmoledThemeEnabled) {
dark.copy(background = Color.Black, surface = Color.Black)
darkColorScheme.copy(background = Color.Black, surface = Color.Black)
} else {
dark
darkColorScheme
}
}

Expand Down
21 changes: 10 additions & 11 deletions themmosample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
id("kotlin-android")
}

@Suppress("UnstableApiUsage")
android {
compileSdk = 34

Expand Down Expand Up @@ -40,9 +39,9 @@ android {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.4"
kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get().toString()
}
packagingOptions {
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
Expand All @@ -51,13 +50,13 @@ android {
}

dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.compose.ui:ui:1.6.0-alpha06")
implementation("androidx.compose.ui:ui-tooling-preview:1.6.0-alpha06")
debugImplementation("androidx.compose.ui:ui-tooling:1.6.0-alpha06")
implementation("androidx.compose.material3:material3:1.2.0-alpha08")
implementation("androidx.activity:activity-compose:1.7.2")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
implementation(libs.androidx.core.core.ktx)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
debugImplementation(libs.androidx.compose.ui.tooling)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.activity.activity.compose)
testImplementation(libs.junit.junit)
androidTestImplementation(libs.androidx.test.ext.junit.ktx)
implementation(project(mapOf("path" to ":themmo")))
}

0 comments on commit 9dc7b6c

Please sign in to comment.