Android Resource Generator


Source link: https://github.com/vokal/android-res-gen

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.

Resources

BottomSheet is an Android component which presents a dismissible view from the bottom of the screen. BottomSheet can be a useful replacement for dialogs and menus but can hold any view so the use cases are endless.

Vault is an Android library that simplifies persistence of data from Contentful via SQLite. It lets you define Java representations for your Contentful models.

Android Library to make a cool intro for your app.

A Gradle plugin to report the number of method references in your APK on every build.

Gradle plugin that tells you what libs have new versions on Maven Central, so when you come back to a project, you know what you can update.

A helper class that extends SpannableStringBuilder and adds methods to easily mark the text with multiple spans.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes