use nanojson instead of org.json
This commit is contained in:
parent
e6eddaff73
commit
b22398ae6c
|
@ -29,11 +29,10 @@ import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.app.NavUtils;
|
import androidx.core.app.NavUtils;
|
||||||
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
import com.grack.nanojson.JsonWriter;
|
||||||
|
|
||||||
import org.acra.ReportField;
|
import org.acra.ReportField;
|
||||||
import org.acra.collector.CrashReportData;
|
import org.acra.collector.CrashReportData;
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.schabi.newpipe.ActivityCommunicator;
|
import org.schabi.newpipe.ActivityCommunicator;
|
||||||
import org.schabi.newpipe.BuildConfig;
|
import org.schabi.newpipe.BuildConfig;
|
||||||
import org.schabi.newpipe.MainActivity;
|
import org.schabi.newpipe.MainActivity;
|
||||||
|
@ -43,6 +42,7 @@ import org.schabi.newpipe.util.ThemeHelper;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -346,29 +346,21 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildJson() {
|
private String buildJson() {
|
||||||
JSONObject errorObject = new JSONObject();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
errorObject.put("user_action", getUserActionString(errorInfo.userAction))
|
return JsonWriter.string()
|
||||||
.put("request", errorInfo.request)
|
.object()
|
||||||
.put("content_language", getContentLangString())
|
.value("user_action", getUserActionString(errorInfo.userAction))
|
||||||
.put("service", errorInfo.serviceName)
|
.value("request", errorInfo.request)
|
||||||
.put("package", getPackageName())
|
.value("content_language", getContentLangString())
|
||||||
.put("version", BuildConfig.VERSION_NAME)
|
.value("service", errorInfo.serviceName)
|
||||||
.put("os", getOsString())
|
.value("package", getPackageName())
|
||||||
.put("time", currentTimeStamp);
|
.value("version", BuildConfig.VERSION_NAME)
|
||||||
|
.value("os", getOsString())
|
||||||
JSONArray exceptionArray = new JSONArray();
|
.value("time", currentTimeStamp)
|
||||||
if (errorList != null) {
|
.array("exceptions", Arrays.asList(errorList))
|
||||||
for (String e : errorList) {
|
.value("user_comment", userCommentBox.getText().toString())
|
||||||
exceptionArray.put(e);
|
.end()
|
||||||
}
|
.done();
|
||||||
}
|
|
||||||
|
|
||||||
errorObject.put("exceptions", exceptionArray);
|
|
||||||
errorObject.put("user_comment", userCommentBox.getText().toString());
|
|
||||||
|
|
||||||
return errorObject.toString(3);
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.e(TAG, "Error while erroring: Could not build json");
|
Log.e(TAG, "Error while erroring: Could not build json");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in New Issue