Remove headings on add podcast page (#7405)

This commit is contained in:
ByteHamster 2024-09-15 10:27:43 +02:00 committed by GitHub
parent dafe821775
commit 61cf9b3405
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 72 additions and 102 deletions

View File

@ -87,18 +87,9 @@
android:id="@+id/quickFeedDiscovery" android:id="@+id/quickFeedDiscovery"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginVertical="16dp"
android:name="de.danoeh.antennapod.ui.discovery.QuickFeedDiscoveryFragment" /> android:name="de.danoeh.antennapod.ui.discovery.QuickFeedDiscoveryFragment" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/advanced"
android:textSize="18sp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:accessibilityHeading="true"
android:textColor="?android:attr/textColorPrimary" />
<TextView <TextView
android:id="@+id/addViaUrlButton" android:id="@+id/addViaUrlButton"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -84,7 +84,7 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="@id/barrier" app:layout_constraintBottom_toBottomOf="@id/barrier"
tools:text="@string/discover_more" tools:text="more »"
style="@style/Widget.MaterialComponents.Button.TextButton" /> style="@style/Widget.MaterialComponents.Button.TextButton" />
<androidx.constraintlayout.widget.Barrier <androidx.constraintlayout.widget.Barrier

View File

@ -305,7 +305,7 @@
<item name="elevation">0dp</item> <item name="elevation">0dp</item>
</style> </style>
<style name="AddPodcastTextView"> <style name="AddPodcastTextView" parent="@style/TextAppearance.Material3.BodyMedium">
<item name="android:drawablePadding">8dp</item> <item name="android:drawablePadding">8dp</item>
<item name="android:paddingTop">8dp</item> <item name="android:paddingTop">8dp</item>
<item name="android:paddingBottom">8dp</item> <item name="android:paddingBottom">8dp</item>

View File

@ -10,10 +10,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import de.danoeh.antennapod.net.discovery.BuildConfig; import de.danoeh.antennapod.net.discovery.BuildConfig;
import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.DBReader;
@ -22,6 +18,7 @@ import de.danoeh.antennapod.net.discovery.ItunesTopListLoader;
import de.danoeh.antennapod.net.discovery.PodcastSearchResult; import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter; import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter;
import de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter; import de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter;
import de.danoeh.antennapod.ui.discovery.databinding.QuickFeedDiscoveryBinding;
import io.reactivex.Observable; import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
@ -36,45 +33,33 @@ import java.util.Locale;
import static android.content.Context.MODE_PRIVATE; import static android.content.Context.MODE_PRIVATE;
public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.OnItemClickListener { public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.OnItemClickListener {
private static final String TAG = "FeedDiscoveryFragment"; private static final String TAG = "FeedDiscoveryFragment";
private static final int NUM_SUGGESTIONS = 12; private static final int NUM_SUGGESTIONS = 12;
private Disposable disposable; private Disposable disposable;
private FeedDiscoverAdapter adapter; private FeedDiscoverAdapter adapter;
private GridView discoverGridLayout; private QuickFeedDiscoveryBinding viewBinding;
private TextView errorTextView;
private TextView poweredByTextView;
private LinearLayout errorView;
private Button errorRetry;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState); super.onCreateView(inflater, container, savedInstanceState);
View root = inflater.inflate(R.layout.quick_feed_discovery, container, false); viewBinding = QuickFeedDiscoveryBinding.inflate(inflater);
View discoverMore = root.findViewById(R.id.discover_more); viewBinding.discoverMore.setOnClickListener(v -> startActivity(new MainActivityStarter(getContext())
discoverMore.setOnClickListener(v -> startActivity(new MainActivityStarter(getContext())
.withFragmentLoaded(DiscoveryFragment.TAG) .withFragmentLoaded(DiscoveryFragment.TAG)
.withAddToBackStack() .withAddToBackStack()
.getIntent())); .getIntent()));
discoverGridLayout = root.findViewById(R.id.discover_grid);
errorView = root.findViewById(R.id.discover_error);
errorTextView = root.findViewById(R.id.discover_error_txtV);
errorRetry = root.findViewById(R.id.discover_error_retry_btn);
poweredByTextView = root.findViewById(R.id.discover_powered_by_itunes);
adapter = new FeedDiscoverAdapter(getActivity()); adapter = new FeedDiscoverAdapter(getActivity());
discoverGridLayout.setAdapter(adapter); viewBinding.discoverGrid.setAdapter(adapter);
discoverGridLayout.setOnItemClickListener(this); viewBinding.discoverGrid.setOnItemClickListener(this);
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics(); DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
float screenWidthDp = displayMetrics.widthPixels / displayMetrics.density; float screenWidthDp = displayMetrics.widthPixels / displayMetrics.density;
if (screenWidthDp > 600) { if (screenWidthDp > 600) {
discoverGridLayout.setNumColumns(6); viewBinding.discoverGrid.setNumColumns(6);
} else { } else {
discoverGridLayout.setNumColumns(4); viewBinding.discoverGrid.setNumColumns(4);
} }
// Fill with dummy elements to have a fixed height and // Fill with dummy elements to have a fixed height and
@ -88,7 +73,13 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
loadToplist(); loadToplist();
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
return root; return viewBinding.getRoot();
}
@Override
public void onDestroyView() {
super.onDestroyView();
viewBinding = null;
} }
@Override @Override
@ -107,32 +98,32 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
} }
private void loadToplist() { private void loadToplist() {
errorView.setVisibility(View.GONE); viewBinding.errorContainer.setVisibility(View.GONE);
errorRetry.setVisibility(View.INVISIBLE); viewBinding.errorRetryButton.setVisibility(View.INVISIBLE);
errorRetry.setText(R.string.retry_label); viewBinding.errorRetryButton.setText(R.string.retry_label);
poweredByTextView.setVisibility(View.VISIBLE); viewBinding.poweredByLabel.setVisibility(View.VISIBLE);
ItunesTopListLoader loader = new ItunesTopListLoader(getContext()); ItunesTopListLoader loader = new ItunesTopListLoader(getContext());
SharedPreferences prefs = getActivity().getSharedPreferences(ItunesTopListLoader.PREFS, MODE_PRIVATE); SharedPreferences prefs = getActivity().getSharedPreferences(ItunesTopListLoader.PREFS, MODE_PRIVATE);
String countryCode = prefs.getString(ItunesTopListLoader.PREF_KEY_COUNTRY_CODE, String countryCode = prefs.getString(ItunesTopListLoader.PREF_KEY_COUNTRY_CODE,
Locale.getDefault().getCountry()); Locale.getDefault().getCountry());
if (prefs.getBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, false)) { if (prefs.getBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, false)) {
errorTextView.setText(R.string.discover_is_hidden); viewBinding.errorLabel.setText(R.string.discover_is_hidden);
errorView.setVisibility(View.VISIBLE); viewBinding.errorContainer.setVisibility(View.VISIBLE);
discoverGridLayout.setVisibility(View.GONE); viewBinding.discoverGrid.setVisibility(View.GONE);
errorRetry.setVisibility(View.GONE); viewBinding.errorRetryButton.setVisibility(View.GONE);
poweredByTextView.setVisibility(View.GONE); viewBinding.poweredByLabel.setVisibility(View.GONE);
return; return;
} }
//noinspection ConstantConditions //noinspection ConstantConditions
if (BuildConfig.FLAVOR.equals("free") && prefs.getBoolean(ItunesTopListLoader.PREF_KEY_NEEDS_CONFIRM, true)) { if (BuildConfig.FLAVOR.equals("free") && prefs.getBoolean(ItunesTopListLoader.PREF_KEY_NEEDS_CONFIRM, true)) {
errorTextView.setText(""); viewBinding.errorLabel.setText("");
errorView.setVisibility(View.VISIBLE); viewBinding.errorContainer.setVisibility(View.VISIBLE);
discoverGridLayout.setVisibility(View.VISIBLE); viewBinding.discoverGrid.setVisibility(View.VISIBLE);
errorRetry.setVisibility(View.VISIBLE); viewBinding.errorRetryButton.setVisibility(View.VISIBLE);
errorRetry.setText(R.string.discover_confirm); viewBinding.errorRetryButton.setText(R.string.discover_confirm);
poweredByTextView.setVisibility(View.VISIBLE); viewBinding.poweredByLabel.setVisibility(View.VISIBLE);
errorRetry.setOnClickListener(v -> { viewBinding.errorRetryButton.setOnClickListener(v -> {
prefs.edit().putBoolean(ItunesTopListLoader.PREF_KEY_NEEDS_CONFIRM, false).apply(); prefs.edit().putBoolean(ItunesTopListLoader.PREF_KEY_NEEDS_CONFIRM, false).apply();
loadToplist(); loadToplist();
}); });
@ -145,22 +136,22 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe( .subscribe(
podcasts -> { podcasts -> {
errorView.setVisibility(View.GONE); viewBinding.errorContainer.setVisibility(View.GONE);
if (podcasts.size() == 0) { if (podcasts.isEmpty()) {
errorTextView.setText(getResources().getText(R.string.search_status_no_results)); viewBinding.errorLabel.setText(getResources().getText(R.string.search_status_no_results));
errorView.setVisibility(View.VISIBLE); viewBinding.errorContainer.setVisibility(View.VISIBLE);
discoverGridLayout.setVisibility(View.INVISIBLE); viewBinding.discoverGrid.setVisibility(View.INVISIBLE);
} else { } else {
discoverGridLayout.setVisibility(View.VISIBLE); viewBinding.discoverGrid.setVisibility(View.VISIBLE);
adapter.updateData(podcasts); adapter.updateData(podcasts);
} }
}, error -> { }, error -> {
Log.e(TAG, Log.getStackTraceString(error)); Log.e(TAG, Log.getStackTraceString(error));
errorTextView.setText(error.getLocalizedMessage()); viewBinding.errorLabel.setText(error.getLocalizedMessage());
errorView.setVisibility(View.VISIBLE); viewBinding.errorContainer.setVisibility(View.VISIBLE);
discoverGridLayout.setVisibility(View.INVISIBLE); viewBinding.discoverGrid.setVisibility(View.INVISIBLE);
errorRetry.setVisibility(View.VISIBLE); viewBinding.errorRetryButton.setVisibility(View.VISIBLE);
errorRetry.setOnClickListener(v -> loadToplist()); viewBinding.errorRetryButton.setOnClickListener(v -> loadToplist());
}); });
} }

