Hide iTunes suggestions by default in F-Droid version
This commit is contained in:
parent
0101f1244e
commit
410b8f1539
|
@ -24,6 +24,7 @@ import com.google.android.material.appbar.MaterialToolbar;
|
||||||
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.BuildConfig;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
|
||||||
private Disposable disposable;
|
private Disposable disposable;
|
||||||
private String countryCode = "US";
|
private String countryCode = "US";
|
||||||
private boolean hidden;
|
private boolean hidden;
|
||||||
|
private boolean needsConfirm;
|
||||||
private MaterialToolbar toolbar;
|
private MaterialToolbar toolbar;
|
||||||
|
|
||||||
public DiscoveryFragment() {
|
public DiscoveryFragment() {
|
||||||
|
@ -102,6 +104,7 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
|
||||||
prefs = getActivity().getSharedPreferences(ItunesTopListLoader.PREFS, Context.MODE_PRIVATE);
|
prefs = getActivity().getSharedPreferences(ItunesTopListLoader.PREFS, Context.MODE_PRIVATE);
|
||||||
countryCode = prefs.getString(ItunesTopListLoader.PREF_KEY_COUNTRY_CODE, Locale.getDefault().getCountry());
|
countryCode = prefs.getString(ItunesTopListLoader.PREF_KEY_COUNTRY_CODE, Locale.getDefault().getCountry());
|
||||||
hidden = prefs.getBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, false);
|
hidden = prefs.getBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, false);
|
||||||
|
needsConfirm = prefs.getBoolean(ItunesTopListLoader.PREF_KEY_NEEDS_CONFIRM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -156,6 +159,7 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
|
||||||
gridView.setVisibility(View.GONE);
|
gridView.setVisibility(View.GONE);
|
||||||
txtvError.setVisibility(View.GONE);
|
txtvError.setVisibility(View.GONE);
|
||||||
butRetry.setVisibility(View.GONE);
|
butRetry.setVisibility(View.GONE);
|
||||||
|
butRetry.setText(R.string.retry_label);
|
||||||
txtvEmpty.setVisibility(View.GONE);
|
txtvEmpty.setVisibility(View.GONE);
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
@ -166,7 +170,24 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
|
||||||
butRetry.setVisibility(View.GONE);
|
butRetry.setVisibility(View.GONE);
|
||||||
txtvEmpty.setVisibility(View.GONE);
|
txtvEmpty.setVisibility(View.GONE);
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
} else {
|
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());
|
ItunesTopListLoader loader = new ItunesTopListLoader(getContext());
|
||||||
disposable = loader.loadToplist(country, 25).subscribe(
|
disposable = loader.loadToplist(country, 25).subscribe(
|
||||||
podcasts -> {
|
podcasts -> {
|
||||||
|
@ -182,7 +203,6 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
|
||||||
butRetry.setVisibility(View.VISIBLE);
|
butRetry.setVisibility(View.VISIBLE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.widget.GridView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.BuildConfig;
|
||||||
import de.danoeh.antennapod.net.discovery.ItunesTopListLoader;
|
import de.danoeh.antennapod.net.discovery.ItunesTopListLoader;
|
||||||
import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
|
import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
@ -61,7 +62,6 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
|
||||||
errorView = root.findViewById(R.id.discover_error);
|
errorView = root.findViewById(R.id.discover_error);
|
||||||
errorTextView = root.findViewById(R.id.discover_error_txtV);
|
errorTextView = root.findViewById(R.id.discover_error_txtV);
|
||||||
errorRetry = root.findViewById(R.id.discover_error_retry_btn);
|
errorRetry = root.findViewById(R.id.discover_error_retry_btn);
|
||||||
errorRetry.setOnClickListener((listener) -> loadToplist());
|
|
||||||
poweredByTextView = root.findViewById(R.id.discover_powered_by_itunes);
|
poweredByTextView = root.findViewById(R.id.discover_powered_by_itunes);
|
||||||
|
|
||||||
adapter = new FeedDiscoverAdapter((MainActivity) getActivity());
|
adapter = new FeedDiscoverAdapter((MainActivity) getActivity());
|
||||||
|
@ -108,14 +108,14 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
|
||||||
private void loadToplist() {
|
private void loadToplist() {
|
||||||
errorView.setVisibility(View.GONE);
|
errorView.setVisibility(View.GONE);
|
||||||
errorRetry.setVisibility(View.INVISIBLE);
|
errorRetry.setVisibility(View.INVISIBLE);
|
||||||
|
errorRetry.setText(R.string.retry_label);
|
||||||
poweredByTextView.setVisibility(View.VISIBLE);
|
poweredByTextView.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());
|
||||||
boolean hidden = prefs.getBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, false);
|
if (prefs.getBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, false)) {
|
||||||
if (hidden) {
|
|
||||||
errorTextView.setText(R.string.discover_is_hidden);
|
errorTextView.setText(R.string.discover_is_hidden);
|
||||||
errorView.setVisibility(View.VISIBLE);
|
errorView.setVisibility(View.VISIBLE);
|
||||||
discoverGridLayout.setVisibility(View.GONE);
|
discoverGridLayout.setVisibility(View.GONE);
|
||||||
|
@ -123,6 +123,20 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
|
||||||
poweredByTextView.setVisibility(View.GONE);
|
poweredByTextView.setVisibility(View.GONE);
|
||||||
return;
|
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)
|
disposable = loader.loadToplist(countryCode, NUM_SUGGESTIONS)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
|
@ -142,6 +156,7 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
|
||||||
errorView.setVisibility(View.VISIBLE);
|
errorView.setVisibility(View.VISIBLE);
|
||||||
discoverGridLayout.setVisibility(View.INVISIBLE);
|
discoverGridLayout.setVisibility(View.INVISIBLE);
|
||||||
errorRetry.setVisibility(View.VISIBLE);
|
errorRetry.setVisibility(View.VISIBLE);
|
||||||
|
errorRetry.setOnClickListener((listener) -> loadToplist());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class ItunesTopListLoader {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
public static final String PREF_KEY_COUNTRY_CODE = "country_code";
|
public static final String PREF_KEY_COUNTRY_CODE = "country_code";
|
||||||
public static final String PREF_KEY_HIDDEN_DISCOVERY_COUNTRY = "hidden_discovery_country";
|
public static final String PREF_KEY_HIDDEN_DISCOVERY_COUNTRY = "hidden_discovery_country";
|
||||||
|
public static final String PREF_KEY_NEEDS_CONFIRM = "needs_confirm";
|
||||||
public static final String PREFS = "CountryRegionPrefs";
|
public static final String PREFS = "CountryRegionPrefs";
|
||||||
public static final String COUNTRY_CODE_UNSET = "99";
|
public static final String COUNTRY_CODE_UNSET = "99";
|
||||||
|
|
||||||
|
|
|
@ -724,6 +724,7 @@
|
||||||
<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">more »</string>
|
||||||
<string name="discover_powered_by_itunes">Suggestions by iTunes</string>
|
<string name="discover_powered_by_itunes">Suggestions by iTunes</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>
|
||||||
<string name="country">Country</string>
|
<string name="country">Country</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue