summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle1
-rw-r--r--app/src/main/AndroidManifest.xml4
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java27
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java36
-rw-r--r--app/src/main/java/de/danoeh/antennapod/adapter/FeedDiscoverAdapter.java81
-rw-r--r--app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java125
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java8
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/DiscoveryFragment.java282
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java225
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/QuickFeedDiscoveryFragment.java178
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java8
-rw-r--r--app/src/main/res/layout/addfeed.xml2
-rw-r--r--app/src/main/res/layout/fragment_itunes_search.xml101
-rw-r--r--app/src/main/res/layout/itunes_podcast_listitem.xml59
-rw-r--r--app/src/main/res/layout/quick_feed_discovery.xml93
-rw-r--r--app/src/main/res/layout/quick_feed_discovery_item.xml21
-rw-r--r--app/src/main/res/layout/select_country_dialog.xml24
-rw-r--r--app/src/main/res/menu/countries_menu.xml17
-rw-r--r--app/src/main/res/menu/online_search.xml12
19 files changed, 42 insertions, 1262 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 6cbc9e64f..02031b9e1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -90,6 +90,7 @@ dependencies {
implementation project(':storage:preferences')
implementation project(':ui:app-start-intent')
implementation project(':ui:common')
+ implementation project(':ui:discovery')
implementation project(':ui:echo')
implementation project(':ui:episodes')
implementation project(':ui:glide')
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8bbe4cdb9..b4323f782 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -305,6 +305,10 @@
<data android:mimeType="text/plain"/>
</intent-filter>
+ <intent-filter>
+ <category android:name="android.intent.category.DEFAULT" />
+ <action android:name="de.danoeh.antennapod.intents.ONLINE_FEEDVIEW" />
+ </intent-filter>
</activity>
<activity android:name=".activity.SelectSubscriptionActivity"
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java
index 3c867b88c..f7bfbce7b 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java
@@ -63,6 +63,7 @@ import de.danoeh.antennapod.storage.importexport.AutomaticDatabaseExportWorker;
import de.danoeh.antennapod.storage.preferences.UserPreferences;
import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter;
import de.danoeh.antennapod.ui.common.ThemeUtils;
+import de.danoeh.antennapod.ui.discovery.DiscoveryFragment;
import de.danoeh.antennapod.ui.home.HomeFragment;
import de.danoeh.antennapod.view.LockableBottomSheetBehavior;
import org.apache.commons.lang3.ArrayUtils;
@@ -87,7 +88,6 @@ public class MainActivity extends CastEnabledActivity {
public static final String EXTRA_FEED_ID = "fragment_feed_id";
public static final String EXTRA_REFRESH_ON_START = "refresh_on_start";
- public static final String EXTRA_STARTED_FROM_SEARCH = "started_from_search";
public static final String EXTRA_ADD_TO_BACK_STACK = "add_to_back_stack";
public static final String KEY_GENERATED_VIEW_ID = "generated_view_id";
@@ -347,7 +347,7 @@ public class MainActivity extends CastEnabledActivity {
return recycledViewPool;
}
- public void loadFragment(String tag, Bundle args) {
+ public Fragment createFragmentInstance(String tag, Bundle args) {
Log.d(TAG, "loadFragment(tag: " + tag + ", args: " + args + ")");
Fragment fragment;
switch (tag) {
@@ -375,19 +375,24 @@ public class MainActivity extends CastEnabledActivity {
case SubscriptionFragment.TAG:
fragment = new SubscriptionFragment();
break;
+ case DiscoveryFragment.TAG:
+ fragment = new DiscoveryFragment();
+ break;
default:
// default to home screen
fragment = new HomeFragment();
- tag = HomeFragment.TAG;
args = null;
break;
}
-
if (args != null) {
fragment.setArguments(args);
}
+ return fragment;
+ }
+
+ public void loadFragment(String tag, Bundle args) {
NavDrawerFragment.saveLastNavFragment(this, tag);
- loadFragment(fragment);
+ loadFragment(createFragmentInstance(tag, args));
}
public void loadFeedFragmentById(long feedId, Bundle args) {
@@ -399,7 +404,7 @@ public class MainActivity extends CastEnabledActivity {
loadFragment(fragment);
}
- private void loadFragment(Fragment fragment) {
+ public void loadFragment(Fragment fragment) {
FragmentManager fragmentManager = getSupportFragmentManager();
// clear back stack
for (int i = 0; i < fragmentManager.getBackStackEntryCount(); i++) {
@@ -591,9 +596,8 @@ public class MainActivity extends CastEnabledActivity {
long feedId = intent.getLongExtra(EXTRA_FEED_ID, 0);
Bundle args = intent.getBundleExtra(MainActivityStarter.EXTRA_FRAGMENT_ARGS);
if (feedId > 0) {
- boolean startedFromSearch = intent.getBooleanExtra(EXTRA_STARTED_FROM_SEARCH, false);
boolean addToBackStack = intent.getBooleanExtra(EXTRA_ADD_TO_BACK_STACK, false);
- if (startedFromSearch || addToBackStack) {
+ if (addToBackStack) {
loadChildFragment(FeedItemlistFragment.newInstance(feedId));
} else {
loadFeedFragmentById(feedId, args);
@@ -604,7 +608,12 @@ public class MainActivity extends CastEnabledActivity {
String tag = intent.getStringExtra(MainActivityStarter.EXTRA_FRAGMENT_TAG);
Bundle args = intent.getBundleExtra(MainActivityStarter.EXTRA_FRAGMENT_ARGS);
if (tag != null) {
- loadFragment(tag, args);
+ Fragment fragment = createFragmentInstance(tag, args);
+ if (intent.getBooleanExtra(MainActivityStarter.EXTRA_ADD_TO_BACK_STACK, false)) {
+ loadChildFragment(fragment);
+ } else {
+ loadFragment(fragment);
+ }
}
sheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
} else if (intent.getBooleanExtra(MainActivityStarter.EXTRA_OPEN_PLAYER, false)) {
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java
index 72c200231..3a9fc9b46 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java
@@ -12,7 +12,6 @@ import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
-import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
@@ -23,13 +22,13 @@ import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.app.NavUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter;
+import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter;
import de.danoeh.antennapod.ui.common.ThemeSwitcher;
import de.danoeh.antennapod.core.service.download.DownloadRequestCreator;
import de.danoeh.antennapod.net.discovery.FeedUrlNotFoundException;
@@ -85,6 +84,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import static de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter.ARG_FEEDURL;
+import static de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter.ARG_STARTED_FROM_SEARCH;
+import static de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter.ARG_WAS_MANUAL_URL;
+
/**
* Downloads a feed from a feed URL and parses it. Subclasses can display the
* feed object that was parsed. This activity MUST be started with a given URL
@@ -95,8 +98,6 @@ import java.util.Map;
*/
public class OnlineFeedViewActivity extends AppCompatActivity {
- public static final String ARG_FEEDURL = "arg.feedurl";
- public static final String ARG_WAS_MANUAL_URL = "manual_url";
private static final int RESULT_ERROR = 2;
private static final String TAG = "OnlineFeedViewActivity";
private static final String PREFS = "OnlineFeedViewActivityPreferences";
@@ -236,20 +237,6 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- Intent destIntent = new Intent(this, MainActivity.class);
- if (NavUtils.shouldUpRecreateTask(this, destIntent)) {
- startActivity(destIntent);
- } else {
- NavUtils.navigateUpFromSameTask(this);
- }
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
private void lookupUrlAndDownload(String url) {
download = PodcastSearcherRegistry.lookupUrl(url)
.subscribeOn(Schedulers.io())
@@ -521,13 +508,14 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
}
private void openFeed() {
- // feed.getId() is always 0, we have to retrieve the id from the feed list from
- // the database
- Intent intent = MainActivity.getIntentToOpenFeed(this, getFeedId());
- intent.putExtra(MainActivity.EXTRA_STARTED_FROM_SEARCH,
- getIntent().getBooleanExtra(MainActivity.EXTRA_STARTED_FROM_SEARCH, false));
+ // feed.getId() is always 0, we have to retrieve the id from the feed list from the database
+ MainActivityStarter mainActivityStarter = new MainActivityStarter(this);
+ mainActivityStarter.withOpenFeed(getFeedId());
+ if (getIntent().getBooleanExtra(ARG_STARTED_FROM_SEARCH, false)) {
+ mainActivityStarter.withAddToBackStack();
+ }
finish();
- startActivity(intent);
+ startActivity(mainActivityStarter.getIntent());
}
private void handleUpdatedFeedStatus() {
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/FeedDiscoverAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/FeedDiscoverAdapter.java
deleted file mode 100644
index 5e2c091e9..000000000
--- a/app/src/main/java/de/danoeh/antennapod/adapter/FeedDiscoverAdapter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package de.danoeh.antennapod.adapter;
-
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.resource.bitmap.FitCenter;
-import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
-import com.bumptech.glide.request.RequestOptions;
-import de.danoeh.antennapod.R;
-import de.danoeh.antennapod.activity.MainActivity;
-import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.List;
-
-public class FeedDiscoverAdapter extends BaseAdapter {
-
- private final WeakReference<MainActivity> mainActivityRef;
- private final List<PodcastSearchResult> data = new ArrayList<>();
-
- public FeedDiscoverAdapter(MainActivity mainActivity) {
- this.mainActivityRef = new WeakReference<>(mainActivity);
- }
-
- public void updateData(List<PodcastSearchResult> newData) {
- data.clear();
- data.addAll(newData);
- notifyDataSetChanged();
- }
-
- @Override
- public int getCount() {
- return data.size();
- }
-
- @Override
- public PodcastSearchResult getItem(int position) {
- return data.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return 0;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- Holder holder;
-
- if (convertView == null) {
- convertView = View.inflate(mainActivityRef.get(), R.layout.quick_feed_discovery_item, null);
- holder = new Holder();
- holder.imageView = convertView.findViewById(R.id.discovery_cover);
- convertView.setTag(holder);
- } else {
- holder = (Holder) convertView.getTag();
- }
-
-
- final PodcastSearchResult podcast = getItem(position);
- holder.imageView.setContentDescription(podcast.title);
-
- Glide.with(mainActivityRef.get())
- .load(podcast.imageUrl)
- .apply(new RequestOptions()
- .placeholder(R.color.light_gray)
- .transform(new FitCenter(), new RoundedCorners((int)
- (8 * mainActivityRef.get().getResources().getDisplayMetrics().density)))
- .dontAnimate())
- .into(holder.imageView);
-
- return convertView;
- }
-
- static class Holder {
- ImageView imageView;
- }
-}
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java
deleted file mode 100644
index 9b514dd98..000000000
--- a/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package de.danoeh.antennapod.adapter.itunes;
-
-import android.content.Context;
-import android.widget.ArrayAdapter;
-import androidx.annotation.NonNull;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-
-import com.bumptech.glide.load.resource.bitmap.FitCenter;
-import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
-import com.bumptech.glide.request.RequestOptions;
-
-import java.util.List;
-
-import de.danoeh.antennapod.R;
-import de.danoeh.antennapod.activity.MainActivity;
-import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
-
-public class ItunesAdapter extends ArrayAdapter<PodcastSearchResult> {
- /**
- * Related Context
- */
- private final Context context;
-
- /**
- * List holding the podcasts found in the search
- */
- private final List<PodcastSearchResult> data;
-
- /**
- * Constructor.
- *
- * @param context Related context
- * @param objects Search result
- */
- public ItunesAdapter(Context context, List<PodcastSearchResult> objects) {
- super(context, 0, objects);
- this.data = objects;
- this.context = context;
- }
-
- @NonNull
- @Override
- public View getView(int position, View convertView, @NonNull ViewGroup parent) {
- //Current podcast
- PodcastSearchResult podcast = data.get(position);
-
- //ViewHolder
- PodcastViewHolder viewHolder;
-
- //Resulting view
- View view;
-
- //Handle view holder stuff
- if(convertView == null) {
- view = ((MainActivity) context).getLayoutInflater()
- .inflate(R.layout.itunes_podcast_listitem, parent, false);
- viewHolder = new PodcastViewHolder(view);
- view.setTag(viewHolder);
- } else {
- view = convertView;
- viewHolder = (PodcastViewHolder) view.getTag();
- }
-
- // Set the title
- viewHolder.titleView.setText(podcast.title);
- if (podcast.author != null && ! podcast.author.trim().isEmpty()) {
- viewHolder.authorView.setText(podcast.author);
- viewHolder.authorView.setVisibility(View.VISIBLE);
- } else if (podcast.feedUrl != null && !podcast.feedUrl.contains("itunes.apple.com")) {
- viewHolder.authorView.setText(podcast.feedUrl);
- viewHolder.authorView.setVisibility(View.VISIBLE);
- } else {
- viewHolder.authorView.setVisibility(View.GONE);
- }
-
- //Update the empty imageView with the image from the feed
- Glide.with(context)
- .load(podcast.imageUrl)
- .apply(new RequestOptions()
- .placeholder(R.color.light_gray)
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .transform(new FitCenter(),
- new RoundedCorners((int) (4 * context.getResources().getDisplayMetrics().density)))
- .dontAnimate())
- .into(viewHolder.coverView);
-
- //Feed the grid view
- return view;
- }
-
- /**
- * View holder object for the GridView
- */
- static class PodcastViewHolder {
-
- /**
- * ImageView holding the Podcast image
- */
- final ImageView coverView;
-
- /**
- * TextView holding the Podcast title
- */
- final TextView titleView;
-
- final TextView authorView;
-
-
- /**
- * Constructor
- * @param view GridView cell
- */
- PodcastViewHolder(View view){
- coverView = view.findViewById(R.id.imgvCover);
- titleView = view.findViewById(R.id.txtvTitle);
- authorView = view.findViewById(R.id.txtvAuthor);
- }
- }
-}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java
index 5074c5b64..1ec917176 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java
@@ -25,7 +25,6 @@ import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
-import de.danoeh.antennapod.activity.OnlineFeedViewActivity;
import de.danoeh.antennapod.activity.OpmlImportActivity;
import de.danoeh.antennapod.core.util.download.FeedUpdateManager;
import de.danoeh.antennapod.model.feed.Feed;
@@ -38,6 +37,8 @@ import de.danoeh.antennapod.net.discovery.FyydPodcastSearcher;
import de.danoeh.antennapod.net.discovery.GpodnetPodcastSearcher;
import de.danoeh.antennapod.net.discovery.ItunesPodcastSearcher;
import de.danoeh.antennapod.net.discovery.PodcastIndexPodcastSearcher;
+import de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter;
+import de.danoeh.antennapod.ui.discovery.OnlineSearchFragment;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
@@ -145,10 +146,7 @@ public class AddFeedFragment extends Fragment {
}
private void addUrl(String url) {
- Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class);
- intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, url);
- intent.putExtra(OnlineFeedViewActivity.ARG_WAS_MANUAL_URL, true);
- startActivity(intent);
+ startActivity(new OnlineFeedviewActivityStarter(getContext(), url).withManualUrl().getIntent());
}
private void performSearch() {
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DiscoveryFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DiscoveryFragment.java
deleted file mode 100644
index f7d9710d7..000000000
--- a/app/src/main/java/de/danoeh/antennapod/fragment/DiscoveryFragment.java
+++ /dev/null
@@ -1,282 +0,0 @@
-package de.danoeh.antennapod.fragment;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.GridView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.Toolbar;
-import androidx.fragment.app.Fragment;
-import com.google.android.material.appbar.MaterialToolbar;
-import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import com.google.android.material.textfield.MaterialAutoCompleteTextView;
-import com.google.android.material.textfield.TextInputLayout;
-import de.danoeh.antennapod.R;
-import de.danoeh.antennapod.activity.OnlineFeedViewActivity;
-import de.danoeh.antennapod.adapter.itunes.ItunesAdapter;
-import de.danoeh.antennapod.core.BuildConfig;
-import de.danoeh.antennapod.storage.database.DBReader;
-import de.danoeh.antennapod.event.DiscoveryDefaultUpdateEvent;
-import de.danoeh.antennapod.net.discovery.ItunesTopListLoader;
-import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
-import io.reactivex.Observable;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.disposables.Disposable;
-import io.reactivex.schedulers.Schedulers;
-import org.greenrobot.eventbus.EventBus;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * Searches iTunes store for top podcasts and displays results in a list.
- */
-public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemClickListener {
-
- private static final String TAG = "ItunesSearchFragment";
- private static final int NUM_OF_TOP_PODCASTS = 25;
- private SharedPreferences prefs;
-
- /**
- * Adapter responsible with the search results.
- */
- private ItunesAdapter adapter;
- private GridView gridView;
- private ProgressBar progressBar;
- private TextView txtvError;
- private Button butRetry;
- private TextView txtvEmpty;
-
- /**
- * List of podcasts retreived from the search.
- */
- private List<PodcastSearchResult> searchResults;
- private List<PodcastSearchResult> topList;
- private Disposable disposable;
- private String countryCode = "US";
- private boolean hidden;
- private boolean needsConfirm;
- private MaterialToolbar toolbar;
-
- public DiscoveryFragment() {
- // Required empty public constructor
- }
-
- /**
- * Replace adapter data with provided search results from SearchTask.
- *
- * @param result List of Podcast objects containing search results
- */
- private void updateData(List<PodcastSearchResult> result) {
- this.searchResults = result;
- adapter.clear();
- if (result != null && result.size() > 0) {
- gridView.setVisibility(View.VISIBLE);
- txtvEmpty.setVisibility(View.GONE);
- for (PodcastSearchResult p : result) {
- adapter.add(p);
- }
- adapter.notifyDataSetInvalidated();
- } else {
- gridView.setVisibility(View.GONE);
- txtvEmpty.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- 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
- public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View root = inflater.inflate(R.layout.fragment_itunes_search, container, false);
- gridView = root.findViewById(R.id.gridView);
- adapter = new ItunesAdapter(getActivity(), new ArrayList<>());
- gridView.setAdapter(adapter);
-
- toolbar = root.findViewById(R.id.toolbar);
- toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());
- toolbar.inflateMenu(R.menu.countries_menu);
- MenuItem discoverHideItem = toolbar.getMenu().findItem(R.id.discover_hide_item);
- discoverHideItem.setChecked(hidden);
- toolbar.setOnMenuItemClickListener(this);
-
- //Show information about the podcast when the list item is clicked
- gridView.setOnItemClickListener((parent, view1, position, id) -> {
- PodcastSearchResult podcast = searchResults.get(position);
- if (podcast.feedUrl == null) {
- return;
- }
- Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class);
- intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, podcast.feedUrl);
- startActivity(intent);
- });
-
- progressBar = root.findViewById(R.id.progressBar);
- txtvError = root.findViewById(R.id.txtvError);
- butRetry = root.findViewById(R.id.butRetry);
- txtvEmpty = root.findViewById(android.R.id.empty);
-
- loadToplist(countryCode);
- return root;
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- if (disposable != null) {
- disposable.dispose();
- }
- adapter = null;
- }
-
- private void loadToplist(String country) {
- if (disposable != null) {
- disposable.dispose();
- }
-
- 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);
-
- if (hidden) {
- gridView.setVisibility(View.GONE);
- txtvError.setVisibility(View.VISIBLE);
- txtvError.setText(getResources().getString(R.string.discover_is_hidden));
- butRetry.setVisibility(View.GONE);
- txtvEmpty.setVisibility(View.GONE);
- progressBar.setVisibility(View.GONE);
- 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 = Observable.fromCallable(() ->
- loader.loadToplist(country, NUM_OF_TOP_PODCASTS, DBReader.getFeedList()))
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .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
- public boolean onMenuItemClick(MenuItem item) {
- final int itemId = item.getItemId();
- if (itemId == R.id.discover_hide_item) {
- item.setChecked(!item.isChecked());
- hidden = item.isChecked();
- prefs.edit().putBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, hidden).apply();
-
- EventBus.getDefault().post(new DiscoveryDefaultUpdateEvent());
- loadToplist(countryCode);
- return true;
- } else if (itemId == R.id.discover_countries_item) {
-
- LayoutInflater inflater = getLayoutInflater();
- View selectCountryDialogView = inflater.inflate(R.layout.select_country_dialog, null);
- MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
- builder.setView(selectCountryDialogView);
-
- List<String> countryCodeArray = new ArrayList<>(Arrays.asList(Locale.getISOCountries()));
- Map<String, String> countryCodeNames = new HashMap<>();
- Map<String, String> countryNameCodes = new HashMap<>();
- for (String code : countryCodeArray) {
- Locale locale = new Locale("", code);
- String countryName = locale.getDisplayCountry();
- countryCodeNames.put(code, countryName);
- countryNameCodes.put(countryName, code);
- }
-
- List<String> countryNamesSort = new ArrayList<>(countryCodeNames.values());
- Collections.sort(countryNamesSort);
-
- ArrayAdapter<String> dataAdapter =
- new ArrayAdapter<>(this.getContext(), android.R.layout.simple_list_item_1, countryNamesSort);
- TextInputLayout textInput = selectCountryDialogView.findViewById(R.id.country_text_input);
- MaterialAutoCompleteTextView editText = (MaterialAutoCompleteTextView) textInput.getEditText();
- editText.setAdapter(dataAdapter);
- editText.setText(countryCodeNames.get(countryCode));
- editText.setOnClickListener(view -> {
- if (editText.getText().length() != 0) {
- editText.setText("");
- editText.postDelayed(editText::showDropDown, 100);
- }
- });
- editText.setOnFocusChangeListener((v, hasFocus) -> {
- if (hasFocus) {
- editText.setText("");
- editText.postDelayed(editText::showDropDown, 100);
- }
- });
-
- builder.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
- String countryName = editText.getText().toString();
- if (countryNameCodes.containsKey(countryName)) {
- countryCode = countryNameCodes.get(countryName);
- MenuItem discoverHideItem = toolbar.getMenu().findItem(R.id.discover_hide_item);
- discoverHideItem.setChecked(false);
- hidden = false;
- }
-
- prefs.edit().putBoolean(ItunesTopListLoader.PREF_KEY_HIDDEN_DISCOVERY_COUNTRY, hidden).apply();
- prefs.edit().putString(ItunesTopListLoader.PREF_KEY_COUNTRY_CODE, countryCode).apply();
-
- EventBus.getDefault().post(new DiscoveryDefaultUpdateEvent());
- loadToplist(countryCode);
- });
- builder.setNegativeButton(R.string.cancel_label, null);
- builder.show();
- return true;
- }
- return false;
- }
-}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java
deleted file mode 100644
index 9e34c0a27..000000000
--- a/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java
+++ /dev/null
@@ -1,225 +0,0 @@
-package de.danoeh.antennapod.fragment;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.AbsListView;
-import android.widget.Button;
-import android.widget.GridView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import androidx.appcompat.widget.SearchView;
-import androidx.fragment.app.Fragment;
-
-import com.google.android.material.appbar.MaterialToolbar;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import de.danoeh.antennapod.R;
-import de.danoeh.antennapod.activity.MainActivity;
-import de.danoeh.antennapod.activity.OnlineFeedViewActivity;
-import de.danoeh.antennapod.adapter.itunes.ItunesAdapter;
-import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
-import de.danoeh.antennapod.net.discovery.PodcastSearcher;
-import de.danoeh.antennapod.net.discovery.PodcastSearcherRegistry;
-import io.reactivex.disposables.Disposable;
-
-public class OnlineSearchFragment extends Fragment {
-
- private static final String TAG = "FyydSearchFragment";
- private static final String ARG_SEARCHER = "searcher";
- private static final String ARG_QUERY = "query";
-
- /**
- * Adapter responsible with the search results
- */
- private ItunesAdapter adapter;
- private PodcastSearcher searchProvider;
- private GridView gridView;
- private ProgressBar progressBar;
- private TextView txtvError;
- private Button butRetry;
- private TextView txtvEmpty;
-
- /**
- * List of podcasts retreived from the search
- */
- private List<PodcastSearchResult> searchResults;
- private Disposable disposable;
-
- public static OnlineSearchFragment newInstance(Class<? extends PodcastSearcher> searchProvider) {
- return newInstance(searchProvider, null);
- }
-
- public static OnlineSearchFragment newInstance(Class<? extends PodcastSearcher> searchProvider, String query) {
- OnlineSearchFragment fragment = new OnlineSearchFragment();
- Bundle arguments = new Bundle();
- arguments.putString(ARG_SEARCHER, searchProvider.getName());
- arguments.putString(ARG_QUERY, query);
- fragment.setArguments(arguments);
- return fragment;
- }
-
- /**
- * Constructor
- */
- public OnlineSearchFragment() {
- // Required empty public constructor
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- for (PodcastSearcherRegistry.SearcherInfo info : PodcastSearcherRegistry.getSearchProviders()) {
- if (info.searcher.getClass().getName().equals(getArguments().getString(ARG_SEARCHER))) {
- searchProvider = info.searcher;
- break;
- }
- }
- if (searchProvider == null) {
- throw new IllegalArgumentException("Podcast searcher not found");
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View root = inflater.inflate(R.layout.fragment_itunes_search, container, false);
- gridView = root.findViewById(R.id.gridView);
- adapter = new ItunesAdapter(getActivity(), new ArrayList<>());
- gridView.setAdapter(adapter);
-
- //Show information about the podcast when the list item is clicked
- gridView.setOnItemClickListener((parent, view1, position, id) -> {
- PodcastSearchResult podcast = searchResults.get(position);
- Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class);
- intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, podcast.feedUrl);
- intent.putExtra(MainActivity.EXTRA_STARTED_FROM_SEARCH, true);
- startActivity(intent);
- });
- progressBar = root.findViewById(R.id.progressBar);
- txtvError = root.findViewById(R.id.txtvError);
- butRetry = root.findViewById(R.id.butRetry);
- txtvEmpty = root.findViewById(android.R.id.empty);
- TextView txtvPoweredBy = root.findViewById(R.id.search_powered_by);
- txtvPoweredBy.setText(getString(R.string.search_powered_by, searchProvider.getName()));
- setupToolbar(root.findViewById(R.id.toolbar));
-
- gridView.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {
- if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
- InputMethodManager imm = (InputMethodManager)
- getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
- }
- }
-
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- }
- });
- return root;
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- if (disposable != null) {
- disposable.dispose();
- }
- adapter = null;
- }
-
- private void setupToolbar(MaterialToolbar toolbar) {
- toolbar.inflateMenu(R.menu.online_search);
- toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());
-
- MenuItem searchItem = toolbar.getMenu().findItem(R.id.action_search);
- final SearchView sv = (SearchView) searchItem.getActionView();
- sv.setQueryHint(getString(R.string.search_podcast_hint));
- sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
- @Override
- public boolean onQueryTextSubmit(String s) {
- sv.clearFocus();
- search(s);
- return true;
- }
-
- @Override
- public boolean onQueryTextChange(String s) {
- return false;
- }
- });
- sv.setOnQueryTextFocusChangeListener((view, hasFocus) -> {
- if (hasFocus) {
- showInputMethod(view.findFocus());
- }
- });
- searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
- @Override
- public boolean onMenuItemActionExpand(MenuItem item) {
- return true;
- }
-
- @Override
- public boolean onMenuItemActionCollapse(MenuItem item) {
- getActivity().getSupportFragmentManager().popBackStack();
- return true;
- }
- });
- searchItem.expandActionView();
-
- if (getArguments().getString(ARG_QUERY, null) != null) {
- sv.setQuery(getArguments().getString(ARG_QUERY, null), true);
- }
- }
-
- private void search(String query) {
- if (disposable != null) {
- disposable.dispose();
- }
- showOnlyProgressBar();
- disposable = searchProvider.search(query).subscribe(result -> {
- searchResults = result;
- progressBar.setVisibility(View.GONE);
- adapter.clear();
- adapter.addAll(searchResults);
- adapter.notifyDataSetInvalidated();
- gridView.setVisibility(!searchResults.isEmpty() ? View.VISIBLE : View.GONE);
- txtvEmpty.setVisibility(searchResults.isEmpty() ? View.VISIBLE : View.GONE);
- txtvEmpty.setText(getString(R.string.no_results_for_query, query));
- }, error -> {
- Log.e(TAG, Log.getStackTraceString(error));
- progressBar.setVisibility(View.GONE);
- txtvError.setText(error.toString());
- txtvError.setVisibility(View.VISIBLE);
- butRetry.setOnClickListener(v -> search(query));
- butRetry.setVisibility(View.VISIBLE);
- });
- }
-
- private void showOnlyProgressBar() {
- gridView.setVisibility(View.GONE);
- txtvError.setVisibility(View.GONE);
- butRetry.setVisibility(View.GONE);
- txtvEmpty.setVisibility(View.GONE);
- progressBar.setVisibility(View.VISIBLE);
- }
-
- private void showInputMethod(View view) {
- InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
- if (imm != null) {
- imm.showSoftInput(view, 0);
- }
- }
-}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QuickFeedDiscoveryFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QuickFeedDiscoveryFragment.java
deleted file mode 100644
index f68fc1a81..000000000
--- a/app/src/main/java/de/danoeh/antennapod/fragment/QuickFeedDiscoveryFragment.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package de.danoeh.antennapod.fragment;
-
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.DisplayMetrics;
-
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-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 de.danoeh.antennapod.BuildConfig;
-import de.danoeh.antennapod.R;
-import de.danoeh.antennapod.activity.MainActivity;
-import de.danoeh.antennapod.activity.OnlineFeedViewActivity;
-import de.danoeh.antennapod.adapter.FeedDiscoverAdapter;
-import de.danoeh.antennapod.storage.database.DBReader;
-import de.danoeh.antennapod.event.DiscoveryDefaultUpdateEvent;
-import de.danoeh.antennapod.net.discovery.ItunesTopListLoader;
-import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
-import io.reactivex.Observable;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.disposables.Disposable;
-import io.reactivex.schedulers.Schedulers;
-import org.greenrobot.eventbus.EventBus;
-import org.greenrobot.eventbus.Subscribe;
-import org.greenrobot.eventbus.ThreadMode;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import static android.content.Context.MODE_PRIVATE;
-
-
-public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.OnItemClickListener {
- private static final String TAG = "FeedDiscoveryFragment";
- private static final int NUM_SUGGESTIONS = 12;
-
- private Disposable disposable;
- private FeedDiscoverAdapter adapter;
- private GridView discoverGridLayout;
- private TextView errorTextView;
- private TextView poweredByTextView;
- private LinearLayout errorView;
- private Button errorRetry;
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- super.onCreateView(inflater, container, savedInstanceState);
- View root = inflater.inflate(R.layout.quick_feed_discovery, container, false);
- View discoverMore = root.findViewById(R.id.discover_more);
- discoverMore.setOnClickListener(v ->
- ((MainActivity) getActivity()).loadChildFragment(new DiscoveryFragment()));
-
- 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((MainActivity) getActivity());
- discoverGridLayout.setAdapter(adapter);
- discoverGridLayout.setOnItemClickListener(this);
-
- DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
- float screenWidthDp = displayMetrics.widthPixels / displayMetrics.density;
- if (screenWidthDp > 600) {
- discoverGridLayout.setNumColumns(6);
- } else {
- discoverGridLayout.setNumColumns(4);
- }
-
- // Fill with dummy elements to have a fixed height and
- // prevent the UI elements below from jumping on slow connections
- List<PodcastSearchResult> dummies = new ArrayList<>();
- for (int i = 0; i < NUM_SUGGESTIONS; i++) {
- dummies.add(PodcastSearchResult.dummy());
- }
-
- adapter.updateData(dummies);
- loadToplist();
-
- EventBus.getDefault().register(this);
- return root;
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- EventBus.getDefault().unregister(this);
- if (disposable != null) {
- disposable.dispose();
- }
- }
-
- @Subscribe(threadMode = ThreadMode.MAIN)
- @SuppressWarnings("unused")
- public void onDiscoveryDefaultUpdateEvent(DiscoveryDefaultUpdateEvent event) {
- loadToplist();
- }
-
- 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());
- 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);
- errorRetry.setVisibility(View.GONE);
- 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 = Observable.fromCallable(() ->
- loader.loadToplist(countryCode, NUM_SUGGESTIONS, DBReader.getFeedList()))
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(
- podcasts -> {
- errorView.setVisibility(View.GONE);
- if (podcasts.size() == 0) {
- errorTextView.setText(getResources().getText(R.string.search_status_no_results));
- errorView.setVisibility(View.VISIBLE);
- discoverGridLayout.setVisibility(View.INVISIBLE);
- } else {
- discoverGridLayout.setVisibility(View.VISIBLE);
- adapter.updateData(podcasts);
- }
- }, error -> {
- Log.e(TAG, Log.getStackTraceString(error));
- errorTextView.setText(error.getLocalizedMessage());
- errorView.setVisibility(View.VISIBLE);
- discoverGridLayout.setVisibility(View.INVISIBLE);
- errorRetry.setVisibility(View.VISIBLE);
- errorRetry.setOnClickListener(v -> loadToplist());
- });
- }
-
- @Override
- public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
- PodcastSearchResult podcast = adapter.getItem(position);
- if (TextUtils.isEmpty(podcast.feedUrl)) {
- return;
- }
- Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class);
- intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, podcast.feedUrl);
- startActivity(intent);
- }
-}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java
index 76b53a264..73fce9f1f 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java
@@ -2,7 +2,6 @@ package de.danoeh.antennapod.fragment;
import android.content.Context;
-import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -29,7 +28,6 @@ import com.leinardi.android.speeddial.SpeedDialView;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
-import de.danoeh.antennapod.activity.OnlineFeedViewActivity;
import de.danoeh.antennapod.adapter.EpisodeItemListAdapter;
import de.danoeh.antennapod.adapter.HorizontalFeedListAdapter;
import de.danoeh.antennapod.core.menuhandler.MenuItemUtils;
@@ -46,6 +44,8 @@ import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
import de.danoeh.antennapod.net.discovery.CombinedSearcher;
import de.danoeh.antennapod.storage.database.DBReader;
+import de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter;
+import de.danoeh.antennapod.ui.discovery.OnlineSearchFragment;
import de.danoeh.antennapod.view.EmptyViewHandler;
import de.danoeh.antennapod.view.EpisodeItemListRecyclerView;
import de.danoeh.antennapod.view.LiftOnScrollListener;
@@ -425,9 +425,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
in.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
String query = searchView.getQuery().toString();
if (query.matches("http[s]?://.*")) {
- Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class);
- intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, query);
- startActivity(intent);
+ startActivity(new OnlineFeedviewActivityStarter(getContext(), query).getIntent());
return;
}
((MainActivity) getActivity()).loadChildFragment(
diff --git a/app/src/main/res/layout/addfeed.xml b/app/src/main/res/layout/addfeed.xml
index eee07c669..d3e3c3c1d 100644
--- a/app/src/main/res/layout/addfeed.xml
+++ b/app/src/main/res/layout/addfeed.xml
@@ -85,7 +85,7 @@
android:id="@+id/quickFeedDiscovery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:name="de.danoeh.antennapod.fragment.QuickFeedDiscoveryFragment" />
+ android:name="de.danoeh.antennapod.ui.discovery.QuickFeedDiscoveryFragment" />
<TextView
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/fragment_itunes_search.xml b/app/src/main/res/layout/fragment_itunes_search.xml
deleted file mode 100644
index 4dd767d58..000000000
--- a/app/src/main/res/layout/fragment_itunes_search.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <com.google.android.material.appbar.AppBarLayout
- android:id="@+id/appbar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:fitsSystemWindows="true"
- android:elevation="0dp">
-
- <com.google.android.material.appbar.MaterialToolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?attr/actionBarSize"
- android:theme="?attr/actionBarTheme"
- app:title="@string/discover"
- app:navigationContentDescription="@string/toolbar_back_button_content_description"
- app:navigationIcon="?homeAsUpIndicator" />
-
- </com.google.android.material.appbar.AppBarLayout>
-
- <GridView
- android:id="@+id/gridView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_below="@id/appbar"
- android:clipToPadding="false"
- android:columnWidth="400dp"
- android:gravity="center"
- android:horizontalSpacing="8dp"
- android:numColumns="auto_fit"
- android:paddingBottom="@dimen/list_vertical_padding"
- android:paddingTop="@dimen/list_vertical_padding"
- android:stretchMode="columnWidth"
- android:verticalSpacing="8dp"
- tools:listitem="@layout/itunes_podcast_listitem" />
-
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_centerInParent="true"
- android:gravity="center"
- android:visibility="gone"
- android:text="@string/search_status_no_results" />
-
- <ProgressBar
- android:id="@+id/progressBar"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:indeterminateOnly="true"
- android:visibility="gone" />
-
- <TextView
- android:id="@+id/txtvError"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:layout_margin="16dp"
- android:textAlignment="center"
- android:textSize="@dimen/text_size_small"
- android:visibility="gone"
- tools:visibility="visible"
- tools:text="Error message"
- tools:background="@android:color/holo_red_light" />
-
- <Button
- android:id="@+id/butRetry"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/txtvError"
- android:layout_centerHorizontal="true"
- android:layout_margin="16dp"
- android:text="@string/retry_label"
- android:visibility="gone"
- tools:visibility="visible"
- tools:background="@android:color/holo_red_light" />
-
- <TextView
- android:id="@+id/search_powered_by"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="?android:attr/textColorTertiary"
- android:text="@string/discover_powered_by_itunes"
- android:textSize="12sp"
- android:padding="4dp"
- android:background="?android:attr/colorBackground"
- android:layout_alignParentBottom="true"
- android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true"
- android:textAlignment="textEnd" />
-
-</RelativeLayout>
diff --git a/app/src/main/res/layout/itunes_podcast_listitem.xml b/app/src/main/res/layout/itunes_podcast_listitem.xml
deleted file mode 100644
index da2de457b..000000000
--- a/app/src/main/res/layout/itunes_podcast_listitem.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="8dp"
- android:paddingLeft="16dp"
- android:paddingRight="16dp"
- android:paddingBottom="8dp"
- tools:background="@android:color/darker_gray">
-
- <ImageView
- android:id="@+id/imgvCover"
- android:layout_width="@dimen/thumbnail_length_itemlist"
- android:layout_height="@dimen/thumbnail_length_itemlist"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:layout_alignParentTop="true"
- android:adjustViewBounds="true"
- android:importantForAccessibility="no"
- android:cropToPadding="true"
- android:scaleType="fitXY"
- tools:background="@android:color/holo_green_dark"
- tools:src="@tools:sample/avatars" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_toRightOf="@id/imgvCover"
- android:layout_toEndOf="@id/imgvCover"
- android:layout_centerVertical="true"
- android:orientation="vertical"
- android:layout_marginLeft="16dp"
- android:layout_marginStart="16dp">
-
- <TextView
- android:id="@+id/txtvTitle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
- tools:background="@android:color/holo_green_dark"
- tools:text="Podcast title" />
-
- <TextView
- android:id="@+id/txtvAuthor"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="14sp"
- android:textColor="?android:attr/textColorSecondary"
- android:ellipsize="middle"
- android:maxLines="2"
- style="android:style/TextAppearance.Small"
- tools:text="author"
- tools:background="@android:color/holo_green_dark" />
-
- </LinearLayout>
-
-</RelativeLayout>
diff --git a/app/src/main/res/layout/quick_feed_discovery.xml b/app/src/main/res/layout/quick_feed_discovery.xml
deleted file mode 100644
index 4781bf323..000000000
--- a/app/src/main/res/layout/quick_feed_discovery.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- 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
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <de.danoeh.antennapod.ui.common.WrappingGridView
- android:id="@+id/discover_grid"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:numColumns="4"
- android:scrollbars="none"
- android:layout_marginTop="8dp"
- android:layout_centerInParent="true"
- android:layout_gravity="center_horizontal"
- app:layout_columnWeight="1"
- app:layout_rowWeight="1" />
-
- <LinearLayout
- android:id="@+id/discover_error"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:gravity="center"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/discover_error_txtV"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_margin="16dp"
- android:textSize="@dimen/text_size_small"
- tools:text="Error message"
- tools:background="@android:color/holo_red_light" />
-
- <Button
- android:id="@+id/discover_error_retry_btn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="16dp"
- android:text="@string/retry_label"
- tools:background="@android:color/holo_red_light" />
-
- </LinearLayout>
-
- </RelativeLayout>
-
- <TextView
- android:id="@+id/discover_powered_by_itunes"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="?android:attr/textColorTertiary"
- android:text="@string/discover_powered_by_itunes"
- android:textSize="12sp"
- android:layout_gravity="right|end"
- android:paddingHorizontal="4dp"
- android:textAlignment="textEnd" />
-
-</LinearLayout>
diff --git a/app/src/main/res/layout/quick_feed_discovery_item.xml b/app/src/main/res/layout/quick_feed_discovery_item.xml
deleted file mode 100644
index 4407eb2f5..000000000
--- a/app/src/main/res/layout/quick_feed_discovery_item.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:squareImageView="http://schemas.android.com/apk/de.danoeh.antennapod"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="4dp"
- android:clipToPadding="false">
-
- <de.danoeh.antennapod.ui.common.SquareImageView
- android:id="@+id/discovery_cover"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:elevation="4dp"
- android:outlineProvider="background"
- android:foreground="?android:attr/selectableItemBackground"
- squareImageView:direction="width"
- tools:src="@tools:sample/avatars" />
-
-</LinearLayout>
diff --git a/app/src/main/res/layout/select_country_dialog.xml b/app/src/main/res/layout/select_country_dialog.xml
deleted file mode 100644
index 70f93bb77..000000000
--- a/app/src/main/res/layout/select_country_dialog.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <com.google.android.material.textfield.TextInputLayout
- android:id="@+id/country_text_input"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="20dp"
- android:hint="@string/select_country"
- app:endIconMode="none"
- style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu">
-
- <AutoCompleteTextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- </com.google.android.material.textfield.TextInputLayout>
-
-</LinearLayout>
diff --git a/app/src/main/res/menu/countries_menu.xml b/app/src/main/res/menu/countries_menu.xml
deleted file mode 100644
index e0bd7dafe..000000000
--- a/app/src/main/res/menu/countries_menu.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
-
- <item
- android:id="@+id/discover_hide_item"
- android:checkable="true"
- android:enabled="true"
- android:title="@string/discover_hide"
- android:visible="true"
- app:showAsAction="never" />
- <item
- android:id="@+id/discover_countries_item"
- android:enabled="true"
- android:title="@string/select_country"
- android:visible="true" />
-</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/online_search.xml b/app/src/main/res/menu/online_search.xml
deleted file mode 100644
index 374a054fa..000000000
--- a/app/src/main/res/menu/online_search.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:custom="http://schemas.android.com/apk/res-auto">
-
- <item
- android:id="@+id/action_search"
- android:icon="@drawable/ic_search"
- custom:showAsAction="collapseActionView|ifRoom"
- custom:actionViewClass="androidx.appcompat.widget.SearchView"
- android:title="@string/search_label"/>
-
-</menu>