From 3863a5d19007deb62c97c07ee288cc86cca6f7ec Mon Sep 17 00:00:00 2001 From: orelogo Date: Tue, 12 Jul 2016 15:39:58 -0400 Subject: [PATCH 1/5] Add 'no result' text to unmatched search results --- .../java/de/danoeh/antennapod/fragment/SearchFragment.java | 3 +++ core/src/main/res/values/strings.xml | 1 + 2 files changed, 4 insertions(+) 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 db57279de..91a6719f7 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java @@ -182,6 +182,9 @@ public class SearchFragment extends ListFragment { } searchAdapter.notifyDataSetChanged(); setListShown(true); + + String query = getArguments().getString(ARG_QUERY); + setEmptyText(getString(R.string.no_results_for_query) + " \"" + query + "\""); } private final SearchlistAdapter.ItemAccess itemAccess = new SearchlistAdapter.ItemAccess() { diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 783f6c1d9..4ef696deb 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -421,6 +421,7 @@ No results were found Search Found in title + No results were found for OPML files allow you to move your podcasts from one podcatcher to another. From b5928194d5ede85d519fdebc9b56c5c322b5b137 Mon Sep 17 00:00:00 2001 From: orelogo Date: Wed, 13 Jul 2016 13:25:13 -0400 Subject: [PATCH 2/5] Search Results: prevent duplicate feed items - title results take precedence over shownotes results --- .../antennapod/core/storage/FeedSearcher.java | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java index b88d774a2..7be851944 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java @@ -25,19 +25,20 @@ public class FeedSearcher { */ public static List performSearch(final Context context, final String query, final long selectedFeed) { - final int values[] = {0, 0, 1, 2}; - final String[] subtitles = {context.getString(R.string.found_in_shownotes_label), - context.getString(R.string.found_in_shownotes_label), + final int values[] = {2, 1, 0, 0}; + final String[] subtitles = {context.getString(R.string.found_in_title_label), context.getString(R.string.found_in_chapters_label), - context.getString(R.string.found_in_title_label)}; + context.getString(R.string.found_in_shownotes_label), + context.getString(R.string.found_in_shownotes_label)}; List result = new ArrayList<>(); List>> tasks = new ArrayList<>(); - tasks.add(DBTasks.searchFeedItemContentEncoded(context, selectedFeed, query)); - tasks.add(DBTasks.searchFeedItemDescription(context, selectedFeed, query)); - tasks.add(DBTasks.searchFeedItemChapters(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemTitle(context, selectedFeed, query)); + tasks.add(DBTasks.searchFeedItemChapters(context, selectedFeed, query)); + tasks.add(DBTasks.searchFeedItemDescription(context, selectedFeed, query)); + tasks.add(DBTasks.searchFeedItemContentEncoded(context, selectedFeed, query)); + for (FutureTask> task : tasks) { task.run(); } @@ -46,7 +47,9 @@ public class FeedSearcher { FutureTask> task = tasks.get(i); List items = task.get(); for (FeedItem item : items) { - result.add(new SearchResult(item, values[i], subtitles[i])); + if (result.isEmpty() || !isDuplicate(result, item)) { + result.add(new SearchResult(item, values[i], subtitles[i])); + } } } @@ -56,4 +59,20 @@ public class FeedSearcher { Collections.sort(result, new SearchResultValueComparator()); return result; } + + /** + * Determines if the feed item is already in the search result list. + * + * @param result list of search results + * @param item feed item to validate + * @return true if the feed item is already in the results + */ + private static boolean isDuplicate(List result, FeedItem item) { + for (SearchResult resultItem : result) { + if (resultItem.getComponent().getId() == item.getId()) { + return true; + } + } + return false; + } } From 658594e90f7c94f9ee14b98b97c01be472148b51 Mon Sep 17 00:00:00 2001 From: orelogo Date: Wed, 13 Jul 2016 13:44:48 -0400 Subject: [PATCH 3/5] Search Results: Add transparency to played episodes --- .../de/danoeh/antennapod/adapter/SearchlistAdapter.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java index ac10d53f6..98683219b 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java @@ -11,6 +11,7 @@ import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; +import com.nineoldandroids.view.ViewHelper; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.Feed; @@ -96,6 +97,12 @@ public class SearchlistAdapter extends BaseAdapter { holder.subtitle.setText(result.getSubtitle()); } + if(item.isPlayed()) { + ViewHelper.setAlpha(convertView, 0.5f); + } else { + ViewHelper.setAlpha(convertView, 1.0f); + } + Glide.with(context) .load(item.getFeed().getImageLocation()) .placeholder(R.color.light_gray) From b4b51e6e5808ccc443032fbd309854b33363dd1b Mon Sep 17 00:00:00 2001 From: orelogo Date: Wed, 13 Jul 2016 18:53:18 -0400 Subject: [PATCH 4/5] Search Results: reformat "no result" text for easier translation --- .../main/java/de/danoeh/antennapod/fragment/SearchFragment.java | 2 +- core/src/main/res/values/strings.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 91a6719f7..f64b4c20a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java @@ -184,7 +184,7 @@ public class SearchFragment extends ListFragment { setListShown(true); String query = getArguments().getString(ARG_QUERY); - setEmptyText(getString(R.string.no_results_for_query) + " \"" + query + "\""); + setEmptyText(getString(R.string.no_results_for_query, query)); } private final SearchlistAdapter.ItemAccess itemAccess = new SearchlistAdapter.ItemAccess() { diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 4ef696deb..d0c2bd8e2 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -421,7 +421,7 @@ No results were found Search Found in title - No results were found for + No results were found for \"%1$s\" OPML files allow you to move your podcasts from one podcatcher to another. From 16e640ab1af3e1a194263910e5594840b5ec3bce Mon Sep 17 00:00:00 2001 From: orelogo Date: Mon, 18 Jul 2016 01:10:31 -0400 Subject: [PATCH 5/5] Search Results: Clarify documentation and strings` --- .../danoeh/antennapod/adapter/SearchlistAdapter.java | 6 +----- .../danoeh/antennapod/core/storage/FeedSearcher.java | 10 +++++++++- core/src/main/res/values/strings.xml | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java index 98683219b..8e1aa24e0 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java @@ -97,11 +97,7 @@ public class SearchlistAdapter extends BaseAdapter { holder.subtitle.setText(result.getSubtitle()); } - if(item.isPlayed()) { - ViewHelper.setAlpha(convertView, 0.5f); - } else { - ViewHelper.setAlpha(convertView, 1.0f); - } + ViewHelper.setAlpha(convertView, item.isPlayed() ? 0.5f : 1.0f); Glide.with(context) .load(item.getFeed().getImageLocation()) diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java index 7be851944..9d136273c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java @@ -21,7 +21,15 @@ public class FeedSearcher { /** - * Performs a search in all feeds or one specific feed. + * Search through a feed, or all feeds, for episodes that match the query in either the title, + * chapter, or show notes. The search is first performed on titles, then chapters, and finally + * show notes. The list of resulting episodes also describes where the first match occurred + * (title, chapters, or show notes). + * + * @param context + * @param query search query + * @param selectedFeed feed to search, 0 to search through all feeds + * @return list of episodes containing the query */ public static List performSearch(final Context context, final String query, final long selectedFeed) { diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index d0c2bd8e2..a029b190d 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -415,8 +415,8 @@ Flattr episode when playback ends - Search for Feeds or Episodes - Found in shownotes + Search for episodes + Found in show notes Found in chapters No results were found Search