Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1058)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java

Issue 2714723002: Add feature for condensed NTP tiles. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
index 1994220097dc7f42a9727d9eac12361fbee15b48..7dd1cc9f1c3adf05e363fd6adf3b38b4893f14c3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
@@ -75,12 +75,6 @@ public class NewTabPageView
*/
private static final String PARAM_NTP_TILE_TITLE_LINES = "ntp_tile_title_lines";
- /**
- * The maximum number of tiles to try and fit in a row. On smaller screens, there may not be
- * enough space to fit all of them.
- */
- private static final int MAX_TILE_COLUMNS = 4;
-
private NewTabPageRecyclerView mRecyclerView;
private NewTabPageLayout mNewTabPageLayout;
@@ -230,6 +224,7 @@ public class NewTabPageView
mTileGridLayout = (TileGridLayout) mNewTabPageLayout.findViewById(R.id.tile_grid_layout);
mTileGridLayout.setMaxRows(getMaxTileRows(searchProviderHasLogo));
+ mTileGridLayout.setMaxColumns(getMaxTileColumns());
mTileGroup = new TileGroup(
mManager, mContextMenuManager, mTileGroupDelegate, /* observer = */ this);
@@ -245,7 +240,7 @@ public class NewTabPageView
setSearchProviderHasLogo(searchProviderHasLogo);
mPendingLoadTasks++;
- mTileGroup.startObserving(getMaxTileRows(searchProviderHasLogo) * MAX_TILE_COLUMNS);
+ mTileGroup.startObserving(getMaxTileRows(searchProviderHasLogo) * getMaxTileColumns());
// Set up snippets
NewTabPageAdapter newTabPageAdapter = new NewTabPageAdapter(mManager, mNewTabPageLayout,
@@ -805,6 +800,19 @@ public class NewTabPageView
ChromeFeatureList.NTP_CONDENSED_LAYOUT, PARAM_NTP_MAX_TILE_ROWS, defaultValue);
}
+ /**
+ * Determines The maximum number of tiles to try and fit in a row. On smaller screens, there
+ * may not be enough space to fit all of them.
+ */
+ private int getMaxTileColumns() {
+ if (!mUiConfig.getCurrentDisplayStyle().isSmall()
+ && ChromeFeatureList.isEnabled(
+ ChromeFeatureList.NTP_CONDENSED_TILE_LAYOUT_FOR_LARGE_SCREENS)) {
+ return 5;
+ }
+ return 4;
+ }
+
private static int getTileTitleLines() {
int defaultValue = 2;
if (ChromeFeatureList.isEnabled(ChromeFeatureList.NTP_CONDENSED_LAYOUT)) {
@@ -814,6 +822,15 @@ public class NewTabPageView
ChromeFeatureList.NTP_CONDENSED_LAYOUT, PARAM_NTP_TILE_TITLE_LINES, defaultValue);
}
+ private boolean shouldUseCondensedTileLayout() {
+ if (mUiConfig.getCurrentDisplayStyle().isSmall()) {
+ return ChromeFeatureList.isEnabled(
+ ChromeFeatureList.NTP_CONDENSED_TILE_LAYOUT_FOR_SMALL_SCREENS);
+ }
+ return ChromeFeatureList.isEnabled(
+ ChromeFeatureList.NTP_CONDENSED_TILE_LAYOUT_FOR_LARGE_SCREENS);
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mNewTabPageLayout != null) {
@@ -855,7 +872,8 @@ public class NewTabPageView
@Override
public void onTileDataChanged() {
- mTileGroup.renderTileViews(mTileGridLayout, !mLoadHasCompleted, getTileTitleLines());
+ mTileGroup.renderTileViews(mTileGridLayout, !mLoadHasCompleted, getTileTitleLines(),
+ shouldUseCondensedTileLayout());
mSnapshotTileGridChanged = true;
// The page contents are initially hidden; otherwise they'll be drawn centered on the page

Powered by Google App Engine
This is Rietveld 408576698