Hide 'Not subscribed' message the first time we show preview (#7296)

This commit is contained in:
ByteHamster 2024-07-20 16:19:25 +02:00 committed by GitHub
parent 9d6d37548f
commit 7d1509f816
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 5 deletions

View File

@ -87,6 +87,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
MaterialToolbar.OnMenuItemClickListener, EpisodeItemListAdapter.OnSelectModeListener { MaterialToolbar.OnMenuItemClickListener, EpisodeItemListAdapter.OnSelectModeListener {
public static final String TAG = "ItemlistFragment"; public static final String TAG = "ItemlistFragment";
private static final String ARGUMENT_FEED_ID = "argument.de.danoeh.antennapod.feed_id"; 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"; private static final String KEY_UP_ARROW = "up_arrow";
protected static final int EPISODES_PER_PAGE = 150; protected static final int EPISODES_PER_PAGE = 150;
protected int page = 1; protected int page = 1;
@ -98,6 +99,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
private MoreContentListFooterUtil nextPageLoader; private MoreContentListFooterUtil nextPageLoader;
private boolean displayUpArrow; private boolean displayUpArrow;
private long feedID; private long feedID;
private boolean isFirstTime = false;
private Feed feed; private Feed feed;
private Disposable disposable; private Disposable disposable;
private FeedItemListFragmentBinding viewBinding; private FeedItemListFragmentBinding viewBinding;
@ -110,9 +112,14 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
* @return the newly created instance of an ItemlistFragment * @return the newly created instance of an ItemlistFragment
*/ */
public static FeedItemlistFragment newInstance(long feedId) { public static FeedItemlistFragment newInstance(long feedId) {
return newInstance(feedId, false);
}
public static FeedItemlistFragment newInstance(long feedId, boolean isFirstTime) {
FeedItemlistFragment i = new FeedItemlistFragment(); FeedItemlistFragment i = new FeedItemlistFragment();
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putLong(ARGUMENT_FEED_ID, feedId); b.putLong(ARGUMENT_FEED_ID, feedId);
b.putBoolean(ARGUMENT_IS_FIRST_TIME, isFirstTime);
i.setArguments(b); i.setArguments(b);
return i; return i;
} }
@ -124,6 +131,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
Bundle args = getArguments(); Bundle args = getArguments();
Validate.notNull(args); Validate.notNull(args);
feedID = args.getLong(ARGUMENT_FEED_ID); feedID = args.getLong(ARGUMENT_FEED_ID);
isFirstTime = args.getBoolean(ARGUMENT_IS_FIRST_TIME, false);
} }
@Nullable @Nullable
@ -478,6 +486,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
if (feed.getState() != Feed.STATE_SUBSCRIBED) { if (feed.getState() != Feed.STATE_SUBSCRIBED) {
viewBinding.header.descriptionContainer.setVisibility(View.VISIBLE); viewBinding.header.descriptionContainer.setVisibility(View.VISIBLE);
viewBinding.header.headerDescriptionLabel.setText(HtmlToPlainText.getPlainText(feed.getDescription())); viewBinding.header.headerDescriptionLabel.setText(HtmlToPlainText.getPlainText(feed.getDescription()));
viewBinding.header.subscribeNagLabel.setVisibility(isFirstTime ? View.GONE : View.VISIBLE);
} else if (feed.getItemFilter() != null) { } else if (feed.getItemFilter() != null) {
FeedItemFilter filter = feed.getItemFilter(); FeedItemFilter filter = feed.getItemFilter();
if (filter.getValues().length > 0) { if (filter.getValues().length > 0) {

View File

@ -234,7 +234,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
if (subscribedFeed.getState() == Feed.STATE_SUBSCRIBED) { if (subscribedFeed.getState() == Feed.STATE_SUBSCRIBED) {
openFeed(subscribedFeed.getId()); openFeed(subscribedFeed.getId());
} else { } else {
showFeedFragment(subscribedFeed.getId()); showFeedFragment(subscribedFeed.getId(), false);
} }
}, error -> Log.e(TAG, Log.getStackTraceString(error)), () -> startFeedDownload(url)); }, error -> Log.e(TAG, Log.getStackTraceString(error)), () -> startFeedDownload(url));
return null; return null;
@ -292,7 +292,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
}) })
.subscribeOn(Schedulers.computation()) .subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(this::showFeedFragment, error -> { .subscribe(id -> showFeedFragment(id, true), error -> {
error.printStackTrace(); error.printStackTrace();
showErrorDialog(error.getMessage(), ""); showErrorDialog(error.getMessage(), "");
}); });
@ -333,13 +333,13 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
} }
} }
private void showFeedFragment(long id) { private void showFeedFragment(long id, boolean isFirstTime) {
if (isFeedFoundBySearch) { if (isFeedFoundBySearch) {
Toast.makeText(this, R.string.no_feed_url_podcast_found_by_search, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.no_feed_url_podcast_found_by_search, Toast.LENGTH_LONG).show();
} }
viewBinding.progressBar.setVisibility(View.GONE); viewBinding.progressBar.setVisibility(View.GONE);
FeedItemlistFragment fragment = FeedItemlistFragment.newInstance(id); FeedItemlistFragment fragment = FeedItemlistFragment.newInstance(id, isFirstTime);
getSupportFragmentManager() getSupportFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.fragmentContainer, fragment, FeedItemlistFragment.TAG) .replace(R.id.fragmentContainer, fragment, FeedItemlistFragment.TAG)

View File

@ -200,15 +200,16 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingHorizontal="16dp" android:paddingHorizontal="16dp"
android:paddingTop="16dp"
android:background="?android:attr/colorBackground" android:background="?android:attr/colorBackground"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone"> android:visibility="gone">
<TextView <TextView
android:id="@+id/subscribeNagLabel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:layout_marginTop="16dp"
android:paddingHorizontal="16dp" android:paddingHorizontal="16dp"
android:paddingVertical="8dp" android:paddingVertical="8dp"
android:background="@drawable/bg_message_info" android:background="@drawable/bg_message_info"