Add debug prefs to show error snackbar/notification
This commit is contained in:
parent
c8e2ab4c83
commit
c000c1d455
4 changed files with 44 additions and 9 deletions
|
|
@ -5,6 +5,9 @@ import android.os.Bundle;
|
|||
import androidx.preference.Preference;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.error.ErrorInfo;
|
||||
import org.schabi.newpipe.error.ErrorUtil;
|
||||
import org.schabi.newpipe.error.UserAction;
|
||||
import org.schabi.newpipe.util.PicassoHelper;
|
||||
|
||||
import leakcanary.LeakCanary;
|
||||
|
|
@ -20,10 +23,16 @@ public class DebugSettingsFragment extends BasePreferenceFragment {
|
|||
= findPreference(getString(R.string.show_image_indicators_key));
|
||||
final Preference crashTheAppPreference
|
||||
= findPreference(getString(R.string.crash_the_app_key));
|
||||
final Preference showErrorSnackbarPreference
|
||||
= findPreference(getString(R.string.show_error_snackbar_key));
|
||||
final Preference createErrorNotificationPreference
|
||||
= findPreference(getString(R.string.create_error_notification_key));
|
||||
|
||||
assert showMemoryLeaksPreference != null;
|
||||
assert showImageIndicatorsPreference != null;
|
||||
assert crashTheAppPreference != null;
|
||||
assert showErrorSnackbarPreference != null;
|
||||
assert createErrorNotificationPreference != null;
|
||||
|
||||
showMemoryLeaksPreference.setOnPreferenceClickListener(preference -> {
|
||||
startActivity(LeakCanary.INSTANCE.newLeakDisplayActivityIntent());
|
||||
|
|
@ -38,5 +47,17 @@ public class DebugSettingsFragment extends BasePreferenceFragment {
|
|||
crashTheAppPreference.setOnPreferenceClickListener(preference -> {
|
||||
throw new RuntimeException();
|
||||
});
|
||||
|
||||
showErrorSnackbarPreference.setOnPreferenceClickListener(preference -> {
|
||||
ErrorUtil.showUiErrorSnackbar(DebugSettingsFragment.this,
|
||||
"Dummy", new RuntimeException("Dummy"));
|
||||
return true;
|
||||
});
|
||||
|
||||
createErrorNotificationPreference.setOnPreferenceClickListener(preference -> {
|
||||
ErrorUtil.createNotification(requireContext(),
|
||||
new ErrorInfo(new RuntimeException("Dummy"), UserAction.UI_ERROR, "Dummy"));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue