| 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.OfflinePageUtils; | |
| 17 import org.chromium.chrome.browser.widget.TintedDrawable; | 16 import org.chromium.chrome.browser.widget.TintedDrawable; |
| 18 | 17 |
| 19 /** | 18 /** |
| 20 * The toolbar at the bottom of the new tab page. Contains buttons to open the b
ookmarks and | 19 * The toolbar at the bottom of the new tab page. Contains buttons to open the b
ookmarks and |
| 21 * recent tabs pages. | 20 * recent tabs pages. |
| 22 */ | 21 */ |
| 23 public class NewTabPageToolbar extends LinearLayout { | 22 public class NewTabPageToolbar extends LinearLayout { |
| 24 | 23 |
| 25 private ViewGroup mBookmarksButton, mRecentTabsButton, mInterestsButton; | 24 private ViewGroup mBookmarksButton, mRecentTabsButton, mInterestsButton; |
| 26 | 25 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 41 | 40 |
| 42 public View getInterestsButton() { | 41 public View getInterestsButton() { |
| 43 return mInterestsButton; | 42 return mInterestsButton; |
| 44 } | 43 } |
| 45 | 44 |
| 46 @Override | 45 @Override |
| 47 protected void onFinishInflate() { | 46 protected void onFinishInflate() { |
| 48 super.onFinishInflate(); | 47 super.onFinishInflate(); |
| 49 mBookmarksButton = initButton(R.id.bookmarks_button, R.drawable.btn_star
); | 48 mBookmarksButton = initButton(R.id.bookmarks_button, R.drawable.btn_star
); |
| 50 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); |
| 51 ((TextView) mBookmarksButton.getChildAt(0)) | 50 ((TextView) mBookmarksButton.getChildAt(0)).setText(R.string.ntp_bookmar
ks); |
| 52 .setText(OfflinePageUtils.getStringId(R.string.ntp_bookmarks)); | 51 ((TextView) mBookmarksButton.getChildAt(0)).setContentDescription(getRes
ources().getString( |
| 53 ((TextView) mBookmarksButton.getChildAt(0)) | 52 R.string.accessibility_ntp_toolbar_btn_bookmarks)); |
| 54 .setContentDescription(getResources().getString(OfflinePageUtils
.getStringId( | |
| 55 R.string.accessibility_ntp_toolbar_btn_bookmarks))); | |
| 56 mInterestsButton = initButton(R.id.interests_button, R.drawable.btn_sta
r_filled); | 53 mInterestsButton = initButton(R.id.interests_button, R.drawable.btn_sta
r_filled); |
| 57 } | 54 } |
| 58 | 55 |
| 59 private ViewGroup initButton(int buttonId, int drawableId) { | 56 private ViewGroup initButton(int buttonId, int drawableId) { |
| 60 ViewGroup button = (ViewGroup) findViewById(buttonId); | 57 ViewGroup button = (ViewGroup) findViewById(buttonId); |
| 61 TextView textView = (TextView) button.getChildAt(0); | 58 TextView textView = (TextView) button.getChildAt(0); |
| 62 | 59 |
| 63 TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResource
s(), drawableId); | 60 TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResource
s(), drawableId); |
| 64 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( | 61 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( |
| 65 textView, icon, null, null, null); | 62 textView, icon, null, null, null); |
| 66 | 63 |
| 67 return button; | 64 return button; |
| 68 } | 65 } |
| 69 } | 66 } |
| OLD | NEW |