From 44c5da16649effc33c06001781f8b13dc03411c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Marti=CC=81n?= Date: Thu, 28 May 2015 19:52:06 +0200 Subject: [PATCH] Improved docs with new resource injection annotations and better proguard file --- docs/annotations.adoc | 32 ++++++++++++++++++++++++++++++++ docs/groovy.adoc | 4 ++-- docs/proguard.adoc | 14 +++++++++----- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/docs/annotations.adoc b/docs/annotations.adoc index 8bce810..66c5b2a 100644 --- a/docs/annotations.adoc +++ b/docs/annotations.adoc @@ -572,3 +572,35 @@ Almost everything that can be put into a Bundle, just like with `@SaveInstance`: * Primitive types *(int, double, long, char...)*. * Classes that implement `Parcelable` or `Serializable`. * Arrays an Lists all above. + +=== @Res annotations + +Some annotations have been added to inject resources directly on your groovy classes: + +* `@StringRes`: String. +* `@IntegerRes`: int, Integer. +* `@BooleanRes`: boolean, Boolean. +* `@DimenRes`: float, Float. +* `@ColorRes`: int, Integer. +* `@StringArrayRes`: String[]. +* `@IntegerArrayRes`: int[], Integer[]. +* `@DrawableRes`: Drawable. +* `@AnimationRes`: Animation. +* `@ColorStateListRes`: ColorStateList. + +These will be linked to their resources when `SwissKnife.inject` method is called. + +Also, at its current state, resource injection will only work with your project's **R** resources, it won't work with any **android.R** resources. + +==== Example: + +Here's a quick example: + +[source,groovy] +---- +@AnimationRes(R.anim.fade_in) +Animation fadeInAnimation + +@StringArrayRes +String[] menuOptions // will look for R.array.menuOptions +---- \ No newline at end of file diff --git a/docs/groovy.adoc b/docs/groovy.adoc index 9006a07..7262b50 100644 --- a/docs/groovy.adoc +++ b/docs/groovy.adoc @@ -22,8 +22,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.0.0' - classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.5' + classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6' } } diff --git a/docs/proguard.adoc b/docs/proguard.adoc index b9a20f7..76bb34e 100644 --- a/docs/proguard.adoc +++ b/docs/proguard.adoc @@ -13,16 +13,20 @@ ProGuard shrinks all unused methods by default from your code. As most methods a # Groovy stuff so the compiler doesn't complain -dontwarn org.codehaus.groovy.** -dontwarn groovy** +-dontwarn com.vividsolutions.** +-dontwarn com.squareup.** +-dontwarn okio.** -keep class org.codehaus.groovy.vmplugin.** --keep class org.codehaus.groovy.runtime.dgm* +-keep class org.codehaus.groovy.runtime.** -keepclassmembers class org.codehaus.groovy.runtime.dgm* {*;} -keepclassmembers class ** implements org.codehaus.groovy.runtime.GeneratedClosure {*;} -keepclassmembers class org.codehaus.groovy.reflection.GroovyClassValue* {*;} + # Don't shrink SwissKnife methods --dontshrink class com.arasthel.swissknife.** +-keep class com.arasthel.swissknife** { *; } -# Don't shrink annotated methods on your classes --dontshrink class com.myname.myproject.MyClass --dontshrink class com.myname.myproject.subpackage.** +# Add this for any classes that will have SK injections +-keep class * extends android.app.Activity +-keepclassmembers class * extends android.app.Activity {*;} ----