|
@@ -37,7 +37,6 @@ import com.nextcloud.talk.utils.ssl.MagicKeyManager;
|
|
import com.nextcloud.talk.utils.ssl.MagicTrustManager;
|
|
import com.nextcloud.talk.utils.ssl.MagicTrustManager;
|
|
import com.nextcloud.talk.utils.ssl.SSLSocketFactoryCompat;
|
|
import com.nextcloud.talk.utils.ssl.SSLSocketFactoryCompat;
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.net.CookieManager;
|
|
import java.net.CookieManager;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
@@ -47,7 +46,6 @@ import java.security.KeyStoreException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.UnrecoverableKeyException;
|
|
import java.security.UnrecoverableKeyException;
|
|
import java.security.cert.CertificateException;
|
|
import java.security.cert.CertificateException;
|
|
-import java.util.Random;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import javax.inject.Singleton;
|
|
import javax.inject.Singleton;
|
|
@@ -77,6 +75,7 @@ public class RestModule {
|
|
|
|
|
|
private static final String TAG = "RestModule";
|
|
private static final String TAG = "RestModule";
|
|
|
|
|
|
|
|
+ @Singleton
|
|
@Provides
|
|
@Provides
|
|
NcApi provideNcApi(Retrofit retrofit) {
|
|
NcApi provideNcApi(Retrofit retrofit) {
|
|
return retrofit.create(NcApi.class);
|
|
return retrofit.create(NcApi.class);
|
|
@@ -102,6 +101,7 @@ public class RestModule {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Singleton
|
|
@Provides
|
|
@Provides
|
|
Retrofit provideRetrofit(OkHttpClient httpClient) {
|
|
Retrofit provideRetrofit(OkHttpClient httpClient) {
|
|
Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
|
|
Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
|
|
@@ -152,25 +152,18 @@ public class RestModule {
|
|
return new SSLSocketFactoryCompat(keyManager, magicTrustManager);
|
|
return new SSLSocketFactoryCompat(keyManager, magicTrustManager);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Singleton
|
|
@Provides
|
|
@Provides
|
|
CookieManager provideCookieManager() {
|
|
CookieManager provideCookieManager() {
|
|
return new CookieManager();
|
|
return new CookieManager();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Singleton
|
|
@Provides
|
|
@Provides
|
|
- Cache provideCache(UserUtils userUtils) {
|
|
|
|
|
|
+ Cache provideCache() {
|
|
int cacheSize = 128 * 1024 * 1024; // 128 MB
|
|
int cacheSize = 128 * 1024 * 1024; // 128 MB
|
|
- String userId = "";
|
|
|
|
|
|
|
|
- if (userUtils.getCurrentUser() != null) {
|
|
|
|
- userId = Long.toString(userUtils.getCurrentUser().getId());
|
|
|
|
- } else {
|
|
|
|
- Random r = new Random( System.currentTimeMillis() );
|
|
|
|
- userId = "nc-temp-" + (10000 + r.nextInt(20000));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return new Cache(new File(NextcloudTalkApplication.getSharedApplication().getCacheDir() + "/" +
|
|
|
|
- userId), cacheSize);
|
|
|
|
|
|
+ return new Cache(NextcloudTalkApplication.getSharedApplication().getCacheDir(), cacheSize);
|
|
}
|
|
}
|
|
|
|
|
|
@Singleton
|
|
@Singleton
|
|
@@ -182,6 +175,7 @@ public class RestModule {
|
|
return dispatcher;
|
|
return dispatcher;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Singleton
|
|
@Provides
|
|
@Provides
|
|
OkHttpClient provideHttpClient(Proxy proxy, AppPreferences appPreferences,
|
|
OkHttpClient provideHttpClient(Proxy proxy, AppPreferences appPreferences,
|
|
MagicTrustManager magicTrustManager,
|
|
MagicTrustManager magicTrustManager,
|