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

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

Issue 2808773002: Fixed ellipsize of publisher instead of timespan string. (Closed)
Patch Set: Refactor variable name. Created 3 years, 8 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 2dad1b217748cba66943d746ed405674f9201c46..6df27cb5f5e77b5bad2566f55f88a06a479d70e3 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
@@ -65,7 +65,7 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
public static final RefreshOfflineBadgeVisibilityCallback
REFRESH_OFFLINE_BADGE_VISIBILITY_CALLBACK = new RefreshOfflineBadgeVisibilityCallback();
- private static final String PUBLISHER_FORMAT_STRING = "%s - %s";
+ private static final String TIME_SPAN_FORMAT_STRING = " - %s";
private static final int FADE_IN_ANIMATION_TIME_MS = 300;
private static final int[] FAVICON_SERVICE_SUPPORTED_SIZES = {16, 24, 32, 48, 64};
private static final String FAVICON_SERVICE_FORMAT =
@@ -79,6 +79,7 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
private final TextView mHeadlineTextView;
private final TextView mPublisherTextView;
private final TextView mArticleSnippetTextView;
+ private final TextView mArticleTimeSpanTextView;
private final TintedImageView mThumbnailView;
private final ImageView mOfflineBadge;
private final View mPublisherBar;
@@ -113,6 +114,7 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
mHeadlineTextView = (TextView) itemView.findViewById(R.id.article_headline);
mPublisherTextView = (TextView) itemView.findViewById(R.id.article_publisher);
mArticleSnippetTextView = (TextView) itemView.findViewById(R.id.article_snippet);
+ mArticleTimeSpanTextView = (TextView) itemView.findViewById(R.id.article_time);
mPublisherBar = itemView.findViewById(R.id.publisher_bar);
mOfflineBadge = (ImageView) itemView.findViewById(R.id.offline_icon);
@@ -188,7 +190,6 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
updateLayout();
mHeadlineTextView.setText(mArticle.mTitle);
- mPublisherTextView.setText(getAttributionString(mArticle));
// The favicon of the publisher should match the TextView height.
int widthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
@@ -197,7 +198,8 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
mPublisherFaviconSizePx = mPublisherTextView.getMeasuredHeight();
mArticleSnippetTextView.setText(mArticle.mPreviewText);
-
+ mPublisherTextView.setText(getPublisherString(mArticle));
+ mArticleTimeSpanTextView.setText(getTimeSpanString(mArticle));
setThumbnail();
// Set the favicon of the publisher.
@@ -269,8 +271,14 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
return true;
}
- private static String getAttributionString(SnippetArticle article) {
- if (article.mPublishTimestampMilliseconds == 0) return article.mPublisher;
+ private static String getPublisherString(SnippetArticle article) {
+ // We format the publisher here so that having a publisher name in an RTL language
+ // doesn't mess up the formatting on an LTR device and vice versa.
+ return BidiFormatter.getInstance().unicodeWrap(article.mPublisher);
+ }
+
+ private static String getTimeSpanString(SnippetArticle article) {
+ if (article.mPublishTimestampMilliseconds == 0) return "";
dgn 2017/04/10 21:42:00 physical web URLs don't have a publish timestamp.
Galia 2017/04/11 15:54:32 This function returns a string like " - 14 minutes
dgn 2017/04/11 17:00:38 You're right, I misread. It also looks like there
// DateUtils.getRelativeTimeSpanString(...) calls through to TimeZone.getDefault(). If this
// has never been called before it loads the current time zone from disk. In most likelihood
@@ -288,10 +296,9 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
- // We format the publisher here so that having a publisher name in an RTL language
- // doesn't mess up the formatting on an LTR device and vice versa.
- return String.format(PUBLISHER_FORMAT_STRING,
- BidiFormatter.getInstance().unicodeWrap(article.mPublisher), relativeTimeSpan);
+
+ // We add a dash before the elapsed time. E.g. " - 14 minutes ago"
dgn 2017/04/10 21:42:00 nit: add "." at the end of sentences.
Bernhard Bauer 2017/04/10 23:03:03 Super-nit: also add a comma before the e.g. so we
Galia 2017/04/11 15:54:32 Done.
+ return String.format(TIME_SPAN_FORMAT_STRING, relativeTimeSpan);
dgn 2017/04/10 21:42:00 doesn't that raise a warning about unspecified loc
Galia 2017/04/11 15:54:32 No. I was looking at this before and the dash goes
}
private void setThumbnailFromBitmap(Bitmap thumbnail) {

Powered by Google App Engine
This is Rietveld 408576698