Created
January 14, 2015 23:33
-
-
Save SelvinPL/f89476b6585690cb252b to your computer and use it in GitHub Desktop.
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' | |
def createTheme(colorPrimary, colorPrimaryDark, colorAccent, colorDisabled) { | |
def returnTheme = new Expando() | |
returnTheme.colorPrimary = colorPrimary | |
returnTheme.colorPrimaryDark = colorPrimaryDark | |
returnTheme.colorAccent = colorAccent | |
returnTheme.colorDisabled = colorDisabled | |
return returnTheme | |
} | |
def colorDisabled = "ADADAD" | |
//define theme | |
def themeOrangeBlueGrey = createTheme("F57C00", "E65100", "78909C", colorDisabled) | |
def themeIndigoPink = createTheme("3F51B5", "1A237E", "F50057", colorDisabled) | |
def themeOSA1 = createTheme("284E3D", "293326", "8CC63F", colorDisabled) | |
def themeOSA1a = createTheme("284E3D", "1A3327", "8CC63F", colorDisabled) | |
def themeOSA2 = createTheme("404F3C", "1F261D", "A6C03B", colorDisabled) | |
def themeTealLime = createTheme("009688", "00796B", "C6FF00", colorDisabled) | |
//select theme | |
def theme = themeOSA1a | |
. | |
. | |
. | |
. | |
. | |
. | |
android.applicationVariants.all { variant -> | |
variant.resValue "color", "colorPrimary", "#" + theme.colorPrimary | |
variant.resValue "color", "colorPrimaryDark", "#" + theme.colorPrimaryDark | |
variant.resValue "color", "colorAccent", "#" + theme.colorAccent | |
variant.resValue "color", "colorDisabled", "#" + theme.colorDisabled | |
for ( i in 1..9 ) { | |
def hex = Integer.toHexString(((int)i * 25.5)) | |
variant.resValue "color", "colorPrimary" + "A" + i + "0", "#" + hex + theme.colorPrimary | |
variant.resValue "color", "colorPrimaryDark" + "A" + i + "0", "#" + hex + theme.colorPrimaryDark | |
variant.resValue "color", "colorAccent" + "A" + i + "0", "#" + hex + theme.colorAccent | |
variant.resValue "color", "colorDisabled" + "A" + i + "0", "#" + hex + theme.colorDisabled | |
} | |
variant.outputs.each { output -> | |
def apk = output.outputFile | |
def newName = "TheApp" | |
newName = newName + "-${android.defaultConfig.versionName}.apk" | |
output.outputFile = new File(new File(apk.parentFile, variant.name), newName) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment