Loading build.gradle +18 −3 Original line number Diff line number Diff line buildscript { repositories { jcenter() google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.3.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' } } Loading Loading @@ -34,6 +34,18 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } lintOptions{ // translations are imported from transifex, so no need to check here disable 'MissingTranslation' disable 'ExtraTranslation' disable 'MissingQuantity' disable 'InconsistentArrays' disable 'TypographyEllipsis' } productFlavors { } } Loading @@ -41,6 +53,9 @@ android { dependencies { implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation "androidx.appcompat:appcompat:1.0.2" implementation 'androidx.annotation:annotation:1.0.2' implementation 'androidx.core:core:1.0.1' implementation 'androidx.fragment:fragment:1.0.0' implementation 'com.google.code.gson:gson:2.8.5' Loading @@ -52,7 +67,7 @@ dependencies { implementation 'commons-io:commons-io:2.6' implementation 'com.squareup.retrofit2:retrofit:2.5.0' implementation 'com.squareup.okhttp3:okhttp:3.12.0' implementation 'com.squareup.okhttp3:okhttp:3.12.2' // Required for local unit tests (JUnit 4 framework) testImplementation 'junit:junit:4.12' Loading gradle/wrapper/gradle-wrapper.properties +2 −2 Original line number Diff line number Diff line Loading @@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip distributionSha256Sum=36bf7ff499223d5139f005822130ccca784c91591b514677fd376eed966c907e distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip distributionSha256Sum=336b6898b491f6334502d8074a6b8c2d73ed83b92123106bd4bf837f04111043 src/main/java/com/nextcloud/android/sso/aidl/NextcloudRequest.java +11 −29 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import androidx.core.util.ObjectsCompat; public class NextcloudRequest implements Serializable { private static final long serialVersionUID = 215521212534240L; //assign a long value Loading Loading @@ -162,37 +164,17 @@ public class NextcloudRequest implements Serializable { NextcloudRequest rq = (NextcloudRequest)obj; boolean equal; equal = checkEqual("accountName", this.accountName, rq.accountName); equal &= checkEqual("header", this.header, rq.header); equal &= checkEqual("method", this.method, rq.method); equal &= checkEqual("packageName", this.packageName, rq.packageName); equal &= checkEqual("parameter", this.parameter, rq.parameter); equal &= checkEqual("requestBody", this.requestBody, rq.requestBody); equal &= checkEqual("token", this.token, rq.token); equal &= checkEqual("url", this.url, rq.url); equal &= checkEqual("followRedirects", this.followRedirects, rq.followRedirects); equal = ObjectsCompat.equals(this.accountName, rq.accountName); equal &= ObjectsCompat.equals(this.header, rq.header); equal &= ObjectsCompat.equals(this.method, rq.method); equal &= ObjectsCompat.equals(this.packageName, rq.packageName); equal &= ObjectsCompat.equals(this.parameter, rq.parameter); equal &= ObjectsCompat.equals(this.requestBody, rq.requestBody); equal &= ObjectsCompat.equals(this.token, rq.token); equal &= ObjectsCompat.equals(this.url, rq.url); equal &= ObjectsCompat.equals(this.followRedirects, rq.followRedirects); return equal; //return super.equals(obj); } private boolean checkEqual(String name, Object o1, Object o2) { if(o1 == null && o2 == null) { return true; } if(o1 != null) { boolean eq = o1.equals(o2); if(!eq) { System.err.println("[" + name + "] Expected: " + o1 + " Was: " + o2); } return eq; } else { // o1 == null and o2 != null System.err.println("[" + name + "] Expected: " + o1 + " Was: " + o2); } return false; } } src/main/java/com/nextcloud/android/sso/api/NextcloudAPI.java +17 −28 Original line number Diff line number Diff line Loading @@ -26,9 +26,6 @@ import com.google.gson.Gson; import com.nextcloud.android.sso.aidl.NextcloudRequest; import com.nextcloud.android.sso.model.SingleSignOnAccount; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; Loading Loading @@ -84,36 +81,29 @@ public class NextcloudAPI { } public <T> Observable<T> performRequestObservable(final Type type, final NextcloudRequest request) { return Observable.fromPublisher(new Publisher<T>() { @Override public void subscribe(Subscriber<? super T> s) { return Observable.fromPublisher( s-> { try { s.onNext((T) performRequest(type, request)); s.onNext(performRequest(type, request)); s.onComplete(); } catch (Exception e) { s.onError(e); } } }); } public <T> T performRequest(final @NonNull Type type, NextcloudRequest request) throws Exception { Log.d(TAG, "performRequest() called with: type = [" + type + "], request = [" + request + "]"); InputStream os = performNetworkRequest(request); Reader targetReader = new InputStreamReader(os); T result = null; try (InputStream os = performNetworkRequest(request); Reader targetReader = new InputStreamReader(os)) { if (type != Void.class) { result = gson.fromJson(targetReader, type); if (result != null) { Log.d(TAG, result.toString()); } } targetReader.close(); os.close(); } return result; } Loading @@ -129,13 +119,12 @@ public class NextcloudAPI { return networkRequest.performNetworkRequest(request, null); } /* public static <T> T deserializeObjectAndCloseStream(InputStream is) throws IOException, ClassNotFoundException { ObjectInputStream ois = new ObjectInputStream(is); T result = (T) ois.readObject(); is.close(); ois.close(); return result; try (ObjectInputStream ois = new ObjectInputStream(is)) { return (T) ois.readObject(); } } */ Loading src/main/java/com/nextcloud/android/sso/helper/ReactivexHelper.java +1 −7 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ import com.nextcloud.android.sso.aidl.NextcloudRequest; import com.nextcloud.android.sso.api.NextcloudAPI; import io.reactivex.Completable; import io.reactivex.functions.Action; /** * Nextcloud SingleSignOn Loading @@ -30,12 +29,7 @@ public final class ReactivexHelper { private ReactivexHelper() { } public static Completable wrapInCompletable(final NextcloudAPI nextcloudAPI, final NextcloudRequest request) { return Completable.fromAction(new Action() { @Override public void run() throws Exception { nextcloudAPI.performRequest(Void.class, request); } }); return Completable.fromAction(() -> nextcloudAPI.performRequest(Void.class, request)); } } Loading Loading
build.gradle +18 −3 Original line number Diff line number Diff line buildscript { repositories { jcenter() google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.3.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' } } Loading Loading @@ -34,6 +34,18 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } lintOptions{ // translations are imported from transifex, so no need to check here disable 'MissingTranslation' disable 'ExtraTranslation' disable 'MissingQuantity' disable 'InconsistentArrays' disable 'TypographyEllipsis' } productFlavors { } } Loading @@ -41,6 +53,9 @@ android { dependencies { implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation "androidx.appcompat:appcompat:1.0.2" implementation 'androidx.annotation:annotation:1.0.2' implementation 'androidx.core:core:1.0.1' implementation 'androidx.fragment:fragment:1.0.0' implementation 'com.google.code.gson:gson:2.8.5' Loading @@ -52,7 +67,7 @@ dependencies { implementation 'commons-io:commons-io:2.6' implementation 'com.squareup.retrofit2:retrofit:2.5.0' implementation 'com.squareup.okhttp3:okhttp:3.12.0' implementation 'com.squareup.okhttp3:okhttp:3.12.2' // Required for local unit tests (JUnit 4 framework) testImplementation 'junit:junit:4.12' Loading
gradle/wrapper/gradle-wrapper.properties +2 −2 Original line number Diff line number Diff line Loading @@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip distributionSha256Sum=36bf7ff499223d5139f005822130ccca784c91591b514677fd376eed966c907e distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip distributionSha256Sum=336b6898b491f6334502d8074a6b8c2d73ed83b92123106bd4bf837f04111043
src/main/java/com/nextcloud/android/sso/aidl/NextcloudRequest.java +11 −29 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import androidx.core.util.ObjectsCompat; public class NextcloudRequest implements Serializable { private static final long serialVersionUID = 215521212534240L; //assign a long value Loading Loading @@ -162,37 +164,17 @@ public class NextcloudRequest implements Serializable { NextcloudRequest rq = (NextcloudRequest)obj; boolean equal; equal = checkEqual("accountName", this.accountName, rq.accountName); equal &= checkEqual("header", this.header, rq.header); equal &= checkEqual("method", this.method, rq.method); equal &= checkEqual("packageName", this.packageName, rq.packageName); equal &= checkEqual("parameter", this.parameter, rq.parameter); equal &= checkEqual("requestBody", this.requestBody, rq.requestBody); equal &= checkEqual("token", this.token, rq.token); equal &= checkEqual("url", this.url, rq.url); equal &= checkEqual("followRedirects", this.followRedirects, rq.followRedirects); equal = ObjectsCompat.equals(this.accountName, rq.accountName); equal &= ObjectsCompat.equals(this.header, rq.header); equal &= ObjectsCompat.equals(this.method, rq.method); equal &= ObjectsCompat.equals(this.packageName, rq.packageName); equal &= ObjectsCompat.equals(this.parameter, rq.parameter); equal &= ObjectsCompat.equals(this.requestBody, rq.requestBody); equal &= ObjectsCompat.equals(this.token, rq.token); equal &= ObjectsCompat.equals(this.url, rq.url); equal &= ObjectsCompat.equals(this.followRedirects, rq.followRedirects); return equal; //return super.equals(obj); } private boolean checkEqual(String name, Object o1, Object o2) { if(o1 == null && o2 == null) { return true; } if(o1 != null) { boolean eq = o1.equals(o2); if(!eq) { System.err.println("[" + name + "] Expected: " + o1 + " Was: " + o2); } return eq; } else { // o1 == null and o2 != null System.err.println("[" + name + "] Expected: " + o1 + " Was: " + o2); } return false; } }
src/main/java/com/nextcloud/android/sso/api/NextcloudAPI.java +17 −28 Original line number Diff line number Diff line Loading @@ -26,9 +26,6 @@ import com.google.gson.Gson; import com.nextcloud.android.sso.aidl.NextcloudRequest; import com.nextcloud.android.sso.model.SingleSignOnAccount; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; Loading Loading @@ -84,36 +81,29 @@ public class NextcloudAPI { } public <T> Observable<T> performRequestObservable(final Type type, final NextcloudRequest request) { return Observable.fromPublisher(new Publisher<T>() { @Override public void subscribe(Subscriber<? super T> s) { return Observable.fromPublisher( s-> { try { s.onNext((T) performRequest(type, request)); s.onNext(performRequest(type, request)); s.onComplete(); } catch (Exception e) { s.onError(e); } } }); } public <T> T performRequest(final @NonNull Type type, NextcloudRequest request) throws Exception { Log.d(TAG, "performRequest() called with: type = [" + type + "], request = [" + request + "]"); InputStream os = performNetworkRequest(request); Reader targetReader = new InputStreamReader(os); T result = null; try (InputStream os = performNetworkRequest(request); Reader targetReader = new InputStreamReader(os)) { if (type != Void.class) { result = gson.fromJson(targetReader, type); if (result != null) { Log.d(TAG, result.toString()); } } targetReader.close(); os.close(); } return result; } Loading @@ -129,13 +119,12 @@ public class NextcloudAPI { return networkRequest.performNetworkRequest(request, null); } /* public static <T> T deserializeObjectAndCloseStream(InputStream is) throws IOException, ClassNotFoundException { ObjectInputStream ois = new ObjectInputStream(is); T result = (T) ois.readObject(); is.close(); ois.close(); return result; try (ObjectInputStream ois = new ObjectInputStream(is)) { return (T) ois.readObject(); } } */ Loading
src/main/java/com/nextcloud/android/sso/helper/ReactivexHelper.java +1 −7 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ import com.nextcloud.android.sso.aidl.NextcloudRequest; import com.nextcloud.android.sso.api.NextcloudAPI; import io.reactivex.Completable; import io.reactivex.functions.Action; /** * Nextcloud SingleSignOn Loading @@ -30,12 +29,7 @@ public final class ReactivexHelper { private ReactivexHelper() { } public static Completable wrapInCompletable(final NextcloudAPI nextcloudAPI, final NextcloudRequest request) { return Completable.fromAction(new Action() { @Override public void run() throws Exception { nextcloudAPI.performRequest(Void.class, request); } }); return Completable.fromAction(() -> nextcloudAPI.performRequest(Void.class, request)); } } Loading