Skip to content

Remove Apache dependency to allow for higher Android target SDK. #554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ branches:
language: android
sudo: false

jdk:
- oraclejdk8

android:
components:
- build-tools-23.0.1
- android-22
- doc-23
- extra-android-support
- tools
- platform-tools
- build-tools-25.0.2
- android-25
- doc-25
- extra-android-m2repository

before_install:
Expand Down
16 changes: 8 additions & 8 deletions Parse/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ version = '1.13.2-SNAPSHOT'

buildscript {
repositories {
mavenCentral()
jcenter()
}

dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1x'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.1'
}
}

Expand All @@ -39,16 +39,16 @@ android {
}
}

ext.okhttpVersion = '3.6.0'
dependencies {
compile 'com.parse.bolts:bolts-tasks:1.4.0'
compile "com.squareup.okhttp3:okhttp:$okhttpVersion"
provided 'com.facebook.stetho:stetho:1.4.2'

provided 'com.squareup.okhttp3:okhttp:3.3.1'
provided 'com.facebook.stetho:stetho:1.3.0'

testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.skyscreamer:jsonassert:1.2.3'
testCompile 'org.robolectric:robolectric:3.3'
testCompile 'org.skyscreamer:jsonassert:1.4.0'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'com.squareup.okhttp3:mockwebserver:3.3.1'
testCompile "com.squareup.okhttp3:mockwebserver:$okhttpVersion"
}

android.libraryVariants.all { variant ->
Expand Down
15 changes: 9 additions & 6 deletions Parse/src/main/java/com/parse/NotificationCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,22 @@
private static final NotificationCompatImpl IMPL;

interface NotificationCompatImpl {
public Notification build(Builder b);
Notification build(Builder b);
}

static class NotificationCompatImplBase implements NotificationCompatImpl {
@Override
public Notification build(Builder b) {
Notification result = (Notification) b.mNotification;
result.setLatestEventInfo(b.mContext, b.mContentTitle, b.mContentText, b.mContentIntent);
public Notification build(Builder builder) {
Notification result = builder.mNotification;
NotificationCompat.Builder newBuilder = new NotificationCompat.Builder(builder.mContext);
newBuilder.setContentTitle(builder.mContentTitle);
newBuilder.setContentText(builder.mContentText);
newBuilder.setContentIntent(builder.mContentIntent);
// translate high priority requests into legacy flag
if (b.mPriority > PRIORITY_DEFAULT) {
if (builder.mPriority > PRIORITY_DEFAULT) {
result.flags |= FLAG_HIGH_PRIORITY;
}
return result;
return newBuilder.build();
}
}

Expand Down
247 changes: 0 additions & 247 deletions Parse/src/main/java/com/parse/ParseApacheHttpClient.java

This file was deleted.

24 changes: 2 additions & 22 deletions Parse/src/main/java/com/parse/ParseHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package com.parse;

import android.net.SSLSessionCache;
import android.os.Build;

import com.parse.http.ParseHttpRequest;
import com.parse.http.ParseHttpResponse;
Expand All @@ -27,11 +26,9 @@
/** package */ abstract class ParseHttpClient<LibraryRequest, LibraryResponse> {
private static final String TAG = "com.parse.ParseHttpClient";

private static final String APACHE_HTTPCLIENT_NAME = "org.apache.http";
private static final String URLCONNECTION_NAME = "net.java.URLConnection";
private static final String OKHTTP_NAME = "com.squareup.okhttp3";

private static final String OKHTTPCLIENT_PATH = "okhttp3.OkHttpClient";

private static final String MAX_CONNECTIONS_PROPERTY_NAME = "http.maxConnections";
private static final String KEEP_ALIVE_PROPERTY_NAME = "http.keepAlive";
Expand All @@ -40,16 +37,8 @@ public static ParseHttpClient createClient(int socketOperationTimeout,
SSLSessionCache sslSessionCache) {
String httpClientLibraryName;
ParseHttpClient httpClient;
if (hasOkHttpOnClasspath()) {
httpClientLibraryName = OKHTTP_NAME;
httpClient = new ParseOkHttpClient(socketOperationTimeout, sslSessionCache);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
httpClientLibraryName = URLCONNECTION_NAME;
httpClient = new ParseURLConnectionHttpClient(socketOperationTimeout, sslSessionCache);
} else {
httpClientLibraryName = APACHE_HTTPCLIENT_NAME;
httpClient = new ParseApacheHttpClient(socketOperationTimeout, sslSessionCache);
}
httpClientLibraryName = OKHTTP_NAME;
httpClient = new ParseOkHttpClient(socketOperationTimeout, sslSessionCache);
PLog.i(TAG, "Using " + httpClientLibraryName + " library for networking communication.");
return httpClient;
}
Expand All @@ -65,15 +54,6 @@ public static void setKeepAlive(boolean isKeepAlive) {
System.setProperty(KEEP_ALIVE_PROPERTY_NAME, String.valueOf(isKeepAlive));
}

private static boolean hasOkHttpOnClasspath() {
try {
Class.forName(OKHTTPCLIENT_PATH);
return true;
} catch (ClassNotFoundException e) {
return false;
}
}

private boolean hasExecuted;

// There is no need to keep locks for interceptor lists since they will only be changed before
Expand Down
Loading