Skip to content

Commit

Permalink
Add Consumer proguard rules
Browse files Browse the repository at this point in the history
  • Loading branch information
janishar committed Apr 3, 2018
1 parent 7cfa150 commit b0f269b
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keepattributes *Annotation*
-keepclassmembers class ** {
@com.mindorks.butterknifelite.annotations.** <methods>;
}
1 change: 0 additions & 1 deletion app/src/main/java/com/mindorks/demo/ActivityTinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Gravity;

import com.mindorks.butterknifelite.ButterKnifeLite;
import com.mindorks.butterknifelite.annotations.BindView;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.mindorks.placeholderview.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Created by janisharali on 18/08/16.
*/

/**
* Will keep any class after proguard minify
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface Keep {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Created by janisharali on 18/08/16.
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface Layout {
@LayoutRes int value();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mindorks.placeholderview.compiler.structures;

import com.mindorks.placeholderview.annotations.Keep;
import com.mindorks.placeholderview.annotations.infinite.LoadMore;
import com.mindorks.placeholderview.annotations.internal.BindingSuffix;
import com.mindorks.placeholderview.compiler.RClassBuilder;
Expand Down Expand Up @@ -55,7 +56,8 @@ protected TypeSpec.Builder createClassBuilder() {
.superclass(parentClassName)
.addSuperinterface(ParameterizedTypeName.get(loadMoreCallbackClassName,
TypeVariableName.get(getClassDetail().getTypeElement().asType())))
.addModifiers(Modifier.PUBLIC);
.addModifiers(Modifier.PUBLIC)
.addAnnotation(Keep.class);
}

public LoadMoreViewBinderClassStructure addConstructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mindorks.placeholderview.compiler.structures;

import com.mindorks.placeholderview.annotations.Keep;
import com.mindorks.placeholderview.annotations.internal.BindingSuffix;
import com.mindorks.placeholderview.annotations.swipe.SwipeInDirectional;
import com.mindorks.placeholderview.annotations.swipe.SwipeOutDirectional;
Expand Down Expand Up @@ -52,7 +53,8 @@ protected TypeSpec.Builder createClassBuilder() {
getClassDetail().getFrameViewClassName(),
getClassDetail().getSwipeDirectionalOptionClassName(),
getClassDetail().getSwipeDecorClassName()))
.addModifiers(Modifier.PUBLIC);
.addModifiers(Modifier.PUBLIC)
.addAnnotation(Keep.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mindorks.placeholderview.compiler.structures;

import com.mindorks.placeholderview.annotations.Keep;
import com.mindorks.placeholderview.annotations.internal.BindingSuffix;
import com.mindorks.placeholderview.annotations.swipe.SwipeCancelState;
import com.mindorks.placeholderview.annotations.swipe.SwipeHead;
Expand Down Expand Up @@ -56,7 +57,8 @@ protected TypeSpec.Builder createClassBuilder() {
getClassDetail().getFrameViewClassName(),
getClassDetail().getSwipeOptionClassName(),
getClassDetail().getSwipeDecorClassName()))
.addModifiers(Modifier.PUBLIC);
.addModifiers(Modifier.PUBLIC)
.addAnnotation(Keep.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mindorks.placeholderview.compiler.structures;

import com.mindorks.placeholderview.annotations.Click;
import com.mindorks.placeholderview.annotations.Keep;
import com.mindorks.placeholderview.annotations.Layout;
import com.mindorks.placeholderview.annotations.LongClick;
import com.mindorks.placeholderview.annotations.NonReusable;
Expand Down Expand Up @@ -57,7 +58,8 @@ protected TypeSpec.Builder createClassBuilder() {
getClassDetail().getSuperClassName(),
TypeVariableName.get(getClassDetail().getTypeElement().asType()),
TypeVariableName.get(getClassDetail().getViewTypeParameterClassName().simpleName())))
.addModifiers(Modifier.PUBLIC);
.addModifiers(Modifier.PUBLIC)
.addAnnotation(Keep.class);
}

public ViewBinderClassStructure addConstructor() {
Expand Down
1 change: 1 addition & 0 deletions placeholderview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ android {
targetSdkVersion rootProject.ext.libTargetSdkVersion
versionCode rootProject.ext.libPublishVersionCode
versionName rootProject.ext.libPublishVersionName
consumerProguardFiles 'proguard-rules.pro'
}
buildTypes {
release {
Expand Down
5 changes: 5 additions & 0 deletions placeholderview/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep @com.mindorks.placeholderview.annotations.Layout public class *
-keep @com.mindorks.placeholderview.annotations.Keep public class *
-keepclassmembers @com.mindorks.placeholderview.annotations.Layout class ** { *;}
-keepclassmembers @com.mindorks.placeholderview.annotations.Keep class ** { *;}

0 comments on commit b0f269b

Please sign in to comment.