| 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.content.res.Resources; | 8 import android.content.res.Resources; |
| 9 import android.util.AttributeSet; | 9 import android.util.AttributeSet; |
| 10 import android.view.View; | 10 import android.view.View; |
| 11 import android.widget.LinearLayout; | 11 import android.widget.LinearLayout; |
| 12 | 12 |
| 13 import org.chromium.base.ApiCompatibilityUtils; | 13 import org.chromium.base.ApiCompatibilityUtils; |
| 14 import org.chromium.chrome.R; | 14 import org.chromium.chrome.R; |
| 15 import org.chromium.chrome.browser.ChromeFeatureList; | |
| 16 | 15 |
| 17 /** | 16 /** |
| 18 * Layout for the new tab page. This positions the page elements in the correct
vertical positions. | 17 * Layout for the new tab page. This positions the page elements in the correct
vertical positions. |
| 19 * There are no separate phone and tablet UIs; this layout adapts based on the a
vailable space. | 18 * There are no separate phone and tablet UIs; this layout adapts based on the a
vailable space. |
| 20 */ | 19 */ |
| 21 public class NewTabPageLayout extends LinearLayout { | 20 public class NewTabPageLayout extends LinearLayout { |
| 22 | 21 |
| 23 // Space permitting, the spacers will grow from 0dp to the heights given bel
ow. If there is | 22 // Space permitting, the spacers will grow from 0dp to the heights given bel
ow. If there is |
| 24 // additional space, it will be distributed evenly between the top and botto
m spacers. | 23 // additional space, it will be distributed evenly between the top and botto
m spacers. |
| 25 private static final float TOP_SPACER_HEIGHT_DP = 44f; | 24 private static final float TOP_SPACER_HEIGHT_DP = 44f; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 165 } |
| 167 top += ((MarginLayoutParams) mMostVisitedLayout.getLayoutParams()).topMa
rgin; | 166 top += ((MarginLayoutParams) mMostVisitedLayout.getLayoutParams()).topMa
rgin; |
| 168 return top; | 167 return top; |
| 169 } | 168 } |
| 170 | 169 |
| 171 /** | 170 /** |
| 172 * Set the search box style. Modify the search box to enable material when s
nippets or | 171 * Set the search box style. Modify the search box to enable material when s
nippets or |
| 173 * material design is enabled. | 172 * material design is enabled. |
| 174 */ | 173 */ |
| 175 private void setSearchBoxStyle() { | 174 private void setSearchBoxStyle() { |
| 176 if ((ChromeFeatureList.isEnabled(ChromeFeatureList.NTP_SNIPPETS) | 175 if (NtpColorUtils.shouldUseMaterialColors() |
| 177 || ChromeFeatureList.isEnabled(ChromeFeatureList.NTP_MATERIA
L_DESIGN)) | |
| 178 && ApiCompatibilityUtils.setElevation(mSearchBoxView, | 176 && ApiCompatibilityUtils.setElevation(mSearchBoxView, |
| 179 getResources().getDimensionPixelSize(R.dimen.toolbar_
elevation))) { | 177 getResources().getDimensionPixelSize(R.dimen.toolbar_
elevation))) { |
| 180 // Replace drawable with one that does not contain a border. | 178 // Replace drawable with one that does not contain a border. |
| 181 mSearchBoxView.setBackgroundResource(R.drawable.bg_ntp_search_box_ma
terial); | 179 mSearchBoxView.setBackgroundResource(R.drawable.bg_ntp_search_box_ma
terial); |
| 182 } | 180 } |
| 183 } | 181 } |
| 184 | 182 |
| 185 /** | 183 /** |
| 186 * Distribute extra vertical space between the three spacer views. | 184 * Distribute extra vertical space between the three spacer views. |
| 187 * @param extraHeight The amount of extra space, in pixels. | 185 * @param extraHeight The amount of extra space, in pixels. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 214 | 212 |
| 215 /** | 213 /** |
| 216 * Convenience method to call |measure| on the given View with MeasureSpecs
converted from the | 214 * Convenience method to call |measure| on the given View with MeasureSpecs
converted from the |
| 217 * given dimensions (in pixels) with MeasureSpec.EXACTLY. | 215 * given dimensions (in pixels) with MeasureSpec.EXACTLY. |
| 218 */ | 216 */ |
| 219 private void setMeasure(View view, int widthPx, int heightPx) { | 217 private void setMeasure(View view, int widthPx, int heightPx) { |
| 220 view.measure(MeasureSpec.makeMeasureSpec(widthPx, MeasureSpec.EXACTLY), | 218 view.measure(MeasureSpec.makeMeasureSpec(widthPx, MeasureSpec.EXACTLY), |
| 221 MeasureSpec.makeMeasureSpec(heightPx, MeasureSpec.EXACTLY)); | 219 MeasureSpec.makeMeasureSpec(heightPx, MeasureSpec.EXACTLY)); |
| 222 } | 220 } |
| 223 } | 221 } |
| OLD | NEW |