diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-09-03 19:41:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 19:41:48 +0200 |
commit | 2ad713772dd1de7ea8463fc54744d1bcc7d786d3 (patch) | |
tree | 81ea62d5f8776609dbe427139358b47fbaef5a77 | |
parent | 4fd3696d7fa308a5dc7d637605f45f4d6e5b1170 (diff) | |
download | AntennaPod-2ad713772dd1de7ea8463fc54744d1bcc7d786d3.zip |
Show subscribe nag only after interacting with episode (#7378)
4 files changed, 40 insertions, 21 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java index 0a7b85eac..f9c41496f 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java @@ -87,7 +87,6 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem MaterialToolbar.OnMenuItemClickListener, EpisodeItemListAdapter.OnSelectModeListener { public static final String TAG = "ItemlistFragment"; private static final String ARGUMENT_FEED_ID = "argument.de.danoeh.antennapod.feed_id"; - private static final String ARGUMENT_IS_FIRST_TIME = "argument.de.danoeh.antennapod.first_time"; private static final String KEY_UP_ARROW = "up_arrow"; protected static final int EPISODES_PER_PAGE = 150; protected int page = 1; @@ -99,7 +98,6 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem private MoreContentListFooterUtil nextPageLoader; private boolean displayUpArrow; private long feedID; - private boolean isFirstTime = false; private Feed feed; private Disposable disposable; private FeedItemListFragmentBinding viewBinding; @@ -112,14 +110,9 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem * @return the newly created instance of an ItemlistFragment */ public static FeedItemlistFragment newInstance(long feedId) { - return newInstance(feedId, false); - } - - public static FeedItemlistFragment newInstance(long feedId, boolean isFirstTime) { FeedItemlistFragment i = new FeedItemlistFragment(); Bundle b = new Bundle(); b.putLong(ARGUMENT_FEED_ID, feedId); - b.putBoolean(ARGUMENT_IS_FIRST_TIME, isFirstTime); i.setArguments(b); return i; } @@ -131,7 +124,6 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem Bundle args = getArguments(); Validate.notNull(args); feedID = args.getLong(ARGUMENT_FEED_ID); - isFirstTime = args.getBoolean(ARGUMENT_IS_FIRST_TIME, false); } @Nullable @@ -486,7 +478,8 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem if (feed.getState() != Feed.STATE_SUBSCRIBED) { viewBinding.header.descriptionContainer.setVisibility(View.VISIBLE); viewBinding.header.headerDescriptionLabel.setText(HtmlToPlainText.getPlainText(feed.getDescription())); - viewBinding.header.subscribeNagLabel.setVisibility(isFirstTime ? View.GONE : View.VISIBLE); + viewBinding.header.subscribeNagLabel.setVisibility( + feed.hasInteractedWithEpisode() ? View.VISIBLE : View.GONE); } else if (feed.getItemFilter() != null) { FeedItemFilter filter = feed.getItemFilter(); if (filter.getValues().length > 0) { diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/onlinefeedview/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/onlinefeedview/OnlineFeedViewActivity.java index df32bcfb2..7e994b1ed 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/onlinefeedview/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/onlinefeedview/OnlineFeedViewActivity.java @@ -234,7 +234,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity { if (subscribedFeed.getState() == Feed.STATE_SUBSCRIBED) { openFeed(subscribedFeed.getId()); } else { - showFeedFragment(subscribedFeed.getId(), false); + showFeedFragment(subscribedFeed.getId()); } }, error -> Log.e(TAG, Log.getStackTraceString(error)), () -> startFeedDownload(url)); return null; @@ -292,7 +292,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity { }) .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(id -> showFeedFragment(id, true), error -> { + .subscribe(this::showFeedFragment, error -> { error.printStackTrace(); showErrorDialog(error.getMessage(), ""); }); @@ -333,13 +333,13 @@ public class OnlineFeedViewActivity extends AppCompatActivity { } } - private void showFeedFragment(long id, boolean isFirstTime) { + private void showFeedFragment(long id) { if (isFeedFoundBySearch) { Toast.makeText(this, R.string.no_feed_url_podcast_found_by_search, Toast.LENGTH_LONG).show(); } viewBinding.progressBar.setVisibility(View.GONE); - FeedItemlistFragment fragment = FeedItemlistFragment.newInstance(id, isFirstTime); + FeedItemlistFragment fragment = FeedItemlistFragment.newInstance(id); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentContainer, fragment, FeedItemlistFragment.TAG) diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java b/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java index 2bd06a350..bce31cdd9 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java @@ -483,6 +483,38 @@ public class Feed { this.state = state; } + public boolean hasEpisodeInApp() { + if (items == null) { + return false; + } + for (FeedItem item : items) { + if (item.isTagged(FeedItem.TAG_FAVORITE) + || item.isTagged(FeedItem.TAG_QUEUE) + || item.isDownloaded()) { + return true; + } + } + return false; + } + + public boolean hasInteractedWithEpisode() { + if (items == null) { + return false; + } + for (FeedItem item : items) { + if (item.isTagged(FeedItem.TAG_FAVORITE) + || item.isTagged(FeedItem.TAG_QUEUE) + || item.isDownloaded() + || item.isPlayed()) { + return true; + } + if (item.getMedia() != null && item.getMedia().getPosition() > 0) { + return true; + } + } + return false; + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/NonSubscribedFeedsCleaner.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/NonSubscribedFeedsCleaner.java index 47a5a5aee..31d4c4d7f 100644 --- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/NonSubscribedFeedsCleaner.java +++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/NonSubscribedFeedsCleaner.java @@ -3,7 +3,6 @@ package de.danoeh.antennapod.storage.database; import android.content.Context; import android.util.Log; import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; import de.danoeh.antennapod.model.feed.SortOrder; @@ -33,13 +32,8 @@ public class NonSubscribedFeedsCleaner { return false; } else if (feed.getItems() == null) { return false; - } - for (FeedItem item : feed.getItems()) { - if (item.isTagged(FeedItem.TAG_FAVORITE) - || item.isTagged(FeedItem.TAG_QUEUE) - || item.isDownloaded()) { - return false; - } + } else if (feed.hasEpisodeInApp()) { + return false; } return feed.getLastRefreshAttempt() < System.currentTimeMillis() - TIME_TO_KEEP; } |