use intent system to pass errors to error activity
This commit is contained in:
parent
a2effef346
commit
14eaedd73a
|
@ -32,10 +32,10 @@ android {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
compile 'com.android.support:appcompat-v7:24.2.0'
|
compile 'com.android.support:appcompat-v7:24.2.1'
|
||||||
compile 'com.android.support:support-v4:24.2.0'
|
compile 'com.android.support:support-v4:24.2.1'
|
||||||
compile 'com.android.support:design:24.2.0'
|
compile 'com.android.support:design:24.2.1'
|
||||||
compile 'com.android.support:recyclerview-v7:24.2.0'
|
compile 'com.android.support:recyclerview-v7:24.2.1'
|
||||||
compile 'org.jsoup:jsoup:1.8.3'
|
compile 'org.jsoup:jsoup:1.8.3'
|
||||||
compile 'org.mozilla:rhino:1.7.7'
|
compile 'org.mozilla:rhino:1.7.7'
|
||||||
compile 'info.guardianproject.netcipher:netcipher:1.2'
|
compile 'info.guardianproject.netcipher:netcipher:1.2'
|
||||||
|
@ -46,4 +46,5 @@ dependencies {
|
||||||
compile 'com.google.code.gson:gson:2.4'
|
compile 'com.google.code.gson:gson:2.4'
|
||||||
compile 'com.nononsenseapps:filepicker:3.0.0'
|
compile 'com.nononsenseapps:filepicker:3.0.0'
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
|
compile 'ch.acra:acra:4.9.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.acra.collector.CrashReportData;
|
||||||
|
import org.acra.sender.ReportSender;
|
||||||
|
import org.acra.sender.ReportSenderException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by the-scrabi on 13.09.16.
|
||||||
|
*/
|
||||||
|
public class AcraReportSender implements ReportSender {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void send(Context context, CrashReportData report) throws ReportSenderException {
|
||||||
|
Log.e("Newpipe UI ERROR", report.toString());
|
||||||
|
try {
|
||||||
|
((String)null).length();
|
||||||
|
} catch(Exception e) {
|
||||||
|
ErrorActivity.reportError(context, e, null, null,
|
||||||
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,"none",
|
||||||
|
"App crash, UI failure", R.string.app_ui_crash));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.acra.config.ACRAConfiguration;
|
||||||
|
import org.acra.sender.ReportSender;
|
||||||
|
import org.acra.sender.ReportSenderFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by the-scrabi on 13.09.16.
|
||||||
|
*/
|
||||||
|
public class AcraReportSenderFactory implements ReportSenderFactory {
|
||||||
|
public ReportSender create(Context context, ACRAConfiguration config) {
|
||||||
|
return new AcraReportSender();
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,8 +42,5 @@ public class ActivityCommunicator {
|
||||||
// Thumbnail send from VideoItemDetailFragment to BackgroundPlayer
|
// Thumbnail send from VideoItemDetailFragment to BackgroundPlayer
|
||||||
public volatile Bitmap backgroundPlayerThumbnail;
|
public volatile Bitmap backgroundPlayerThumbnail;
|
||||||
|
|
||||||
// Sent from any activity to ErrorActivity.
|
|
||||||
public volatile List<Throwable> errorList;
|
|
||||||
public volatile Class returnActivity;
|
public volatile Class returnActivity;
|
||||||
public volatile ErrorActivity.ErrorInfo errorInfo;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,17 @@ package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||||
|
|
||||||
|
import org.acra.ACRA;
|
||||||
|
import org.acra.config.ACRAConfiguration;
|
||||||
|
import org.acra.config.ACRAConfigurationException;
|
||||||
|
import org.acra.config.ConfigurationBuilder;
|
||||||
|
import org.acra.sender.ReportSenderFactory;
|
||||||
|
import org.schabi.newpipe.extractor.ServiceList;
|
||||||
import org.schabi.newpipe.settings.SettingsActivity;
|
import org.schabi.newpipe.settings.SettingsActivity;
|
||||||
|
|
||||||
import info.guardianproject.netcipher.NetCipher;
|
import info.guardianproject.netcipher.NetCipher;
|
||||||
|
@ -30,12 +37,28 @@ import info.guardianproject.netcipher.proxy.OrbotHelper;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class App extends Application {
|
public class App extends Application {
|
||||||
|
private static final String TAG = App.class.toString();
|
||||||
|
|
||||||
private static boolean useTor;
|
private static boolean useTor;
|
||||||
|
|
||||||
|
final Class<? extends ReportSenderFactory>[] reportSenderFactoryClasses
|
||||||
|
= new Class[]{AcraReportSenderFactory.class};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
// init crashreport
|
||||||
|
try {
|
||||||
|
final ACRAConfiguration acraConfig = new ConfigurationBuilder(this)
|
||||||
|
.setReportSenderFactoryClasses(reportSenderFactoryClasses)
|
||||||
|
.build();
|
||||||
|
ACRA.init(this, acraConfig);
|
||||||
|
} catch(ACRAConfigurationException ace) {
|
||||||
|
ace.printStackTrace();
|
||||||
|
ErrorActivity.reportError(this, ace, null, null,
|
||||||
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,"none",
|
||||||
|
"Could not initialize ACRA crash report", R.string.app_ui_crash));
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize image loader
|
// Initialize image loader
|
||||||
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
|
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
|
||||||
|
|
|
@ -8,6 +8,8 @@ import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.NavUtils;
|
import android.support.v4.app.NavUtils;
|
||||||
|
@ -57,7 +59,7 @@ import java.util.Vector;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ErrorActivity extends AppCompatActivity {
|
public class ErrorActivity extends AppCompatActivity {
|
||||||
public static class ErrorInfo {
|
public static class ErrorInfo implements Parcelable {
|
||||||
public int userAction;
|
public int userAction;
|
||||||
public String request;
|
public String request;
|
||||||
public String serviceName;
|
public String serviceName;
|
||||||
|
@ -71,15 +73,59 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
info.message = message;
|
info.message = message;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeInt(this.userAction);
|
||||||
|
dest.writeString(this.request);
|
||||||
|
dest.writeString(this.serviceName);
|
||||||
|
dest.writeInt(this.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ErrorInfo(Parcel in) {
|
||||||
|
this.userAction = in.readInt();
|
||||||
|
this.request = in.readString();
|
||||||
|
this.serviceName = in.readString();
|
||||||
|
this.message = in.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<ErrorInfo> CREATOR = new Parcelable.Creator<ErrorInfo>() {
|
||||||
|
@Override
|
||||||
|
public ErrorInfo createFromParcel(Parcel source) {
|
||||||
|
return new ErrorInfo(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErrorInfo[] newArray(int size) {
|
||||||
|
return new ErrorInfo[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LOG TAGS
|
||||||
public static final String TAG = ErrorActivity.class.toString();
|
public static final String TAG = ErrorActivity.class.toString();
|
||||||
|
|
||||||
|
// BUNDLE TAGS
|
||||||
|
public static final String ERROR_INFO = "error_info";
|
||||||
|
public static final String ERROR_LIST = "error_list";
|
||||||
|
|
||||||
|
// MESSAGE ID
|
||||||
public static final int SEARCHED = 0;
|
public static final int SEARCHED = 0;
|
||||||
public static final int REQUESTED_STREAM = 1;
|
public static final int REQUESTED_STREAM = 1;
|
||||||
public static final int GET_SUGGESTIONS = 2;
|
public static final int GET_SUGGESTIONS = 2;
|
||||||
public static final int SOMETHING_ELSE = 3;
|
public static final int SOMETHING_ELSE = 3;
|
||||||
public static final int USER_REPORT = 4;
|
public static final int USER_REPORT = 4;
|
||||||
public static final int LOAD_IMAGE = 5;
|
public static final int LOAD_IMAGE = 5;
|
||||||
|
|
||||||
|
// MESSAGE STRING
|
||||||
public static final String SEARCHED_STRING = "searched";
|
public static final String SEARCHED_STRING = "searched";
|
||||||
public static final String REQUESTED_STREAM_STRING = "requested stream";
|
public static final String REQUESTED_STREAM_STRING = "requested stream";
|
||||||
public static final String GET_SUGGESTIONS_STRING = "get suggestions";
|
public static final String GET_SUGGESTIONS_STRING = "get suggestions";
|
||||||
|
@ -91,7 +137,7 @@ 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;
|
||||||
|
|
||||||
private List<Throwable> errorList;
|
private String[] errorList;
|
||||||
private ErrorInfo errorInfo;
|
private ErrorInfo errorInfo;
|
||||||
private Class returnActivity;
|
private Class returnActivity;
|
||||||
private String currentTimeStamp;
|
private String currentTimeStamp;
|
||||||
|
@ -115,19 +161,19 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
ActivityCommunicator ac = ActivityCommunicator.getCommunicator();
|
ActivityCommunicator ac = ActivityCommunicator.getCommunicator();
|
||||||
ac.errorList = el;
|
|
||||||
ac.returnActivity = returnAcitivty;
|
ac.returnActivity = returnAcitivty;
|
||||||
ac.errorInfo = errorInfo;
|
|
||||||
Intent intent = new Intent(context, ErrorActivity.class);
|
Intent intent = new Intent(context, ErrorActivity.class);
|
||||||
|
intent.putExtra(ERROR_INFO, errorInfo);
|
||||||
|
intent.putExtra(ERROR_LIST, elToSl(el));
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
}).show();
|
}).show();
|
||||||
} else {
|
} else {
|
||||||
ActivityCommunicator ac = ActivityCommunicator.getCommunicator();
|
ActivityCommunicator ac = ActivityCommunicator.getCommunicator();
|
||||||
ac.errorList = el;
|
|
||||||
ac.returnActivity = returnAcitivty;
|
ac.returnActivity = returnAcitivty;
|
||||||
ac.errorInfo = errorInfo;
|
|
||||||
Intent intent = new Intent(context, ErrorActivity.class);
|
Intent intent = new Intent(context, ErrorActivity.class);
|
||||||
|
intent.putExtra(ERROR_INFO, errorInfo);
|
||||||
|
intent.putExtra(ERROR_LIST, elToSl(el));
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +215,9 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_error);
|
setContentView(R.layout.activity_error);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
@ -179,23 +228,20 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivityCommunicator ac = ActivityCommunicator.getCommunicator();
|
|
||||||
errorList = ac.errorList;
|
|
||||||
returnActivity = ac.returnActivity;
|
|
||||||
errorInfo = ac.errorInfo;
|
|
||||||
|
|
||||||
reportButton = (Button) findViewById(R.id.errorReportButton);
|
reportButton = (Button) findViewById(R.id.errorReportButton);
|
||||||
userCommentBox = (EditText) findViewById(R.id.errorCommentBox);
|
userCommentBox = (EditText) findViewById(R.id.errorCommentBox);
|
||||||
errorView = (TextView) findViewById(R.id.errorView);
|
errorView = (TextView) findViewById(R.id.errorView);
|
||||||
infoView = (TextView) findViewById(R.id.errorInfosView);
|
infoView = (TextView) findViewById(R.id.errorInfosView);
|
||||||
errorMessageView = (TextView) findViewById(R.id.errorMessageView);
|
errorMessageView = (TextView) findViewById(R.id.errorMessageView);
|
||||||
|
|
||||||
errorView.setText(formErrorText(errorList));
|
ActivityCommunicator ac = ActivityCommunicator.getCommunicator();
|
||||||
|
returnActivity = ac.returnActivity;
|
||||||
|
errorInfo = intent.getParcelableExtra(ERROR_INFO);
|
||||||
|
errorList = intent.getStringArrayExtra(ERROR_LIST);
|
||||||
|
|
||||||
//importand add gurumeditaion
|
//importand add gurumeditaion
|
||||||
addGuruMeditaion();
|
addGuruMeditaion();
|
||||||
currentTimeStamp = getCurrentTimeStamp();
|
currentTimeStamp = getCurrentTimeStamp();
|
||||||
buildInfo(errorInfo);
|
|
||||||
|
|
||||||
reportButton.setOnClickListener(new View.OnClickListener() {
|
reportButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -214,12 +260,16 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
globIpRangeThread = new Thread(new IpRagneRequester());
|
globIpRangeThread = new Thread(new IpRagneRequester());
|
||||||
globIpRangeThread.start();
|
globIpRangeThread.start();
|
||||||
|
|
||||||
|
// normal bugreport
|
||||||
|
buildInfo(errorInfo);
|
||||||
if(errorInfo.message != 0) {
|
if(errorInfo.message != 0) {
|
||||||
errorMessageView.setText(errorInfo.message);
|
errorMessageView.setText(errorInfo.message);
|
||||||
} else {
|
} else {
|
||||||
errorMessageView.setVisibility(View.GONE);
|
errorMessageView.setVisibility(View.GONE);
|
||||||
findViewById(R.id.messageWhatHappenedView).setVisibility(View.GONE);
|
findViewById(R.id.messageWhatHappenedView).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errorView.setText(formErrorText(errorList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -255,12 +305,12 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
return sw.getBuffer().toString();
|
return sw.getBuffer().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formErrorText(List<Throwable> el) {
|
private String formErrorText(String[] el) {
|
||||||
String text = "";
|
String text = "";
|
||||||
if(el != null) {
|
if(el != null) {
|
||||||
for (Throwable e : el) {
|
for (String e : el) {
|
||||||
text += "-------------------------------------\n"
|
text += "-------------------------------------\n"
|
||||||
+ getStackTrace(e);
|
+ e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text += "-------------------------------------";
|
text += "-------------------------------------";
|
||||||
|
@ -316,8 +366,8 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
|
|
||||||
JSONArray exceptionArray = new JSONArray();
|
JSONArray exceptionArray = new JSONArray();
|
||||||
if(errorList != null) {
|
if(errorList != null) {
|
||||||
for (Throwable e : errorList) {
|
for (String e : errorList) {
|
||||||
exceptionArray.put(getStackTrace(e));
|
exceptionArray.put(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,4 +471,13 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// errorList to StringList
|
||||||
|
private static String[] elToSl(List<Throwable> stackTraces) {
|
||||||
|
String[] out = new String[stackTraces.size()];
|
||||||
|
for(int i = 0; i < stackTraces.size(); i++) {
|
||||||
|
out[i] = getStackTrace(stackTraces.get(i));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@
|
||||||
<string name="live_streams_not_supported">This is a LIVE STREAM. These are not yet supported.</string>
|
<string name="live_streams_not_supported">This is a LIVE STREAM. These are not yet supported.</string>
|
||||||
<string name="could_not_get_stream">Could not get any stream.</string>
|
<string name="could_not_get_stream">Could not get any stream.</string>
|
||||||
<string name="could_not_load_image">Could not load Image</string>
|
<string name="could_not_load_image">Could not load Image</string>
|
||||||
|
<string name="app_ui_crash">App/UI crashed</string>
|
||||||
<!-- error activity -->
|
<!-- error activity -->
|
||||||
<string name="sorry_string">Sorry that should not happen.</string>
|
<string name="sorry_string">Sorry that should not happen.</string>
|
||||||
<string name="guru_meditation" translatable="false">Guru Meditation.</string>
|
<string name="guru_meditation" translatable="false">Guru Meditation.</string>
|
||||||
|
|
Loading…
Reference in New Issue