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

Issue 1351303003: Add the UI for the Interests Prototype. (Closed)

Created:
5 years, 3 months ago by tache
Modified:
5 years, 1 month ago
CC:
chromium-reviews, Sergiu
Base URL:
https://chromium.googlesource.com/chromium/src.git@ntp-interests-jni
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add the UI for the Interests Prototype. The interests are displayed in a 2 column grid. For each interest its name and a representative image is displayed. When an interest is clicked the user is taken to a news search about that interest. BUG=537145

Patch Set 1 #

Total comments: 51

Patch Set 2 : #

Patch Set 3 : Fetch the oauth token from the native code. #

Total comments: 55

Messages

Total messages: 13 (4 generated)
tache
5 years, 3 months ago (2015-09-18 11:56:57 UTC) #2
Marc Treib
First bunch of comments below. Mostly nits, but a few "real" ones as well. https://codereview.chromium.org/1351303003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java ...
5 years, 3 months ago (2015-09-18 13:26:04 UTC) #3
tache
https://codereview.chromium.org/1351303003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java File chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java (right): https://codereview.chromium.org/1351303003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java#newcode70 chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:70: private DownloadImage mDownloadTask = null; On 2015/09/18 13:26:03, Marc ...
5 years, 3 months ago (2015-09-21 15:35:55 UTC) #4
Marc Treib
BTW, do we have a bug (on crbug.com) yet for this feature? If not, you ...
5 years, 3 months ago (2015-09-21 16:20:08 UTC) #5
tache
5 years, 2 months ago (2015-09-29 13:20:37 UTC) #7
Bernhard Bauer
+Newt for NTP https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java File chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java (right): https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java#newcode186 chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:186: private class DownloadImageTask extends AsyncTask<String, Integer, ...
5 years, 2 months ago (2015-09-29 14:33:28 UTC) #9
newt (away)
https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/res/layout/interests_page.xml File chrome/android/java/res/layout/interests_page.xml (right): https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/res/layout/interests_page.xml#newcode6 chrome/android/java/res/layout/interests_page.xml:6: <org.chromium.chrome.browser.ntp.InterestsPageView InterestsPageView should be a FrameLayout (which is simpler) ...
5 years, 2 months ago (2015-09-29 17:33:22 UTC) #10
Marc Treib
https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java File chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java (right): https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java#newcode14 chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:14: public static final String AUTH_SCOPE = On 2015/09/29 14:33:28, ...
5 years, 2 months ago (2015-10-06 14:12:33 UTC) #11
PEConn
5 years, 1 month ago (2015-11-18 15:26:57 UTC) #13
This has been moved to https://codereview.chromium.org/1459593002/ .

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/res...
File chrome/android/java/res/layout/interests_page.xml (right):

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/res...
chrome/android/java/res/layout/interests_page.xml:6:
<org.chromium.chrome.browser.ntp.InterestsPageView
On 2015/09/29 17:33:21, newt wrote:
> InterestsPageView should be a FrameLayout (which is simpler) since it only has
a
> single child. (and remove android:orientation too, sine that doesn't apply to
> FrameLayouts)

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/res...
chrome/android/java/res/layout/interests_page.xml:8:
android:id="@+id/interests_content"
On 2015/09/29 17:33:21, newt wrote:
> nit: don't add an ID unless you're going to use it. Leaving out the ID makes
it
> clear that the view isn't manipulated programmatically, which is helpful to
> know.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/res...
chrome/android/java/res/layout/interests_page.xml:16: <GridView
xmlns:android="http://schemas.android.com/apk/res/android"
On 2015/09/29 17:33:21, newt wrote:
> remove redundant xmlns attribute (it's only needed on the root element in the
> file)

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/res...
chrome/android/java/res/layout/interests_page.xml:17:
android:id="@+id/interests_list_view"
On 2015/09/29 17:33:21, newt wrote:
> indentation should look like this:
> 
> <org.chromium.chrome.browser.ntp.InterestsPageView
>     xmlns:android="http://schemas.android.com/apk/res/android"
>     ... />
> 
>     <GridView
>         android:id="@+id/interests_list_view"
>         ... />
> 
> </org.chromium.chrome.browser.ntp.InterestsPageView>

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/res...
File chrome/android/java/res/values/dimens.xml (right):

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/res...
chrome/android/java/res/values/dimens.xml:255: <dimen
name="ntp_interest_item_image_text_size">20dp</dimen>
On 2015/09/29 17:33:21, newt wrote:
> Text sizes should always be specified in "sp" not "dp". This allows the text
> size to change when the user adjusts their system font size preferences.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
File
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java
(right):

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:106:
* Resets the view contents so that it can be reused in the list view.
On 2015/09/29 17:33:22, newt wrote:
> s/list/grid

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:115:
mDownloadTask.setShouldUpdateView(false);
On 2015/09/29 17:33:22, newt wrote:
> How about mDownloadTask.cancel(), and then checking isCancelled() instead of
> mShouldUpdateView down below.

