Skip to content

Commit

Permalink
[Read Later] Fix crash when adding from the dedicated menu item
Browse files Browse the repository at this point in the history
There are 2 problems being fixed:
(1) typeSwapBookmarksIfNecessary now stores the type-swapped items
    in a different array. This is the array to search for the new
    bookmark.
(2) sSkipShowSaveFlowForTesting can be null and the if statement
    doesn't account for that.

(cherry picked from commit 237a880)

Bug: 1315511
Change-Id: Iac5c43c847085e4b64e4453540c4c4d6492126ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3580056
Reviewed-by: bttk - <bttk@chromium.org>
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#992820}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3594486
Reviewed-by: Krishna Govind <govind@chromium.org>
Commit-Queue: Krishna Govind <govind@chromium.org>
Owners-Override: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/5005@{#62}
Cr-Branched-From: 5b4d945-refs/heads/main@{#992738}
  • Loading branch information
Brandon Wylie authored and Chromium LUCI CQ committed Apr 20, 2022
1 parent 8d36698 commit 0e64146
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,18 @@ public static boolean maybeTypeSwapAndShowSaveFlow(@NonNull Activity activity,
// remove the regular bookmark first so the save flow is shown.
List<BookmarkId> bookmarkIds = new ArrayList<>();
bookmarkIds.add(bookmarkId);
ReadingListUtils.typeSwapBookmarksIfNecessary(bookmarkBridge, bookmarkIds,
new ArrayList<>(), bookmarkBridge.getReadingListFolder());
if (sSkipShowSaveFlowForTesting) return true;
List<BookmarkId> typeSwappedBookmarks = new ArrayList<>();
typeSwapBookmarksIfNecessary(bookmarkBridge, bookmarkIds, typeSwappedBookmarks,
bookmarkBridge.getReadingListFolder());

assert typeSwappedBookmarks.size() == 1;
if (typeSwappedBookmarks.size() != 1) return false;

BookmarkId newBookmark = typeSwappedBookmarks.get(0);
if (Boolean.TRUE.equals(sSkipShowSaveFlowForTesting)) return true;
BookmarkUtils.showSaveFlow(activity, bottomsheetController,
/*fromExplicitTrackUi=*/false, bookmarkIds.get(0), /*wasBookmarkMoved=*/true);
/*fromExplicitTrackUi=*/false, newBookmark,
/*wasBookmarkMoved=*/true);
return true;
}

Expand Down

0 comments on commit 0e64146

Please sign in to comment.