View File

@ -6,32 +6,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="@string/discover"
android:textSize="18sp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
android:accessibilityHeading="true"
android:textColor="?android:attr/textColorPrimary" />
<Button
android:id="@+id/discover_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:minWidth="0dp"
android:text="@string/discover_more"
style="@style/Widget.MaterialComponents.Button.TextButton" />
</LinearLayout>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -49,7 +23,7 @@
android:layout_rowWeight="1" /> android:layout_rowWeight="1" />
<LinearLayout <LinearLayout
android:id="@+id/discover_error" android:id="@+id/errorContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"
@ -57,7 +31,7 @@
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/discover_error_txtV" android:id="@+id/errorLabel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
@ -67,7 +41,7 @@
tools:background="@android:color/holo_red_light" /> tools:background="@android:color/holo_red_light" />
<Button <Button
android:id="@+id/discover_error_retry_btn" android:id="@+id/errorRetryButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16dp" android:layout_margin="16dp"
@ -78,15 +52,30 @@
</RelativeLayout> </RelativeLayout>
<TextView <LinearLayout
android:id="@+id/discover_powered_by_itunes"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="?android:attr/textColorTertiary" android:layout_gravity="center_vertical"
android:text="@string/discover_powered_by_itunes" android:orientation="horizontal">
android:textSize="12sp"
android:layout_gravity="right|end" <TextView
android:paddingHorizontal="4dp" android:id="@+id/poweredByLabel"
android:textAlignment="textEnd" /> android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/discover_powered_by_itunes"
android:paddingHorizontal="4dp"
style="@style/TextAppearance.Material3.BodySmall" />
<Button
android:id="@+id/discover_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="40dp"
android:minWidth="0dp"
android:text="@string/discover_more"
style="@style/Widget.MaterialComponents.Button.TextButton" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -773,13 +773,12 @@
<string name="search_itunes_label">Search Apple Podcasts</string> <string name="search_itunes_label">Search Apple Podcasts</string>
<string name="search_podcastindex_label">Search Podcast Index</string> <string name="search_podcastindex_label">Search Podcast Index</string>
<string name="search_fyyd_label">Search fyyd</string> <string name="search_fyyd_label">Search fyyd</string>
<string name="advanced">Advanced</string>
<string name="add_podcast_by_url">Add podcast by RSS address</string> <string name="add_podcast_by_url">Add podcast by RSS address</string>
<string name="add_podcast_by_url_hint" translatable="false">www.example.com/feed</string> <string name="add_podcast_by_url_hint" translatable="false">www.example.com/feed</string>
<string name="discover">Discover</string> <string name="discover">Discover</string>
<string name="discover_hide">Hide</string> <string name="discover_hide">Hide</string>
<string name="discover_is_hidden">You selected to hide suggestions.</string> <string name="discover_is_hidden">You selected to hide suggestions.</string>
<string name="discover_more">more »</string> <string name="discover_more">Discover more »</string>
<string name="discover_powered_by_itunes">Suggestions by Apple Podcasts</string> <string name="discover_powered_by_itunes">Suggestions by Apple Podcasts</string>
<string name="discover_confirm">Show suggestions</string> <string name="discover_confirm">Show suggestions</string>
<string name="search_powered_by">Results by %1$s</string> <string name="search_powered_by">Results by %1$s</string>