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

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

Issue 2591673002: [NTP::PhysicalWeb] Do not show published time. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.ntp.snippets; 5 package org.chromium.chrome.browser.ntp.snippets;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.res.Resources; 8 import android.content.res.Resources;
9 import android.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.graphics.drawable.BitmapDrawable; 10 import android.graphics.drawable.BitmapDrawable;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 import java.net.URI; 44 import java.net.URI;
45 import java.net.URISyntaxException; 45 import java.net.URISyntaxException;
46 import java.util.concurrent.TimeUnit; 46 import java.util.concurrent.TimeUnit;
47 47
48 /** 48 /**
49 * A class that represents the view for a single card snippet. 49 * A class that represents the view for a single card snippet.
50 */ 50 */
51 public class SnippetArticleViewHolder 51 public class SnippetArticleViewHolder
52 extends CardViewHolder implements ImpressionTracker.Listener, ContextMen uManager.Delegate { 52 extends CardViewHolder implements ImpressionTracker.Listener, ContextMen uManager.Delegate {
53 private static final String PUBLISHER_FORMAT_STRING = "%s - %s"; 53 private static final String PUBLISHER_FORMAT_STRING = "%s%s";
dgn 2016/12/20 11:15:39 that's kind of icky... how about something like th
54 private static final String PUBLISHED_TIME_FORMAT_STRING = " - %s";
54 private static final int FADE_IN_ANIMATION_TIME_MS = 300; 55 private static final int FADE_IN_ANIMATION_TIME_MS = 300;
55 private static final int[] FAVICON_SERVICE_SUPPORTED_SIZES = {16, 24, 32, 48 , 64}; 56 private static final int[] FAVICON_SERVICE_SUPPORTED_SIZES = {16, 24, 32, 48 , 64};
56 private static final String FAVICON_SERVICE_FORMAT = 57 private static final String FAVICON_SERVICE_FORMAT =
57 "https://s2.googleusercontent.com/s2/favicons?domain=%s&src=chrome_n ewtab_mobile&sz=%d&alt=404"; 58 "https://s2.googleusercontent.com/s2/favicons?domain=%s&src=chrome_n ewtab_mobile&sz=%d&alt=404";
58 59
59 private final NewTabPageManager mNewTabPageManager; 60 private final NewTabPageManager mNewTabPageManager;
60 private final TextView mHeadlineTextView; 61 private final TextView mHeadlineTextView;
61 private final TextView mPublisherTextView; 62 private final TextView mPublisherTextView;
62 private final TextView mArticleSnippetTextView; 63 private final TextView mArticleSnippetTextView;
63 private final ImageView mThumbnailView; 64 private final ImageView mThumbnailView;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 updateLayout(); 197 updateLayout();
197 198
198 mHeadlineTextView.setText(mArticle.mTitle); 199 mHeadlineTextView.setText(mArticle.mTitle);
199 200
200 // DateUtils.getRelativeTimeSpanString(...) calls through to TimeZone.ge tDefault(). If this 201 // DateUtils.getRelativeTimeSpanString(...) calls through to TimeZone.ge tDefault(). If this
201 // has never been called before it loads the current time zone from disk . In most likelihood 202 // has never been called before it loads the current time zone from disk . In most likelihood
202 // this will have been called previously and the current time zone will have been cached, 203 // this will have been called previously and the current time zone will have been cached,
203 // but in some cases (eg instrumentation tests) it will cause a strict m ode violation. 204 // but in some cases (eg instrumentation tests) it will cause a strict m ode violation.
204 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); 205 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
205 try { 206 try {
207 String relativeTimeString = "";
206 long time = SystemClock.elapsedRealtime(); 208 long time = SystemClock.elapsedRealtime();
207 CharSequence relativeTimeSpan = DateUtils.getRelativeTimeSpanString( 209 if (mArticle.mPublishTimestampMilliseconds != 0) {
208 mArticle.mPublishTimestampMilliseconds, System.currentTimeMi llis(), 210 CharSequence relativeTimeSpan =
209 DateUtils.MINUTE_IN_MILLIS); 211 DateUtils.getRelativeTimeSpanString(mArticle.mPublishTim estampMilliseconds,
212 System.currentTimeMillis(), DateUtils.MINUTE_IN_ MILLIS);
213 relativeTimeString = String.format(PUBLISHED_TIME_FORMAT_STRING, relativeTimeSpan);
214 }
210 RecordHistogram.recordTimesHistogram("Android.StrictMode.SnippetUIBu ildTime", 215 RecordHistogram.recordTimesHistogram("Android.StrictMode.SnippetUIBu ildTime",
211 SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS) ; 216 SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS) ;
212 217
213 // We format the publisher here so that having a publisher name in a n RTL language 218 // We format the publisher here so that having a publisher name in a n RTL language
214 // doesn't mess up the formatting on an LTR device and vice versa. 219 // doesn't mess up the formatting on an LTR device and vice versa.
215 String publisherAttribution = String.format(PUBLISHER_FORMAT_STRING, 220 String publisherAttribution = String.format(PUBLISHER_FORMAT_STRING,
216 BidiFormatter.getInstance().unicodeWrap(mArticle.mPublisher) , relativeTimeSpan); 221 BidiFormatter.getInstance().unicodeWrap(mArticle.mPublisher) ,
222 relativeTimeString);
217 mPublisherTextView.setText(publisherAttribution); 223 mPublisherTextView.setText(publisherAttribution);
218 } finally { 224 } finally {
dgn 2016/12/20 11:15:39 nit: why is the try/finally that big? shouldn't it
PEConn 2016/12/20 11:24:07 That is the only part that can fail, but if it doe
219 StrictMode.setThreadPolicy(oldPolicy); 225 StrictMode.setThreadPolicy(oldPolicy);
220 } 226 }
221 227
222 // The favicon of the publisher should match the TextView height. 228 // The favicon of the publisher should match the TextView height.
223 int widthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); 229 int widthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
224 int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED) ; 230 int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED) ;
225 mPublisherTextView.measure(widthSpec, heightSpec); 231 mPublisherTextView.measure(widthSpec, heightSpec);
226 mPublisherFaviconSizePx = mPublisherTextView.getMeasuredHeight(); 232 mPublisherFaviconSizePx = mPublisherTextView.getMeasuredHeight();
227 233
228 mArticleSnippetTextView.setText(mArticle.mPreviewText); 234 mArticleSnippetTextView.setText(mArticle.mPreviewText);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 ApiCompatibilityUtils.setCompoundDrawablesRelative( 393 ApiCompatibilityUtils.setCompoundDrawablesRelative(
388 mPublisherTextView, drawable, null, null, null); 394 mPublisherTextView, drawable, null, null, null);
389 mPublisherTextView.setVisibility(View.VISIBLE); 395 mPublisherTextView.setVisibility(View.VISIBLE);
390 } 396 }
391 397
392 @Override 398 @Override
393 public boolean isDismissable() { 399 public boolean isDismissable() {
394 return !isPeeking(); 400 return !isPeeking();
395 } 401 }
396 } 402 }
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698