dev.rikka.tools.materialthemebuilder.generator.ValuesGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugin Show documentation
Show all versions of gradle-plugin Show documentation
A gradle plugin that generates Material Design 3 themes for Android projects.
The newest version!
package dev.rikka.tools.materialthemebuilder.generator;
import com.google.common.base.CaseFormat;
import dev.rikka.tools.materialthemebuilder.MaterialTheme;
import java.io.File;
public abstract class ValuesGenerator extends XmlGenerator {
public ValuesGenerator(File file) {
super(file);
}
@Override
protected void startGenerate() {
beginResource();
}
@Override
protected void endGenerate() {
endResource();
}
protected void beginResource() {
os.println("");
}
protected void endResource() {
os.println(" ");
}
protected void color(int color, String name) {
os.printf("#%06X %n", name, color);
}
protected void styleColorRef(String name, String value) {
os.printf("- @color/%s
%n", name, value);
}
protected void style(String name, String value) {
os.printf("- %s
%n", name, value);
}
protected void attr(String name, String format) {
os.printf(" %n", name, format);
}
protected void beginStyle(String name, String parentName) {
os.printf("");
}
protected void beginDeclareStyleable(String name) {
os.printf("%n", name);
}
protected void endDeclareStyleable() {
os.println(" ");
}
protected void print(String s) {
os.print(s);
}
protected void textColorStyles() {
for (String textColor : MaterialTheme.TEXT_COLORS) {
for (String emphasis : MaterialTheme.TEXT_COLOR_EMPHASIS) {
String name = "text"
+ CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, textColor)
+ emphasis
+ ("".equals(emphasis) ? "" : "Emphasis");
String value = MaterialTheme.getColorStateListFilename(textColor, emphasis);
styleColorRef(name, value);
}
}
}
protected void floatDimen(String name, String value) {
os.printf("- %s
%n", name, value);
}
}