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

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

Issue 2270443002: Set minimum line number on snippets in narrow layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 4 years, 4 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/snippets/SnippetArticleViewHolder.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
index d6419ceb1214e2ff76b17c02b778642b0f766484..d775bfd93f43e5dbaee9bcfa66e77810fef289d8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
@@ -255,22 +255,28 @@ public class SnippetArticleViewHolder extends CardViewHolder
boolean narrow = mUiConfig.getCurrentDisplayStyle() == UiConfig.DISPLAY_STYLE_NARROW;
boolean minimal = mArticle.mCardLayout == ContentSuggestionsCardLayout.MINIMAL_CARD;
- // If the screen is narrow, increase the number of lines in the header.
- mHeadlineTextView.setMaxLines(narrow ? 4 : 2);
-
// If the screen is narrow or we are using the minimal layout, hide the article snippet.
- mArticleSnippetTextView.setVisibility((narrow || minimal) ? View.GONE : View.VISIBLE);
+ boolean hideSnippet = narrow || minimal;
+ mArticleSnippetTextView.setVisibility(hideSnippet ? View.GONE : View.VISIBLE);
// If we are using minimal layout, hide the thumbnail.
- mThumbnailView.setVisibility(minimal ? View.GONE : View.VISIBLE);
+ boolean hideThumbnail = minimal;
+ mThumbnailView.setVisibility(hideThumbnail ? View.GONE : View.VISIBLE);
+
+ // If the screen is narrow, increase the number of lines in the header.
+ mHeadlineTextView.setMaxLines(narrow ? 4 : 2);
+
+ // If the screen is narrow, ensure a minimum number of lines to prevent overlap between the
+ // publisher and the header.
+ mHeadlineTextView.setMinLines((narrow && !hideThumbnail) ? 3 : 1);
// If we aren't showing the article snippet, reduce the top margin for publisher text.
RelativeLayout.LayoutParams params =
(RelativeLayout.LayoutParams) mPublisherTextView.getLayoutParams();
int topMargin = mPublisherTextView.getResources().getDimensionPixelSize(
- minimal ? R.dimen.snippets_publisher_margin_top_without_article_snippet
- : R.dimen.snippets_publisher_margin_top_with_article_snippet);
+ hideSnippet ? R.dimen.snippets_publisher_margin_top_without_article_snippet
+ : R.dimen.snippets_publisher_margin_top_with_article_snippet);
params.setMargins(params.leftMargin,
topMargin,

Powered by Google App Engine
This is Rietveld 408576698