Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove placeholder on NTP #8241

Merged
merged 3 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions android/java/apk_for_test.flags
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
-keep class org.chromium.chrome.browser.ntp.NewTabPageLayout {
*** insertSiteSectionView(...);
*** mSiteSectionView;
*** mTileGroup;
*** updateTileGridPlaceholderVisibility(...);
}

-keep class org.chromium.chrome.browser.feed.FeedSurfaceCoordinator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public class BraveNewTabPageLayout
private DatabaseHelper mDatabaseHelper;

private ViewGroup mSiteSectionView;
private TileGroup mTileGroup;
private LottieAnimationView mBadgeAnimationView;
private VerticalViewPager ntpWidgetViewPager;
private NTPWidgetAdapter ntpWidgetAdapter;
Expand Down Expand Up @@ -255,6 +256,10 @@ public void onClick(View v) {
mainLayout.addView(mSiteSectionView, insertionPoint);
}

protected void updateTileGridPlaceholderVisibility() {
// This function is kept empty to avoid placeholder implementation
}

private List<NTPWidgetItem> setWidgetList() {
NTPWidgetManager ntpWidgetManager = NTPWidgetManager.getInstance();
LayoutInflater inflater =
Expand Down Expand Up @@ -295,8 +300,8 @@ public void onClick(View v) {
} else if (!mNTPBackgroundImagesBridge.isSuperReferral()
|| !NTPBackgroundImagesBridge.enableSponsoredImages()
|| Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
boolean showPlaceholder =
getTileGroup().hasReceivedData() && getTileGroup().isEmpty();
boolean showPlaceholder = mTileGroup != null && mTileGroup.hasReceivedData()
&& mTileGroup.isEmpty();
if (mSiteSectionView != null && !showPlaceholder) {
mTopsiteErrorMessage.setVisibility(View.GONE);
if (mSiteSectionView.getLayoutParams()
Expand Down Expand Up @@ -433,10 +438,6 @@ protected void onAttachedToWindow() {
if (sponsoredTab == null) {
initilizeSponsoredTab();
}
if (getPlaceholder() != null
&& ((ViewGroup)getPlaceholder().getParent()) != null) {
((ViewGroup)getPlaceholder().getParent()).removeView(getPlaceholder());
}
checkAndShowNTPImage(false);
mNTPBackgroundImagesBridge.addObserver(mNTPBackgroundImageServiceObserver);
if (PackageUtils.isFirstInstall(mActivity)
Expand Down Expand Up @@ -978,13 +979,8 @@ public void onTileCountChanged() {
return;
}

if (getPlaceholder() != null
&& ((ViewGroup)getPlaceholder().getParent()) != null) {
((ViewGroup)getPlaceholder().getParent()).removeView(getPlaceholder());
}

boolean showPlaceholder =
getTileGroup().hasReceivedData() && getTileGroup().isEmpty();
mTileGroup != null && mTileGroup.hasReceivedData() && mTileGroup.isEmpty();
if (!showPlaceholder) {
mTopsiteErrorMessage.setVisibility(View.GONE);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public void testMethodsExist() throws Exception {
"shouldCloseAppWithZeroTabs", false, null));
Assert.assertTrue(methodExists("org/chromium/chrome/browser/ntp/NewTabPageLayout",
"insertSiteSectionView", false, null));
Assert.assertTrue(methodExists("org/chromium/chrome/browser/ntp/NewTabPageLayout",
"updateTileGridPlaceholderVisibility", false, null));
Assert.assertTrue(methodExists("org/chromium/chrome/browser/query_tiles/QueryTileSection",
"getMaxRowsForMostVisitedTiles", false, null));
Assert.assertTrue(
Expand Down Expand Up @@ -288,6 +290,8 @@ public void testFieldsExist() throws Exception {
"org/chromium/chrome/browser/sync/AndroidSyncSettings", "mMasterSyncEnabled"));
Assert.assertTrue(fieldExists(
"org/chromium/chrome/browser/ntp/NewTabPageLayout", "mSiteSectionView"));
Assert.assertTrue(
fieldExists("org/chromium/chrome/browser/ntp/NewTabPageLayout", "mTileGroup"));
Assert.assertTrue(fieldExists(
"org/chromium/chrome/browser/feed/FeedSurfaceCoordinator", "mActivity"));
Assert.assertTrue(fieldExists(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public BraveNewTabPageLayoutClassAdapter(ClassVisitor visitor) {
deleteField(sBraveNewTabPageLayoutClassName, "mSiteSectionView");
makeProtectedField(sNewTabPageLayoutClassName, "mSiteSectionView");

deleteField(sBraveNewTabPageLayoutClassName, "mTileGroup");
makeProtectedField(sNewTabPageLayoutClassName, "mTileGroup");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unit test for this field


makePublicMethod(sNewTabPageLayoutClassName, "updateTileGridPlaceholderVisibility");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unit test for this method

addMethodAnnotation(sBraveNewTabPageLayoutClassName, "updateTileGridPlaceholderVisibility",
"Ljava/lang/Override;");

changeSuperName(sNewTabPageLayoutClassName, sNewTabPageLayoutSuperClassName);
}
}