Change information
Commit message:
[ThemeSync] Add pre-defined theme collection options.
In this CL, we allow to add at most 2 pre-defined theme collection
images when the options in the history list is less than 6.
1. The history list will show: default + local history + remote
history + pre-defined options (2 chrome colors + 2 theme
collections);
2. In NtpThemeSyncHistoryCoordinator, we fetch URLs from the theme
collection id0 and filter out any URLs already exist in local
history to prevent duplicated entries;
3. For pre-defined theme collection images, we fetch its preview image
and show it in the recyclerview. The preview image is saved in
NtpBackgroundDataImageBase.
4. After the user the user clicks a pre-defined theme collection item,
fetch its background bitmap. After the bitmap is ready, we will pick
the primary color based on the preview bitmap, and save the data to
the local history of the shared preference. This is different from
a regular theme collection data, the saving data is done when the
bottom sheet is closed. If user clicks it again, we reused the
fetched bitmap.
5. Resolve an image missing issue when clicking multiple options from
the history list. This is because the newly selected items will be
persistent to the shared preference, and the bitmap of the removed
entry will be deleted as at most 3 items are kept in local history.
To fix it, any time when a item (originally from the local history)
is clicked, we save its bitmap to disk in case it has been deleted
before. We don't update the history list when it is showing.
6. Fix the issue that recyclerview's scroll position is reset after
clicking an item at the end by returning the history recyclerview
in NtpCustomizationBottomSheetContent.
Demo: http://shortn/_AEeTlThxRE.
Bug: 488439751
Change-Id: If21e27a6a672886f0f7f6c8345e7266413e1252c
Cr-Commit-Position: refs/heads/main@{#1668241}
Files:
- M chrome/browser/ntp_customization/java/src/org/chromium/chrome/browser/ntp_customization/NtpCustomizationBottomSheetContent.java
- M chrome/browser/ntp_customization/java/src/org/chromium/chrome/browser/ntp_customization/NtpCustomizationCoordinator.java
- M chrome/browser/ntp_customization/java/src/org/chromium/chrome/browser/ntp_customization/NtpCustomizationUtils.java
- M chrome/browser/ntp_customization/java/src/org/chromium/chrome/browser/ntp_customization/theme/theme_collections/NtpThemeCollectionManager.java
- M chrome/browser/ntp_customization/java/src/org/chromium/chrome/browser/ntp_customization/theme_sync/NtpThemeSyncHistoryCoordinator.java
- M chrome/browser/ntp_customization/java/src/org/chromium/chrome/browser/ntp_customization/theme_sync/NtpThemeSyncHistoryRecyclerViewAdaptor.java
- M chrome/browser/ntp_customization/java/src/org/chromium/chrome/browser/ntp_customization/theme_sync/data/NtpBackgroundDataImageBase.java
- M chrome/browser/ntp_customization/java/src/org/chromium/chrome/browser/ntp_customization/theme_sync/data/NtpBackgroundDataManager.java
- M chrome/browser/ntp_customization/java/src/org/chromium/chrome/browser/ntp_customization/theme_sync/data/NtpBackgroundDataThemeCollection.java
- M chrome/browser/ntp_customization/junit/src/org/chromium/chrome/browser/ntp_customization/NtpCustomizationBottomSheetContentUnitTest.java
- M chrome/browser/ntp_customization/junit/src/org/chromium/chrome/browser/ntp_customization/theme_sync/NtpThemeSyncHistoryCoordinatorUnitTest.java
- M chrome/browser/ntp_customization/junit/src/org/chromium/chrome/browser/ntp_customization/theme_sync/NtpThemeSyncHistoryRecyclerViewAdaptorUnitTest.java
Change size: XL
Delta: 12 files changed, 966 insertions(+), 120 deletions(-)
Branch: refs/heads/main
Submit Requirements:
Code-Review: +1 by Xinyi Ji