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

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

Issue 1459593002: Added a UI for the Interests Prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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; 5 package org.chromium.chrome.browser.ntp;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.util.AttributeSet; 8 import android.util.AttributeSet;
9 import android.view.View; 9 import android.view.View;
10 import android.view.ViewGroup; 10 import android.view.ViewGroup;
11 import android.widget.LinearLayout; 11 import android.widget.LinearLayout;
12 import android.widget.TextView; 12 import android.widget.TextView;
13 13
14 import org.chromium.base.ApiCompatibilityUtils; 14 import org.chromium.base.ApiCompatibilityUtils;
15 import org.chromium.chrome.R; 15 import org.chromium.chrome.R;
16 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; 16 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
17 import org.chromium.chrome.browser.widget.TintedDrawable; 17 import org.chromium.chrome.browser.widget.TintedDrawable;
18 18
19 /** 19 /**
20 * The toolbar at the bottom of the new tab page. Contains buttons to open the b ookmarks and 20 * The toolbar at the bottom of the new tab page. Contains buttons to open the b ookmarks and
21 * recent tabs pages. 21 * recent tabs pages.
22 */ 22 */
23 public class NewTabPageToolbar extends LinearLayout { 23 public class NewTabPageToolbar extends LinearLayout {
24 24
25 private ViewGroup mBookmarksButton, mRecentTabsButton; 25 private ViewGroup mBookmarksButton, mRecentTabsButton, mInterestsButton;
26 26
27 /** 27 /**
28 * Constructor for inflating from xml. 28 * Constructor for inflating from xml.
29 */ 29 */
30 public NewTabPageToolbar(Context context, AttributeSet attrs) { 30 public NewTabPageToolbar(Context context, AttributeSet attrs) {
31 super(context, attrs); 31 super(context, attrs);
32 } 32 }
33 33
34 public View getBookmarksButton() { 34 public View getBookmarksButton() {
35 return mBookmarksButton; 35 return mBookmarksButton;
36 } 36 }
37 37
38 public View getRecentTabsButton() { 38 public View getRecentTabsButton() {
39 return mRecentTabsButton; 39 return mRecentTabsButton;
40 } 40 }
41 41
42 public View getInterestsButton() {
43 return mInterestsButton;
44 }
45
42 @Override 46 @Override
43 protected void onFinishInflate() { 47 protected void onFinishInflate() {
44 mBookmarksButton = initButton(R.id.bookmarks_button, R.drawable.btn_star ); 48 mBookmarksButton = initButton(R.id.bookmarks_button, R.drawable.btn_star );
45 mRecentTabsButton = initButton(R.id.recent_tabs_button, R.drawable.btn_r ecents); 49 mRecentTabsButton = initButton(R.id.recent_tabs_button, R.drawable.btn_r ecents);
46 if (OfflinePageBridge.isEnabled()) { 50 if (OfflinePageBridge.isEnabled()) {
47 ((TextView) mBookmarksButton.getChildAt(0)).setText( 51 ((TextView) mBookmarksButton.getChildAt(0)).setText(
48 R.string.offline_pages_ntp_button_name); 52 R.string.offline_pages_ntp_button_name);
49 ((TextView) mBookmarksButton.getChildAt(0)).setContentDescription( 53 ((TextView) mBookmarksButton.getChildAt(0)).setContentDescription(
50 getResources().getString(R.string.offline_pages_ntp_button_a ccessibility)); 54 getResources().getString(R.string.offline_pages_ntp_button_a ccessibility));
51 } 55 }
56 ((TextView) mBookmarksButton.getChildAt(0)).setText(OfflinePageBridge.is Enabled()
57 ? R.string.offline_pages_ntp_button_name : R.string.ntp_bookmark s);
58 mInterestsButton = initButton(R.id.interests_button, R.drawable.btn_sta r_filled);
52 } 59 }
53 60
54 private ViewGroup initButton(int buttonId, int drawableId) { 61 private ViewGroup initButton(int buttonId, int drawableId) {
55 ViewGroup button = (ViewGroup) findViewById(buttonId); 62 ViewGroup button = (ViewGroup) findViewById(buttonId);
56 TextView textView = (TextView) button.getChildAt(0); 63 TextView textView = (TextView) button.getChildAt(0);
57 64
58 TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResource s(), drawableId); 65 TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResource s(), drawableId);
59 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( 66 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
60 textView, icon, null, null, null); 67 textView, icon, null, null, null);
61 68
62 return button; 69 return button;
63 } 70 }
64 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698