Commit 45d49746 authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

Download Home : Hide chips that don't match search query

Details :
1 - Search filter is cascaded before the type filter in the filter chain,
    hence chips that don't have item types in the search text will be hidden.
2 - Empty view will show a different string when we are in search mode
    and we have no matching results.

Bug: 892332
Change-Id: Ib99534b9c1a0b3f5333d4646356863a8639cd926
Reviewed-on: https://chromium-review.googlesource.com/c/1275140
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598876}
parent 36955f04
......@@ -31,6 +31,7 @@ public class EmptyCoordinator implements OfflineItemFilterObserver, FilterCoordi
private final EmptyView mView;
private boolean mShowingPrefetch;
private boolean mInSearchMode;
/** Creates a {@link EmptyCoordinator} instance that monitors {@code source}. */
public EmptyCoordinator(Context context, PrefetchStatusProvider prefetchStatusProvider,
......@@ -51,6 +52,14 @@ public class EmptyCoordinator implements OfflineItemFilterObserver, FilterCoordi
return mView.getView();
}
/**
* Method to inform the coordinator about a change in search mode.
* @param inSearchMode Whether we are currently in active search mode.
*/
public void setInSearchMode(boolean inSearchMode) {
mInSearchMode = inSearchMode;
}
// OfflineItemFilterObserver implementation.
@Override
public void onItemsAdded(Collection<OfflineItem> items) {
......@@ -93,13 +102,15 @@ public class EmptyCoordinator implements OfflineItemFilterObserver, FilterCoordi
iconId = R.drawable.ic_library_news_feed;
if (mPrefetchStatusProvider.enabled()) {
textId = R.string.download_manager_prefetch_tab_empty;
textId = mInSearchMode ? R.string.download_manager_prefetch_tab_no_results
: R.string.download_manager_prefetch_tab_empty;
} else {
textId = R.string.download_manager_enable_prefetch_message;
}
} else {
iconId = R.drawable.downloads_big;
textId = R.string.download_manager_ui_empty;
textId = mInSearchMode ? R.string.download_manager_no_results
: R.string.download_manager_ui_empty;
}
mModel.set(EmptyProperties.EMPTY_TEXT_RES_ID, textId);
......
......@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.download.home.list;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
......@@ -164,8 +165,7 @@ public class DateOrderedListCoordinator implements ToolbarCoordinator.ToolbarLis
@Override
public void setSearchQuery(String query) {
// TODO(crbug.com/881047): Check with UX, if the text on empty view should change during
// search.
mEmptyCoordinator.setInSearchMode(!TextUtils.isEmpty(query));
mMediator.onFilterStringChanged(query);
}
......
......@@ -126,8 +126,8 @@ class DateOrderedListMediator {
// [OffTheRecordOfflineItemFilter] ->
// [InvalidStateOfflineItemFilter] ->
// [DeleteUndoOfflineItemFilter] ->
// [TypeOfflineItemFilter] ->
// [SearchOfflineItemFitler] ->
// [SearchOfflineItemFitler] ->
// [TypeOfflineItemFilter] ->
// [DateOrderedListMutator] ->
// [ListItemModel]
......@@ -141,9 +141,9 @@ class DateOrderedListMediator {
mOffTheRecordFilter = new OffTheRecordOfflineItemFilter(offTheRecord, mSource);
mInvalidStateFilter = new InvalidStateOfflineItemFilter(mOffTheRecordFilter);
mDeleteUndoFilter = new DeleteUndoOfflineItemFilter(mInvalidStateFilter);
mTypeFilter = new TypeOfflineItemFilter(mDeleteUndoFilter);
mSearchFilter = new SearchOfflineItemFilter(mTypeFilter);
mListMutator = new DateOrderedListMutator(mSearchFilter, mModel, new JustNowProvider());
mSearchFilter = new SearchOfflineItemFilter(mDeleteUndoFilter);
mTypeFilter = new TypeOfflineItemFilter(mSearchFilter);
mListMutator = new DateOrderedListMutator(mTypeFilter, mModel, new JustNowProvider());
mSearchFilter.addObserver(new EmptyStateObserver(mSearchFilter, dateOrderedListObserver));
mThumbnailProvider = new ThumbnailProviderImpl(
......@@ -224,7 +224,7 @@ class DateOrderedListMediator {
* options are available.
*/
public OfflineItemFilterSource getFilterSource() {
return mDeleteUndoFilter;
return mSearchFilter;
}
/**
......
......@@ -2512,6 +2512,9 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_DOWNLOAD_MANAGER_PREFETCH_TAB_EMPTY" desc="Tab text indicating that there is no prefetched content.">
No content here
</message>
<message name="IDS_DOWNLOAD_MANAGER_PREFETCH_TAB_NO_RESULTS" desc="Tab text indicating that no prefetched content matched a search query.">
No content found
</message>
<message name="IDS_DOWNLOAD_MANAGER_ENABLE_PREFETCH_MESSAGE" desc="Tab text indicating that users can enable prefetch to allow chrome to download articles on Wi-Fi.">
Allow Chrome to download articles for you when on Wi-Fi under settings.
</message>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment