From fd03a78cb4a979a1430c5b1d5782d2d1f0cbad90 Mon Sep 17 00:00:00 2001 From: TheRemakerMan Date: Sun, 23 Jul 2023 15:41:06 +0700 Subject: [PATCH] feat: Implement theme builder plugin to generate colored material themes --- app/build.gradle.kts | 17 +++++ app/src/main/AndroidManifest.xml | 12 ++-- .../org/cosmicide/rewrite/MainActivity.kt | 2 +- app/src/main/res/values-night-v27/themes.xml | 16 ----- app/src/main/res/values-night/themes.xml | 40 +---------- app/src/main/res/values-v27/themes.xml | 9 ++- app/src/main/res/values-v31/themes.xml | 13 ++-- app/src/main/res/values/colors.xml | 66 +------------------ app/src/main/res/values/styles.xml | 4 -- app/src/main/res/values/themes.xml | 49 ++------------ build.gradle.kts | 1 + 11 files changed, 46 insertions(+), 183 deletions(-) delete mode 100644 app/src/main/res/values-night-v27/themes.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cc820e00..b58e66d4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -11,6 +11,7 @@ plugins { id("com.google.gms.google-services") id("com.google.firebase.firebase-perf") id("com.google.android.gms.oss-licenses-plugin") + id("dev.rikka.tools.materialthemebuilder") } android { @@ -106,6 +107,22 @@ fun getGitCommit(): String { } } +materialThemeBuilder { + themes { + for ((name, color) in listOf( + "Pyro" to "#EF7A35" + )) { + create(name) { + primaryColor = color + lightThemeFormat = "Theme.CosmicIde.%s.Light" + lightThemeParent = "Theme.CosmicIde" + darkThemeFormat = "Theme.CosmicIde.%s.Dark" + darkThemeParent = "Theme.CosmicIde" + } + } + } +} + dependencies { implementation("com.android.tools:r8:8.0.40") implementation("com.android.tools.smali:smali-dexlib2:3.0.3") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 17257f9d..fe5287c1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/Theme.CosmicIDERewrite" + android:theme="@style/Theme.CosmicIde.Pyro" tools:targetApi="33"> + android:exported="true" + android:theme="@style/Theme.CosmicIde.Start"> @@ -64,15 +65,16 @@ + android:theme="@style/Theme.CosmicIde.Pyro" /> + + android:theme="@style/Theme.CosmicIde.Pyro" /> + android:theme="@style/Theme.CosmicIde.Pyro" /> \ No newline at end of file diff --git a/app/src/main/kotlin/org/cosmicide/rewrite/MainActivity.kt b/app/src/main/kotlin/org/cosmicide/rewrite/MainActivity.kt index c96dd390..d508760a 100644 --- a/app/src/main/kotlin/org/cosmicide/rewrite/MainActivity.kt +++ b/app/src/main/kotlin/org/cosmicide/rewrite/MainActivity.kt @@ -25,8 +25,8 @@ import org.cosmicide.rewrite.util.ResourceUtil class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { - installSplashScreen() super.onCreate(savedInstanceState) + installSplashScreen() WindowCompat.setDecorFitsSystemWindows(window, false) val binding = ActivityMainBinding.inflate(layoutInflater) diff --git a/app/src/main/res/values-night-v27/themes.xml b/app/src/main/res/values-night-v27/themes.xml deleted file mode 100644 index 7c765ba6..00000000 --- a/app/src/main/res/values-night-v27/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index a1418b2c..5d6f81b4 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -6,69 +6,7 @@ --> - #8029DA - #FFFFFF - #EEDBFF - #2A0053 - #655A6F - #FFFFFF - #ECDDF7 - #20182A - #805159 - #FFFFFF - #FFD9DE - #321018 - #BA1A1A - #FFDAD6 - #FFFFFF - #410002 - #FFFBFF - #1D1B1E - #7B757F - #F5EFF4 - #322F33 - #DAB9FF - #000000 - #8029DA - #CCC4CF - #000000 - #FEF7FC - #1D1B1E - #E8E0EB - #4A454E - - #DAB9FF - #470084 - #6500B8 - #EEDBFF - #CFC1DA - #362D40 - #4D4357 - #ECDDF7 - #F2B7C0 - #4B252C - #653B42 - #FFD9DE - #FFB4AB - #93000A - #690005 - #FFDAD6 - #1D1B1E - #E7E1E5 - #958E98 - #1D1B1E - #E7E1E5 - #8029DA - #000000 - #DAB9FF - #4A454E - #000000 - #151316 - #CAC5C9 - #4A454E - #CCC4CF - - #1F1E2B + #1B1B1B #FFFFFF - #7C22D6 + #EF7A35 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index e13a9553..00cf778a 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -25,8 +25,4 @@ ?attr/shapeAppearanceCornerLarge - - \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index ca0e395c..724adab9 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -6,56 +6,21 @@ --> - - - diff --git a/build.gradle.kts b/build.gradle.kts index 7378b4e9..d0e84f8b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,4 +19,5 @@ plugins { id("org.jetbrains.kotlin.android") version "1.8.22" apply false id("org.jetbrains.kotlin.jvm") version "1.8.22" apply false id("org.jetbrains.kotlin.plugin.allopen") version "1.8.22" apply false + id("dev.rikka.tools.materialthemebuilder") version "1.3.3" apply false }