Commit 4f546807 authored by Xing Liu's avatar Xing Liu Committed by Chromium LUCI CQ

Read later: Change string for empty view in bookmark UI.

When we are inside the reading list folder, the empty view string is
changed to a reading list specific string.

The search string doesn't change.

Bug: 1148877
Change-Id: I521c988f5a2eda7744feb41d05cac0fe4cee9a17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2595918Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837756}
parent 9d15ff73
...@@ -317,6 +317,11 @@ class BookmarkItemsAdapter extends DragReorderableListAdapter<BookmarkListEntry> ...@@ -317,6 +317,11 @@ class BookmarkItemsAdapter extends DragReorderableListAdapter<BookmarkListEntry>
if (folder.getType() == BookmarkType.READING_LIST) { if (folder.getType() == BookmarkType.READING_LIST) {
TrackerFactory.getTrackerForProfile(Profile.getLastUsedRegularProfile()) TrackerFactory.getTrackerForProfile(Profile.getLastUsedRegularProfile())
.notifyEvent(EventConstants.READ_LATER_BOOKMARK_FOLDER_OPENED); .notifyEvent(EventConstants.READ_LATER_BOOKMARK_FOLDER_OPENED);
mDelegate.getSelectableListLayout().setEmptyViewText(
R.string.reading_list_empty_list_title, R.string.bookmark_no_result);
} else {
mDelegate.getSelectableListLayout().setEmptyViewText(
R.string.bookmarks_folder_empty, R.string.bookmark_no_result);
} }
} }
......
...@@ -1109,6 +1109,27 @@ public class BookmarkTest { ...@@ -1109,6 +1109,27 @@ public class BookmarkTest {
CriteriaHelper.pollUiThread(() -> mBookmarkModel.getReadingListItem(TEST_URL_A) == null); CriteriaHelper.pollUiThread(() -> mBookmarkModel.getReadingListItem(TEST_URL_A) == null);
} }
@Test
@SmallTest
@Features.EnableFeatures({ChromeFeatureList.READ_LATER})
public void testReadingListEmptyView() throws Exception {
BookmarkPromoHeader.forcePromoStateForTests(PromoState.PROMO_NONE);
openBookmarkManager();
// Open the "Reading list" folder.
TestThreadUtils.runOnUiThreadBlocking(
() -> mManager.openFolder(mBookmarkModel.getRootFolderId()));
onView(withText("Reading list")).perform(click());
// We should see an empty view with reading list text.
onView(withText(R.string.reading_list_empty_list_title)).check(matches(isDisplayed()));
// Open other folders will show the default empty view text.
TestThreadUtils.runOnUiThreadBlocking(
() -> mManager.openFolder(mBookmarkModel.getMobileFolderId()));
onView(withText(R.string.bookmarks_folder_empty)).check(matches(isDisplayed()));
}
@Test @Test
@SmallTest @SmallTest
@Features.EnableFeatures({ChromeFeatureList.READ_LATER}) @Features.EnableFeatures({ChromeFeatureList.READ_LATER})
......
...@@ -233,10 +233,7 @@ public class SelectableListLayout<E> ...@@ -233,10 +233,7 @@ public class SelectableListLayout<E>
* @return The {@link TextView} displayed when the list is empty. * @return The {@link TextView} displayed when the list is empty.
*/ */
public TextView initializeEmptyView(int emptyStringResId, int searchEmptyStringResId) { public TextView initializeEmptyView(int emptyStringResId, int searchEmptyStringResId) {
mEmptyStringResId = emptyStringResId; setEmptyViewText(emptyStringResId, searchEmptyStringResId);
mSearchEmptyStringResId = searchEmptyStringResId;
mEmptyView.setText(mEmptyStringResId);
// Dummy listener to have the touch events dispatched to this view tree for navigation UI. // Dummy listener to have the touch events dispatched to this view tree for navigation UI.
mEmptyViewWrapper.setOnTouchListener((v, event) -> true); mEmptyViewWrapper.setOnTouchListener((v, event) -> true);
...@@ -244,6 +241,19 @@ public class SelectableListLayout<E> ...@@ -244,6 +241,19 @@ public class SelectableListLayout<E>
return mEmptyView; return mEmptyView;
} }
/**
* Sets the view text when the selectable list is empty.
* @param emptyStringResId The string to show when the selectable list is empty.
* @param searchEmptyStringResId The string to show when the selectable list is empty during
* a search.
*/
public void setEmptyViewText(int emptyStringResId, int searchEmptyStringResId) {
mEmptyStringResId = emptyStringResId;
mSearchEmptyStringResId = searchEmptyStringResId;
mEmptyView.setText(mEmptyStringResId);
}
/** /**
* Called when the view that owns the SelectableListLayout is destroyed. * Called when the view that owns the SelectableListLayout is destroyed.
*/ */
......
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