mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-11-04 12:28:25 +00:00 
			
		
		
		
	add stetho
This commit is contained in:
		
							parent
							
								
									297e8d1848
								
							
						
					
					
						commit
						266dc37da2
					
				@ -21,6 +21,10 @@ dependencies {
 | 
				
			|||||||
    api 'org.apache.jackrabbit:jackrabbit-webdav:2.12.4'
 | 
					    api 'org.apache.jackrabbit:jackrabbit-webdav:2.12.4'
 | 
				
			||||||
    api 'com.squareup.okhttp3:okhttp:3.10.0'
 | 
					    api 'com.squareup.okhttp3:okhttp:3.10.0'
 | 
				
			||||||
    api project(':dav4android')
 | 
					    api project(':dav4android')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Used for network and database debuging
 | 
				
			||||||
 | 
					    debugApi 'com.facebook.stetho:stetho:1.5.0'
 | 
				
			||||||
 | 
					    debugApi 'com.facebook.stetho:stetho-okhttp3:1.5.0'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
android {
 | 
					android {
 | 
				
			||||||
 | 
				
			|||||||
@ -26,6 +26,8 @@ package com.owncloud.android.lib.common.http;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import android.content.Context;
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.facebook.stetho.okhttp3.StethoInterceptor;
 | 
				
			||||||
 | 
					import com.owncloud.android.lib.BuildConfig;
 | 
				
			||||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
 | 
					import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
 | 
				
			||||||
import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor;
 | 
					import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor;
 | 
				
			||||||
import com.owncloud.android.lib.common.http.interceptors.UserAgentInterceptor;
 | 
					import com.owncloud.android.lib.common.http.interceptors.UserAgentInterceptor;
 | 
				
			||||||
@ -68,13 +70,17 @@ public class HttpClient {
 | 
				
			|||||||
                        NetworkUtils.getKnownServersStore(sContext));
 | 
					                        NetworkUtils.getKnownServersStore(sContext));
 | 
				
			||||||
                final SSLContext sslContext = SSLContext.getInstance("TLS");
 | 
					                final SSLContext sslContext = SSLContext.getInstance("TLS");
 | 
				
			||||||
                sslContext.init(null, new TrustManager[] {trustManager}, null);
 | 
					                sslContext.init(null, new TrustManager[] {trustManager}, null);
 | 
				
			||||||
                sOkHttpClient = new OkHttpClient.Builder()
 | 
					                OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder()
 | 
				
			||||||
                        .addInterceptor(getOkHttpInterceptor())
 | 
					                        .addInterceptor(getOkHttpInterceptor())
 | 
				
			||||||
                        .protocols(Arrays.asList(Protocol.HTTP_1_1))
 | 
					                        .protocols(Arrays.asList(Protocol.HTTP_1_1))
 | 
				
			||||||
                        .followRedirects(false)
 | 
					                        .followRedirects(false)
 | 
				
			||||||
                        .sslSocketFactory(sslContext.getSocketFactory(), trustManager)
 | 
					                        .sslSocketFactory(sslContext.getSocketFactory(), trustManager)
 | 
				
			||||||
                        .hostnameVerifier(new BrowserCompatHostnameVerifier())
 | 
					                        .hostnameVerifier(new BrowserCompatHostnameVerifier())
 | 
				
			||||||
                        .build();
 | 
					                if(BuildConfig.DEBUG) {
 | 
				
			||||||
 | 
					                    clientBuilder.addNetworkInterceptor(new StethoInterceptor());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                sOkHttpClient = clientBuilder.build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            } catch (Exception e) {
 | 
					            } catch (Exception e) {
 | 
				
			||||||
                Log_OC.e(TAG, "Could not setup SSL system.", e);
 | 
					                Log_OC.e(TAG, "Could not setup SSL system.", e);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -27,8 +27,10 @@ package com.owncloud.android.lib.resources.files;
 | 
				
			|||||||
import android.net.Uri;
 | 
					import android.net.Uri;
 | 
				
			||||||
import android.os.Parcel;
 | 
					import android.os.Parcel;
 | 
				
			||||||
import android.os.Parcelable;
 | 
					import android.os.Parcelable;
 | 
				
			||||||
 | 
					import android.util.Log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.owncloud.android.lib.common.network.WebdavEntry;
 | 
					import com.owncloud.android.lib.common.network.WebdavEntry;
 | 
				
			||||||
 | 
					import com.owncloud.android.lib.common.utils.Log_OC;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.Serializable;
 | 
					import java.io.Serializable;
 | 
				
			||||||
import java.math.BigDecimal;
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
@ -232,8 +234,9 @@ public class RemoteFile implements Parcelable, Serializable {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static String getRemotePathFromUrl(HttpUrl url, String displayName) {
 | 
					    private static String getRemotePathFromUrl(HttpUrl url, String displayName) {
 | 
				
			||||||
        final String pathToRemove = NEW_WEBDAV_FILES_PATH_4_0 + displayName;
 | 
					        final String davPath = NEW_WEBDAV_FILES_PATH_4_0 + displayName;
 | 
				
			||||||
        return Uri.decode(url.encodedPath()).replace(pathToRemove, "");
 | 
					        final String pathToOc = url.encodedPath().split(davPath)[0];
 | 
				
			||||||
 | 
					        return Uri.decode(url.encodedPath()).replace(pathToOc + davPath, "");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user