Browse Source

[Architecture] clean up

misc/jme/add-logging-to-state-machine
ganfra 2 years ago
parent
commit
ba28628bdf
  1. 1
      features/onboarding/build.gradle.kts
  2. 18
      features/rageshake/src/main/kotlin/io/element/android/features/rageshake/reporter/BugReporterMultipartBody.java
  3. 16
      features/rageshake/src/main/kotlin/io/element/android/features/rageshake/reporter/DefaultBugReporter.kt

1
features/onboarding/build.gradle.kts

@ -30,7 +30,6 @@ anvil {
generateDaggerFactories.set(true) generateDaggerFactories.set(true)
} }
dependencies { dependencies {
implementation(projects.libraries.core) implementation(projects.libraries.core)
implementation(projects.libraries.elementresources) implementation(projects.libraries.elementresources)

18
features/rageshake/src/main/java/io/element/android/features/rageshake/reporter/BugReporterMultipartBody.java → features/rageshake/src/main/kotlin/io/element/android/features/rageshake/reporter/BugReporterMultipartBody.java

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022 New Vector Ltd * Copyright (c) 2023 New Vector Ltd
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,7 +39,7 @@ public class BugReporterMultipartBody extends RequestBody {
/** /**
* Upload listener * Upload listener
* *
* @param totalWritten total written bytes * @param totalWritten total written bytes
* @param contentLength content length * @param contentLength content length
*/ */
void onWrite(long totalWritten, long contentLength); void onWrite(long totalWritten, long contentLength);
@ -132,24 +132,24 @@ public class BugReporterMultipartBody extends RequestBody {
if (headers != null) { if (headers != null) {
for (int h = 0, headerCount = headers.size(); h < headerCount; h++) { for (int h = 0, headerCount = headers.size(); h < headerCount; h++) {
sink.writeUtf8(headers.name(h)) sink.writeUtf8(headers.name(h))
.write(COLONSPACE) .write(COLONSPACE)
.writeUtf8(headers.value(h)) .writeUtf8(headers.value(h))
.write(CRLF); .write(CRLF);
} }
} }
MediaType contentType = body.contentType(); MediaType contentType = body.contentType();
if (contentType != null) { if (contentType != null) {
sink.writeUtf8("Content-Type: ") sink.writeUtf8("Content-Type: ")
.writeUtf8(contentType.toString()) .writeUtf8(contentType.toString())
.write(CRLF); .write(CRLF);
} }
int contentLength = (int) body.contentLength(); int contentLength = (int) body.contentLength();
if (contentLength != -1) { if (contentLength != -1) {
sink.writeUtf8("Content-Length: ") sink.writeUtf8("Content-Length: ")
.writeUtf8(contentLength + "") .writeUtf8(contentLength + "")
.write(CRLF); .write(CRLF);
} else if (countBytes) { } else if (countBytes) {
// We can't measure the body's size without the sizes of its components. // We can't measure the body's size without the sizes of its components.
byteCountBuffer.clear(); byteCountBuffer.clear();

16
features/rageshake/src/main/kotlin/io/element/android/features/rageshake/reporter/DefaultBugReporter.kt

@ -260,15 +260,15 @@ class DefaultBugReporter @Inject constructor(
?.toUri() ?.toUri()
?.toFile() ?.toFile()
?.let { screenshotFile -> ?.let { screenshotFile ->
try { try {
builder.addFormDataPart( builder.addFormDataPart(
"file", "file",
screenshotFile.name, screenshotFile.asRequestBody(MimeTypes.OctetStream.toMediaTypeOrNull()) screenshotFile.name, screenshotFile.asRequestBody(MimeTypes.OctetStream.toMediaTypeOrNull())
) )
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "## sendBugReport() : fail to write screenshot") Timber.e(e, "## sendBugReport() : fail to write screenshot")
}
} }
}
} }
// add some github labels // add some github labels

Loading…
Cancel
Save