Skip to content

Commit d6855a6

Browse files
authored
Merge pull request #5672 from Stypox/crash-button
Add crash button to debug settings
2 parents 1f77e00 + 9be970a commit d6855a6

4 files changed

Lines changed: 24 additions & 5 deletions

File tree

app/src/debug/java/org/schabi/newpipe/settings/DebugSettingsFragment.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.os.Bundle;
44

55
import androidx.annotation.Nullable;
6+
import androidx.preference.Preference;
67

78
import org.schabi.newpipe.R;
89

@@ -13,11 +14,22 @@ public class DebugSettingsFragment extends BasePreferenceFragment {
1314
public void onCreate(@Nullable final Bundle savedInstanceState) {
1415
super.onCreate(savedInstanceState);
1516

16-
findPreference(getString(R.string.show_memory_leaks_key))
17-
.setOnPreferenceClickListener(preference -> {
18-
startActivity(LeakCanary.INSTANCE.newLeakDisplayActivityIntent());
19-
return true;
20-
});
17+
final Preference showMemoryLeaksPreference
18+
= findPreference(getString(R.string.show_memory_leaks_key));
19+
final Preference crashTheAppPreference
20+
= findPreference(getString(R.string.crash_the_app_key));
21+
22+
assert showMemoryLeaksPreference != null;
23+
assert crashTheAppPreference != null;
24+
25+
showMemoryLeaksPreference.setOnPreferenceClickListener(preference -> {
26+
startActivity(LeakCanary.INSTANCE.newLeakDisplayActivityIntent());
27+
return true;
28+
});
29+
30+
crashTheAppPreference.setOnPreferenceClickListener(preference -> {
31+
throw new RuntimeException();
32+
});
2133
}
2234

2335
@Override

app/src/main/res/values/settings_keys.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
<string name="show_memory_leaks_key" translatable="false">show_memory_leaks_key</string>
173173
<string name="allow_disposed_exceptions_key" translatable="false">allow_disposed_exceptions_key</string>
174174
<string name="show_original_time_ago_key" translatable="false">show_original_time_ago_text_key</string>
175+
<string name="crash_the_app_key" translatable="false">crash_the_app_key</string>
175176

176177
<!-- THEMES -->
177178
<string name="theme_key" translatable="false">theme</string>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@
518518
<string name="enable_disposed_exceptions_summary">Force reporting of undeliverable Rx exceptions outside of fragment or activity lifecycle after disposal</string>
519519
<string name="show_original_time_ago_title">Show original time ago on items</string>
520520
<string name="show_original_time_ago_summary">Original texts from services will be visible in stream items</string>
521+
<string name="crash_the_app">Crash the app</string>
521522
<!-- Subscriptions import/export -->
522523
<string name="import_export_title">Import/export</string>
523524
<string name="import_title">Import</string>

app/src/main/res/xml/debug_settings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@
2929
android:summary="@string/show_original_time_ago_summary"
3030
android:title="@string/show_original_time_ago_title"
3131
app:iconSpaceReserved="false" />
32+
33+
<Preference
34+
android:key="@string/crash_the_app_key"
35+
android:title="@string/crash_the_app"
36+
app:iconSpaceReserved="false" />
3237
</PreferenceScreen>

0 commit comments

Comments
 (0)