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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileView.java

Issue 2714723002: Add feature for condensed NTP tiles. (Closed)
Patch Set: Cleanups. 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/suggestions/TileView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileView.java b/chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileView.java
index 0c36d8eb2f7eeab1352c36401000cdc3999586ef..316e0a4ed11779c217f887005345fc660737bfc4 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileView.java
@@ -5,7 +5,9 @@
package org.chromium.chrome.browser.suggestions;
import android.content.Context;
+import android.content.res.Resources;
import android.util.AttributeSet;
+import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
@@ -46,14 +48,43 @@ public class TileView extends FrameLayout {
* after inflation.
* @param tile The tile that holds the data to populate this view.
* @param titleLines The number of text lines to use for the tile title.
+ * @param condensed Whether to use a condensed layout.
*/
- public void initialize(Tile tile, int titleLines) {
+ public void initialize(Tile tile, int titleLines, boolean condensed) {
mTitleView.setLines(titleLines);
mUrl = tile.getUrl();
+
+ // TODO(mvanouwerkerk): Move this code to xml - https://crbug.com/695817.
+ if (condensed) {
+ Resources res = getResources();
+
+ setPadding(0, 0, 0, 0);
+ LayoutParams tileParams = (LayoutParams) getLayoutParams();
+ tileParams.width = res.getDimensionPixelOffset(R.dimen.tile_view_width_condensed);
+ setLayoutParams(tileParams);
+
+ LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams();
+ iconParams.setMargins(0,
+ res.getDimensionPixelOffset(R.dimen.tile_view_icon_margin_top_condensed), 0, 0);
+ mIconView.setLayoutParams(iconParams);
+
+ View highlightView = findViewById(R.id.tile_view_highlight);
+ LayoutParams highlightParams = (LayoutParams) highlightView.getLayoutParams();
+ highlightParams.setMargins(0,
+ res.getDimensionPixelOffset(R.dimen.tile_view_icon_margin_top_condensed), 0, 0);
+ highlightView.setLayoutParams(highlightParams);
+
+ LayoutParams titleParams = (LayoutParams) mTitleView.getLayoutParams();
+ titleParams.setMargins(0,
+ res.getDimensionPixelOffset(R.dimen.tile_view_title_margin_top_condensed), 0,
+ 0);
+ mTitleView.setLayoutParams(titleParams);
+ }
+
renderTile(tile);
}
- /** @return The url associated to this view. */
+ /** @return The url associated with this view. */
public String getUrl() {
return mUrl;
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileGroup.java ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698