Verified Commit b972d1fc authored by akwizgran's avatar akwizgran

Update ACRA usage for new version.

parent ccbeee60
...@@ -6,7 +6,6 @@ import android.support.annotation.NonNull; ...@@ -6,7 +6,6 @@ import android.support.annotation.NonNull;
import org.acra.collector.CrashReportData; import org.acra.collector.CrashReportData;
import org.acra.sender.ReportSender; import org.acra.sender.ReportSender;
import org.acra.sender.ReportSenderException; import org.acra.sender.ReportSenderException;
import org.acra.util.JSONReportBuilder.JSONReportException;
import org.briarproject.bramble.api.reporting.DevReporter; import org.briarproject.bramble.api.reporting.DevReporter;
import org.briarproject.bramble.util.AndroidUtils; import org.briarproject.bramble.util.AndroidUtils;
import org.briarproject.briar.android.AndroidComponent; import org.briarproject.briar.android.AndroidComponent;
...@@ -34,12 +33,7 @@ public class BriarReportSender implements ReportSender { ...@@ -34,12 +33,7 @@ public class BriarReportSender implements ReportSender {
@NonNull CrashReportData errorContent) @NonNull CrashReportData errorContent)
throws ReportSenderException { throws ReportSenderException {
component.inject(this); component.inject(this);
String crashReport; String crashReport = errorContent.toJSON().toString();
try {
crashReport = errorContent.toJSON().toString();
} catch (JSONReportException e) {
throw new ReportSenderException("Couldn't create JSON", e);
}
try { try {
File reportDir = AndroidUtils.getReportDir(ctx); File reportDir = AndroidUtils.getReportDir(ctx);
String reportId = errorContent.getProperty(REPORT_ID); String reportId = errorContent.getProperty(REPORT_ID);
......
...@@ -24,9 +24,11 @@ import org.acra.ReportField; ...@@ -24,9 +24,11 @@ import org.acra.ReportField;
import org.acra.collector.CrashReportData; import org.acra.collector.CrashReportData;
import org.acra.dialog.BaseCrashReportDialog; import org.acra.dialog.BaseCrashReportDialog;
import org.acra.file.CrashReportPersister; import org.acra.file.CrashReportPersister;
import org.acra.model.Element;
import org.briarproject.briar.R; import org.briarproject.briar.R;
import org.briarproject.briar.android.Localizer; import org.briarproject.briar.android.Localizer;
import org.briarproject.briar.android.util.UserFeedback; import org.briarproject.briar.android.util.UserFeedback;
import org.json.JSONException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -282,7 +284,7 @@ public class DevReportActivity extends BaseCrashReportDialog ...@@ -282,7 +284,7 @@ public class DevReportActivity extends BaseCrashReportDialog
CrashReportPersister persister = new CrashReportPersister(); CrashReportPersister persister = new CrashReportPersister();
try { try {
return persister.load(reportFile); return persister.load(reportFile);
} catch (IOException e) { } catch (IOException | JSONException e) {
LOG.log(WARNING, "Could not load report file", e); LOG.log(WARNING, "Could not load report file", e);
return null; return null;
} }
...@@ -292,9 +294,10 @@ public class DevReportActivity extends BaseCrashReportDialog ...@@ -292,9 +294,10 @@ public class DevReportActivity extends BaseCrashReportDialog
protected void onPostExecute(CrashReportData crashData) { protected void onPostExecute(CrashReportData crashData) {
LayoutInflater inflater = getLayoutInflater(); LayoutInflater inflater = getLayoutInflater();
if (crashData != null) { if (crashData != null) {
for (Entry<ReportField, String> e : crashData.entrySet()) { for (Entry<ReportField, Element> e : crashData.entrySet()) {
ReportField field = e.getKey(); ReportField field = e.getKey();
String value = e.getValue().replaceAll("\\\\n", "\n"); String value = e.getValue().toString()
.replaceAll("\\\\n", "\n");
boolean required = requiredFields.contains(field); boolean required = requiredFields.contains(field);
boolean excluded = excludedFields.contains(field); boolean excluded = excludedFields.contains(field);
View v = inflater.inflate(R.layout.list_item_crash, View v = inflater.inflate(R.layout.list_item_crash,
...@@ -343,10 +346,10 @@ public class DevReportActivity extends BaseCrashReportDialog ...@@ -343,10 +346,10 @@ public class DevReportActivity extends BaseCrashReportDialog
data.remove(field); data.remove(field);
} }
} else { } else {
Iterator<Entry<ReportField, String>> iter = Iterator<Entry<ReportField, Element>> iter =
data.entrySet().iterator(); data.entrySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Entry<ReportField, String> e = iter.next(); Entry<ReportField, Element> e = iter.next();
if (!requiredFields.contains(e.getKey())) { if (!requiredFields.contains(e.getKey())) {
iter.remove(); iter.remove();
} }
...@@ -354,7 +357,7 @@ public class DevReportActivity extends BaseCrashReportDialog ...@@ -354,7 +357,7 @@ public class DevReportActivity extends BaseCrashReportDialog
} }
persister.store(data, reportFile); persister.store(data, reportFile);
return true; return true;
} catch (IOException e) { } catch (IOException | JSONException e) {
LOG.log(WARNING, "Error processing report file", e); LOG.log(WARNING, "Error processing report file", e);
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment