From d43365f6e668fc02a65616155967dbba7dbeacd3 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 11 Mar 2016 14:56:41 +0100 Subject: [PATCH] add custom error report function --- .../org/schabi/newpipe/ErrorActivity.java | 33 ++++++++++++++----- .../schabi/newpipe/VideoItemListActivity.java | 9 +++++ app/src/main/res/menu/videoitem_list.xml | 4 +++ app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/ErrorActivity.java index c5ba0e65c..fbb76012d 100644 --- a/app/src/main/java/org/schabi/newpipe/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/ErrorActivity.java @@ -78,10 +78,12 @@ public class ErrorActivity extends AppCompatActivity { public static final int REQUESTED_STREAM = 1; public static final int GET_SUGGESTIONS = 2; public static final int SOMETHING_ELSE = 3; + public static final int USER_REPORT = 4; public static final String SEARCHED_STRING = "searched"; public static final String REQUESTED_STREAM_STRING = "requested stream"; public static final String GET_SUGGESTIONS_STRING = "get suggestions"; public static final String SOMETHING_ELSE_STRING = "something"; + public static final String USER_REPORT_STRING = "user report"; public static final String ERROR_EMAIL_ADDRESS = "crashreport@newpipe.schabi.org"; public static final String ERROR_EMAIL_SUBJECT = "Exception in NewPipe " + BuildConfig.VERSION_NAME; @@ -129,16 +131,23 @@ public class ErrorActivity extends AppCompatActivity { public static void reportError(final Context context, final Exception e, final Class returnAcitivty, View rootView, final ErrorInfo errorInfo) { - List el = new Vector<>(); - el.add(e); + List el = null; + if(e != null) { + el = new Vector<>(); + el.add(e); + } reportError(context, el, returnAcitivty, rootView, errorInfo); } // async call public static void reportError(Handler handler, final Context context, final Exception e, final Class returnAcitivty, final View rootView, final ErrorInfo errorInfo) { - List el = new Vector<>(); - el.add(e); + + List el = null; + if(e != null) { + el = new Vector<>(); + el.add(e); + } reportError(handler, context, el, returnAcitivty, rootView, errorInfo); } @@ -230,9 +239,11 @@ public class ErrorActivity extends AppCompatActivity { private String formErrorText(List el) { String text = ""; - for (Exception e : el) { - text += "-------------------------------------\n" - + ExceptionUtils.getStackTrace(e); + if(el != null) { + for (Exception e : el) { + text += "-------------------------------------\n" + + ExceptionUtils.getStackTrace(e); + } } text += "-------------------------------------"; return text; @@ -286,8 +297,10 @@ public class ErrorActivity extends AppCompatActivity { .put("ip_range", globIpRange); JSONArray exceptionArray = new JSONArray(); - for (Exception e : errorList) { - exceptionArray.put(ExceptionUtils.getStackTrace(e)); + if(errorList != null) { + for (Exception e : errorList) { + exceptionArray.put(ExceptionUtils.getStackTrace(e)); + } } errorObject.put("exceptions", exceptionArray); @@ -312,6 +325,8 @@ public class ErrorActivity extends AppCompatActivity { return GET_SUGGESTIONS_STRING; case SOMETHING_ELSE: return SOMETHING_ELSE_STRING; + case USER_REPORT: + return USER_REPORT_STRING; default: return "Your description is in another castle."; } diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java index 3814c60a5..9ca3664f5 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java @@ -24,6 +24,7 @@ import org.schabi.newpipe.extractor.StreamingService; import java.io.IOException; import java.util.ArrayList; +import java.util.Vector; /** * Copyright (C) Christian Schabesberger 2015 @@ -346,6 +347,14 @@ public class VideoItemListActivity extends AppCompatActivity startActivity(intent); return true; } + case R.id.action_report_error: { + ErrorActivity.reportError(VideoItemListActivity.this, new Vector(), + null, null, + ErrorActivity.ErrorInfo.make(ErrorActivity.USER_REPORT, + ServiceList.getNameOfService(currentStreamingServiceId), + "user_report", R.string.user_report)); + return true; + } default: return videoFragment.onOptionsItemSelected(item) || super.onOptionsItemSelected(item); diff --git a/app/src/main/res/menu/videoitem_list.xml b/app/src/main/res/menu/videoitem_list.xml index 54d582dc6..8091e8c46 100644 --- a/app/src/main/res/menu/videoitem_list.xml +++ b/app/src/main/res/menu/videoitem_list.xml @@ -10,4 +10,8 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ff2790216..1d675eeb1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -113,6 +113,8 @@ Dislikes Use Tor (Experimental) Force download traffic through Tor for increased privacy (streaming videos not yet supported). + Report an Error + User report Cannot create download directory \'%1$s\' Created download directory \'%1$s\'