Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

vokal/android-res-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Android Resource Generator

Automatic resource exporter plugin for android projects: generating density specific drawables from PDF files.

Setup

If using Artifactory:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:${toolsVersion}'
        classpath 'io.vokal.gradle:resgen:1.0.1'
    }
}

If using precompiled JAR:

buildscript {
    repositories {
        …
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:${toolsVersion}'
        classpath files('libs/resgen-1.0.1.jar')
        classpath 'org.apache.pdfbox:pdfbox:2.0.0'
    }
}

Usage

Options

  • densities [array of strings] - Default: ["hdpi", "xhdpi", "xxhdpi"]
  • jpeg [array of strings] - Usage: File pattern to match for jpeg rendering
  • jpegQuality [float] - Usage: Quality Range from 0 to 100
  • mipmap [array of strings] - Usage: File pattern to match for mipmap rendering
  • mipmapDensities [array of strings] - Default: ["hdpi", "xhdpi", "xxhdpi", "xxxhdpi"]
apply plugin: 'com.android.application'
apply plugin: 'io.vokal.resgen'

android {
   …
   // if PDF files are placed in a folder named 'res-gen' they will be recognized automatically
   // or you can configure the location of your PDF files with the following
   sourceSets {
       main {
           pdf.srcDir 'src/main/pdf'
       }
   }
}

resgen {
   densities "mdpi", "hdpi", "xhdpi", "xxhdpi"
   jpeg "bg_*", "exact_filename" // may contain wildcards (* or ?) or regex
   jpegQuality 80 // default is 85 if only jpeg patterns specified
   mipmap "ic_launcher", "*_image" // names of assets you would like in mipmap folders (wildcard or regex accepted)
   mipmapDensities "hdpi", "xhdpi", "xxhdpi", "xxxhdpi" // densities for mipmaps, defaults to densities
}

Densities are from the set: ["ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"] (xxxhdpi is only applicable for mipmapDensities)

Place PDF assets file in /main/src/res-gen folder (or whatever your sourceDir is set to.)

If you have alternative resources for different configurations (language, orientation, smallest width) you can nest the structure in res-gen folder:

res-gen/
    en/
        port/
            background.pdf
        land/
            background.pdf
    es/
        port/
            background.pdf
        land/
            background.pdf

You must follow the Qualifier name rules and order the nesting as Android expects. (currently only accepts qualifiers listed before density (dpi) in the table)

Drawables are generated from PDF files as part of the build process or can be generated manually with gradle task generate{variantName}ResRasterizePdf. eg. generateDebugResRasterizePdf, generateStageDebugResRasterizePdf Drawables will be re-generated automatically when PDF file is updated.

About

Automatic res exporter plugin for android projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages