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

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

Issue 1351303003: Add the UI for the Interests Prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ntp-interests-jni
Patch Set: Fetch the oauth token from the native code. Created 5 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.ntp;
6
7 import android.app.Activity;
8 import android.content.Context;
9 import android.view.LayoutInflater;
10 import android.view.View;
11
12 import org.chromium.chrome.R;
13 import org.chromium.chrome.browser.NativePage;
14 import org.chromium.chrome.browser.ntp.InterestsService.GetInterestsCallback;
15 import org.chromium.chrome.browser.ntp.InterestsService.Interest;
16 import org.chromium.chrome.browser.profiles.Profile;
17 import org.chromium.chrome.browser.tab.Tab;
18
19 import java.util.Arrays;
20 import java.util.List;
21
22 /**
23 * List the interests of the user. When an interest is clicked the user is redir ect to a google
24 * search with news about that subject.
25 */
26 public class InterestsPage implements NativePage {
newt (away) 2015/09/29 17:33:22 Will this ever be displayed as a webpage, or only
27 private final Profile mProfile;
28 private final InterestsPageView mPageView;
29 private final String mTitle;
30 private final int mBackgroundColor;
31
32 private static final String TAG = "cr.browser.ntp";
Bernhard Bauer 2015/09/29 14:33:28 Tags are not supposed to start with "cr." anymore;
PEConn 2015/11/18 15:26:57 Done.
33
34 /**
35 * Creates a InterestsPage to be shown in document mode.
36 *
37 * @param context The view context for showing the page.
38 * @param tab The tab from which interests page is loaded.
39 * @param profile The profile from which to load interests.
40 * @param listener The InterestsSelectedListener to notify when the user cli cks an interest.
41 * @param activity The activity from which the interests page is loaded.
42 */
43 public InterestsPage(Context context, Tab tab, final Profile profile,
44 InterestsListener listener, Activity activity) {
45 mProfile = profile;
46 mTitle = context.getResources().getString(R.string.ntp_interests);
47 mBackgroundColor = context.getResources().getColor(R.color.ntp_bg);
48
49 LayoutInflater inflater = LayoutInflater.from(context);
50
51 mPageView = (InterestsPageView) inflater.inflate(R.layout.interests_page , null);
52 mPageView.setListener(listener);
53
54 new InterestsService(profile).getInterests(
55 new GetInterestsCallback() {
56 @Override
57 public void onInterestsAvailableCallback(Interest[] interest s) {
58 List<Interest> interestList = Arrays.asList(interests);
59
60 mPageView.setInterests(interestList);
61 }
62 });
63
newt (away) 2015/09/29 17:33:22 remove empty line
PEConn 2015/11/18 15:26:57 Done.
64 }
65
66 /**
67 * Interface to be notified when the user clicks on a interest.
68 **/
69 public interface InterestsListener {
70 /**
71 * Called when a interest is selected.
72 *
73 * @param name The name of the selected interest.
74 */
75 void onInterestClicked(String name);
76 }
77
78 @Override
79 public String getTitle() {
80 return mTitle;
81 }
82
83 @Override
84 public int getBackgroundColor() {
85 return mBackgroundColor;
86 }
87
88 @Override
89 public View getView() {
90 return mPageView;
91 }
92
93 /**
94 * Releases internal resources. This must be called eventually, and the obje ct should not used
Bernhard Bauer 2015/09/29 14:33:28 This comment is unnecessary.
PEConn 2015/11/18 15:26:57 Done.
95 * after calling this.
96 */
97 @Override
98 public void destroy() {
99 }
100
101 @Override
102 public String getHost() {
103 return "interests";
104 }
105
106 @Override
107 public String getUrl() {
108 return "chrome-native://interests";
newt (away) 2015/09/29 17:33:22 If this does need to be a NativePage, then add the
109 }
110
111 @Override
112 public void updateForUrl(String url) {
113 }
114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698