SponsorBlock: added Disable Error Reporting extra setting

This commit is contained in:
polymorphicshade 2021-02-16 17:33:12 -07:00
parent e2fb610fae
commit 9674ee17ba
4 changed files with 15 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
@ -19,6 +20,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NavUtils;
import androidx.preference.PreferenceManager;
import com.google.android.material.snackbar.Snackbar;
import com.grack.nanojson.JsonWriter;
@ -94,6 +96,13 @@ public class ErrorActivity extends AppCompatActivity {
public static void reportError(final Context context, final List<Throwable> el,
final Class returnActivity, final View rootView,
final ErrorInfo errorInfo) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean(context
.getString(R.string.disable_error_reports_key), false)) {
return;
}
if (rootView != null) {
Snackbar.make(rootView, R.string.error_snackbar_message, 3 * 1000)
.setActionTextColor(Color.YELLOW)

View file

@ -371,6 +371,7 @@
<string name="enable_local_player_key" translatable="false">enable_local_player</string>
<string name="disable_tablet_ui_key" translatable="false">disable_tablet_ui</string>
<string name="disable_tv_ui_key" translatable="false">disable_tv_ui</string>
<string name="disable_error_reports_key" translatable="false">disable_error_reports</string>
<!-- Localizations -->
<string name="default_localization_key" translatable="false">system</string>

View file

@ -764,4 +764,6 @@
<string name="disable_tablet_ui_summary">Ignore tablet layouts. This is intended for specific workarounds. You may need to restart the app to see the effects.</string>
<string name="disable_tv_ui_title">Disable TV UI</string>
<string name="disable_tv_ui_summary">Ignore TV layouts. This is intended for specific workarounds. You may need to restart the app to see the effects.</string>
<string name="disable_error_reports_title">Disable Error Reporting</string>
<string name="disable_error_reports_summary">Prevent all error reporting screens from appearing. This may result in the app behaving unexpectedly. <b>USE AT YOUR OWN RISK!</b></string>
</resources>

View file

@ -30,8 +30,8 @@
<SwitchPreference
app:iconSpaceReserved="false"
android:defaultValue="false"
android:key="@string/disable_tv_ui_key"
android:summary="@string/disable_tv_ui_summary"
android:title="@string/disable_tv_ui_title"/>
android:key="@string/disable_error_reports_key"
android:summary="@string/disable_error_reports_summary"
android:title="@string/disable_error_reports_title"/>
</PreferenceCategory>
</PreferenceScreen>