Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Implement theme builder plugin to generate colored material themes #61

Merged
merged 2 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down
12 changes: 7 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<provider
Expand All @@ -53,7 +53,8 @@

<activity
android:name=".MainActivity"
android:exported="true">
android:exported="true"
android:theme="@style/Theme.CosmicIde.Start">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -64,15 +65,16 @@

<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.CosmicIDERewrite" />
android:theme="@style/Theme.CosmicIde.Pyro" />

<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/Theme.CosmicIDERewrite" />
android:theme="@style/Theme.CosmicIde.Pyro" />

<activity
android:name="com.developer.crashx.activity.DefaultErrorActivity"
android:process=":error_activity"
android:theme="@style/Theme.CosmicIDERewrite" />
android:theme="@style/Theme.CosmicIde.Pyro" />
</application>

</manifest>
2 changes: 1 addition & 1 deletion app/src/main/kotlin/org/cosmicide/rewrite/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,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)
Expand Down
16 changes: 0 additions & 16 deletions app/src/main/res/values-night-v27/themes.xml

This file was deleted.

40 changes: 1 addition & 39 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,5 @@
-->

<resources>

<style name="Base.Theme.CosmicIDERewrite" parent="Theme.Material3.Dark.NoActionBar">
<item name="android:colorBackground">@color/dark_colorBackground</item>
<item name="android:fontFamily">@font/inter</item>
<item name="android:statusBarColor">@android:color/transparent</item>

<item name="appBarLayoutStyle">@style/Widget.CosmicIde.AppBarLayout</item>
<item name="fontFamily">@font/inter</item>
<item name="popupMenuStyle">@style/Widget.Material3.PopupMenu</item>

<!-- Colors -->
<item name="colorPrimary">@color/dark_colorPrimary</item>
<item name="colorOnPrimary">@color/dark_colorOnPrimary</item>
<item name="colorPrimaryContainer">@color/dark_colorPrimaryContainer</item>
<item name="colorOnPrimaryContainer">@color/dark_colorOnPrimaryContainer</item>
<item name="colorSecondary">@color/dark_colorSecondary</item>
<item name="colorOnSecondary">@color/dark_colorOnSecondary</item>
<item name="colorSecondaryContainer">@color/dark_colorSecondaryContainer</item>
<item name="colorOnSecondaryContainer">@color/dark_colorOnSecondaryContainer</item>
<item name="colorTertiary">@color/dark_colorTertiary</item>
<item name="colorOnTertiary">@color/dark_colorOnTertiary</item>
<item name="colorTertiaryContainer">@color/dark_colorTertiaryContainer</item>
<item name="colorOnTertiaryContainer">@color/dark_colorOnTertiaryContainer</item>
<item name="colorError">@color/dark_colorError</item>
<item name="colorErrorContainer">@color/dark_colorErrorContainer</item>
<item name="colorOnError">@color/dark_colorOnError</item>
<item name="colorOnErrorContainer">@color/dark_colorOnErrorContainer</item>
<item name="colorOnBackground">@color/dark_colorOnBackground</item>
<item name="colorOutline">@color/dark_colorOutline</item>
<item name="colorOnSurfaceInverse">@color/dark_colorInverseOnSurface</item>
<item name="colorSurfaceInverse">@color/dark_colorInverseSurface</item>
<item name="colorSurface">@color/dark_colorSurface</item>
<item name="colorOnSurface">@color/dark_colorOnSurface</item>
<item name="colorSurfaceVariant">@color/dark_colorSurfaceVariant</item>
<item name="colorOnSurfaceVariant">@color/dark_colorOnSurfaceVariant</item>
<item name="colorPrimaryInverse">@color/dark_colorInversePrimary</item>
</style>

<style name="Theme.CosmicIDERewrite" parent="Base.Theme.CosmicIDERewrite" />
<style name="Theme.CosmicIde.Pyro" parent="Theme.CosmicIde.Pyro.Dark" />
</resources>
9 changes: 4 additions & 5 deletions app/src/main/res/values-v27/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
~ You should have received a copy of the GNU General Public License along with Foobar. If not, see <https://www.gnu.org/licenses/>.
-->

<resources xmlns:tools="http://schemas.android.com/tools">

<style name="Base.V27.CosmicIDERewrite" parent="Base.Theme.CosmicIDERewrite">
<resources>
<style name="Theme.CosmicIde.BaseV27" parent="Theme.CosmicIde.Base">
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowLightNavigationBar">?attr/isLightTheme</item>
<item tools:ignore="NewApi" name="android:enforceNavigationBarContrast">false</item>
<item name="android:enforceNavigationBarContrast">false</item>
</style>

