Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Weblate 2018-03-21 23:37:21 +01:00
commit 27527b18e1

View file

@ -77,12 +77,10 @@ public class ErrorActivity extends AppCompatActivity {
public static final String ERROR_EMAIL_ADDRESS = "crashreport@newpipe.schabi.org"; public static final String ERROR_EMAIL_ADDRESS = "crashreport@newpipe.schabi.org";
public static final String ERROR_EMAIL_SUBJECT = "Exception in NewPipe " + BuildConfig.VERSION_NAME; public static final String ERROR_EMAIL_SUBJECT = "Exception in NewPipe " + BuildConfig.VERSION_NAME;
Thread globIpRangeThread;
private String[] errorList; private String[] errorList;
private ErrorInfo errorInfo; private ErrorInfo errorInfo;
private Class returnActivity; private Class returnActivity;
private String currentTimeStamp; private String currentTimeStamp;
private String globIpRange;
// views // views
private TextView errorView; private TextView errorView;
private EditText userCommentBox; private EditText userCommentBox;
@ -224,9 +222,6 @@ public class ErrorActivity extends AppCompatActivity {
}); });
reportButton.setEnabled(false); reportButton.setEnabled(false);
globIpRangeThread = new Thread(new IpRangeRequester());
globIpRangeThread.start();
// normal bugreport // normal bugreport
buildInfo(errorInfo); buildInfo(errorInfo);
if (errorInfo.message != 0) { if (errorInfo.message != 0) {
@ -342,8 +337,7 @@ public class ErrorActivity extends AppCompatActivity {
.put("package", getPackageName()) .put("package", getPackageName())
.put("version", BuildConfig.VERSION_NAME) .put("version", BuildConfig.VERSION_NAME)
.put("os", getOsString()) .put("os", getOsString())
.put("time", currentTimeStamp) .put("time", currentTimeStamp);
.put("ip_range", globIpRange);
JSONArray exceptionArray = new JSONArray(); JSONArray exceptionArray = new JSONArray();
if (errorList != null) { if (errorList != null) {
@ -454,41 +448,4 @@ public class ErrorActivity extends AppCompatActivity {
dest.writeInt(this.message); dest.writeInt(this.message);
} }
} }
private class IpRangeRequester implements Runnable {
Handler h = new Handler();
public void run() {
String ipRange = "none";
try {
Downloader dl = Downloader.getInstance();
String ip = dl.download("https://ipv4.icanhazip.com");
ipRange = Parser.matchGroup1("([0-9]*\\.[0-9]*\\.)[0-9]*\\.[0-9]*", ip)
+ "0.0";
} catch (Throwable e) {
Log.w(TAG, "Error while error: could not get iprange", e);
} finally {
h.post(new IpRangeReturnRunnable(ipRange));
}
}
}
private class IpRangeReturnRunnable implements Runnable {
String ipRange;
public IpRangeReturnRunnable(String ipRange) {
this.ipRange = ipRange;
}
public void run() {
globIpRange = ipRange;
if (infoView != null) {
String text = infoView.getText().toString();
text += "\n" + globIpRange;
infoView.setText(text);
reportButton.setEnabled(true);
}
}
}
} }