From 9be970a4c4ecadac6613a5cd350f0b07b31d121b Mon Sep 17 00:00:00 2001 From: Stypox Date: Mon, 22 Feb 2021 21:59:04 +0100 Subject: [PATCH] Add crash button to debug settings --- .../settings/DebugSettingsFragment.java | 22 ++++++++++++++----- app/src/main/res/values/settings_keys.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/debug_settings.xml | 5 +++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/src/debug/java/org/schabi/newpipe/settings/DebugSettingsFragment.java b/app/src/debug/java/org/schabi/newpipe/settings/DebugSettingsFragment.java index 3d63414a8..7e2ff69b8 100644 --- a/app/src/debug/java/org/schabi/newpipe/settings/DebugSettingsFragment.java +++ b/app/src/debug/java/org/schabi/newpipe/settings/DebugSettingsFragment.java @@ -3,6 +3,7 @@ package org.schabi.newpipe.settings; import android.os.Bundle; import androidx.annotation.Nullable; +import androidx.preference.Preference; import org.schabi.newpipe.R; @@ -13,11 +14,22 @@ public class DebugSettingsFragment extends BasePreferenceFragment { public void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - findPreference(getString(R.string.show_memory_leaks_key)) - .setOnPreferenceClickListener(preference -> { - startActivity(LeakCanary.INSTANCE.newLeakDisplayActivityIntent()); - return true; - }); + final Preference showMemoryLeaksPreference + = findPreference(getString(R.string.show_memory_leaks_key)); + final Preference crashTheAppPreference + = findPreference(getString(R.string.crash_the_app_key)); + + assert showMemoryLeaksPreference != null; + assert crashTheAppPreference != null; + + showMemoryLeaksPreference.setOnPreferenceClickListener(preference -> { + startActivity(LeakCanary.INSTANCE.newLeakDisplayActivityIntent()); + return true; + }); + + crashTheAppPreference.setOnPreferenceClickListener(preference -> { + throw new RuntimeException(); + }); } @Override diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 011bd850a..7f45ca18c 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -172,6 +172,7 @@ show_memory_leaks_key allow_disposed_exceptions_key show_original_time_ago_text_key + crash_the_app_key theme diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8ff79d3a4..6a13c2b03 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -518,6 +518,7 @@ Force reporting of undeliverable Rx exceptions outside of fragment or activity lifecycle after disposal Show original time ago on items Original texts from services will be visible in stream items + Crash the app Import/export Import diff --git a/app/src/main/res/xml/debug_settings.xml b/app/src/main/res/xml/debug_settings.xml index 8396f675c..8dda516fe 100644 --- a/app/src/main/res/xml/debug_settings.xml +++ b/app/src/main/res/xml/debug_settings.xml @@ -29,4 +29,9 @@ android:summary="@string/show_original_time_ago_summary" android:title="@string/show_original_time_ago_title" app:iconSpaceReserved="false" /> + +