Skip to content

Commit

Permalink
Merge pull request TeamNewPipe/NewPipe#5672 from Stypox/crash-button
Browse files Browse the repository at this point in the history
Add crash button to debug settings
  • Loading branch information
TobiGr authored and tossj committed Apr 21, 2021
1 parent 370ac2e commit dcf3794
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.preference.Preference;

import org.schabi.newpipelegacy.R;

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<string name="show_memory_leaks_key" translatable="false">show_memory_leaks_key</string>
<string name="allow_disposed_exceptions_key" translatable="false">allow_disposed_exceptions_key</string>
<string name="show_original_time_ago_key" translatable="false">show_original_time_ago_text_key</string>
<string name="crash_the_app_key" translatable="false">crash_the_app_key</string>

<!-- THEMES -->
<string name="theme_key" translatable="false">theme</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@
<string name="enable_disposed_exceptions_summary">Force reporting of undeliverable Rx exceptions outside of fragment or activity lifecycle after disposal</string>
<string name="show_original_time_ago_title">Show original time ago on items</string>
<string name="show_original_time_ago_summary">Original texts from services will be visible in stream items</string>
<string name="crash_the_app">Crash the app</string>
<!-- Subscriptions import/export -->
<string name="import_export_title">Import/export</string>
<string name="import_title">Import</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/debug_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@
android:summary="@string/show_original_time_ago_summary"
android:title="@string/show_original_time_ago_title"
app:iconSpaceReserved="false" />

<Preference
android:key="@string/crash_the_app_key"
android:title="@string/crash_the_app"
app:iconSpaceReserved="false" />
</PreferenceScreen>

0 comments on commit dcf3794

Please sign in to comment.