Implement a proguard file to keep things clean

Dropbox runs wild with 20,000 methods otherwise
This commit is contained in:
Ender's Games 2018-10-02 05:02:53 -04:00
parent 69d2f1cc60
commit ef7e04ff24
3 changed files with 78 additions and 4 deletions

View File

@ -58,7 +58,7 @@ android {
}
release {
debuggable false
minifyEnabled false
minifyEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release

View File

@ -0,0 +1,66 @@
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
# Optimizations: If you don't want to optimize, use the
# proguard-android.txt configuration file instead of this one, which
# turns off the optimization flags. Adding optimization introduces
# certain risks, since for example not all optimizations performed by
# ProGuard works on all versions of Dalvik. The following flags turn
# off various optimizations known to have issues, but the list may not
# be complete or up to date. (The "arithmetic" optimization can be
# used if you are only targeting Android 2.0 or later.) Make sure you
# test thoroughly if you go this route.
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify
# The remainder of this file is identical to the non-optimized version
# of the Proguard configuration file (except that the other file has
# flags to turn off optimization).
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-keepattributes *Annotation*
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
-dontwarn okio.**
-dontwarn okhttp3.**
-dontwarn com.squareup.okhttp.**
-dontwarn com.google.appengine.**
-dontwarn java.io.**
-dontwarn java.nio.file.**
-dontwarn javax.naming.**
-dontwarn javax.servlet.**
-dontwarn junit.textui.**
-keepattributes Signature
-keepattributes InnerClasses
-keepattributes Exceptions,SourceFile,LineNumberTable

View File

@ -16,7 +16,6 @@ import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.DropBoxManager;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
@ -46,7 +45,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.TimeUnit;
public class CloudFragment extends Fragment {
@ -77,7 +75,17 @@ public class CloudFragment extends Fragment {
Environment.getExternalStorageDirectory().getAbsolutePath());
buttonListener();
confirmDialog = new AlertDialog.Builder(getActivity());
Auth.startOAuth2Authentication(getActivity(), APP_KEY);
// Auth.startOAuth2Authentication(getActivity(), APP_KEY);
String accessToken = mPrefs.getString("access-token", null);
if (accessToken != null) {
DropboxClientFactory.init(accessToken);
} else {
accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
mPrefs.edit().putString("access-token", accessToken).apply();
DropboxClientFactory.init(accessToken);
}
}
}
public void buttonListener() {