Skip to content

feat: update project dependencies and code refactoring #1141

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 23 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 20 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ jacoco.exec
# Node
node_modules/
npm-debug.log
*.hprof
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Snyk Badge](https://snyk.io/test/github/parse-community/Parse-SDK-Android/badge.svg)](https://snyk.io/test/github/parse-community/Parse-SDK-Android)
[![codecov](https://codecov.io/gh/parse-community/Parse-SDK-Android/branch/master/graph/badge.svg)](https://codecov.io/gh/parse-community/Parse-SDK-Android)

[![android min api](https://img.shields.io/badge/Android_API->=16-66c718.svg)](https://github.com/parse-community/parse-dashboard/releases)
[![android min api](https://img.shields.io/badge/Android_API->=21-66c718.svg)](https://github.com/parse-community/parse-dashboard/releases)
[![auto-release](https://img.shields.io/badge/%F0%9F%9A%80-auto--release-9e34eb.svg)](https://github.com/parse-community/parse-dashboard/releases)

[![](https://jitpack.io/v/parse-community/Parse-SDK-Android.svg)](https://jitpack.io/#parse-community/Parse-SDK-Android)
Expand Down
34 changes: 18 additions & 16 deletions bolts-tasks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ apply plugin: 'maven-publish'

dependencies {
compileOnly 'com.google.android:android:4.1.1.4'
testImplementation 'junit:junit:4.13.2'
testImplementation "junit:junit:$rootProject.ext.junitVersion"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

javadoc.options.addStringOption('Xdoclint:none', '-quiet')
Expand All @@ -28,6 +33,18 @@ artifacts {
archives javadocJar
}

//region Publishing

afterEvaluate {
publishing {
publications {
boltsPublication(MavenPublication) {
from components.java
}
}
}
}

//endregion

//region Code Coverage
Expand All @@ -44,18 +61,3 @@ jacocoTestReport {
}

//endregion

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

afterEvaluate {
publishing {
publications {
boltsPublication(MavenPublication) {
from components.java
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -101,28 +100,4 @@ public void printStackTrace(PrintWriter err) {
err.append("\n");
}
}

/** @deprecated Please use {@link #getInnerThrowables()} instead. */
@Deprecated
public List<Exception> getErrors() {
List<Exception> errors = new ArrayList<>();
if (innerThrowables == null) {
return errors;
}

for (Throwable cause : innerThrowables) {
if (cause instanceof Exception) {
errors.add((Exception) cause);
} else {
errors.add(new Exception(cause));
}
}
return errors;
}

/** @deprecated Please use {@link #getInnerThrowables()} instead. */
@Deprecated
public Throwable[] getCauses() {
return innerThrowables.toArray(new Throwable[0]);
}
}
13 changes: 0 additions & 13 deletions bolts-tasks/src/main/java/com/parse/boltsinternal/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ public static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh)
unobservedExceptionHandler = eh;
}

/** @deprecated Please use {@link com.parse.boltsinternal.TaskCompletionSource ()} instead. */
public static <TResult> Task<TResult>.TaskCompletionSource create() {
Task<TResult> task = new Task<>();
return task.new TaskCompletionSource();
}

/** Creates a completed task with the given value. */
@SuppressWarnings("unchecked")
public static <TResult> Task<TResult> forResult(TResult value) {
Expand Down Expand Up @@ -988,11 +982,4 @@ public interface UnobservedExceptionHandler {
*/
void unobservedException(Task<?> t, UnobservedTaskException e);
}

/** @deprecated Please use {@link com.parse.boltsinternal.TaskCompletionSource} instead. */
public class TaskCompletionSource
extends com.parse.boltsinternal.TaskCompletionSource<TResult> {

/* package */ TaskCompletionSource() {}
}
}
48 changes: 0 additions & 48 deletions bolts-tasks/src/test/java/com/parse/boltsinternal/TaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -1133,51 +1132,4 @@ public void testSetCancelledOnCompletedTask() {
}

// endregion

// region deprecated

@SuppressWarnings("deprecation")
@Test
public void testDeprecatedTaskCompletionSource() {
Task<Void>.TaskCompletionSource tcsA = Task.create();
tcsA.setResult(null);
assertTrue(tcsA.getTask().isCompleted());

TaskCompletionSource<Void> tcsB = Task.create();
tcsB.setResult(null);
assertTrue(tcsA.getTask().isCompleted());
}

@SuppressWarnings("deprecation")
@Test
public void testDeprecatedAggregateExceptionMethods() {
final Exception error0 = new Exception("This is an exception (0).");
final Exception error1 = new Exception("This is an exception (1).");
final Error error2 = new Error("This is an error.");

List<Exception> exceptions = new ArrayList<>();
exceptions.add(error0);
exceptions.add(error1);

// Test old functionality
AggregateException aggregate = new AggregateException(exceptions);
assertEquals("There were multiple errors.", aggregate.getMessage());
assertEquals(2, aggregate.getErrors().size());
assertEquals(error0, aggregate.getErrors().get(0));
assertEquals(error1, aggregate.getErrors().get(1));
assertEquals(2, aggregate.getCauses().length);
assertEquals(error0, aggregate.getCauses()[0]);
assertEquals(error1, aggregate.getCauses()[1]);

// Test deprecated getErrors method returns sane results with non-Exceptions
aggregate = new AggregateException("message", new Throwable[] {error0, error1, error2});
assertEquals("message", aggregate.getMessage());
assertEquals(3, aggregate.getErrors().size());
assertEquals(error0, aggregate.getErrors().get(0));
assertEquals(error1, aggregate.getErrors().get(1));
assertNotSame(error2, aggregate.getErrors().get(2));
assertEquals(error2, aggregate.getErrors().get(2).getCause());
}

// endregion
}
18 changes: 10 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.3"
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jacoco:org.jacoco.core:$jacocoVersion"
classpath "com.dicedmelon.gradle:jacoco-android:0.1.5"
classpath "io.freefair.gradle:android-gradle-plugins:4.2.0-m1"
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.16.0"
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.17.1"
}
}

plugins {
id "com.github.ben-manes.versions" version "0.28.0"
id "com.diffplug.spotless" version "5.16.0"
id "com.diffplug.spotless" version "5.17.1"
}

allprojects {
Expand Down Expand Up @@ -63,8 +61,12 @@ allprojects {
}

ext {
compileSdkVersion = 30
compileSdkVersion = 31

minSdkVersion = 16
targetSdkVersion = 30
minSdkVersion = 21
targetSdkVersion = 31

mockitoCoreVersion = "3.12.4"
junitVersion = "4.13.2"
robolectricVersion = "4.7"
}
2 changes: 1 addition & 1 deletion coroutines/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ android {
}

ext {
coroutinesVersion = "1.5.0"
coroutinesVersion = "1.5.2"
}

dependencies {
Expand Down
9 changes: 5 additions & 4 deletions facebook/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ android {
}

dependencies {
api "com.facebook.android:facebook-login:8.2.0"
api "com.facebook.android:facebook-login:12.1.0"
implementation project(":parse")

testImplementation "junit:junit:4.13.2"
testImplementation "org.mockito:mockito-core:3.9.0"
testImplementation "org.robolectric:robolectric:4.6"
testImplementation "junit:junit:$rootProject.ext.junitVersion"
testImplementation "org.mockito:mockito-core:$rootProject.ext.mockitoCoreVersion"
testImplementation "org.mockito:mockito-inline:$rootProject.ext.mockitoCoreVersion"
testImplementation "org.robolectric:robolectric:$rootProject.ext.robolectricVersion"
}

afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import com.facebook.AccessToken;
import com.facebook.AccessTokenSource;
Expand All @@ -22,6 +23,7 @@
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import com.parse.boltsinternal.Task;
import com.parse.boltsinternal.TaskCompletionSource;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
Expand Down Expand Up @@ -92,7 +94,7 @@ public Task<Map<String, String>> authenticateAsync(
"Unable to authenticate when another authentication is in process"));
}

final Task<Map<String, String>>.TaskCompletionSource tcs = Task.create();
final TaskCompletionSource<Map<String, String>> tcs = new TaskCompletionSource<>();
LoginManager manager = facebookSdkDelegate.getLoginManager();

callbackManager = facebookSdkDelegate.createCallbackManager();
Expand All @@ -112,20 +114,20 @@ public void onCancel() {
}

@Override
public void onError(FacebookException e) {
public void onError(@NonNull FacebookException e) {
tcs.trySetError(e);
}
});

if (LoginAuthorizationType.PUBLISH.equals(authorizationType)) {
if (fragment != null) {
manager.logInWithPublishPermissions(fragment, permissions);
manager.logInWithPublishPermissions(fragment, callbackManager, permissions);
} else {
manager.logInWithPublishPermissions(activity, permissions);
}
} else {
if (fragment != null) {
manager.logInWithReadPermissions(fragment, permissions);
manager.logInWithReadPermissions(fragment, callbackManager, permissions);
} else {
manager.logInWithReadPermissions(activity, permissions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.parse.SaveCallback;
import com.parse.boltsinternal.Continuation;
import com.parse.boltsinternal.Task;
import com.parse.boltsinternal.TaskCompletionSource;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
Expand Down Expand Up @@ -565,7 +566,7 @@ private static <T> Task<T> callbackOnMainThreadInternalAsync(
if (callback == null) {
return task;
}
final Task<T>.TaskCompletionSource tcs = Task.create();
final TaskCompletionSource<T> tcs = new TaskCompletionSource<T>();
task.continueWith(
(Continuation<T, Void>)
task1 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,16 @@ public void doAuthenticateAsyncWith(
verify(loginManager).logInWithPublishPermissions(activity, permissions);
}
if (fragment != null) {
verify(loginManager).logInWithPublishPermissions(fragment, permissions);
verify(loginManager)
.logInWithPublishPermissions(fragment, callbackManager, permissions);
}
} else {
if (activity != null) {
verify(loginManager).logInWithReadPermissions(activity, permissions);
}
if (fragment != null) {
verify(loginManager).logInWithReadPermissions(fragment, permissions);
verify(loginManager)
.logInWithReadPermissions(fragment, callbackManager, permissions);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyMapOf;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doThrow;
Expand Down Expand Up @@ -56,7 +55,7 @@ public class ParseFacebookUtilsTest {

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
ParseFacebookUtils.controller = controller;
ParseFacebookUtils.userDelegate = userDelegate;
}
Expand Down Expand Up @@ -117,9 +116,7 @@ public void testRestoreAuthenticationFailure() throws java.text.ParseException {
.registerAuthenticationCallback(eq("facebook"), callbackCaptor.capture());
AuthenticationCallback callback = callbackCaptor.getValue();
Map<String, String> authData = new HashMap<>();
doThrow(new RuntimeException())
.when(controller)
.setAuthData(anyMapOf(String.class, String.class));
doThrow(new RuntimeException()).when(controller).setAuthData(anyMap());

assertFalse(callback.onRestore(authData));
verify(controller).setAuthData(authData);
Expand Down Expand Up @@ -160,7 +157,7 @@ public void testLogInWithAccessToken() {
ParseFacebookUtils.isInitialized = true;

ParseUser user = mock(ParseUser.class);
when(userDelegate.logInWithInBackground(anyString(), anyMapOf(String.class, String.class)))
when(userDelegate.logInWithInBackground(anyString(), anyMap()))
.thenReturn(Task.forResult(user));
AccessToken token = TestUtils.newAccessToken();
Task<ParseUser> task = ParseFacebookUtils.logInInBackground(token);
Expand Down Expand Up @@ -225,7 +222,7 @@ private void doLogInWith(
ParseFacebookUtils.isInitialized = true;

ParseUser user = mock(ParseUser.class);
when(userDelegate.logInWithInBackground(anyString(), anyMapOf(String.class, String.class)))
when(userDelegate.logInWithInBackground(anyString(), anyMap()))
.thenReturn(Task.forResult(user));
Task<ParseUser> task;
if (FacebookController.LoginAuthorizationType.PUBLISH.equals(type)) {
Expand Down Expand Up @@ -266,8 +263,7 @@ public void testLinkWithAccessToken() {
ParseFacebookUtils.isInitialized = true;

ParseUser user = mock(ParseUser.class);
when(user.linkWithInBackground(anyString(), anyMapOf(String.class, String.class)))
.thenReturn(Task.forResult(null));
when(user.linkWithInBackground(anyString(), anyMap())).thenReturn(Task.forResult(null));
AccessToken token = TestUtils.newAccessToken();
Task<Void> task = ParseFacebookUtils.linkInBackground(user, token);
verify(controller).getAuthData(token);
Expand Down
Loading