summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2022-11-06 21:43:20 +0100
committerByteHamster <info@bytehamster.com>2022-11-06 21:43:20 +0100
commit410b8f1539b8b9397577312c28bf87ed5fd15d62 (patch)
tree4934bf6004832e99b2d5498a4b4bf3dfba17f778 /app
parent0101f1244ebe088edbe000b1966a92ca4994023a (diff)
downloadAntennaPod-410b8f1539b8b9397577312c28bf87ed5fd15d62.zip
Hide iTunes suggestions by default in F-Droid version
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/DiscoveryFragment.java50
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/QuickFeedDiscoveryFragment.java21
2 files changed, 53 insertions, 18 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DiscoveryFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DiscoveryFragment.java
index a6db1e46b..c87a43a9c 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/DiscoveryFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/DiscoveryFragment.java
@@ -24,6 +24,7 @@ import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
import com.google.android.material.textfield.TextInputLayout;
+import de.danoeh.antennapod.core.BuildConfig;
import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
@@ -69,6 +70,7 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
private Disposable disposable;
private String countryCode = "US";
private boolean hidden;
+ private boolean needsConfirm;
private MaterialToolbar toolbar;
public DiscoveryFragment() {
@@ -102,6 +104,7 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
prefs = getActivity().getSharedPreferences(ItunesTopListLoader.PREFS, Context.MODE_PRIVATE);
countryCode = prefs.getString(ItunesTopListLoader.PREF_KEY_COUNTRY_CODE, Locale.getDefault().getCountry());
hidden = prefs.getBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, false);
+ needsConfirm = prefs.getBoolean(ItunesTopListLoader.PREF_KEY_NEEDS_CONFIRM, true);
}
@Override
@@ -156,6 +159,7 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
gridView.setVisibility(View.GONE);
txtvError.setVisibility(View.GONE);
butRetry.setVisibility(View.GONE);
+ butRetry.setText(R.string.retry_label);
txtvEmpty.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
@@ -166,22 +170,38 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
butRetry.setVisibility(View.GONE);
txtvEmpty.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
- } else {
- ItunesTopListLoader loader = new ItunesTopListLoader(getContext());
- disposable = loader.loadToplist(country, 25).subscribe(
- podcasts -> {
- progressBar.setVisibility(View.GONE);
- topList = podcasts;
- updateData(topList);
- }, error -> {
- Log.e(TAG, Log.getStackTraceString(error));
- progressBar.setVisibility(View.GONE);
- txtvError.setText(error.getMessage());
- txtvError.setVisibility(View.VISIBLE);
- butRetry.setOnClickListener(v -> loadToplist(country));
- butRetry.setVisibility(View.VISIBLE);
- });
+ return;
}
+ //noinspection ConstantConditions
+ if (BuildConfig.FLAVOR.equals("free") && needsConfirm) {
+ txtvError.setVisibility(View.VISIBLE);
+ txtvError.setText("");
+ butRetry.setVisibility(View.VISIBLE);
+ butRetry.setText(R.string.discover_confirm);
+ butRetry.setOnClickListener(v -> {
+ prefs.edit().putBoolean(ItunesTopListLoader.PREF_KEY_NEEDS_CONFIRM, false).apply();
+ needsConfirm = false;
+ loadToplist(country);
+ });
+ txtvEmpty.setVisibility(View.GONE);
+ progressBar.setVisibility(View.GONE);
+ return;
+ }
+
+ ItunesTopListLoader loader = new ItunesTopListLoader(getContext());
+ disposable = loader.loadToplist(country, 25).subscribe(
+ podcasts -> {
+ progressBar.setVisibility(View.GONE);
+ topList = podcasts;
+ updateData(topList);
+ }, error -> {
+ Log.e(TAG, Log.getStackTraceString(error));
+ progressBar.setVisibility(View.GONE);
+ txtvError.setText(error.getMessage());
+ txtvError.setVisibility(View.VISIBLE);
+ butRetry.setOnClickListener(v -> loadToplist(country));
+ butRetry.setVisibility(View.VISIBLE);
+ });
}
@Override
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QuickFeedDiscoveryFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QuickFeedDiscoveryFragment.java
index 37bdc3c9e..acdd1e1c7 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/QuickFeedDiscoveryFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/QuickFeedDiscoveryFragment.java
@@ -17,6 +17,7 @@ import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.net.discovery.ItunesTopListLoader;
import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
import org.greenrobot.eventbus.EventBus;
@@ -61,7 +62,6 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
errorView = root.findViewById(R.id.discover_error);
errorTextView = root.findViewById(R.id.discover_error_txtV);
errorRetry = root.findViewById(R.id.discover_error_retry_btn);
- errorRetry.setOnClickListener((listener) -> loadToplist());
poweredByTextView = root.findViewById(R.id.discover_powered_by_itunes);
adapter = new FeedDiscoverAdapter((MainActivity) getActivity());
@@ -108,14 +108,14 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
private void loadToplist() {
errorView.setVisibility(View.GONE);
errorRetry.setVisibility(View.INVISIBLE);
+ errorRetry.setText(R.string.retry_label);
poweredByTextView.setVisibility(View.VISIBLE);
ItunesTopListLoader loader = new ItunesTopListLoader(getContext());
SharedPreferences prefs = getActivity().getSharedPreferences(ItunesTopListLoader.PREFS, MODE_PRIVATE);
String countryCode = prefs.getString(ItunesTopListLoader.PREF_KEY_COUNTRY_CODE,
Locale.getDefault().getCountry());
- boolean hidden = prefs.getBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, false);
- if (hidden) {
+ if (prefs.getBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, false)) {
errorTextView.setText(R.string.discover_is_hidden);
errorView.setVisibility(View.VISIBLE);
discoverGridLayout.setVisibility(View.GONE);
@@ -123,6 +123,20 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
poweredByTextView.setVisibility(View.GONE);
return;
}
+ //noinspection ConstantConditions
+ if (BuildConfig.FLAVOR.equals("free") && prefs.getBoolean(ItunesTopListLoader.PREF_KEY_NEEDS_CONFIRM, true)) {
+ errorTextView.setText("");
+ errorView.setVisibility(View.VISIBLE);
+ discoverGridLayout.setVisibility(View.VISIBLE);
+ errorRetry.setVisibility(View.VISIBLE);
+ errorRetry.setText(R.string.discover_confirm);
+ poweredByTextView.setVisibility(View.VISIBLE);
+ errorRetry.setOnClickListener(v -> {
+ prefs.edit().putBoolean(ItunesTopListLoader.PREF_KEY_NEEDS_CONFIRM, false).apply();
+ loadToplist();
+ });
+ return;
+ }
disposable = loader.loadToplist(countryCode, NUM_SUGGESTIONS)
.subscribe(
@@ -142,6 +156,7 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
errorView.setVisibility(View.VISIBLE);
discoverGridLayout.setVisibility(View.INVISIBLE);
errorRetry.setVisibility(View.VISIBLE);
+ errorRetry.setOnClickListener((listener) -> loadToplist());
});
}