diff --git a/.gitignore b/.gitignore index 60de42dc..5341424a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,3 @@ /build *.iml /*/build -/theme-build-tmp -/gradle/local.properties -/templates diff --git a/build.gradle b/build.gradle index cfeb6003..38a87e64 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,4 @@ -// Written by Alexander Sosedkin -// This scripts builds the icon theme, rendering png files in build-time. -// Should be portable, doesn't require rsvg-tools or inkscape at all. - -// Somebody who knows groovy/gradle should have a look at that -// and correct all the dirty hacks I've used here, willingly or unwillingly. - -// For some reasons the former template was so messy, that the icons -// based on it do not render. Please paste the icon onto the new template -// (svg-icons/twelf-icon-template.png). - -// It also generates pre-colored svg icon templates -// in a directory named 'templates'. +// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { @@ -18,8 +6,6 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:1.0.1' - classpath 'org.apache.xmlgraphics:batik-codec:1.7' - classpath 'org.apache.xmlgraphics:batik-rasterizer:1.7' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -32,20 +18,7 @@ allprojects { } } -import org.apache.batik.apps.rasterizer.SVGConverter -import org.apache.batik.apps.rasterizer.DestinationType -void svgToPng(String svg_filename, String png_filename, int size) { - println 'Converting ' + svg_filename + ' to size ' + size - SVGConverter svgConverter = new SVGConverter() - svgConverter.setSources([svg_filename] as String[]) - svgConverter.setDestinationType(DestinationType.PNG) - svgConverter.setHeight(size) - svgConverter.setWidth(size) - svgConverter.setDst(new File(png_filename)) - svgConverter.execute() -} - -project(':theme-build-tmp') { +project(':theme') { apply plugin: 'base' apply plugin: 'com.android.application' android { @@ -62,99 +35,4 @@ project(':theme-build-tmp') { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) } - - task copyTemplate(type:Copy) { - from '../theme' - into '.' - } - preBuild.dependsOn(copyTemplate) - copyTemplate.outputs.dir '.' - clean.dependsOn cleanCopyTemplate - - task renderPngs << { - // TODO: proper path concatenation? - final outDir = './theme-build-tmp/src/main/assets/icons/res/drawable-' - final sizes = [mdpi: 48, hdpi: 72, xhdpi: 96, xxhdpi: 144, xxxhdpi: 192] - final svgs = fileTree(dir: '../svg-icons', include: '*.svg') - for (f in svgs) { - for (e in sizes) { - svgToPng(f.path, - outDir + e.key + '/' + - org.apache.commons.io.FilenameUtils.getBaseName(f.name) + - '.png', - e.value) - } - } - } - renderPngs.dependsOn(copyTemplate) - preBuild.dependsOn(renderPngs) - // TODO: cleaning should be more elegant - } - - -// generating pre-colored svg templates from a master svg template - -final shadeIndigo900 = '#1a237e' -final shadeBlueGrey900 = '#263238' -final shadeDeepOrange900 = '#bf360c' -final shadeBrown900 = '#3e2723' -final shadeGrey900 = '#212121' -final colors = [ // main, shade/shadow - 'blue': ['#2196f3', shadeIndigo900], - 'indigo': ['#3f51b5', shadeIndigo900], - 'deep-purple': ['#673ab7', shadeIndigo900], - 'purple': ['#9c27b0', shadeIndigo900], - - 'blue-grey': ['#607d8b', shadeBlueGrey900], - 'light-blue': ['#03a9f4', shadeBlueGrey900], - 'cyan': ['#00bcd4', shadeBlueGrey900], - 'teal': ['#009688', shadeBlueGrey900], - 'green': ['#4caf50', shadeBlueGrey900], - 'light-green': ['#8bc34a', shadeBlueGrey900], - 'lime': ['#cddc39', shadeBlueGrey900], - - 'yellow': ['#ffeb3b', shadeDeepOrange900], - 'amber': ['#ffc107', shadeDeepOrange900], - 'orange': ['#ff9800', shadeDeepOrange900], - - 'deep-orange': ['#ff5722', shadeBrown900], - 'red': ['#f44336', shadeBrown900], - 'pink': ['#e91e63', shadeBrown900], - 'brown': ['#795548', shadeBrown900], - - // TODO: maybe these should not be included? - /* - 'grey50': ['#fafafa', shadeGrey900], - 'grey100': ['#f5f5f5', shadeGrey900], - 'grey200': ['#eeeeee', shadeGrey900], - 'grey300': ['#e0e0e0', shadeGrey900], - 'grey400': ['#bdbdbd', shadeGrey900], - 'grey500': ['#9e9e9e', shadeGrey900], - 'grey600': ['#757575', shadeGrey900], - 'grey700': ['#616161', shadeGrey900], - 'grey800': ['#424242', shadeGrey900], - */ -] - -project(':templates') { - apply plugin: 'base' - task build << { - final master_tpl = new File('./svg-icons/twelf_icon_template.svg').text - new File("./templates").mkdir() - for (c in colors) { - println 'Generating template ' + c.key + '.svg' - new File('./templates/' + c.key + '.svg').write( - master_tpl - .replace('#03a9f4', c.value[0]) - .replace('#01579b', c.value[1]) - ) - } - } - build.outputs.upToDateWhen { false } // hack - build.outputs.dir './templates' - clean.dependsOn cleanBuild - // TODO: fix cleaning - // TODO: fix rebuilding -} -project(':theme-build-tmp').build.dependsOn project(':templates').build diff --git a/settings.gradle b/settings.gradle index 5c21b3d8..1087ea5a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1 @@ -include ':theme-build-tmp' -include ':templates' +include ':theme' \ No newline at end of file diff --git a/svg-icons/syncthing.svg b/svg-icons/syncthing.svg deleted file mode 100644 index a7f1f3b0..00000000 --- a/svg-icons/syncthing.svg +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/svg-icons/twelf_icon_template.svg b/svg-icons/twelf_icon_template.svg deleted file mode 100644 index 96079f4e..00000000 --- a/svg-icons/twelf_icon_template.svg +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - diff --git a/tools/svgs_to_pngs.sh b/tools/svgs_to_pngs.sh new file mode 100644 index 00000000..525d644f --- /dev/null +++ b/tools/svgs_to_pngs.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Thanks to t184256 + + +for SVG in svgs/*.svg; do + N=$(basename $SVG .svg) + inkscape -f $SVG -w 48 -h 48 -e \ + theme/src/main/assets/icons/res/test/drawable-mdpi/$N.png + inkscape -f $SVG -w 72 -h 72 -e \ + theme/src/main/assets/icons/res/test/drawable-hdpi/$N.png + inkscape -f $SVG -w 96 -h 96 -e \ + theme/src/main/assets/icons/res/test/drawable-xhdpi/$N.png + inkscape -f $SVG -w 144 -h 144 -e \ + theme/src/main/assets/icons/res/test/drawable-xxhdpi/$N.png + inkscape -f $SVG -w 192 -h 192 -e \ + theme/src/main/assets/icons/res/test/drawable-xxxhdpi/$N.png +done