<style name="Theme.CosmicIDERewrite" parent="Base.V27.CosmicIDERewrite" />
<style name="Theme.CosmicIde" parent="Theme.CosmicIde.BaseV27" />
</resources>
13 changes: 6 additions & 7 deletions app/src/main/res/values-v31/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
-->

<resources>

<style name="Base.V31.CosmicIDERewrite" parent="Base.V27.CosmicIDERewrite">
<style name="Theme.CosmicIde.BaseV31" parent="Theme.CosmicIde.BaseV27">
<item name="android:windowSplashScreenBackground">@color/logo_background</item>
<item name="android:windowSplashScreenBrandingImage">@drawable/banner</item>
</style>

<style name="Theme.CosmicIDERewrite" parent="Base.V31.CosmicIDERewrite" />
<style name="Theme.CosmicIde" parent="Theme.CosmicIde.BaseV31" />

<style name="Theme.CosmicIde.Start" parent="Theme.SplashScreen">
<item name="android:windowSplashScreenAnimationDuration">2147483647</item>

<style name="Theme.CosmicIDERewrite.Start" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/logo_background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_animated</item>
<!-- Integer.MAX_VALUE -->
<item name="android:windowSplashScreenAnimationDuration">2147483647</item>
<item name="postSplashScreenTheme">@style/Theme.CosmicIDERewrite</item>
<item name="postSplashScreenTheme">@style/Theme.CosmicIde.Pyro</item>
</style>
</resources>
66 changes: 2 additions & 64 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,7 @@
-->

<resources>
<color name="light_colorPrimary">#8029DA</color>
<color name="light_colorOnPrimary">#FFFFFF</color>
<color name="light_colorPrimaryContainer">#EEDBFF</color>
<color name="light_colorOnPrimaryContainer">#2A0053</color>
<color name="light_colorSecondary">#655A6F</color>
<color name="light_colorOnSecondary">#FFFFFF</color>
<color name="light_colorSecondaryContainer">#ECDDF7</color>
<color name="light_colorOnSecondaryContainer">#20182A</color>
<color name="light_colorTertiary">#805159</color>
<color name="light_colorOnTertiary">#FFFFFF</color>
<color name="light_colorTertiaryContainer">#FFD9DE</color>
<color name="light_colorOnTertiaryContainer">#321018</color>
<color name="light_colorError">#BA1A1A</color>
<color name="light_colorErrorContainer">#FFDAD6</color>
<color name="light_colorOnError">#FFFFFF</color>
<color name="light_colorOnErrorContainer">#410002</color>
<color name="light_colorBackground">#FFFBFF</color>
<color name="light_colorOnBackground">#1D1B1E</color>
<color name="light_colorOutline">#7B757F</color>
<color name="light_colorInverseOnSurface">#F5EFF4</color>
<color name="light_colorInverseSurface">#322F33</color>
<color name="light_colorInversePrimary">#DAB9FF</color>
<color name="light_colorShadow">#000000</color>
<color name="light_colorSurfaceTint">#8029DA</color>
<color name="light_colorOutlineVariant">#CCC4CF</color>
<color name="light_colorScrim">#000000</color>
<color name="light_colorSurface">#FEF7FC</color>
<color name="light_colorOnSurface">#1D1B1E</color>
<color name="light_colorSurfaceVariant">#E8E0EB</color>
<color name="light_colorOnSurfaceVariant">#4A454E</color>

<color name="dark_colorPrimary">#DAB9FF</color>
<color name="dark_colorOnPrimary">#470084</color>
<color name="dark_colorPrimaryContainer">#6500B8</color>
<color name="dark_colorOnPrimaryContainer">#EEDBFF</color>
<color name="dark_colorSecondary">#CFC1DA</color>
<color name="dark_colorOnSecondary">#362D40</color>
<color name="dark_colorSecondaryContainer">#4D4357</color>
<color name="dark_colorOnSecondaryContainer">#ECDDF7</color>
<color name="dark_colorTertiary">#F2B7C0</color>
<color name="dark_colorOnTertiary">#4B252C</color>
<color name="dark_colorTertiaryContainer">#653B42</color>
<color name="dark_colorOnTertiaryContainer">#FFD9DE</color>
<color name="dark_colorError">#FFB4AB</color>
<color name="dark_colorErrorContainer">#93000A</color>
<color name="dark_colorOnError">#690005</color>
<color name="dark_colorOnErrorContainer">#FFDAD6</color>
<color name="dark_colorBackground">#1D1B1E</color>
<color name="dark_colorOnBackground">#E7E1E5</color>
<color name="dark_colorOutline">#958E98</color>
<color name="dark_colorInverseOnSurface">#1D1B1E</color>
<color name="dark_colorInverseSurface">#E7E1E5</color>
<color name="dark_colorInversePrimary">#8029DA</color>
<color name="dark_colorShadow">#000000</color>
<color name="dark_colorSurfaceTint">#DAB9FF</color>
<color name="dark_colorOutlineVariant">#4A454E</color>
<color name="dark_colorScrim">#000000</color>
<color name="dark_colorSurface">#151316</color>
<color name="dark_colorOnSurface">#CAC5C9</color>
<color name="dark_colorSurfaceVariant">#4A454E</color>
<color name="dark_colorOnSurfaceVariant">#CCC4CF</color>

