mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Upgrade other libraries
This commit is contained in:
parent
f8b665a245
commit
8b04fdab77
@ -3,7 +3,7 @@ import javax.tools.JavaCompiler
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.41'
|
||||
ext.kotlin_version = '1.3.50'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
@ -94,8 +94,8 @@ dependencies {
|
||||
def moshi_version = '1.8.0'
|
||||
def lifecycle_version = '2.1.0'
|
||||
def coroutines_version = "1.1.1"
|
||||
def markwon_version = '3.0.0'
|
||||
def daggerVersion = '2.23.1'
|
||||
def markwon_version = '3.1.0'
|
||||
def daggerVersion = '2.24'
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
|
||||
@ -108,10 +108,10 @@ dependencies {
|
||||
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
|
||||
|
||||
// Network
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
|
||||
implementation 'com.squareup.retrofit2:converter-moshi:2.4.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.14.1'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
|
||||
implementation 'com.squareup.retrofit2:converter-moshi:2.6.2'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.2.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.0'
|
||||
implementation 'com.novoda:merlin:1.2.0'
|
||||
implementation "com.squareup.moshi:moshi-adapters:$moshi_version"
|
||||
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
|
||||
@ -135,24 +135,24 @@ dependencies {
|
||||
// DI
|
||||
implementation "com.google.dagger:dagger:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.4.0'
|
||||
kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.4.0'
|
||||
compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.5.0'
|
||||
kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.5.0'
|
||||
|
||||
// Logging
|
||||
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
|
||||
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
|
||||
|
||||
// Bus
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
|
||||
debugImplementation 'com.airbnb.okreplay:okreplay:1.4.0'
|
||||
releaseImplementation 'com.airbnb.okreplay:noop:1.4.0'
|
||||
androidTestImplementation 'com.airbnb.okreplay:espresso:1.4.0'
|
||||
debugImplementation 'com.airbnb.okreplay:okreplay:1.5.0'
|
||||
releaseImplementation 'com.airbnb.okreplay:noop:1.5.0'
|
||||
androidTestImplementation 'com.airbnb.okreplay:espresso:1.5.0'
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.robolectric:robolectric:4.0.2'
|
||||
testImplementation 'org.robolectric:robolectric:4.3'
|
||||
//testImplementation 'org.robolectric:shadows-support-v4:3.0'
|
||||
testImplementation "io.mockk:mockk:1.8.13.kotlin13"
|
||||
testImplementation 'io.mockk:mockk:1.9.3.kotlin12'
|
||||
testImplementation 'org.amshove.kluent:kluent-android:1.44'
|
||||
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
|
||||
|
||||
@ -162,7 +162,7 @@ dependencies {
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
androidTestImplementation 'org.amshove.kluent:kluent-android:1.44'
|
||||
androidTestImplementation "io.mockk:mockk-android:1.8.13.kotlin13"
|
||||
androidTestImplementation 'io.mockk:mockk-android:1.9.3.kotlin12'
|
||||
androidTestImplementation "androidx.arch.core:core-testing:$lifecycle_version"
|
||||
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
|
||||
|
||||
|
@ -52,12 +52,12 @@ internal class CurlLoggingInterceptor @Inject constructor(private val logger: Ht
|
||||
var compressed = false
|
||||
|
||||
var curlCmd = "curl"
|
||||
if (curlOptions != null) {
|
||||
curlCmd += " " + curlOptions!!
|
||||
curlOptions?.let {
|
||||
curlCmd += " $it"
|
||||
}
|
||||
curlCmd += " -X " + request.method()
|
||||
curlCmd += " -X " + request.method
|
||||
|
||||
val requestBody = request.body()
|
||||
val requestBody = request.body
|
||||
if (requestBody != null) {
|
||||
if (requestBody.contentLength() > 100_000) {
|
||||
Timber.w("Unable to log curl command data, size is too big (${requestBody.contentLength()})")
|
||||
@ -76,9 +76,9 @@ internal class CurlLoggingInterceptor @Inject constructor(private val logger: Ht
|
||||
}
|
||||
}
|
||||
|
||||
val headers = request.headers()
|
||||
val headers = request.headers
|
||||
var i = 0
|
||||
val count = headers.size()
|
||||
val count = headers.size
|
||||
while (i < count) {
|
||||
val name = headers.name(i)
|
||||
val value = headers.value(i)
|
||||
@ -89,7 +89,7 @@ internal class CurlLoggingInterceptor @Inject constructor(private val logger: Ht
|
||||
i++
|
||||
}
|
||||
|
||||
curlCmd += ((if (compressed) " --compressed " else " ") + "'" + request.url().toString()
|
||||
curlCmd += ((if (compressed) " --compressed " else " ") + "'" + request.url.toString()
|
||||
// Replace localhost for emulator by localhost for shell
|
||||
.replace("://10.0.2.2:8080/".toRegex(), "://127.0.0.1:8080/")
|
||||
+ "'")
|
||||
@ -97,7 +97,7 @@ internal class CurlLoggingInterceptor @Inject constructor(private val logger: Ht
|
||||
// Add Json formatting
|
||||
curlCmd += " | python -m json.tool"
|
||||
|
||||
logger.log("--- cURL (" + request.url() + ")")
|
||||
logger.log("--- cURL (" + request.url + ")")
|
||||
logger.log(curlCmd)
|
||||
|
||||
return chain.proceed(request)
|
||||
|
@ -43,7 +43,7 @@ internal class ProgressRequestBody(private val delegate: RequestBody,
|
||||
@Throws(IOException::class)
|
||||
override fun writeTo(sink: BufferedSink) {
|
||||
countingSink = CountingSink(sink)
|
||||
val bufferedSink = Okio.buffer(countingSink)
|
||||
val bufferedSink = countingSink.buffer()
|
||||
delegate.writeTo(bufferedSink)
|
||||
bufferedSink.flush()
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ internal fun <T> Response<T>.toFailure(): Failure {
|
||||
* Convert a okhttp3 Response to a Failure, and eventually parse errorBody to convert it to a MatrixError
|
||||
*/
|
||||
internal fun okhttp3.Response.toFailure(): Failure {
|
||||
return toFailure(body(), code())
|
||||
return toFailure(body, code)
|
||||
}
|
||||
|
||||
private fun toFailure(errorBody: ResponseBody?, httpCode: Int): Failure {
|
||||
|
@ -57,7 +57,7 @@ constructor(trustPinned: Array<TrustManager>, acceptedTlsVersions: List<TlsVersi
|
||||
context.init(null, trustPinned, SecureRandom())
|
||||
internalSSLSocketFactory = context.socketFactory
|
||||
enabledProtocols = Array(acceptedTlsVersions.size) {
|
||||
acceptedTlsVersions[it].javaName()
|
||||
acceptedTlsVersions[it].javaName
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,8 @@ internal class DefaultFileService @Inject constructor(private val context: Conte
|
||||
.build()
|
||||
|
||||
val response = okHttpClient.newCall(request).execute()
|
||||
val inputStream = response.body()?.byteStream()
|
||||
Timber.v("Response size ${response.body()?.contentLength()} - Stream available: ${inputStream?.available()}")
|
||||
val inputStream = response.body?.byteStream()
|
||||
Timber.v("Response size ${response.body?.contentLength()} - Stream available: ${inputStream?.available()}")
|
||||
if (!response.isSuccessful
|
||||
|| inputStream == null) {
|
||||
throw IOException()
|
||||
|
@ -23,6 +23,8 @@ import im.vector.matrix.android.internal.network.ProgressRequestBody
|
||||
import im.vector.matrix.android.internal.network.awaitResponse
|
||||
import im.vector.matrix.android.internal.network.toFailure
|
||||
import okhttp3.*
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
@ -41,7 +43,7 @@ internal class FileUploader @Inject constructor(@Authenticated
|
||||
filename: String?,
|
||||
mimeType: String,
|
||||
progressListener: ProgressRequestBody.Listener? = null): ContentUploadResponse {
|
||||
val uploadBody = RequestBody.create(MediaType.parse(mimeType), file)
|
||||
val uploadBody = RequestBody.create(mimeType.toMediaTypeOrNull(), file)
|
||||
return upload(uploadBody, filename, progressListener)
|
||||
|
||||
}
|
||||
@ -50,13 +52,13 @@ internal class FileUploader @Inject constructor(@Authenticated
|
||||
filename: String?,
|
||||
mimeType: String,
|
||||
progressListener: ProgressRequestBody.Listener? = null): ContentUploadResponse {
|
||||
val uploadBody = RequestBody.create(MediaType.parse(mimeType), byteArray)
|
||||
val uploadBody = RequestBody.create(mimeType.toMediaTypeOrNull(), byteArray)
|
||||
return upload(uploadBody, filename, progressListener)
|
||||
}
|
||||
|
||||
|
||||
private suspend fun upload(uploadBody: RequestBody, filename: String?, progressListener: ProgressRequestBody.Listener?): ContentUploadResponse {
|
||||
val urlBuilder = HttpUrl.parse(uploadUrl)?.newBuilder() ?: throw RuntimeException()
|
||||
val urlBuilder = uploadUrl.toHttpUrlOrNull()?.newBuilder() ?: throw RuntimeException()
|
||||
|
||||
val httpUrl = urlBuilder
|
||||
.addQueryParameter("filename", filename)
|
||||
@ -73,7 +75,7 @@ internal class FileUploader @Inject constructor(@Authenticated
|
||||
if (!response.isSuccessful) {
|
||||
throw response.toFailure()
|
||||
} else {
|
||||
response.body()?.source()?.let {
|
||||
response.body?.source()?.let {
|
||||
responseAdapter.fromJson(it)
|
||||
}
|
||||
?: throw IOException()
|
||||
|
@ -17,7 +17,9 @@
|
||||
package im.vector.matrix.android.internal.util
|
||||
|
||||
import androidx.annotation.WorkerThread
|
||||
import okio.Okio
|
||||
import okio.buffer
|
||||
import okio.sink
|
||||
import okio.source
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
|
||||
@ -26,8 +28,8 @@ import java.io.InputStream
|
||||
*/
|
||||
@WorkerThread
|
||||
fun writeToFile(inputStream: InputStream, outputFile: File) {
|
||||
Okio.buffer(Okio.source(inputStream)).use { input ->
|
||||
Okio.buffer(Okio.sink(outputFile)).use { output ->
|
||||
inputStream.source().buffer().use { input ->
|
||||
outputFile.sink().buffer().use { output ->
|
||||
output.writeAll(input)
|
||||
}
|
||||
}
|
||||
|
@ -216,14 +216,14 @@ android {
|
||||
|
||||
dependencies {
|
||||
|
||||
def epoxy_version = "3.7.0"
|
||||
def epoxy_version = '3.8.0'
|
||||
def arrow_version = "0.8.2"
|
||||
def coroutines_version = "1.0.1"
|
||||
def markwon_version = '3.0.0'
|
||||
def coroutines_version = "1.1.1"
|
||||
def markwon_version = '3.1.0'
|
||||
def big_image_viewer_version = '1.5.6'
|
||||
def glide_version = '4.9.0'
|
||||
def glide_version = '4.10.0'
|
||||
def moshi_version = '1.8.0'
|
||||
def daggerVersion = '2.23.1'
|
||||
def daggerVersion = '2.24'
|
||||
|
||||
implementation project(":matrix-sdk-android")
|
||||
implementation project(":matrix-sdk-android-rx")
|
||||
@ -235,7 +235,7 @@ dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
//Do not use beta2 at the moment, as it breaks things
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
|
||||
implementation 'androidx.core:core-ktx:1.1.0'
|
||||
|
||||
implementation "org.threeten:threetenbp:1.4.0:no-tzdb"
|
||||
@ -251,12 +251,12 @@ dependencies {
|
||||
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||
|
||||
// Debug
|
||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||
implementation 'com.facebook.stetho:stetho:1.5.1'
|
||||
|
||||
// rx
|
||||
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0'
|
||||
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.1'
|
||||
// RXBinding
|
||||
implementation 'com.jakewharton.rxbinding3:rxbinding:3.0.0'
|
||||
implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.0.0'
|
||||
@ -265,7 +265,7 @@ dependencies {
|
||||
implementation("com.airbnb.android:epoxy:$epoxy_version")
|
||||
kapt "com.airbnb.android:epoxy-processor:$epoxy_version"
|
||||
implementation "com.airbnb.android:epoxy-paging:$epoxy_version"
|
||||
implementation 'com.airbnb.android:mvrx:1.0.1'
|
||||
implementation 'com.airbnb.android:mvrx:1.1.0'
|
||||
|
||||
// Work
|
||||
implementation "androidx.work:work-runtime-ktx:2.3.0-alpha01"
|
||||
@ -292,7 +292,7 @@ dependencies {
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
|
||||
// Passphrase strength helper
|
||||
implementation 'com.nulab-inc:zxcvbn:1.2.5'
|
||||
implementation 'com.nulab-inc:zxcvbn:1.2.7'
|
||||
|
||||
//Alerter
|
||||
implementation 'com.tapadoo.android:alerter:4.0.3'
|
||||
@ -300,8 +300,8 @@ dependencies {
|
||||
implementation 'com.otaliastudios:autocomplete:1.1.0'
|
||||
|
||||
// Butterknife
|
||||
implementation 'com.jakewharton:butterknife:10.1.0'
|
||||
kapt 'com.jakewharton:butterknife-compiler:10.1.0'
|
||||
implementation 'com.jakewharton:butterknife:10.2.0'
|
||||
kapt 'com.jakewharton:butterknife-compiler:10.2.0'
|
||||
|
||||
// Shake detection
|
||||
implementation 'com.squareup:seismic:1.0.2'
|
||||
@ -316,7 +316,7 @@ dependencies {
|
||||
implementation 'com.danikula:videocache:2.7.1'
|
||||
|
||||
// Badge for compatibility
|
||||
implementation 'me.leolin:ShortcutBadger:1.1.2@aar'
|
||||
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
|
||||
|
||||
// File picker
|
||||
implementation 'com.github.jaiselrahman:FilePicker:1.2.2'
|
||||
@ -324,8 +324,8 @@ dependencies {
|
||||
// DI
|
||||
implementation "com.google.dagger:dagger:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.4.0'
|
||||
kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.4.0'
|
||||
compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.5.0'
|
||||
kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.5.0'
|
||||
|
||||
// gplay flavor only
|
||||
// Warning: due to the exclude, Android Studio does not propose to upgrade. Uncomment next line to be proposed to upgrade
|
||||
|
@ -20,10 +20,10 @@ import android.app.DownloadManager
|
||||
import android.content.Context
|
||||
import androidx.annotation.WorkerThread
|
||||
import arrow.core.Try
|
||||
import okio.Okio
|
||||
import okio.buffer
|
||||
import okio.sink
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
|
||||
/**
|
||||
* Save a string to a file with Okio
|
||||
@ -31,9 +31,9 @@ import java.io.InputStream
|
||||
@WorkerThread
|
||||
fun writeToFile(str: String, file: File): Try<Unit> {
|
||||
return Try {
|
||||
val sink = Okio.sink(file)
|
||||
val sink = file.sink()
|
||||
|
||||
val bufferedSink = Okio.buffer(sink)
|
||||
val bufferedSink = sink.buffer()
|
||||
|
||||
bufferedSink.writeString(str, Charsets.UTF_8)
|
||||
|
||||
@ -48,9 +48,9 @@ fun writeToFile(str: String, file: File): Try<Unit> {
|
||||
@WorkerThread
|
||||
fun writeToFile(data: ByteArray, file: File): Try<Unit> {
|
||||
return Try {
|
||||
val sink = Okio.sink(file)
|
||||
val sink = file.sink()
|
||||
|
||||
val bufferedSink = Okio.buffer(sink)
|
||||
val bufferedSink = sink.buffer()
|
||||
|
||||
bufferedSink.write(data)
|
||||
|
||||
|
@ -34,7 +34,6 @@ import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import com.bumptech.glide.load.engine.Resource as Resource1
|
||||
|
||||
|
||||
class VectorGlideModelLoaderFactory(private val activeSessionHolder: ActiveSessionHolder)
|
||||
@ -112,8 +111,8 @@ class VectorGlideDataFetcher(private val activeSessionHolder: ActiveSessionHolde
|
||||
.build()
|
||||
|
||||
val response = client.newCall(request).execute()
|
||||
val inputStream = response.body()?.byteStream()
|
||||
Timber.v("Response size ${response.body()?.contentLength()} - Stream available: ${inputStream?.available()}")
|
||||
val inputStream = response.body?.byteStream()
|
||||
Timber.v("Response size ${response.body?.contentLength()} - Stream available: ${inputStream?.available()}")
|
||||
if (!response.isSuccessful) {
|
||||
callback.onLoadFailed(IOException("Unexpected code $response"))
|
||||
return
|
||||
|
@ -20,7 +20,6 @@ import android.content.Context
|
||||
import android.os.Build
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import me.leolin.shortcutbadger.ShortcutBadger
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Manage application badge (displayed in the launcher)
|
||||
@ -45,12 +44,7 @@ object BadgeProxy {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
ShortcutBadger.setBadge(context, badgeValue)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## updateBadgeCount(): Exception Msg=" + e.message)
|
||||
}
|
||||
|
||||
ShortcutBadger.applyCount(context, badgeValue)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,8 @@ import im.vector.riotx.features.settings.VectorLocale
|
||||
import im.vector.riotx.features.themes.ThemeUtils
|
||||
import im.vector.riotx.features.version.VersionProvider
|
||||
import okhttp3.*
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import timber.log.Timber
|
||||
@ -53,7 +55,7 @@ import javax.inject.Singleton
|
||||
@Singleton
|
||||
class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSessionHolder,
|
||||
private val versionProvider: VersionProvider,
|
||||
private val vectorFileLogger : VectorFileLogger) {
|
||||
private val vectorFileLogger: VectorFileLogger) {
|
||||
var inMultiWindowMode = false
|
||||
|
||||
companion object {
|
||||
@ -248,7 +250,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
|
||||
// add the gzipped files
|
||||
for (file in gzippedFiles) {
|
||||
builder.addFormDataPart("compressed-log", file.name, RequestBody.create(MediaType.parse("application/octet-stream"), file))
|
||||
builder.addFormDataPart("compressed-log", file.name, file.asRequestBody("application/octet-stream".toMediaTypeOrNull()))
|
||||
}
|
||||
|
||||
mBugReportFiles.addAll(gzippedFiles)
|
||||
@ -270,7 +272,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
fos.close()
|
||||
|
||||
builder.addFormDataPart("file",
|
||||
logCatScreenshotFile.name, RequestBody.create(MediaType.parse("application/octet-stream"), logCatScreenshotFile))
|
||||
logCatScreenshotFile.name, logCatScreenshotFile.asRequestBody("application/octet-stream".toMediaTypeOrNull()))
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## sendBugReport() : fail to write screenshot$e")
|
||||
}
|
||||
@ -336,9 +338,9 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
try {
|
||||
mBugReportCall = mOkHttpClient.newCall(request)
|
||||
response = mBugReportCall!!.execute()
|
||||
responseCode = response!!.code()
|
||||
responseCode = response.code
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "response " + e.message)
|
||||
Timber.e(e, "response")
|
||||
errorMessage = e.localizedMessage
|
||||
}
|
||||
|
||||
@ -346,44 +348,42 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
if (null != errorMessage) {
|
||||
serverError = "Failed with error $errorMessage"
|
||||
} else if (null == response || null == response.body()) {
|
||||
} else if (null == response || null == response.body) {
|
||||
serverError = "Failed with error $responseCode"
|
||||
} else {
|
||||
var inputStream: InputStream? = null
|
||||
|
||||
try {
|
||||
inputStream = response.body()!!.byteStream()
|
||||
inputStream = response.body!!.byteStream()
|
||||
|
||||
if (null != inputStream) {
|
||||
var ch = inputStream.read()
|
||||
val b = StringBuilder()
|
||||
while (ch != -1) {
|
||||
b.append(ch.toChar())
|
||||
ch = inputStream.read()
|
||||
}
|
||||
serverError = b.toString()
|
||||
inputStream.close()
|
||||
var ch = inputStream.read()
|
||||
val b = StringBuilder()
|
||||
while (ch != -1) {
|
||||
b.append(ch.toChar())
|
||||
ch = inputStream.read()
|
||||
}
|
||||
serverError = b.toString()
|
||||
inputStream.close()
|
||||
|
||||
// check if the error message
|
||||
try {
|
||||
val responseJSON = JSONObject(serverError)
|
||||
serverError = responseJSON.getString("error")
|
||||
} catch (e: JSONException) {
|
||||
Timber.e(e, "doInBackground ; Json conversion failed " + e.message)
|
||||
}
|
||||
// check if the error message
|
||||
try {
|
||||
val responseJSON = JSONObject(serverError)
|
||||
serverError = responseJSON.getString("error")
|
||||
} catch (e: JSONException) {
|
||||
Timber.e(e, "doInBackground ; Json conversion failed")
|
||||
}
|
||||
|
||||
// should never happen
|
||||
if (null == serverError) {
|
||||
serverError = "Failed with error $responseCode"
|
||||
}
|
||||
// should never happen
|
||||
if (null == serverError) {
|
||||
serverError = "Failed with error $responseCode"
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## sendBugReport() : failed to parse error " + e.message)
|
||||
Timber.e(e, "## sendBugReport() : failed to parse error")
|
||||
} finally {
|
||||
try {
|
||||
inputStream?.close()
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## sendBugReport() : failed to close the error stream " + e.message)
|
||||
Timber.e(e, "## sendBugReport() : failed to close the error stream")
|
||||
}
|
||||
|
||||
}
|
||||
@ -398,9 +398,9 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
override fun onProgressUpdate(vararg progress: Int?) {
|
||||
if (null != listener) {
|
||||
try {
|
||||
listener.onProgress(progress?.get(0) ?: 0)
|
||||
listener.onProgress(progress[0] ?: 0)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## onProgress() : failed " + e.message)
|
||||
Timber.e(e, "## onProgress() : failed")
|
||||
}
|
||||
|
||||
}
|
||||
@ -424,7 +424,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
listener.onUploadFailed(reason)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## onPostExecute() : failed " + e.message)
|
||||
Timber.e(e, "## onPostExecute() : failed")
|
||||
}
|
||||
|
||||
}
|
||||
@ -637,13 +637,13 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
line = reader.readLine()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Timber.e(e, "getLog fails with " + e.localizedMessage)
|
||||
Timber.e(e, "getLog fails")
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close()
|
||||
} catch (e: IOException) {
|
||||
Timber.e(e, "getLog fails with " + e.localizedMessage)
|
||||
Timber.e(e, "getLog fails with")
|
||||
}
|
||||
|
||||
}
|
||||
@ -661,7 +661,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
* @return the gzipped file
|
||||
*/
|
||||
private fun compressFile(fin: File): File? {
|
||||
Timber.v("## compressFile() : compress " + fin.name)
|
||||
Timber.v("## compressFile() : compress ${fin.name}")
|
||||
|
||||
val dstFile = File(fin.parent, fin.name + ".gz")
|
||||
|
||||
@ -688,19 +688,19 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
gos.close()
|
||||
inputStream.close()
|
||||
|
||||
Timber.v("## compressFile() : " + fin.length() + " compressed to " + dstFile.length() + " bytes")
|
||||
Timber.v("## compressFile() : ${fin.length()} compressed to ${dstFile.length()} bytes")
|
||||
return dstFile
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## compressFile() failed " + e.message)
|
||||
Timber.e(e, "## compressFile() failed")
|
||||
} catch (oom: OutOfMemoryError) {
|
||||
Timber.e(oom, "## compressFile() failed " + oom.message)
|
||||
Timber.e(oom, "## compressFile() failed")
|
||||
} finally {
|
||||
try {
|
||||
fos?.close()
|
||||
gos?.close()
|
||||
inputStream?.close()
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## compressFile() failed to close inputStream " + e.message)
|
||||
Timber.e(e, "## compressFile() failed to close inputStream")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class BugReporterMultipartBody extends RequestBody {
|
||||
private BugReporterMultipartBody(ByteString boundary, List<Part> parts) {
|
||||
mBoundary = boundary;
|
||||
mContentType = MediaType.parse(FORM + "; boundary=" + boundary.utf8());
|
||||
mParts = Util.immutableList(parts);
|
||||
mParts = Util.toImmutableList(parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user