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.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
@ -19,6 +20,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NavUtils; import androidx.core.app.NavUtils;
import androidx.preference.PreferenceManager;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.grack.nanojson.JsonWriter; 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, public static void reportError(final Context context, final List<Throwable> el,
final Class returnActivity, final View rootView, final Class returnActivity, final View rootView,
final ErrorInfo errorInfo) { 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) { if (rootView != null) {
Snackbar.make(rootView, R.string.error_snackbar_message, 3 * 1000) Snackbar.make(rootView, R.string.error_snackbar_message, 3 * 1000)
.setActionTextColor(Color.YELLOW) .setActionTextColor(Color.YELLOW)

View file

@ -371,6 +371,7 @@
<string name="enable_local_player_key" translatable="false">enable_local_player</string> <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_tablet_ui_key" translatable="false">disable_tablet_ui</string>
<string name="disable_tv_ui_key" translatable="false">disable_tv_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 --> <!-- Localizations -->
<string name="default_localization_key" translatable="false">system</string> <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_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_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_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> </resources>

View file

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