Fix file uploads

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2019-10-18 16:26:24 +02:00
parent d5abcc01a3
commit 23bc417ba4
13 changed files with 54 additions and 69 deletions

View File

@ -197,9 +197,7 @@ dependencies {
implementation "android.arch.work:work-rxjava2:${work_version}"
implementation 'com.google.android:flexbox:1.1.0'
androidTestImplementation "android.arch.work:work-testing:${work_version}"
implementation ('com.gitlab.bitfireAT:dav4jvm:f2078bc846', {
exclude group: 'org.ogce', module: 'xpp3' // Android comes with its own XmlPullParser
})
implementation 'com.gitlab.bitfireAT:dav4jvm:ee66e8e5'
implementation 'org.conscrypt:conscrypt-android:2.2.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
@ -219,9 +217,9 @@ dependencies {
implementation 'com.bluelinelabs:conductor-autodispose:3.0.0-rc2'
implementation "com.github.miquelbeltran:conductor-viewmodel:1.0.3"
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.2.2'
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.2'
implementation 'com.squareup.okhttp3:okhttp:3.14.4'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.14.4'
implementation 'com.squareup.okhttp3:logging-interceptor:3.14.4'
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.2'

View File

@ -22,12 +22,12 @@ package com.nextcloud.talk.components.filebrowser.models;
import android.net.Uri;
import android.text.TextUtils;
import at.bitfire.dav4android.Property;
import at.bitfire.dav4android.Response;
import at.bitfire.dav4android.property.DisplayName;
import at.bitfire.dav4android.property.GetContentType;
import at.bitfire.dav4android.property.GetLastModified;
import at.bitfire.dav4android.property.ResourceType;
import at.bitfire.dav4jvm.Property;
import at.bitfire.dav4jvm.Response;
import at.bitfire.dav4jvm.property.DisplayName;
import at.bitfire.dav4jvm.property.GetContentType;
import at.bitfire.dav4jvm.property.GetLastModified;
import at.bitfire.dav4jvm.property.ResourceType;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.nextcloud.talk.components.filebrowser.models.properties.NCEncrypted;
import com.nextcloud.talk.components.filebrowser.models.properties.NCPreview;

View File

@ -20,7 +20,7 @@
package com.nextcloud.talk.components.filebrowser.models;
import at.bitfire.dav4android.Response;
import at.bitfire.dav4jvm.Response;
import lombok.Data;
@Data

View File

@ -21,9 +21,9 @@
package com.nextcloud.talk.components.filebrowser.models.properties;
import android.text.TextUtils;
import at.bitfire.dav4android.Property;
import at.bitfire.dav4android.PropertyFactory;
import at.bitfire.dav4android.XmlUtils;
import at.bitfire.dav4jvm.Property;
import at.bitfire.dav4jvm.PropertyFactory;
import at.bitfire.dav4jvm.XmlUtils;
import com.nextcloud.talk.components.filebrowser.webdav.DavUtils;
import java.io.IOException;
import lombok.Getter;

View File

@ -21,9 +21,9 @@
package com.nextcloud.talk.components.filebrowser.models.properties;
import android.text.TextUtils;
import at.bitfire.dav4android.Property;
import at.bitfire.dav4android.PropertyFactory;
import at.bitfire.dav4android.XmlUtils;
import at.bitfire.dav4jvm.Property;
import at.bitfire.dav4jvm.PropertyFactory;
import at.bitfire.dav4jvm.XmlUtils;
import com.nextcloud.talk.components.filebrowser.webdav.DavUtils;
import java.io.IOException;
import lombok.Getter;

View File

@ -21,9 +21,9 @@
package com.nextcloud.talk.components.filebrowser.models.properties;
import android.text.TextUtils;
import at.bitfire.dav4android.Property;
import at.bitfire.dav4android.PropertyFactory;
import at.bitfire.dav4android.XmlUtils;
import at.bitfire.dav4jvm.Property;
import at.bitfire.dav4jvm.PropertyFactory;
import at.bitfire.dav4jvm.XmlUtils;
import com.nextcloud.talk.components.filebrowser.webdav.DavUtils;
import java.io.IOException;
import lombok.Getter;

View File

@ -21,9 +21,9 @@
package com.nextcloud.talk.components.filebrowser.models.properties;
import android.text.TextUtils;
import at.bitfire.dav4android.Property;
import at.bitfire.dav4android.PropertyFactory;
import at.bitfire.dav4android.XmlUtils;
import at.bitfire.dav4jvm.Property;
import at.bitfire.dav4jvm.PropertyFactory;
import at.bitfire.dav4jvm.XmlUtils;
import com.nextcloud.talk.components.filebrowser.webdav.DavUtils;
import java.io.IOException;
import lombok.Getter;

View File

@ -21,9 +21,9 @@
package com.nextcloud.talk.components.filebrowser.models.properties;
import android.text.TextUtils;
import at.bitfire.dav4android.Property;
import at.bitfire.dav4android.PropertyFactory;
import at.bitfire.dav4android.XmlUtils;
import at.bitfire.dav4jvm.Property;
import at.bitfire.dav4jvm.PropertyFactory;
import at.bitfire.dav4jvm.XmlUtils;
import com.nextcloud.talk.components.filebrowser.webdav.DavUtils;
import java.io.IOException;
import lombok.Getter;

View File

@ -20,26 +20,23 @@
package com.nextcloud.talk.components.filebrowser.webdav;
import at.bitfire.dav4android.Property;
import at.bitfire.dav4android.PropertyFactory;
import at.bitfire.dav4android.PropertyRegistry;
import at.bitfire.dav4android.property.CreationDate;
import at.bitfire.dav4android.property.DisplayName;
import at.bitfire.dav4android.property.GetContentLength;
import at.bitfire.dav4android.property.GetContentType;
import at.bitfire.dav4android.property.GetETag;
import at.bitfire.dav4android.property.GetLastModified;
import at.bitfire.dav4android.property.ResourceType;
import at.bitfire.dav4jvm.Property;
import at.bitfire.dav4jvm.PropertyFactory;
import at.bitfire.dav4jvm.PropertyRegistry;
import at.bitfire.dav4jvm.property.CreationDate;
import at.bitfire.dav4jvm.property.DisplayName;
import at.bitfire.dav4jvm.property.GetContentLength;
import at.bitfire.dav4jvm.property.GetContentType;
import at.bitfire.dav4jvm.property.GetETag;
import at.bitfire.dav4jvm.property.GetLastModified;
import at.bitfire.dav4jvm.property.ResourceType;
import com.nextcloud.talk.components.filebrowser.models.properties.NCEncrypted;
import com.nextcloud.talk.components.filebrowser.models.properties.NCPreview;
import com.nextcloud.talk.components.filebrowser.models.properties.OCFavorite;
import com.nextcloud.talk.components.filebrowser.models.properties.OCId;
import com.nextcloud.talk.components.filebrowser.models.properties.OCSize;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DavUtils {
public static final String OC_NAMESPACE = "http://owncloud.org/ns";
@ -95,23 +92,13 @@ public class DavUtils {
public static void registerCustomFactories() {
PropertyRegistry propertyRegistry = PropertyRegistry.INSTANCE;
try {
Field factories = propertyRegistry.getClass().getDeclaredField("factories");
factories.setAccessible(true);
Map<Property.Name, PropertyFactory> reflectionMap = (HashMap<Property.Name,
PropertyFactory>) factories.get(propertyRegistry);
List<PropertyFactory> propertyFactories = new ArrayList<>();
propertyFactories.add(new OCId.Factory());
propertyFactories.add(new NCPreview.Factory());
propertyFactories.add(new NCEncrypted.Factory());
propertyFactories.add(new OCFavorite.Factory());
propertyFactories.add(new OCSize.Factory());
reflectionMap.put(OCId.NAME, new OCId.Factory());
reflectionMap.put(NCPreview.NAME, new NCPreview.Factory());
reflectionMap.put(NCEncrypted.NAME, new NCEncrypted.Factory());
reflectionMap.put(OCFavorite.NAME, new OCFavorite.Factory());
reflectionMap.put(OCSize.NAME, new OCSize.Factory());
factories.set(propertyRegistry, reflectionMap);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
propertyRegistry.register(propertyFactories);
}
}

View File

@ -20,9 +20,9 @@
package com.nextcloud.talk.components.filebrowser.webdav;
import at.bitfire.dav4android.DavResource;
import at.bitfire.dav4android.Response;
import at.bitfire.dav4android.exception.DavException;
import at.bitfire.dav4jvm.DavResource;
import at.bitfire.dav4jvm.Response;
import at.bitfire.dav4jvm.exception.DavException;
import com.nextcloud.talk.components.filebrowser.models.BrowserFile;
import com.nextcloud.talk.components.filebrowser.models.DavResponse;
import com.nextcloud.talk.dagger.modules.RestModule;

View File

@ -1137,7 +1137,7 @@ class ChatController(args: Bundle) : BaseController(), MessagesListAdapter
) {
val xChatLastGivenHeader: String? = response.headers()
.get("X-Chat-Last-Given")
if (response.headers().size > 0 && !TextUtils.isEmpty(xChatLastGivenHeader)) {
if (response.headers().size() > 0 && !TextUtils.isEmpty(xChatLastGivenHeader)) {
val header = Integer.parseInt(xChatLastGivenHeader!!)
if (header > 0) {

View File

@ -112,7 +112,7 @@ fun createOkHttpClient(
// Trust own CA and all self-signed certs
httpClient.sslSocketFactory(sslSocketFactoryCompat, magicTrustManager)
httpClient.retryOnConnectionFailure(true)
httpClient.hostnameVerifier(magicTrustManager.getHostnameVerifier(OkHostnameVerifier))
httpClient.hostnameVerifier(magicTrustManager.getHostnameVerifier(OkHostnameVerifier.INSTANCE))
httpClient.dispatcher(dispatcher)
if (Proxy.NO_PROXY != proxy) {

View File

@ -45,14 +45,14 @@ class NetworkUtils {
.header("User-Agent", ApiUtils.getUserAgent())
.header("Accept", "application/json")
.header("OCS-APIRequest", "true")
.method(original.method, original.body)
.method(original.method(), original.body())
.build()
val response = chain.proceed(request)
if (request.url.encodedPath.contains("/avatar/")) {
if (request.url().encodedPath().contains("/avatar/")) {
AvatarStatusCodeHolder.getInstance()
.statusCode = response.code
.statusCode = response.code()
}
return response
@ -68,7 +68,7 @@ class NetworkUtils {
route: Route?,
response: Response
): Request? {
if (response.request.header(authenticatorType) != null) {
if (response.request().header(authenticatorType) != null) {
return null
}
@ -77,13 +77,13 @@ class NetworkUtils {
var attemptsCount = 0
while ({ countedResponse = countedResponse?.priorResponse; countedResponse }() != null) {
while ({ countedResponse = countedResponse?.priorResponse(); countedResponse }() != null) {
attemptsCount++
if (attemptsCount == 3) {
return null
}
}
return response.request.newBuilder()
return response.request().newBuilder()
.header(authenticatorType, credentials)
.build()
}