Skip to content

Commit

Permalink
Improved docs with new resource injection annotations and better prog…
Browse files Browse the repository at this point in the history
…uard file
  • Loading branch information
jmartinesp committed May 28, 2015
1 parent 11401e6 commit 44c5da1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
32 changes: 32 additions & 0 deletions docs/annotations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
4 changes: 2 additions & 2 deletions docs/groovy.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
Expand Down
14 changes: 9 additions & 5 deletions docs/proguard.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {*;}
----

0 comments on commit 44c5da1

Please sign in to comment.