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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java

Issue 2006273002: Use the same shadow for the Android NTP fakebox than for the top omnibox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/res/values/dimens.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java
index 95795e3e097f5abf02423dd8d52f99ee57c52f23..f74873f64ed0e786586a868c5b5882e6d861fce0 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java
@@ -10,7 +10,6 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
-import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
/**
@@ -36,6 +35,7 @@ public class NewTabPageLayout extends LinearLayout {
private final int mTabStripHeight;
private int mParentViewportHeight;
+ private int mSearchboxViewShadowWidth;
private boolean mCardsUiEnabled;
private View mTopSpacer; // Spacer above search logo.
@@ -49,7 +49,6 @@ public class NewTabPageLayout extends LinearLayout {
private LogoView mSearchProviderLogoView;
private View mSearchBoxView;
private MostVisitedLayout mMostVisitedLayout;
-
/**
* Constructor for inflating from XML.
*/
@@ -142,7 +141,8 @@ public class NewTabPageLayout extends LinearLayout {
// Make the search box and logo as wide as the most visited items.
if (mMostVisitedLayout.getVisibility() != GONE) {
final int width = mMostVisitedLayout.getMeasuredWidth() - mMostVisitedLayoutBleed;
- setMeasure(mSearchBoxView, width, mSearchBoxView.getMeasuredHeight());
+ setMeasure(mSearchBoxView, width + mSearchboxViewShadowWidth,
+ mSearchBoxView.getMeasuredHeight());
setMeasure(mSearchProviderLogoView, width, mSearchProviderLogoView.getMeasuredHeight());
}
}
@@ -168,16 +168,32 @@ public class NewTabPageLayout extends LinearLayout {
}
/**
- * Set the search box style. Modify the search box to enable material when snippets or
- * material design is enabled.
+ * Set the search box style, adding a shadow if required.
*/
private void setSearchBoxStyle() {
- if (NtpColorUtils.shouldUseMaterialColors()
- && ApiCompatibilityUtils.setElevation(mSearchBoxView,
- getResources().getDimensionPixelSize(R.dimen.toolbar_elevation))) {
- // Replace drawable with one that does not contain a border.
- mSearchBoxView.setBackgroundResource(R.drawable.bg_ntp_search_box_material);
- }
+ if (!NtpColorUtils.shouldUseMaterialColors()) return;
+
+ Resources resources = getContext().getResources();
+
+ // Adjust the margins to account for the bigger size due to the shadow.
+ MarginLayoutParams layoutParams = (MarginLayoutParams) mSearchBoxView.getLayoutParams();
+ layoutParams.setMargins(
+ resources.getDimensionPixelSize(R.dimen.ntp_search_box_material_margin_left),
+ resources.getDimensionPixelSize(R.dimen.ntp_search_box_material_margin_top),
+ resources.getDimensionPixelSize(R.dimen.ntp_search_box_material_margin_right),
+ resources.getDimensionPixelSize(R.dimen.ntp_search_box_material_margin_bottom));
+ layoutParams.height = resources
+ .getDimensionPixelSize(R.dimen.ntp_search_box_material_height);
+ // Width will be adjusted in onMeasure();
+ mSearchboxViewShadowWidth = resources
+ .getDimensionPixelOffset(R.dimen.ntp_search_box_material_extra_width);
+
+ mSearchBoxView.setBackgroundResource(R.drawable.textbox);
+ mSearchBoxView.setPadding(
+ resources.getDimensionPixelSize(R.dimen.ntp_search_box_material_padding_left),
+ resources.getDimensionPixelSize(R.dimen.ntp_search_box_material_padding_top),
+ resources.getDimensionPixelSize(R.dimen.ntp_search_box_material_padding_right),
+ resources.getDimensionPixelSize(R.dimen.ntp_search_box_material_padding_bottom));
}
/**
« no previous file with comments | « chrome/android/java/res/values/dimens.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698