This code was refactored out.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:121:
if (mName != null && mName.equals(name) && mImageUrl != null
On 2015/09/29 17:33:21, newt wrote:
> You can use TextUtils.equals(name, mName) && TextUtils.equals(imageUrl,
> mImageUrl)

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:167:
if (image == null) {
On 2015/09/29 17:33:22, newt wrote:
> Simply ignoring null images is surprising behavior. I'd just remove lines
> 167-169; all the callers check for null images before calling setImage()
anyway.
> Also, make this method private.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:173:
this.setCompoundDrawables(null, image, null, null);
On 2015/09/29 17:33:21, newt wrote:
> remove "this."

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:176:
private void setImageBounds(Drawable image) {
On 2015/09/29 17:33:22, newt wrote:
> Why is this a separate method? I'd just inline it on line 171.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:188:
private InterestsItemView mView;
On 2015/09/29 17:33:22, newt wrote:
> On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> > If this is not a static class, it will have its outer object anyway.
> 
> Alternatively, make this a static class, which is better for inner classes
> anyway as it reduces scope of variables and allows for easier refactoring
later
> if you want to pull out the inner class into a separate class.

The DownloadImageTask is pretty closely tied to the InterestsItemView. If you
wanted to refactor it into a different class you'd have to edit this file anyway
so I left this as a non-static class.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:204:
protected Drawable doInBackground(String... arg0) {
On 2015/09/29 17:33:22, newt wrote:
> s/arg0/args

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsItemView.java:216:
mCache.put(mUrl, image);
On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> I think you could simplify this a bit: Keep the cache out of this class and
just
> always call a method in the outer class here, passing |this| along with the
> Drawable. That method updates the cache, and updates the view iff the passed
> task is the currently active one. That way you can get rid of the cache, URL
and
> update flag in this class.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
File chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPage.java
(right):

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPage.java:32:
private static final String TAG = "cr.browser.ntp";
On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> Tags are not supposed to start with "cr." anymore; the logging system will
> automatically append it.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPage.java:63: 
On 2015/09/29 17:33:22, newt wrote:
> remove empty line

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPage.java:94: *
Releases internal resources. This must be called eventually, and the object
should not used
On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> This comment is unnecessary.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
File
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPageView.java
(right):

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPageView.java:26:
* The user's interests, displayed with a two collumn grid view.
On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> Nit: "column".

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPageView.java:28:
public class InterestsPageView extends LinearLayout {
On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> Just InterestsView? InterestsPageView implies something about how it's used.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPageView.java:32:
private InterestsListAdapter mAdapter;
On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> Make this final as well?

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPageView.java:95:
InterestsItemView view = (InterestsItemView) convertView;
On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> You could extract this variable and the return statement out of the if
> statement, as you assign a value in both branches and return it.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
File
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java
(right):

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:14:
public static final String AUTH_SCOPE =
On 2015/10/06 14:12:33, Marc Treib wrote:
> On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> > What's this for?
> 
> It was used in a previous revision, when getting the access token was done in
> Java. It can be removed now.

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
File chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
(right):

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java:640: if
(mDialog == null) {
On 2015/09/29 14:33:28, Bernhard Bauer wrote:
> When would this happen?

Done.

https://codereview.chromium.org/1351303003/diff/40001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java:645:
String url = String.format(GOOGLE_SEARCH_URL_PATTERN,
On 2015/09/29 17:33:22, newt wrote:
> I think you want TemplateUrlService.getInstance().getUrlForSearchQuery() here.
> 
> Creating Google search URLs manually is fraught with peril, and you definitely
> shouldn't be doing that. For example, one immediate problem: this always
> searches http://google.com, never google.co.uk or bing.fr or whatever the
user's
> default search engine is. (If you need to add custom query params to the URL,
> you might need to modify or add a new method to TemplateUrlService.)
> 
> Also, how does this interact with non-Google search engines?

Done.

Powered by Google App Engine
This is Rietveld 408576698