Add Markdown export of crash logs
Add app language as additional debug information to reports
This commit is contained in:
parent
d9100913d5
commit
3de5afc68e
|
@ -11,7 +11,6 @@ import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
@ -20,6 +19,7 @@ import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
@ -37,6 +37,8 @@ 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;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.util.Localization;
|
||||||
|
import org.schabi.newpipe.util.ShareUtils;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
@ -45,7 +47,6 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
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.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
@ -81,6 +82,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
|
public static final String ERROR_EMAIL_SUBJECT
|
||||||
= "Exception in NewPipe " + BuildConfig.VERSION_NAME;
|
= "Exception in NewPipe " + BuildConfig.VERSION_NAME;
|
||||||
|
|
||||||
|
public static final String ERROR_GITHUB_ISSUE_URL
|
||||||
|
= "https://github.com/TeamNewPipe/NewPipe/issues";
|
||||||
|
|
||||||
private String[] errorList;
|
private String[] errorList;
|
||||||
private ErrorInfo errorInfo;
|
private ErrorInfo errorInfo;
|
||||||
private Class returnActivity;
|
private Class returnActivity;
|
||||||
|
@ -193,7 +198,10 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
actionBar.setDisplayShowTitleEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Button reportButton = findViewById(R.id.errorReportButton);
|
final Button reportEmailButton = findViewById(R.id.errorReportEmailButton);
|
||||||
|
final Button copyButton = findViewById(R.id.errorReportCopyButton);
|
||||||
|
final Button reportGithubButton = findViewById(R.id.errorReportGitHubButton);
|
||||||
|
|
||||||
userCommentBox = findViewById(R.id.errorCommentBox);
|
userCommentBox = findViewById(R.id.errorCommentBox);
|
||||||
TextView errorView = findViewById(R.id.errorView);
|
TextView errorView = findViewById(R.id.errorView);
|
||||||
TextView infoView = findViewById(R.id.errorInfosView);
|
TextView infoView = findViewById(R.id.errorInfosView);
|
||||||
|
@ -205,40 +213,23 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
errorList = intent.getStringArrayExtra(ERROR_LIST);
|
errorList = intent.getStringArrayExtra(ERROR_LIST);
|
||||||
|
|
||||||
// important add guru meditation
|
// important add guru meditation
|
||||||
addGuruMeditaion();
|
addGuruMeditation();
|
||||||
currentTimeStamp = getCurrentTimeStamp();
|
currentTimeStamp = getCurrentTimeStamp();
|
||||||
|
|
||||||
reportButton.setOnClickListener((View v) -> {
|
reportEmailButton.setOnClickListener((View v) -> {
|
||||||
Context context = this;
|
openPrivacyPolicyDialog(this, "EMAIL");
|
||||||
new AlertDialog.Builder(context)
|
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
|
||||||
.setTitle(R.string.privacy_policy_title)
|
|
||||||
.setMessage(R.string.start_accept_privacy_policy)
|
|
||||||
.setCancelable(false)
|
|
||||||
.setNeutralButton(R.string.read_privacy_policy, (dialog, which) -> {
|
|
||||||
Intent webIntent = new Intent(Intent.ACTION_VIEW,
|
|
||||||
Uri.parse(context.getString(R.string.privacy_policy_url))
|
|
||||||
);
|
|
||||||
context.startActivity(webIntent);
|
|
||||||
})
|
|
||||||
.setPositiveButton(R.string.accept, (dialog, which) -> {
|
|
||||||
final Intent i = new Intent(Intent.ACTION_SENDTO)
|
|
||||||
.setData(Uri.parse("mailto:")) // only email apps should handle this
|
|
||||||
.putExtra(Intent.EXTRA_EMAIL, new String[]{ERROR_EMAIL_ADDRESS})
|
|
||||||
.putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT)
|
|
||||||
.putExtra(Intent.EXTRA_TEXT, buildJson());
|
|
||||||
if (i.resolveActivity(getPackageManager()) != null) {
|
|
||||||
startActivity(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.decline, (dialog, which) -> {
|
|
||||||
// do nothing
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
copyButton.setOnClickListener((View v) -> {
|
||||||
|
ShareUtils.copyToClipboard(this, buildMarkdown());
|
||||||
|
Toast.makeText(this, R.string.msg_copied, Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
|
||||||
|
reportGithubButton.setOnClickListener((View v) -> {
|
||||||
|
openPrivacyPolicyDialog(this, "GITHUB");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// normal bugreport
|
// normal bugreport
|
||||||
buildInfo(errorInfo);
|
buildInfo(errorInfo);
|
||||||
if (errorInfo.message != 0) {
|
if (errorInfo.message != 0) {
|
||||||
|
@ -250,7 +241,7 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
|
|
||||||
errorView.setText(formErrorText(errorList));
|
errorView.setText(formErrorText(errorList));
|
||||||
|
|
||||||
//print stack trace once again for debugging:
|
// print stack trace once again for debugging:
|
||||||
for (String e : errorList) {
|
for (String e : errorList) {
|
||||||
Log.e(TAG, e);
|
Log.e(TAG, e);
|
||||||
}
|
}
|
||||||
|
@ -281,6 +272,37 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openPrivacyPolicyDialog(final Context context, final String action) {
|
||||||
|
new AlertDialog.Builder(context)
|
||||||
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
|
.setTitle(R.string.privacy_policy_title)
|
||||||
|
.setMessage(R.string.start_accept_privacy_policy)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setNeutralButton(R.string.read_privacy_policy, (dialog, which) -> {
|
||||||
|
ShareUtils.openUrlInBrowser(context,
|
||||||
|
context.getString(R.string.privacy_policy_url));
|
||||||
|
})
|
||||||
|
.setPositiveButton(R.string.accept, (dialog, which) -> {
|
||||||
|
if (action.equals("EMAIL")) { // send on email
|
||||||
|
final Intent i = new Intent(Intent.ACTION_SENDTO)
|
||||||
|
.setData(Uri.parse("mailto:")) // only email apps should handle this
|
||||||
|
.putExtra(Intent.EXTRA_EMAIL, new String[]{ERROR_EMAIL_ADDRESS})
|
||||||
|
.putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT)
|
||||||
|
.putExtra(Intent.EXTRA_TEXT, buildJson());
|
||||||
|
if (i.resolveActivity(getPackageManager()) != null) {
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
|
} else if (action.equals("GITHUB")) { // open the NewPipe issue page on GitHub
|
||||||
|
ShareUtils.openUrlInBrowser(this, ERROR_GITHUB_ISSUE_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.decline, (dialog, which) -> {
|
||||||
|
// do nothing
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
private String formErrorText(final String[] el) {
|
private String formErrorText(final String[] el) {
|
||||||
StringBuilder text = new StringBuilder();
|
StringBuilder text = new StringBuilder();
|
||||||
if (el != null) {
|
if (el != null) {
|
||||||
|
@ -331,7 +353,9 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
|
|
||||||
text += getUserActionString(info.userAction) + "\n"
|
text += getUserActionString(info.userAction) + "\n"
|
||||||
+ info.request + "\n"
|
+ info.request + "\n"
|
||||||
+ getContentLangString() + "\n"
|
+ getContentLanguageString() + "\n"
|
||||||
|
+ getContentCountryString() + "\n"
|
||||||
|
+ getAppLanguage() + "\n"
|
||||||
+ info.serviceName + "\n"
|
+ info.serviceName + "\n"
|
||||||
+ currentTimeStamp + "\n"
|
+ currentTimeStamp + "\n"
|
||||||
+ getPackageName() + "\n"
|
+ getPackageName() + "\n"
|
||||||
|
@ -347,7 +371,9 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
.object()
|
.object()
|
||||||
.value("user_action", getUserActionString(errorInfo.userAction))
|
.value("user_action", getUserActionString(errorInfo.userAction))
|
||||||
.value("request", errorInfo.request)
|
.value("request", errorInfo.request)
|
||||||
.value("content_language", getContentLangString())
|
.value("content_language", getContentLanguageString())
|
||||||
|
.value("content_country", getContentCountryString())
|
||||||
|
.value("app_language", getAppLanguage())
|
||||||
.value("service", errorInfo.serviceName)
|
.value("service", errorInfo.serviceName)
|
||||||
.value("package", getPackageName())
|
.value("package", getPackageName())
|
||||||
.value("version", BuildConfig.VERSION_NAME)
|
.value("version", BuildConfig.VERSION_NAME)
|
||||||
|
@ -365,6 +391,63 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildMarkdown() {
|
||||||
|
try {
|
||||||
|
final StringBuilder htmlErrorReport = new StringBuilder();
|
||||||
|
|
||||||
|
final String userComment = userCommentBox.getText().toString();
|
||||||
|
if (!userComment.isEmpty()) {
|
||||||
|
htmlErrorReport.append(userComment).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// basic error info
|
||||||
|
htmlErrorReport
|
||||||
|
.append("## Exception")
|
||||||
|
.append("\n* __User Action:__ ")
|
||||||
|
.append(getUserActionString(errorInfo.userAction))
|
||||||
|
.append("\n* __Request:__ ").append(errorInfo.request)
|
||||||
|
.append("\n* __Content Country:__ ").append(getContentCountryString())
|
||||||
|
.append("\n* __Content Language:__ ").append(getContentLanguageString())
|
||||||
|
.append("\n* __App Language:__ ").append(getAppLanguage())
|
||||||
|
.append("\n* __Service:__ ").append(errorInfo.serviceName)
|
||||||
|
.append("\n* __Version:__ ").append(BuildConfig.VERSION_NAME)
|
||||||
|
.append("\n* __OS:__ ").append(getOsString()).append("\n");
|
||||||
|
|
||||||
|
|
||||||
|
// Collapse all logs to a single paragraph when there are more than one
|
||||||
|
// to keep the GitHub issue clean.
|
||||||
|
if (errorList.length > 1) {
|
||||||
|
htmlErrorReport
|
||||||
|
.append("<details><summary><b>Exceptions (")
|
||||||
|
.append(errorList.length)
|
||||||
|
.append(")</b></summary><p>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the logs
|
||||||
|
for (int i = 0; i < errorList.length; i++) {
|
||||||
|
htmlErrorReport.append("<details><summary><b>Crash log ");
|
||||||
|
if (errorList.length > 1) {
|
||||||
|
htmlErrorReport.append(i + 1);
|
||||||
|
}
|
||||||
|
htmlErrorReport.append("</b>")
|
||||||
|
.append("</summary><p>\n")
|
||||||
|
.append("\n```\n").append(errorList[i]).append("\n```\n")
|
||||||
|
.append("</details>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure to close everything
|
||||||
|
if (errorList.length > 1) {
|
||||||
|
htmlErrorReport.append("</p></details>\n");
|
||||||
|
}
|
||||||
|
htmlErrorReport.append("<hr>\n");
|
||||||
|
return htmlErrorReport.toString();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.e(TAG, "Error while erroring: Could not build markdown");
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getUserActionString(final UserAction userAction) {
|
private String getUserActionString(final UserAction userAction) {
|
||||||
if (userAction == null) {
|
if (userAction == null) {
|
||||||
return "Your description is in another castle.";
|
return "Your description is in another castle.";
|
||||||
|
@ -373,24 +456,27 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getContentLangString() {
|
private String getContentCountryString() {
|
||||||
String contentLanguage = PreferenceManager.getDefaultSharedPreferences(this)
|
return Localization.getPreferredContentCountry(this).getCountryCode();
|
||||||
.getString(this.getString(R.string.content_country_key), "none");
|
}
|
||||||
if (contentLanguage.equals(getString(R.string.default_localization_key))) {
|
|
||||||
contentLanguage = Locale.getDefault().toString();
|
private String getContentLanguageString() {
|
||||||
}
|
return Localization.getPreferredLocalization(this).getLocalizationCode();
|
||||||
return contentLanguage;
|
}
|
||||||
|
|
||||||
|
private String getAppLanguage() {
|
||||||
|
return Localization.getAppLocale(getApplicationContext()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOsString() {
|
private String getOsString() {
|
||||||
String osBase = Build.VERSION.SDK_INT >= 23 ? Build.VERSION.BASE_OS : "Android";
|
final String osBase = Build.VERSION.SDK_INT >= 23 ? Build.VERSION.BASE_OS : "Android";
|
||||||
return System.getProperty("os.name")
|
return System.getProperty("os.name")
|
||||||
+ " " + (osBase.isEmpty() ? "Android" : osBase)
|
+ " " + (osBase.isEmpty() ? "Android" : osBase)
|
||||||
+ " " + Build.VERSION.RELEASE
|
+ " " + Build.VERSION.RELEASE
|
||||||
+ " - " + Build.VERSION.SDK_INT;
|
+ " - " + Build.VERSION.SDK_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addGuruMeditaion() {
|
private void addGuruMeditation() {
|
||||||
//just an easter egg
|
//just an easter egg
|
||||||
TextView sorryView = findViewById(R.id.errorSorryView);
|
TextView sorryView = findViewById(R.id.errorSorryView);
|
||||||
String text = sorryView.getText().toString();
|
String text = sorryView.getText().toString();
|
||||||
|
|
|
@ -118,11 +118,31 @@
|
||||||
android:inputType="" />
|
android:inputType="" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/errorReportButton"
|
android:id="@+id/errorReportEmailButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/error_report_button_text" />
|
android:text="@string/error_report_button_text" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/error_report_open_github_notice" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/errorReportCopyButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/copy_for_github" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/errorReportGitHubButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/error_report_open_issue_button_text" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
|
|
@ -65,10 +65,12 @@
|
||||||
<string name="live_streams_not_supported">Live-Streams werden noch nicht unterstützt</string>
|
<string name="live_streams_not_supported">Live-Streams werden noch nicht unterstützt</string>
|
||||||
<string name="light_parsing_error">Konnte Webseite nicht vollständig analysieren</string>
|
<string name="light_parsing_error">Konnte Webseite nicht vollständig analysieren</string>
|
||||||
<string name="error_report_button_text">Fehler via E-Mail melden</string>
|
<string name="error_report_button_text">Fehler via E-Mail melden</string>
|
||||||
|
<string name="copy_for_github">Formatierten Fehlerbericht kopieren</string>
|
||||||
|
<string name="error_report_open_issue_button_text">Fehler auf GitHub melden</string>
|
||||||
<string name="error_snackbar_action">Melden</string>
|
<string name="error_snackbar_action">Melden</string>
|
||||||
<string name="what_device_headline">Info:</string>
|
<string name="what_device_headline">Info:</string>
|
||||||
<string name="what_happened_headline">Dies ist passiert:</string>
|
<string name="what_happened_headline">Dies ist passiert:</string>
|
||||||
<string name="info_labels">Was:\\nAnfrage:\\nSprache des Inhalts:\\nDienst:\\nZeit (GMT):\\nPaket:\\nVersion:\\nOS-Version:</string>
|
<string name="info_labels">Was:\\nAnfrage:\\nSprache des Inhalts:\\nLand des Inhalts:\\nSprache der App:\\nDienst:\\nZeit (GMT):\\nPaket:\\nVersion:\\nOS-Version:</string>
|
||||||
<string name="error_details_headline">Details:</string>
|
<string name="error_details_headline">Details:</string>
|
||||||
<string name="video">Video</string>
|
<string name="video">Video</string>
|
||||||
<string name="audio">Audio</string>
|
<string name="audio">Audio</string>
|
||||||
|
|
|
@ -234,11 +234,14 @@
|
||||||
<string name="sorry_string">Sorry, that should not have happened.</string>
|
<string name="sorry_string">Sorry, that should not have happened.</string>
|
||||||
<string name="guru_meditation" translatable="false">Guru Meditation.</string>
|
<string name="guru_meditation" translatable="false">Guru Meditation.</string>
|
||||||
<string name="error_report_button_text">Report this error via e-mail</string>
|
<string name="error_report_button_text">Report this error via e-mail</string>
|
||||||
|
<string name="copy_for_github">Copy formatted report</string>
|
||||||
|
<string name="error_report_open_issue_button_text">Report error on GitHub</string>
|
||||||
|
<string name="error_report_open_github_notice">Please check whether an issue discussing your crash already exists. When creating duplicate tickets, you take time from us which we could spend with fixing the actual bug.</string>
|
||||||
<string name="error_snackbar_message">Sorry, some errors occurred.</string>
|
<string name="error_snackbar_message">Sorry, some errors occurred.</string>
|
||||||
<string name="error_snackbar_action">Report</string>
|
<string name="error_snackbar_action">Report</string>
|
||||||
<string name="what_device_headline">Info:</string>
|
<string name="what_device_headline">Info:</string>
|
||||||
<string name="what_happened_headline">What happened:</string>
|
<string name="what_happened_headline">What happened:</string>
|
||||||
<string name="info_labels">What:\\nRequest:\\nContent Lang:\\nService:\\nGMT Time:\\nPackage:\\nVersion:\\nOS version:</string>
|
<string name="info_labels">What:\\nRequest:\\nContent Language:\\nContent Country:\\nApp Language:\\nService:\\nGMT Time:\\nPackage:\\nVersion:\\nOS version:</string>
|
||||||
<string name="your_comment">Your comment (in English):</string>
|
<string name="your_comment">Your comment (in English):</string>
|
||||||
<string name="error_details_headline">Details:</string>
|
<string name="error_details_headline">Details:</string>
|
||||||
<!-- Content descriptions (for better accessibility) -->
|
<!-- Content descriptions (for better accessibility) -->
|
||||||
|
|
Loading…
Reference in New Issue