From b0abcd6d5d45c8c8199733c6a547d1d84519f184 Mon Sep 17 00:00:00 2001 From: nopjmp Date: Tue, 3 Jun 2014 11:19:42 -0500 Subject: [PATCH 1/5] Change Volley to be less verbose when not compiled in debug --- Clover/app/src/main/java/com/android/volley/VolleyLog.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Clover/app/src/main/java/com/android/volley/VolleyLog.java b/Clover/app/src/main/java/com/android/volley/VolleyLog.java index 66846902..be5c40af 100644 --- a/Clover/app/src/main/java/com/android/volley/VolleyLog.java +++ b/Clover/app/src/main/java/com/android/volley/VolleyLog.java @@ -52,7 +52,9 @@ public class VolleyLog { } public static void d(String format, Object... args) { - Log.d(TAG, buildMessage(format, args)); + if (DEBUG) { + Log.d(TAG, buildMessage(format, args)); + } } public static void e(String format, Object... args) { From 021edee83f141164f5afd32efd1c10e3c2da4ff8 Mon Sep 17 00:00:00 2001 From: nopjmp Date: Tue, 3 Jun 2014 11:50:36 -0500 Subject: [PATCH 2/5] Make Volley use normal String concatenation in ImageLoader.java The java compiler will make this a StringBuilder if it needs to be. --- .../src/main/java/com/android/volley/toolbox/ImageLoader.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Clover/app/src/main/java/com/android/volley/toolbox/ImageLoader.java b/Clover/app/src/main/java/com/android/volley/toolbox/ImageLoader.java index fe0f32ad..3098aefe 100644 --- a/Clover/app/src/main/java/com/android/volley/toolbox/ImageLoader.java +++ b/Clover/app/src/main/java/com/android/volley/toolbox/ImageLoader.java @@ -474,7 +474,6 @@ public class ImageLoader { * @param maxHeight The max-height of the output. */ private static String getCacheKey(String url, int maxWidth, int maxHeight) { - return new StringBuilder(url.length() + 12).append("#W").append(maxWidth) - .append("#H").append(maxHeight).append(url).toString(); + return "#W" + maxWidth + "#H" + maxHeight + url; } } From 09af20ce28f33548c689c9714cf791a45b5d0236 Mon Sep 17 00:00:00 2001 From: nopjmp Date: Tue, 3 Jun 2014 11:55:13 -0500 Subject: [PATCH 3/5] Volley doesn't call finalize functions inside some classes --- Clover/app/src/main/java/com/android/volley/VolleyLog.java | 1 + .../android/volley/toolbox/PoolingByteArrayOutputStream.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Clover/app/src/main/java/com/android/volley/VolleyLog.java b/Clover/app/src/main/java/com/android/volley/VolleyLog.java index be5c40af..ca1f9ee4 100644 --- a/Clover/app/src/main/java/com/android/volley/VolleyLog.java +++ b/Clover/app/src/main/java/com/android/volley/VolleyLog.java @@ -162,6 +162,7 @@ public class VolleyLog { finish("Request on the loose"); e("Marker log finalized without finish() - uncaught exit point for request"); } + super.finalize(); } /** Returns the time difference between the first and last events in this log. */ diff --git a/Clover/app/src/main/java/com/android/volley/toolbox/PoolingByteArrayOutputStream.java b/Clover/app/src/main/java/com/android/volley/toolbox/PoolingByteArrayOutputStream.java index 99715666..d082e84a 100644 --- a/Clover/app/src/main/java/com/android/volley/toolbox/PoolingByteArrayOutputStream.java +++ b/Clover/app/src/main/java/com/android/volley/toolbox/PoolingByteArrayOutputStream.java @@ -61,8 +61,9 @@ public class PoolingByteArrayOutputStream extends ByteArrayOutputStream { } @Override - public void finalize() { + public void finalize() throws Throwable { mPool.returnBuf(buf); + super.finalize(); } /** From c11327a03de103adb3776593d7b57ca40ed41d79 Mon Sep 17 00:00:00 2001 From: nopjmp Date: Tue, 3 Jun 2014 12:09:24 -0500 Subject: [PATCH 4/5] Useless synchronized with local only variable --- .../src/main/java/org/floens/chan/service/WatchService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Clover/app/src/main/java/org/floens/chan/service/WatchService.java b/Clover/app/src/main/java/org/floens/chan/service/WatchService.java index b0c15ca0..b2798828 100644 --- a/Clover/app/src/main/java/org/floens/chan/service/WatchService.java +++ b/Clover/app/src/main/java/org/floens/chan/service/WatchService.java @@ -170,9 +170,7 @@ public class WatchService extends Service { Logger.d(TAG, "Waiting for interrupt..."); try { Object o = new Object(); - synchronized (o) { - o.wait(); - } + o.wait(); } catch (InterruptedException e) { Logger.d(TAG, "Interrupted!"); } From 8ad8c4cc8d48b0dc23466ae8fe0fb253a8fc9dd0 Mon Sep 17 00:00:00 2001 From: nopjmp Date: Tue, 3 Jun 2014 14:21:24 -0500 Subject: [PATCH 5/5] Enable proguard for optimizations and removing dead code --- Clover/app/build.gradle | 2 + Clover/app/proguard.cfg | 132 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 Clover/app/proguard.cfg diff --git a/Clover/app/build.gradle b/Clover/app/build.gradle index 8b7245fb..cb0c9b6d 100644 --- a/Clover/app/build.gradle +++ b/Clover/app/build.gradle @@ -47,6 +47,8 @@ android { if (doSign) { signingConfig signingConfigs.release } + runProguard true + proguardFiles 'proguard.cfg' } beta.initWith(buildTypes.release) diff --git a/Clover/app/proguard.cfg b/Clover/app/proguard.cfg new file mode 100644 index 00000000..5a8e1dd5 --- /dev/null +++ b/Clover/app/proguard.cfg @@ -0,0 +1,132 @@ +# Preverification is irrelevant for the dex compiler and the Dalvik VM. + +-dontpreverify + +# Reduce the size of the output some more. + +-repackageclasses '' +-allowaccessmodification + +# Switch off some optimizations that trip older versions of the Dalvik VM. + +-optimizations !code/simplification/arithmetic,!code/allocation/variable + +# Keep a fixed source file attribute and all line number tables to get line +# numbers in the stack traces. +# You can comment this out if you're not interested in stack traces. + +-renamesourcefileattribute SourceFile +-keepattributes SourceFile,LineNumberTable + +# RemoteViews might need annotations. + +-keepattributes *Annotation* + +# Preserve all fundamental application classes. + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider + +# Preserve all View implementations, their special context constructors, and +# their setters. + +-keep public class * extends android.view.View { + public (android.content.Context); + public (android.content.Context, android.util.AttributeSet); + public (android.content.Context, android.util.AttributeSet, int); + public void set*(...); +} + +# Preserve all classes that have special context constructors, and the +# constructors themselves. + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet); +} + +# Preserve all classes that have special context constructors, and the +# constructors themselves. + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +# Preserve the special fields of all Parcelable implementations. + +-keepclassmembers class * implements android.os.Parcelable { + static android.os.Parcelable$Creator CREATOR; +} + +# Preserve static fields of inner classes of R classes that might be accessed +# through introspection. + +-keepclassmembers class **.R$* { + public static ; +} + +# Preserve the required interface from the License Verification Library +# (but don't nag the developer if the library is not used at all). + +-keep public interface com.android.vending.licensing.ILicensingService + +-dontnote com.android.vending.licensing.ILicensingService + +# The Android Compatibility library references some classes that may not be +# present in all versions of the API, but we know that's ok. + +-dontwarn android.support.** + +# Preserve all native method names and the names of their classes. + +-keepclasseswithmembernames class * { + native ; +} + +# Preserve the special static methods that are required in all enumeration +# classes. + +-keepclassmembers class * extends java.lang.Enum { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Explicitly preserve all serialization members. The Serializable interface +# is only a marker interface, so it wouldn't save them. +# You can comment this out if your application doesn't use serialization. +# If your code contains serializable classes that have to be backward +# compatible, please refer to the manual. + +-keepclassmembers class * implements java.io.Serializable { + static final long serialVersionUID; + static final java.io.ObjectStreamField[] serialPersistentFields; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} + +# Your application may contain more items that need to be preserved; +# typically classes that are dynamically created using Class.forName: + +# -keep public class mypackage.MyClass +# -keep public interface mypackage.MyInterface +# -keep public class * implements mypackage.MyInterface + +# OrmLite uses reflection +-keep class com.j256.** +-keepclassmembers class com.j256.** { *; } +-keep enum com.j256.** +-keepclassmembers enum com.j256.** { *; } +-keep interface com.j256.** +-keepclassmembers interface com.j256.** { *; } + +# Clover database models +-keep class org.floens.chan.core.model.** { *; } + +# Jsoup +-keep public class org.jsoup.** { + public *; +} \ No newline at end of file