forked from upstream-mirrors/OpenTracks
Fixing ProGuard support by removing usage of reflection and ignoring a few unused classes.
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
-dontwarn com.google.android.googleapps.**
|
||||
-dontwarn com.android.common.**
|
||||
-dontwarn com.google.android.gsf.**
|
||||
-dontwarn org.codehaus.**
|
||||
-dontwarn com.google.appengine.**
|
||||
|
||||
# Keep everything android references from XMLs
|
||||
-keep public class * extends android.app.Activity
|
||||
@@ -20,6 +22,7 @@
|
||||
-keep public class * extends android.app,backup.BackupAgent
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
-keep public class * extends android.preference.Preference
|
||||
-keep public class com.android.vending.licensing.ILicensingService
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
|
||||
@@ -30,13 +30,14 @@ import com.google.android.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.apps.mytracks.util.UnitConversions;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
import com.google.api.client.googleapis.GoogleHeaders;
|
||||
import com.google.api.client.googleapis.GoogleTransport;
|
||||
import com.google.api.client.googleapis.MethodOverrideIntercepter;
|
||||
import com.google.api.client.http.GenericUrl;
|
||||
import com.google.api.client.http.HttpRequest;
|
||||
import com.google.api.client.http.HttpResponse;
|
||||
import com.google.api.client.http.HttpResponseException;
|
||||
import com.google.api.client.http.HttpTransport;
|
||||
import com.google.api.client.http.InputStreamContent;
|
||||
import com.google.api.client.javanet.NetHttpTransport;
|
||||
import com.google.api.client.util.Strings;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -106,6 +107,12 @@ public class SendToFusionTables implements Runnable {
|
||||
private static String MARKER_TYPE_END = "large_red";
|
||||
private static String MARKER_TYPE_WAYPOINT = "large_yellow";
|
||||
|
||||
static {
|
||||
// We manually assign the transport to avoid having HttpTransport try to
|
||||
// load it via reflection (which breaks due to ProGuard).
|
||||
HttpTransport.setLowLevelHttpTransport(new NetHttpTransport());
|
||||
}
|
||||
|
||||
public SendToFusionTables(Activity context, AuthManager auth,
|
||||
long trackId, ProgressIndicator progressIndicator,
|
||||
OnSendCompletedListener onCompletion) {
|
||||
@@ -116,10 +123,14 @@ public class SendToFusionTables implements Runnable {
|
||||
this.onCompletion = onCompletion;
|
||||
this.stringUtils = new StringUtils(context);
|
||||
this.providerUtils = MyTracksProviderUtils.Factory.get(context);
|
||||
transport = GoogleTransport.create();
|
||||
GoogleHeaders headers = (GoogleHeaders) transport.defaultHeaders;
|
||||
|
||||
GoogleHeaders headers = new GoogleHeaders();
|
||||
headers.setApplicationName("Google-MyTracks-" + MyTracksUtils.getMyTracksVersion(context));
|
||||
headers.gdataVersion = GDATA_VERSION;
|
||||
|
||||
transport = new HttpTransport();
|
||||
MethodOverrideIntercepter.setAsFirstFor(transport);
|
||||
transport.defaultHeaders = headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,12 +33,7 @@ public class ApiFeatures {
|
||||
*/
|
||||
public static final int ANDROID_API_LEVEL = Integer.parseInt(
|
||||
Build.VERSION.SDK);
|
||||
|
||||
private static final String PLATFORM_ADAPTER_GINGERBREAD =
|
||||
"com.google.android.apps.mytracks.util.GingerbreadPlatformAdapter";
|
||||
private static final String PLATFORM_ADAPTER_ECLAIR =
|
||||
"com.google.android.apps.mytracks.util.EclairPlatformAdapter";
|
||||
|
||||
|
||||
private static ApiFeatures instance;
|
||||
|
||||
/**
|
||||
@@ -67,30 +62,18 @@ public class ApiFeatures {
|
||||
* Allow subclasses for mocking, but no direct instantiation.
|
||||
*/
|
||||
protected ApiFeatures() {
|
||||
// It is safe to import unsupported classes as long as we only actually
|
||||
// load the class when supported.
|
||||
if (getApiLevel() >= 9) {
|
||||
apiPlatformAdapter = createPlatformAdapter(PLATFORM_ADAPTER_GINGERBREAD);
|
||||
apiPlatformAdapter = new GingerbreadPlatformAdapter();
|
||||
} else if (getApiLevel() >= 5) {
|
||||
apiPlatformAdapter = createPlatformAdapter(PLATFORM_ADAPTER_ECLAIR);
|
||||
apiPlatformAdapter = new EclairPlatformAdapter();
|
||||
} else {
|
||||
// Cupcake adapter is always supported, so it's safe to do static linkage.
|
||||
apiPlatformAdapter = new CupcakePlatformAdapter();
|
||||
}
|
||||
|
||||
|
||||
Log.i(MyTracksConstants.TAG, "Using platform adapter " + apiPlatformAdapter.getClass());
|
||||
}
|
||||
|
||||
private static ApiPlatformAdapter createPlatformAdapter(String className) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(className);
|
||||
return (ApiPlatformAdapter) clazz.newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("ApiFeatures: Unable to find " + className, e);
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException("ApiFeatures: Unable to instantiate " + className, e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException("ApiFeatures: Unable to access " + className, e);
|
||||
}
|
||||
}
|
||||
|
||||
public ApiPlatformAdapter getApiPlatformAdapter() {
|
||||
return apiPlatformAdapter;
|
||||
|
||||
Reference in New Issue
Block a user