<color name="logo_background">#1F1E2B</color>
<color name="logo_background">#1B1B1B</color>
<color name="logo_stroke">#FFFFFF</color>
<color name="logo_accent">#7C22D6</color>
<color name="logo_accent">#EF7A35</color>
</resources>
4 changes: 0 additions & 4 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,4 @@
<item name="shapeAppearance">?attr/shapeAppearanceCornerLarge</item>
</style>

<style name="Widget.CosmicIde.AppBarLayout" parent="Widget.Material3.AppBarLayout">
<item name="android:background">?android:attr/colorBackground</item>
</style>

</resources>
49 changes: 7 additions & 42 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,21 @@
-->

<resources>

<style name="Base.Theme.CosmicIDERewrite" parent="Theme.Material3.Light.NoActionBar">

<item name="android:navigationBarColor">
@android:color/transparent
</item>

<item name="android:colorBackground">@color/light_colorBackground</item>
<style name="Theme.CosmicIde.Base" parent="Theme.Material3.DayNight.NoActionBar">
<item name="android:fontFamily">@font/inter</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>

<item name="appBarLayoutStyle">@style/Widget.CosmicIde.AppBarLayout</item>
<item name="fontFamily">@font/inter</item>
<item name="popupMenuStyle">@style/Widget.Material3.PopupMenu</item>

<!-- Colors -->
<item name="colorPrimary">@color/light_colorPrimary</item>
<item name="colorOnPrimary">@color/light_colorOnPrimary</item>
<item name="colorPrimaryContainer">@color/light_colorPrimaryContainer</item>
<item name="colorOnPrimaryContainer">@color/light_colorOnPrimaryContainer</item>
<item name="colorSecondary">@color/light_colorSecondary</item>
<item name="colorOnSecondary">@color/light_colorOnSecondary</item>
<item name="colorSecondaryContainer">@color/light_colorSecondaryContainer</item>
<item name="colorOnSecondaryContainer">@color/light_colorOnSecondaryContainer</item>
<item name="colorTertiary">@color/light_colorTertiary</item>
<item name="colorOnTertiary">@color/light_colorOnTertiary</item>
<item name="colorTertiaryContainer">@color/light_colorTertiaryContainer</item>
<item name="colorOnTertiaryContainer">@color/light_colorOnTertiaryContainer</item>
<item name="colorError">@color/light_colorError</item>
<item name="colorErrorContainer">@color/light_colorErrorContainer</item>
<item name="colorOnError">@color/light_colorOnError</item>
<item name="colorOnErrorContainer">@color/light_colorOnErrorContainer</item>
<item name="colorOnBackground">@color/light_colorOnBackground</item>
<item name="colorOutline">@color/light_colorOutline</item>
<item name="colorOnSurfaceInverse">@color/light_colorInverseOnSurface</item>
<item name="colorSurfaceInverse">@color/light_colorInverseSurface</item>
<item name="colorSurface">@color/light_colorSurface</item>
<item name="colorOnSurface">@color/light_colorOnSurface</item>
<item name="colorSurfaceVariant">@color/light_colorSurfaceVariant</item>
<item name="colorOnSurfaceVariant">@color/light_colorOnSurfaceVariant</item>
<item name="colorPrimaryInverse">@color/light_colorInversePrimary</item>
</style>

<style name="Theme.CosmicIDERewrite" parent="Base.Theme.CosmicIDERewrite" />
<style name="Theme.CosmicIde" parent="Theme.CosmicIde.Base" />
<style name="Theme.CosmicIde.Pyro" parent="Theme.CosmicIde.Pyro.Light" />

<style name="Theme.CosmicIDERewrite.Start" parent="Theme.SplashScreen">
<style name="Theme.CosmicIde.Start" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/logo_background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_animated</item>
<item name="postSplashScreenTheme">@style/Theme.CosmicIDERewrite</item>
<item name="windowSplashScreenIconBackgroundColor">?colorSurface</item>
<item name="windowSplashScreenIconBackgroundColor">?attr/colorSurface</item>
<item name="postSplashScreenTheme">@style/Theme.CosmicIde.Pyro</item>
</style>
</resources>
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}