Skip to content

Commit aed49e2

Browse files
Jawnnypoorogerhu
authored andcommitted
Remove Apache dependency to allow for higher Android target SDK. (#554)
* Remove Apache dependency to allow for higher Android target SDK. * Remove ParseURLConnectionHttpClient in favor of ParseOkHttpClient * Add JDK specification to Travis * Assure the latest tools are installed * Update to the latest dependencies * Update so that the notification is built properly
1 parent 93dbb83 commit aed49e2

36 files changed

+121
-882
lines changed

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ branches:
55
language: android
66
sudo: false
77

8+
jdk:
9+
- oraclejdk8
10+
811
android:
912
components:
10-
- build-tools-23.0.1
11-
- android-22
12-
- doc-23
13-
- extra-android-support
13+
- tools
14+
- platform-tools
15+
- build-tools-25.0.2
16+
- android-25
17+
- doc-25
1418
- extra-android-m2repository
1519

1620
before_install:

Parse/build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ version = '1.14.1-SNAPSHOT'
88

99
buildscript {
1010
repositories {
11-
mavenCentral()
11+
jcenter()
1212
}
1313

1414
dependencies {
15-
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1x'
15+
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.1'
1616
}
1717
}
1818

@@ -39,16 +39,16 @@ android {
3939
}
4040
}
4141

42+
ext.okhttpVersion = '3.6.0'
4243
dependencies {
4344
compile 'com.parse.bolts:bolts-tasks:1.4.0'
45+
compile "com.squareup.okhttp3:okhttp:$okhttpVersion"
46+
provided 'com.facebook.stetho:stetho:1.4.2'
4447

45-
provided 'com.squareup.okhttp3:okhttp:3.3.1'
46-
provided 'com.facebook.stetho:stetho:1.3.0'
47-
48-
testCompile 'org.robolectric:robolectric:3.0'
49-
testCompile 'org.skyscreamer:jsonassert:1.2.3'
48+
testCompile 'org.robolectric:robolectric:3.3'
49+
testCompile 'org.skyscreamer:jsonassert:1.4.0'
5050
testCompile 'org.mockito:mockito-core:1.10.19'
51-
testCompile 'com.squareup.okhttp3:mockwebserver:3.3.1'
51+
testCompile "com.squareup.okhttp3:mockwebserver:$okhttpVersion"
5252
}
5353

5454
android.libraryVariants.all { variant ->

Parse/src/main/java/com/parse/NotificationCompat.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,22 @@
5050
private static final NotificationCompatImpl IMPL;
5151

5252
interface NotificationCompatImpl {
53-
public Notification build(Builder b);
53+
Notification build(Builder b);
5454
}
5555

5656
static class NotificationCompatImplBase implements NotificationCompatImpl {
5757
@Override
58-
public Notification build(Builder b) {
59-
Notification result = (Notification) b.mNotification;
60-
result.setLatestEventInfo(b.mContext, b.mContentTitle, b.mContentText, b.mContentIntent);
58+
public Notification build(Builder builder) {
59+
Notification result = builder.mNotification;
60+
NotificationCompat.Builder newBuilder = new NotificationCompat.Builder(builder.mContext);
61+
newBuilder.setContentTitle(builder.mContentTitle);
62+
newBuilder.setContentText(builder.mContentText);
63+
newBuilder.setContentIntent(builder.mContentIntent);
6164
// translate high priority requests into legacy flag
62-
if (b.mPriority > PRIORITY_DEFAULT) {
65+
if (builder.mPriority > PRIORITY_DEFAULT) {
6366
result.flags |= FLAG_HIGH_PRIORITY;
6467
}
65-
return result;
68+
return newBuilder.build();
6669
}
6770
}
6871

Parse/src/main/java/com/parse/ParseApacheHttpClient.java

Lines changed: 0 additions & 247 deletions
This file was deleted.

Parse/src/main/java/com/parse/ParseHttpClient.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package com.parse;
1010

1111
import android.net.SSLSessionCache;
12-
import android.os.Build;
1312

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

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

34-
private static final String OKHTTPCLIENT_PATH = "okhttp3.OkHttpClient";
3532

3633
private static final String MAX_CONNECTIONS_PROPERTY_NAME = "http.maxConnections";
3734
private static final String KEEP_ALIVE_PROPERTY_NAME = "http.keepAlive";
@@ -40,16 +37,8 @@ public static ParseHttpClient createClient(int socketOperationTimeout,
4037
SSLSessionCache sslSessionCache) {
4138
String httpClientLibraryName;
4239
ParseHttpClient httpClient;
43-
if (hasOkHttpOnClasspath()) {
44-
httpClientLibraryName = OKHTTP_NAME;
45-
httpClient = new ParseOkHttpClient(socketOperationTimeout, sslSessionCache);
46-
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
47-
httpClientLibraryName = URLCONNECTION_NAME;
48-
httpClient = new ParseURLConnectionHttpClient(socketOperationTimeout, sslSessionCache);
49-
} else {
50-
httpClientLibraryName = APACHE_HTTPCLIENT_NAME;
51-
httpClient = new ParseApacheHttpClient(socketOperationTimeout, sslSessionCache);
52-
}
40+
httpClientLibraryName = OKHTTP_NAME;
41+
httpClient = new ParseOkHttpClient(socketOperationTimeout, sslSessionCache);
5342
PLog.i(TAG, "Using " + httpClientLibraryName + " library for networking communication.");
5443
return httpClient;
5544
}
@@ -65,15 +54,6 @@ public static void setKeepAlive(boolean isKeepAlive) {
6554
System.setProperty(KEEP_ALIVE_PROPERTY_NAME, String.valueOf(isKeepAlive));
6655
}
6756

68-
private static boolean hasOkHttpOnClasspath() {
69-
try {
70-
Class.forName(OKHTTPCLIENT_PATH);
71-
return true;
72-
} catch (ClassNotFoundException e) {
73-
return false;
74-
}
75-
}
76-
7757
private boolean hasExecuted;
7858

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

0 commit comments

Comments
 (0)