OLD | NEW |
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 ((TextView) mBookmarksButton.getChildAt(0)).setText(OfflinePageBridge.is
Enabled() | 50 ((TextView) mBookmarksButton.getChildAt(0)).setText(OfflinePageBridge.is
Enabled() |
47 ? R.string.offline_pages_ntp_button_name : R.string.ntp_bookmark
s); | 51 ? R.string.offline_pages_ntp_button_name : R.string.ntp_bookmark
s); |
| 52 mInterestsButton = initButton(R.id.interests_button, R.drawable.btn_sta
r_filled); |
48 } | 53 } |
49 | 54 |
50 private ViewGroup initButton(int buttonId, int drawableId) { | 55 private ViewGroup initButton(int buttonId, int drawableId) { |
51 ViewGroup button = (ViewGroup) findViewById(buttonId); | 56 ViewGroup button = (ViewGroup) findViewById(buttonId); |
52 TextView textView = (TextView) button.getChildAt(0); | 57 TextView textView = (TextView) button.getChildAt(0); |
53 | 58 |
54 TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResource
s(), drawableId); | 59 TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResource
s(), drawableId); |
55 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( | 60 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( |
56 textView, icon, null, null, null); | 61 textView, icon, null, null, null); |
57 | 62 |
58 return button; | 63 return button; |
59 } | 64 } |
60 } | 65 } |
OLD | NEW |