Search in sources :

Example 1 with PlayerStatusEvent

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);
    }
}
Also used : Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) FeedSortDialog(de.danoeh.antennapod.dialog.FeedSortDialog) ActivityCompat(androidx.core.app.ActivityCompat) R(de.danoeh.antennapod.R) ArrayUtils(org.apache.commons.lang3.ArrayUtils) PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) SubscriptionsFilterDialog(de.danoeh.antennapod.dialog.SubscriptionsFilterDialog) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) List(java.util.List) PreferenceActivity(de.danoeh.antennapod.activity.PreferenceActivity) EventBus(org.greenrobot.eventbus.EventBus) UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent) ListView(android.widget.ListView) PlayerStatusEvent(de.danoeh.antennapod.event.PlayerStatusEvent) Build(android.os.Build) Snackbar(com.google.android.material.snackbar.Snackbar) NavDrawerFragment(de.danoeh.antennapod.fragment.NavDrawerFragment) UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent) PlayerStatusEvent(de.danoeh.antennapod.event.PlayerStatusEvent) PreferenceActivity(de.danoeh.antennapod.activity.PreferenceActivity)

Aggregations

Context (android.content.Context)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 ListView (android.widget.ListView)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 ActivityCompat (androidx.core.app.ActivityCompat)1 PreferenceFragmentCompat (androidx.preference.PreferenceFragmentCompat)1 Snackbar (com.google.android.material.snackbar.Snackbar)1 R (de.danoeh.antennapod.R)1 PreferenceActivity (de.danoeh.antennapod.activity.PreferenceActivity)1 UserPreferences (de.danoeh.antennapod.core.preferences.UserPreferences)1 FeedSortDialog (de.danoeh.antennapod.dialog.FeedSortDialog)1 SubscriptionsFilterDialog (de.danoeh.antennapod.dialog.SubscriptionsFilterDialog)1 PlayerStatusEvent (de.danoeh.antennapod.event.PlayerStatusEvent)1 UnreadItemsUpdateEvent (de.danoeh.antennapod.event.UnreadItemsUpdateEvent)1 NavDrawerFragment (de.danoeh.antennapod.fragment.NavDrawerFragment)1 List (java.util.List)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 EventBus (org.greenrobot.eventbus.EventBus)1