Search in sources :

Example 11 with UnreadItemsUpdateEvent

use of de.danoeh.antennapod.event.UnreadItemsUpdateEvent in project AntennaPod by AntennaPod.

the class PlaybackPreferencesFragment method setupPlaybackScreen.

private void setupPlaybackScreen() {
    final Activity activity = getActivity();
    findPreference(PREF_PLAYBACK_SPEED_LAUNCHER).setOnPreferenceClickListener(preference -> {
        new VariableSpeedDialog().show(getChildFragmentManager(), null);
        return true;
    });
    findPreference(PREF_PLAYBACK_REWIND_DELTA_LAUNCHER).setOnPreferenceClickListener(preference -> {
        SkipPreferenceDialog.showSkipPreference(activity, SkipPreferenceDialog.SkipDirection.SKIP_REWIND, null);
        return true;
    });
    findPreference(PREF_PLAYBACK_FAST_FORWARD_DELTA_LAUNCHER).setOnPreferenceClickListener(preference -> {
        SkipPreferenceDialog.showSkipPreference(activity, SkipPreferenceDialog.SkipDirection.SKIP_FORWARD, null);
        return true;
    });
    if (!PictureInPictureUtil.supportsPictureInPicture(activity)) {
        ListPreference behaviour = findPreference(UserPreferences.PREF_VIDEO_BEHAVIOR);
        behaviour.setEntries(R.array.video_background_behavior_options_without_pip);
        behaviour.setEntryValues(R.array.video_background_behavior_values_without_pip);
    }
    findPreference(PREF_PLAYBACK_PREFER_STREAMING).setOnPreferenceChangeListener((preference, newValue) -> {
        // Update all visible lists to reflect new streaming action button
        EventBus.getDefault().post(new UnreadItemsUpdateEvent());
        UsageStatistics.askAgainLater(UsageStatistics.ACTION_STREAM);
        return true;
    });
    buildEnqueueLocationPreference();
}
Also used : UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent) PreferenceActivity(de.danoeh.antennapod.activity.PreferenceActivity) Activity(android.app.Activity) ListPreference(androidx.preference.ListPreference) VariableSpeedDialog(de.danoeh.antennapod.dialog.VariableSpeedDialog)

Example 12 with UnreadItemsUpdateEvent

use of de.danoeh.antennapod.event.UnreadItemsUpdateEvent 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

UnreadItemsUpdateEvent (de.danoeh.antennapod.event.UnreadItemsUpdateEvent)12 AlertDialog (androidx.appcompat.app.AlertDialog)2 PreferenceActivity (de.danoeh.antennapod.activity.PreferenceActivity)2 Activity (android.app.Activity)1 Context (android.content.Context)1 MediaMetadataRetriever (android.media.MediaMetadataRetriever)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Button (android.widget.Button)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 ActivityCompat (androidx.core.app.ActivityCompat)1 ListPreference (androidx.preference.ListPreference)1 PreferenceFragmentCompat (androidx.preference.PreferenceFragmentCompat)1 Snackbar (com.google.android.material.snackbar.Snackbar)1 Balloon (com.skydoves.balloon.Balloon)1 R (de.danoeh.antennapod.R)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 CancelDownloadActionButton (de.danoeh.antennapod.adapter.actionbutton.CancelDownloadActionButton)1