Created
August 24, 2016 15:10
-
-
Save SelvinPL/ec9a639f3e9495b012ed6958edff7ca2 to your computer and use it in GitHub Desktop.
themes.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
apply from: 'themes.gradle' | |
def colorDisabled = 0xADADAD | |
android { | |
.... | |
productFlavors.whenObjectAdded { flavor -> | |
themes_createExtension(flavor, 0x244124, 0x0B280B, 0x3D5A3D, 0x92bc00, colorDisabled) | |
} | |
.... | |
productFlavors { | |
prod { | |
} | |
.... | |
devTL { | |
//TealLime | |
themes.useTheme (0x009688, 0x00796B, 0x19AFA1, 0xC6FF00, colorDisabled) | |
} | |
devOBG { | |
//OrangeBlueGrey | |
themes.useTheme (0xF57C00, 0xE65100, 0xFF9519, 0x78909C, colorDisabled) | |
} | |
devPG { | |
//PurpleGreen | |
themes.useTheme (0x9B26AF, 0x691A99, 0xB43FC8, 0x68EFAD, colorDisabled) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<!-- Automatically generated file. DO NOT MODIFY --> | |
<!-- Values from product flavor: prod --> | |
<color name="colorAccent">#92BC00</color> | |
<color name="colorAccentA10">#1992BC00</color> | |
<color name="colorAccentA20">#3392BC00</color> | |
<color name="colorAccentA30">#4C92BC00</color> | |
<color name="colorAccentA40">#6692BC00</color> | |
<color name="colorAccentA50">#7F92BC00</color> | |
<color name="colorAccentA60">#9992BC00</color> | |
<color name="colorAccentA70">#B292BC00</color> | |
<color name="colorAccentA80">#CC92BC00</color> | |
<color name="colorAccentA90">#E592BC00</color> | |
<color name="colorDisabled">#ADADAD</color> | |
<color name="colorDisabledA10">#19ADADAD</color> | |
<color name="colorDisabledA20">#33ADADAD</color> | |
<color name="colorDisabledA30">#4CADADAD</color> | |
<color name="colorDisabledA40">#66ADADAD</color> | |
<color name="colorDisabledA50">#7FADADAD</color> | |
<color name="colorDisabledA60">#99ADADAD</color> | |
<color name="colorDisabledA70">#B2ADADAD</color> | |
<color name="colorDisabledA80">#CCADADAD</color> | |
<color name="colorDisabledA90">#E5ADADAD</color> | |
<color name="colorPrimary">#244124</color> | |
<color name="colorPrimaryA10">#19244124</color> | |
<color name="colorPrimaryA20">#33244124</color> | |
<color name="colorPrimaryA30">#4C244124</color> | |
<color name="colorPrimaryA40">#66244124</color> | |
<color name="colorPrimaryA50">#7F244124</color> | |
<color name="colorPrimaryA60">#99244124</color> | |
<color name="colorPrimaryA70">#B2244124</color> | |
<color name="colorPrimaryA80">#CC244124</color> | |
<color name="colorPrimaryA90">#E5244124</color> | |
<color name="colorPrimaryDark">#0B280B</color> | |
<color name="colorPrimaryDarkA10">#190B280B</color> | |
<color name="colorPrimaryDarkA20">#330B280B</color> | |
<color name="colorPrimaryDarkA30">#4C0B280B</color> | |
<color name="colorPrimaryDarkA40">#660B280B</color> | |
<color name="colorPrimaryDarkA50">#7F0B280B</color> | |
<color name="colorPrimaryDarkA60">#990B280B</color> | |
<color name="colorPrimaryDarkA70">#B20B280B</color> | |
<color name="colorPrimaryDarkA80">#CC0B280B</color> | |
<color name="colorPrimaryDarkA90">#E50B280B</color> | |
<color name="colorPrimaryLight">#3D5A3D</color> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<!-- alpha 20% of colorAccent for even month row background --> | |
<color name="good_row_month_even">@color/colorAccentA20</color> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources xmlns:tools="http://schemas.android.com/tools"> | |
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar"> | |
<item name="colorPrimary">@color/colorPrimary</item> | |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
<item name="colorAccent">@color/colorAccent</item> | |
<item name="alertDialogTheme">@style/AppTheme.Dialog.Alert</item> | |
</style> | |
<style name="AppTheme" parent="AppBaseTheme"> | |
</style> | |
<style name="AppTheme.Dialog.Alert" parent="Theme.AppCompat.Dialog.Alert"> | |
<item name="colorAccent">@color/colorAccent</item> | |
</style> | |
<style name="AppTheme.Light.Dialog" parent="Theme.AppCompat.Light.Dialog"> | |
<item name="colorAccent">@color/colorAccent</item> | |
</style> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ThemesExtension { | |
def parent | |
public ThemesExtension(parentIn, int colorPrimary, int colorPrimaryDark, int colorPrimaryLight, int colorAccent, int colorDisabled) { | |
parent = parentIn | |
useTheme(colorPrimary, colorPrimaryDark, colorPrimaryLight, colorAccent, colorDisabled) | |
} | |
public useTheme(int colorPrimary, int colorPrimaryDark, int colorPrimaryLight, int colorAccent, int colorDisabled) { | |
def colors = [:] | |
colors["colorPrimary"] = String.format("#%06X", colorPrimary) | |
colors["colorPrimaryDark"] = String.format("#%06X", colorPrimaryDark) | |
colors["colorPrimaryLight"] = String.format("#%06X", colorPrimaryLight) | |
colors["colorAccent"] = String.format("#%06X", colorAccent) | |
colors["colorDisabled"] = String.format("#%06X", colorDisabled) | |
for (i in 1..9) { | |
def alpha = (int) (i * 25.5) | |
colors["colorPrimary" + "A" + i + "0"] = String.format("#%02X%06X", alpha, colorPrimary) | |
colors["colorPrimaryDark" + "A" + i + "0"] = String.format("#%02X%06X", alpha, colorPrimaryDark) | |
colors["colorAccent" + "A" + i + "0"] = String.format("#%02X%06X", alpha, colorAccent) | |
colors["colorDisabled" + "A" + i + "0"] = String.format("#%02X%06X", alpha, colorDisabled) | |
} | |
colors.each {n, v -> | |
this.parent.resValue("color", n, v) | |
} | |
} | |
} | |
ext { | |
themes_createExtension = { parent, colorPrimary, colorPrimaryDark, colorPrimaryLight, colorAccent, colorDisabled -> | |
parent.extensions.create("themes", ThemesExtension, parent, colorPrimary, colorPrimaryDark, colorPrimaryLight, colorAccent, colorDisabled) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment