Commit e0a1260e authored by Jenna Himawan's avatar Jenna Himawan Committed by Commit Bot

Get rid of Move Up / Down for 1 bookmark

Bug: 989787
Change-Id: I60b320350ccdd640f246d26af422f70b1d2a40b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1733114Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Jenna Himawan <jhimawan@google.com>
Cr-Commit-Position: refs/heads/master@{#683801}
parent e9fa52e0
......@@ -42,12 +42,13 @@ abstract class BookmarkRow extends SelectableItemView<BookmarkId>
@Location
private int mLocation;
@IntDef({Location.TOP, Location.MIDDLE, Location.BOTTOM})
@IntDef({Location.TOP, Location.MIDDLE, Location.BOTTOM, Location.SOLO})
@Retention(RetentionPolicy.SOURCE)
public @interface Location {
int TOP = 0;
int MIDDLE = 1;
int BOTTOM = 2;
int SOLO = 3;
}
/**
......@@ -153,11 +154,14 @@ abstract class BookmarkRow extends SelectableItemView<BookmarkId>
new Item(getContext(), R.string.bookmark_item_delete, true)));
if (mReorderBookmarksEnabled
&& mDelegate.getCurrentState() == BookmarkUIState.STATE_FOLDER) {
if (mLocation != Location.TOP) {
menuItems.add(new Item(getContext(), R.string.menu_item_move_up, true));
}
if (mLocation != Location.BOTTOM) {
menuItems.add(new Item(getContext(), R.string.menu_item_move_down, true));
// Only add move up / move down buttons if there is more than 1 item
if (mLocation != Location.SOLO) {
if (mLocation != Location.TOP) {
menuItems.add(new Item(getContext(), R.string.menu_item_move_up, true));
}
if (mLocation != Location.BOTTOM) {
menuItems.add(new Item(getContext(), R.string.menu_item_move_down, true));
}
}
}
return menuItems.toArray(new Item[menuItems.size()]);
......
......@@ -485,7 +485,9 @@ class ReorderBookmarkItemsAdapter extends DragReorderableListAdapter<BookmarkIte
}
private @Location int getLocationFromPosition(int position) {
if (position == getBookmarkItemStartIndex()) {
if (position == getBookmarkItemStartIndex() && position == getBookmarkItemEndIndex()) {
return Location.SOLO;
} else if (position == getBookmarkItemStartIndex()) {
return Location.TOP;
} else if (position == getBookmarkItemEndIndex()) {
return Location.BOTTOM;
......
......@@ -557,6 +557,23 @@ public class BookmarkReorderTest extends BookmarkTest {
onView(withText("Move down")).check(doesNotExist());
}
@Test
@MediumTest
public void testMoveButtonsGoneWithOneBookmark() throws Exception {
addFolder(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager();
View testFolder = mItemsContainer.findViewHolderForAdapterPosition(1).itemView;
Assert.assertEquals("Wrong bookmark item selected.", TEST_FOLDER_TITLE,
((BookmarkFolderRow) testFolder).getTitle());
View more = testFolder.findViewById(R.id.more);
TestThreadUtils.runOnUiThreadBlocking(more::callOnClick);
onView(withText("Move up")).check(doesNotExist());
onView(withText("Move down")).check(doesNotExist());
}
@Override
protected void openBookmarkManager() throws InterruptedException {
super.openBookmarkManager();
......
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