use of de.danoeh.antennapod.event.PlayerStatusEvent in project AntennaPod by AntennaPod.
the class UserInterfacePreferencesFragment method setupInterfaceScreen.
private void setupInterfaceScreen() {
findPreference(UserPreferences.PREF_THEME).setOnPreferenceChangeListener((preference, newValue) -> {
ActivityCompat.recreate(getActivity());
return true;
});
findPreference(UserPreferences.PREF_SHOW_TIME_LEFT).setOnPreferenceChangeListener((preference, newValue) -> {
UserPreferences.setShowRemainTimeSetting((Boolean) newValue);
EventBus.getDefault().post(new UnreadItemsUpdateEvent());
EventBus.getDefault().post(new PlayerStatusEvent());
return true;
});
findPreference(UserPreferences.PREF_HIDDEN_DRAWER_ITEMS).setOnPreferenceClickListener(preference -> {
showDrawerPreferencesDialog();
return true;
});
findPreference(UserPreferences.PREF_COMPACT_NOTIFICATION_BUTTONS).setOnPreferenceClickListener(preference -> {
showNotificationButtonsDialog();
return true;
});
findPreference(UserPreferences.PREF_BACK_BUTTON_BEHAVIOR).setOnPreferenceChangeListener((preference, newValue) -> {
if (!newValue.equals("page")) {
return true;
}
final Context context = getActivity();
final String[] navTitles = context.getResources().getStringArray(R.array.back_button_go_to_pages);
final String[] navTags = context.getResources().getStringArray(R.array.back_button_go_to_pages_tags);
final String[] choice = { UserPreferences.getBackButtonGoToPage() };
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.back_button_go_to_page_title);
builder.setSingleChoiceItems(navTitles, ArrayUtils.indexOf(navTags, UserPreferences.getBackButtonGoToPage()), (dialogInterface, i) -> {
if (i >= 0) {
choice[0] = navTags[i];
}
});
builder.setPositiveButton(R.string.confirm_label, (dialogInterface, i) -> UserPreferences.setBackButtonGoToPage(choice[0]));
builder.setNegativeButton(R.string.cancel_label, null);
builder.create().show();
return true;
});
findPreference(UserPreferences.PREF_FILTER_FEED).setOnPreferenceClickListener((preference -> {
SubscriptionsFilterDialog.showDialog(requireContext());
return true;
}));
findPreference(UserPreferences.PREF_DRAWER_FEED_ORDER).setOnPreferenceClickListener((preference -> {
FeedSortDialog.showDialog(requireContext());
return true;
}));
findPreference(PREF_SWIPE).setOnPreferenceClickListener(preference -> {
((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_swipe);
return true;
});
if (Build.VERSION.SDK_INT >= 26) {
findPreference(UserPreferences.PREF_EXPANDED_NOTIFICATION).setVisible(false);
}
}
Aggregations