From ef7e04ff24c0b1b034584372f6f81d1a48364831 Mon Sep 17 00:00:00 2001 From: Ender's Games Date: Tue, 2 Oct 2018 05:02:53 -0400 Subject: [PATCH] Implement a proguard file to keep things clean Dropbox runs wild with 20,000 methods otherwise --- shell/android-studio/reicast/build.gradle | 2 +- .../android-studio/reicast/proguard-rules.txt | 66 +++++++++++++++++++ .../emulator/dropbox/CloudFragment.java | 14 +++- 3 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 shell/android-studio/reicast/proguard-rules.txt diff --git a/shell/android-studio/reicast/build.gradle b/shell/android-studio/reicast/build.gradle index a302d8f3e..95eae0c0b 100644 --- a/shell/android-studio/reicast/build.gradle +++ b/shell/android-studio/reicast/build.gradle @@ -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 diff --git a/shell/android-studio/reicast/proguard-rules.txt b/shell/android-studio/reicast/proguard-rules.txt new file mode 100644 index 000000000..bcee8e3c5 --- /dev/null +++ b/shell/android-studio/reicast/proguard-rules.txt @@ -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 ; +} +# 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 ; +} + +# 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 diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/dropbox/CloudFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/dropbox/CloudFragment.java index beff958bf..58f7e08e2 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/dropbox/CloudFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/dropbox/CloudFragment.java @@ -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() {