Skip to content

Commit b0f269b

Browse files
committed
Add Consumer proguard rules
1 parent 7cfa150 commit b0f269b

File tree

10 files changed

+41
-6
lines changed

10 files changed

+41
-6
lines changed

app/proguard-rules.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18+
-keepattributes *Annotation*
19+
-keepclassmembers class ** {
20+
@com.mindorks.butterknifelite.annotations.** <methods>;
21+
}

app/src/main/java/com/mindorks/demo/ActivityTinder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import android.support.annotation.Nullable;
55
import android.support.v7.app.AppCompatActivity;
66
import android.util.Log;
7-
import android.view.Gravity;
87

98
import com.mindorks.butterknifelite.ButterKnifeLite;
109
import com.mindorks.butterknifelite.annotations.BindView;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.mindorks.placeholderview.annotations;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* Created by janisharali on 18/08/16.
10+
*/
11+
12+
/**
13+
* Will keep any class after proguard minify
14+
*/
15+
@Retention(RetentionPolicy.CLASS)
16+
@Target(ElementType.TYPE)
17+
public @interface Keep {
18+
}

placeholderview-annotations/src/main/java/com/mindorks/placeholderview/annotations/Layout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* Created by janisharali on 18/08/16.
1212
*/
13-
@Retention(RetentionPolicy.SOURCE)
13+
@Retention(RetentionPolicy.CLASS)
1414
@Target(ElementType.TYPE)
1515
public @interface Layout {
1616
@LayoutRes int value();

placeholderview-compiler/src/main/java/com/mindorks/placeholderview/compiler/structures/LoadMoreViewBinderClassStructure.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mindorks.placeholderview.compiler.structures;
22

3+
import com.mindorks.placeholderview.annotations.Keep;
34
import com.mindorks.placeholderview.annotations.infinite.LoadMore;
45
import com.mindorks.placeholderview.annotations.internal.BindingSuffix;
56
import com.mindorks.placeholderview.compiler.RClassBuilder;
@@ -55,7 +56,8 @@ protected TypeSpec.Builder createClassBuilder() {
5556
.superclass(parentClassName)
5657
.addSuperinterface(ParameterizedTypeName.get(loadMoreCallbackClassName,
5758
TypeVariableName.get(getClassDetail().getTypeElement().asType())))
58-
.addModifiers(Modifier.PUBLIC);
59+
.addModifiers(Modifier.PUBLIC)
60+
.addAnnotation(Keep.class);
5961
}
6062

6163
public LoadMoreViewBinderClassStructure addConstructor() {

placeholderview-compiler/src/main/java/com/mindorks/placeholderview/compiler/structures/SwipeDirectionalViewBinderClassStructure.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mindorks.placeholderview.compiler.structures;
22

3+
import com.mindorks.placeholderview.annotations.Keep;
34
import com.mindorks.placeholderview.annotations.internal.BindingSuffix;
45
import com.mindorks.placeholderview.annotations.swipe.SwipeInDirectional;
56
import com.mindorks.placeholderview.annotations.swipe.SwipeOutDirectional;
@@ -52,7 +53,8 @@ protected TypeSpec.Builder createClassBuilder() {
5253
getClassDetail().getFrameViewClassName(),
5354
getClassDetail().getSwipeDirectionalOptionClassName(),
5455
getClassDetail().getSwipeDecorClassName()))
55-
.addModifiers(Modifier.PUBLIC);
56+
.addModifiers(Modifier.PUBLIC)
57+
.addAnnotation(Keep.class);
5658
}
5759

5860
@Override

placeholderview-compiler/src/main/java/com/mindorks/placeholderview/compiler/structures/SwipeViewBinderClassStructure.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mindorks.placeholderview.compiler.structures;
22

3+
import com.mindorks.placeholderview.annotations.Keep;
34
import com.mindorks.placeholderview.annotations.internal.BindingSuffix;
45
import com.mindorks.placeholderview.annotations.swipe.SwipeCancelState;
56
import com.mindorks.placeholderview.annotations.swipe.SwipeHead;
@@ -56,7 +57,8 @@ protected TypeSpec.Builder createClassBuilder() {
5657
getClassDetail().getFrameViewClassName(),
5758
getClassDetail().getSwipeOptionClassName(),
5859
getClassDetail().getSwipeDecorClassName()))
59-
.addModifiers(Modifier.PUBLIC);
60+
.addModifiers(Modifier.PUBLIC)
61+
.addAnnotation(Keep.class);
6062
}
6163

6264
@Override

placeholderview-compiler/src/main/java/com/mindorks/placeholderview/compiler/structures/ViewBinderClassStructure.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.mindorks.placeholderview.compiler.structures;
22

33
import com.mindorks.placeholderview.annotations.Click;
4+
import com.mindorks.placeholderview.annotations.Keep;
45
import com.mindorks.placeholderview.annotations.Layout;
56
import com.mindorks.placeholderview.annotations.LongClick;
67
import com.mindorks.placeholderview.annotations.NonReusable;
@@ -57,7 +58,8 @@ protected TypeSpec.Builder createClassBuilder() {
5758
getClassDetail().getSuperClassName(),
5859
TypeVariableName.get(getClassDetail().getTypeElement().asType()),
5960
TypeVariableName.get(getClassDetail().getViewTypeParameterClassName().simpleName())))
60-
.addModifiers(Modifier.PUBLIC);
61+
.addModifiers(Modifier.PUBLIC)
62+
.addAnnotation(Keep.class);
6163
}
6264

6365
public ViewBinderClassStructure addConstructor() {

placeholderview/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ android {
99
targetSdkVersion rootProject.ext.libTargetSdkVersion
1010
versionCode rootProject.ext.libPublishVersionCode
1111
versionName rootProject.ext.libPublishVersionName
12+
consumerProguardFiles 'proguard-rules.pro'
1213
}
1314
buildTypes {
1415
release {

placeholderview/proguard-rules.pro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18+
-keep @com.mindorks.placeholderview.annotations.Layout public class *
19+
-keep @com.mindorks.placeholderview.annotations.Keep public class *
20+
-keepclassmembers @com.mindorks.placeholderview.annotations.Layout class ** { *;}
21+
-keepclassmembers @com.mindorks.placeholderview.annotations.Keep class ** { *;}
22+

0 commit comments

Comments
 (0)