Search in sources :

Example 11 with FeedPreferences

use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.

the class PlaybackVolumeUpdaterTest method updatesPreferencesAndForcesVolumeChangeForLoadedFeedMediaIfPlayerStatusIsPlaying.

@Test
public void updatesPreferencesAndForcesVolumeChangeForLoadedFeedMediaIfPlayerStatusIsPlaying() {
    PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
    when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.PLAYING);
    FeedMedia feedMedia = mockFeedMedia();
    when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
    FeedPreferences feedPreferences = feedMedia.getItem().getFeed().getPreferences();
    playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.HEAVY_REDUCTION);
    verify(feedPreferences, times(1)).setVolumeAdaptionSetting(VolumeAdaptionSetting.HEAVY_REDUCTION);
    verify(mediaPlayer, times(1)).pause(false, false);
    verify(mediaPlayer, times(1)).resume();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Test(org.junit.Test)

Example 12 with FeedPreferences

use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.

the class TagSettingsDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    ArrayList<FeedPreferences> feedPreferencesList = (ArrayList<FeedPreferences>) getArguments().getSerializable(ARG_FEED_PREFERENCES);
    Set<String> commonTags = new HashSet<>(feedPreferencesList.get(0).getTags());
    for (FeedPreferences preference : feedPreferencesList) {
        commonTags.retainAll(preference.getTags());
    }
    displayedTags = new ArrayList<>(commonTags);
    displayedTags.remove(FeedPreferences.TAG_ROOT);
    viewBinding = EditTagsDialogBinding.inflate(getLayoutInflater());
    viewBinding.tagsRecycler.setLayoutManager(new GridLayoutManager(getContext(), 2));
    viewBinding.tagsRecycler.addItemDecoration(new ItemOffsetDecoration(getContext(), 4));
    adapter = new TagSelectionAdapter();
    adapter.setHasStableIds(true);
    viewBinding.tagsRecycler.setAdapter(adapter);
    viewBinding.rootFolderCheckbox.setChecked(commonTags.contains(FeedPreferences.TAG_ROOT));
    viewBinding.newTagButton.setOnClickListener(v -> addTag(viewBinding.newTagEditText.getText().toString().trim()));
    loadTags();
    viewBinding.newTagEditText.setThreshold(1);
    viewBinding.newTagEditText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            viewBinding.newTagEditText.showDropDown();
            viewBinding.newTagEditText.requestFocus();
            return false;
        }
    });
    if (feedPreferencesList.size() > 1) {
        viewBinding.commonTagsInfo.setVisibility(View.VISIBLE);
    }
    AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
    dialog.setView(viewBinding.getRoot());
    dialog.setTitle(R.string.feed_tags_label);
    dialog.setPositiveButton(android.R.string.ok, (d, input) -> {
        addTag(viewBinding.newTagEditText.getText().toString().trim());
        updatePreferencesTags(feedPreferencesList, commonTags);
    });
    dialog.setNegativeButton(R.string.cancel_label, null);
    return dialog.create();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) AlertDialog(androidx.appcompat.app.AlertDialog) ArrayList(java.util.ArrayList) ItemOffsetDecoration(de.danoeh.antennapod.view.ItemOffsetDecoration) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) MotionEvent(android.view.MotionEvent) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) HashSet(java.util.HashSet) NonNull(androidx.annotation.NonNull)

Example 13 with FeedPreferences

use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.

the class TagSettingsDialog method updatePreferencesTags.

private void updatePreferencesTags(List<FeedPreferences> feedPreferencesList, Set<String> commonTags) {
    if (viewBinding.rootFolderCheckbox.isChecked()) {
        displayedTags.add(FeedPreferences.TAG_ROOT);
    }
    for (FeedPreferences preferences : feedPreferencesList) {
        preferences.getTags().removeAll(commonTags);
        preferences.getTags().addAll(displayedTags);
        DBWriter.setFeedPreferences(preferences);
    }
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences)

Example 14 with FeedPreferences

use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.

the class DownloadAuthenticationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(UserPreferences.getTranslucentTheme());
    super.onCreate(savedInstanceState);
    Validate.isTrue(getIntent().hasExtra(ARG_DOWNLOAD_REQUEST), "Download request missing");
    DownloadRequest request = getIntent().getParcelableExtra(ARG_DOWNLOAD_REQUEST);
    new AuthenticationDialog(this, R.string.authentication_label, true, "", "") {

        @Override
        protected void onConfirmed(String username, String password) {
            Completable.fromAction(() -> {
                request.setUsername(username);
                request.setPassword(password);
                if (request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
                    long mediaId = request.getFeedfileId();
                    FeedMedia media = DBReader.getFeedMedia(mediaId);
                    if (media != null) {
                        FeedPreferences preferences = media.getItem().getFeed().getPreferences();
                        if (TextUtils.isEmpty(preferences.getPassword()) || TextUtils.isEmpty(preferences.getUsername())) {
                            preferences.setUsername(username);
                            preferences.setPassword(password);
                            DBWriter.setFeedPreferences(preferences);
                        }
                    }
                }
            }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(() -> {
                DownloadService.download(DownloadAuthenticationActivity.this, false, request);
                finish();
            });
        }

        @Override
        protected void onCancelled() {
            finish();
        }
    }.show();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) AuthenticationDialog(de.danoeh.antennapod.dialog.AuthenticationDialog) DownloadRequest(de.danoeh.antennapod.core.service.download.DownloadRequest)

Example 15 with FeedPreferences

use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.

the class RenameItemDialog method renameTag.

private void renameTag(String title) {
    if (NavDrawerData.DrawerItem.Type.TAG == drawerItem.type) {
        List<FeedPreferences> feedPreferences = new ArrayList<>();
        for (NavDrawerData.DrawerItem item : ((NavDrawerData.TagDrawerItem) drawerItem).children) {
            feedPreferences.add(((NavDrawerData.FeedDrawerItem) item).feed.getPreferences());
        }
        for (FeedPreferences preferences : feedPreferences) {
            preferences.getTags().remove(drawerItem.getTitle());
            preferences.getTags().add(title);
            DBWriter.setFeedPreferences(preferences);
        }
    }
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) NavDrawerData(de.danoeh.antennapod.core.storage.NavDrawerData) ArrayList(java.util.ArrayList)

Aggregations

FeedPreferences (de.danoeh.antennapod.model.feed.FeedPreferences)27 FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)14 Feed (de.danoeh.antennapod.model.feed.Feed)8 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 NonNull (androidx.annotation.NonNull)3 Playable (de.danoeh.antennapod.model.playback.Playable)3 Context (android.content.Context)2 Toast (android.widget.Toast)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 PreferenceListDialog (de.danoeh.antennapod.fragment.preferences.dialog.PreferenceListDialog)2 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)2 VolumeAdaptionSetting (de.danoeh.antennapod.model.feed.VolumeAdaptionSetting)2 File (java.io.File)2 IOException (java.io.IOException)2 UiModeManager (android.app.UiModeManager)1 Log (android.util.Log)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 PluralsRes (androidx.annotation.PluralsRes)1