Search in sources :

Example 1 with FeedPreferences

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

the class FeedMultiSelectActionHandler method autoDeleteEpisodesPrefHandler.

private void autoDeleteEpisodesPrefHandler() {
    PreferenceListDialog preferenceListDialog = new PreferenceListDialog(activity, "Auto delete episodes");
    String[] items = activity.getResources().getStringArray(R.array.spnAutoDeleteItems);
    String[] values = activity.getResources().getStringArray(R.array.spnAutoDeleteValues);
    preferenceListDialog.openDialog(items);
    preferenceListDialog.setOnPreferenceChangedListener(which -> {
        FeedPreferences.AutoDeleteAction autoDeleteAction = null;
        switch(values[which]) {
            case "global":
                autoDeleteAction = FeedPreferences.AutoDeleteAction.GLOBAL;
                break;
            case "always":
                autoDeleteAction = FeedPreferences.AutoDeleteAction.YES;
                break;
            case "never":
                autoDeleteAction = FeedPreferences.AutoDeleteAction.NO;
                break;
            default:
        }
        FeedPreferences.AutoDeleteAction finalAutoDeleteAction = autoDeleteAction;
        saveFeedPreferences(feedPreferences -> {
            feedPreferences.setAutoDeleteAction(finalAutoDeleteAction);
        });
    });
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) PreferenceListDialog(de.danoeh.antennapod.fragment.preferences.dialog.PreferenceListDialog)

Example 2 with FeedPreferences

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

the class NewEpisodesNotification method showIfNeeded.

public void showIfNeeded(Context context, Feed feed) {
    FeedPreferences prefs = feed.getPreferences();
    if (!prefs.getKeepUpdated() || !prefs.getShowEpisodeNotification()) {
        return;
    }
    int newEpisodesBefore = countersBefore.get(feed.getId());
    int newEpisodesAfter = getNewEpisodeCount(feed.getId());
    Log.d(TAG, "New episodes before: " + newEpisodesBefore + ", after: " + newEpisodesAfter);
    if (newEpisodesAfter > newEpisodesBefore) {
        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
        showNotification(newEpisodesAfter, feed, context, notificationManager);
    }
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) NotificationManagerCompat(androidx.core.app.NotificationManagerCompat)

Example 3 with FeedPreferences

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

the class LocalPSMP method setVolumeSync.

/**
 * Sets the playback volume.
 * This method is executed on the caller's thread.
 */
private void setVolumeSync(float volumeLeft, float volumeRight) {
    playerLock.lock();
    Playable playable = getPlayable();
    if (playable instanceof FeedMedia) {
        FeedMedia feedMedia = (FeedMedia) playable;
        FeedPreferences preferences = feedMedia.getItem().getFeed().getPreferences();
        VolumeAdaptionSetting volumeAdaptionSetting = preferences.getVolumeAdaptionSetting();
        float adaptionFactor = volumeAdaptionSetting.getAdaptionFactor();
        volumeLeft *= adaptionFactor;
        volumeRight *= adaptionFactor;
    }
    mediaPlayer.setVolume(volumeLeft, volumeRight);
    Log.d(TAG, "Media player volume was set to " + volumeLeft + " " + volumeRight);
    playerLock.unlock();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) Playable(de.danoeh.antennapod.model.playback.Playable) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) VolumeAdaptionSetting(de.danoeh.antennapod.model.feed.VolumeAdaptionSetting)

Example 4 with FeedPreferences

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

the class FeedParserTask method call.

@Override
public FeedHandlerResult call() {
    Feed feed = new Feed(request.getSource(), request.getLastModified());
    feed.setFile_url(request.getDestination());
    feed.setId(request.getFeedfileId());
    feed.setDownloaded(true);
    feed.setPreferences(new FeedPreferences(0, true, FeedPreferences.AutoDeleteAction.GLOBAL, VolumeAdaptionSetting.OFF, request.getUsername(), request.getPassword()));
    feed.setPageNr(request.getArguments().getInt(DownloadRequest.REQUEST_ARG_PAGE_NR, 0));
    DownloadError reason = null;
    String reasonDetailed = null;
    FeedHandler feedHandler = new FeedHandler();
    FeedHandlerResult result = null;
    try {
        result = feedHandler.parseFeed(feed);
        Log.d(TAG, feed.getTitle() + " parsed");
        checkFeedData(feed);
    } catch (SAXException | IOException | ParserConfigurationException e) {
        successful = false;
        e.printStackTrace();
        reason = DownloadError.ERROR_PARSER_EXCEPTION;
        reasonDetailed = e.getMessage();
    } catch (UnsupportedFeedtypeException e) {
        e.printStackTrace();
        successful = false;
        reason = DownloadError.ERROR_UNSUPPORTED_TYPE;
        if ("html".equalsIgnoreCase(e.getRootElement())) {
            reason = DownloadError.ERROR_UNSUPPORTED_TYPE_HTML;
        }
        reasonDetailed = e.getMessage();
    } catch (InvalidFeedException e) {
        e.printStackTrace();
        successful = false;
        reason = DownloadError.ERROR_PARSER_EXCEPTION;
        reasonDetailed = e.getMessage();
    } finally {
        File feedFile = new File(request.getDestination());
        if (feedFile.exists()) {
            boolean deleted = feedFile.delete();
            Log.d(TAG, "Deletion of file '" + feedFile.getAbsolutePath() + "' " + (deleted ? "successful" : "FAILED"));
        }
    }
    if (successful) {
        downloadStatus = new DownloadStatus(feed, feed.getHumanReadableIdentifier(), DownloadError.SUCCESS, successful, reasonDetailed, request.isInitiatedByUser());
        return result;
    } else {
        downloadStatus = new DownloadStatus(feed, feed.getTitle(), reason, successful, reasonDetailed, request.isInitiatedByUser());
        return null;
    }
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) InvalidFeedException(de.danoeh.antennapod.core.util.InvalidFeedException) UnsupportedFeedtypeException(de.danoeh.antennapod.parser.feed.UnsupportedFeedtypeException) FeedHandlerResult(de.danoeh.antennapod.parser.feed.FeedHandlerResult) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) DownloadError(de.danoeh.antennapod.core.util.DownloadError) FeedHandler(de.danoeh.antennapod.parser.feed.FeedHandler) DownloadStatus(de.danoeh.antennapod.core.service.download.DownloadStatus) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) File(java.io.File) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 5 with FeedPreferences

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

the class PlaybackService method skipIntroEndingPresetChanged.

@Subscribe(threadMode = ThreadMode.MAIN)
@SuppressWarnings("unused")
public void skipIntroEndingPresetChanged(SkipIntroEndingChangedEvent event) {
    if (getPlayable() instanceof FeedMedia) {
        if (((FeedMedia) getPlayable()).getItem().getFeed().getId() == event.getFeedId()) {
            if (event.getSkipEnding() != 0) {
                FeedPreferences feedPreferences = ((FeedMedia) getPlayable()).getItem().getFeed().getPreferences();
                feedPreferences.setFeedSkipIntro(event.getSkipIntro());
                feedPreferences.setFeedSkipEnding(event.getSkipEnding());
            }
        }
    }
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Subscribe(org.greenrobot.eventbus.Subscribe)

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