|
|
@ -5,6 +5,7 @@ import android.content.Context; |
|
|
|
import android.content.SharedPreferences; |
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
import android.net.Uri; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.util.DisplayMetrics; |
|
|
|
import android.widget.ImageView; |
|
|
@ -25,6 +26,9 @@ import com.squareup.picasso.Picasso; |
|
|
|
import net.gotev.uploadservice.UploadService; |
|
|
|
import net.gotev.uploadservice.okhttp.OkHttpStack; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
@ -35,6 +39,8 @@ import gr.thmmy.mthmmy.R; |
|
|
|
import gr.thmmy.mthmmy.session.SessionManager; |
|
|
|
import gr.thmmy.mthmmy.utils.CrashReportingTree; |
|
|
|
import io.fabric.sdk.android.Fabric; |
|
|
|
import okhttp3.CipherSuite; |
|
|
|
import okhttp3.ConnectionSpec; |
|
|
|
import okhttp3.HttpUrl; |
|
|
|
import okhttp3.OkHttpClient; |
|
|
|
import okhttp3.Request; |
|
|
@ -89,7 +95,7 @@ public class BaseApplication extends Application { |
|
|
|
|
|
|
|
SharedPrefsCookiePersistor sharedPrefsCookiePersistor = new SharedPrefsCookiePersistor(getApplicationContext()); |
|
|
|
PersistentCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), sharedPrefsCookiePersistor); |
|
|
|
client = new OkHttpClient.Builder() |
|
|
|
OkHttpClient.Builder builder = new OkHttpClient.Builder() |
|
|
|
.cookieJar(cookieJar) |
|
|
|
.addInterceptor(chain -> { |
|
|
|
Request request = chain.request(); |
|
|
@ -103,8 +109,24 @@ public class BaseApplication extends Application { |
|
|
|
} |
|
|
|
return chain.proceed(request); |
|
|
|
}) |
|
|
|
.callTimeout(30, TimeUnit.SECONDS) |
|
|
|
.callTimeout(30, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Just for KitKats
|
|
|
|
// Necessary because our servers don't have the right cipher suites.
|
|
|
|
// https://github.com/square/okhttp/issues/4053
|
|
|
|
List<CipherSuite> cipherSuites = new ArrayList<>(ConnectionSpec.MODERN_TLS.cipherSuites()); |
|
|
|
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA); |
|
|
|
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA); |
|
|
|
|
|
|
|
ConnectionSpec legacyTls = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) |
|
|
|
.cipherSuites(cipherSuites.toArray(new CipherSuite[0])) |
|
|
|
.build(); |
|
|
|
|
|
|
|
builder.connectionSpecs(Arrays.asList(legacyTls, ConnectionSpec.CLEARTEXT)); |
|
|
|
} |
|
|
|
|
|
|
|
client = builder.build(); |
|
|
|
|
|
|
|
sessionManager = new SessionManager(client, cookieJar, sharedPrefsCookiePersistor, sharedPrefs, draftsPrefs); |
|
|
|
Picasso picasso = new Picasso.Builder(getApplicationContext()) |
|
|
|
.downloader(new OkHttp3Downloader(client)) |
|
|
@ -184,8 +206,7 @@ public class BaseApplication extends Application { |
|
|
|
Fabric.with(this, crashlyticsKit); |
|
|
|
Timber.plant(new CrashReportingTree()); |
|
|
|
Timber.i("Crashlytics enabled."); |
|
|
|
} |
|
|
|
else |
|
|
|
} else |
|
|
|
Timber.i("Crashlytics were already initialized for this app session."); |
|
|
|
} |
|
|
|
} |
|
|
|