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

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: fix 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/layout/new_tab_page_layout.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..aba74e7ebd32a6d05444a3109494ef1267f60a93 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
@@ -6,11 +6,12 @@ package org.chromium.chrome.browser.ntp;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
-import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
/**
@@ -36,6 +37,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 +51,6 @@ public class NewTabPageLayout extends LinearLayout {
private LogoView mSearchProviderLogoView;
private View mSearchBoxView;
private MostVisitedLayout mMostVisitedLayout;
-
Theresa 2016/05/26 21:54:41 nit: please add this line back.
/**
* Constructor for inflating from XML.
*/
@@ -142,7 +143,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 +170,37 @@ 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;
+
+ Drawable background = mSearchBoxView.getBackground();
Theresa 2016/05/26 17:47:26 Can the padding be added via xml? I'm hoping we ca
Bernhard Bauer 2016/05/26 19:43:57 The reason I'm doing this in code is that we still
Theresa 2016/05/26 21:54:41 Can you use defined dimens that represent the corr
Bernhard Bauer 2016/05/27 12:16:41 Done. Note however that keeping the exactly same p
+ Rect padding = new Rect();
+ background.getPadding(padding);
+
+ Resources resources = getContext().getResources();
+ Drawable shadow = resources.getDrawable(R.drawable.textbox);
Theresa 2016/05/26 21:54:41 Resources.getDrawable() is deprecated. Use ApiComp
Bernhard Bauer 2016/05/27 12:16:41 Thanks! That code is gone now though.
+ Rect shadowPadding = new Rect();
+ shadow.getPadding(shadowPadding);
+
+ // Adjust the margins to remove the padding.
Theresa 2016/05/26 21:54:41 Why does the padding need to be removed just to be
Bernhard Bauer 2016/05/27 12:16:41 Sorry, that comment should have been a bit more de
+ MarginLayoutParams layoutParams = (MarginLayoutParams) mSearchBoxView.getLayoutParams();
+ layoutParams.topMargin -= shadowPadding.top;
+ layoutParams.bottomMargin -= shadowPadding.bottom;
+ layoutParams.leftMargin -= shadowPadding.left;
+ layoutParams.rightMargin -= shadowPadding.right;
+ layoutParams.height += shadowPadding.bottom + shadowPadding.top;
+ // Width will be adjusted in onMeasure();
+ mSearchboxViewShadowWidth = shadowPadding.left + shadowPadding.right;
+
+ // Add the extra padding back.
+ mSearchBoxView.setBackground(shadow);
+ mSearchBoxView.setPadding(
+ padding.left + shadowPadding.left,
+ padding.top + shadowPadding.top,
+ padding.right + shadowPadding.right,
+ padding.bottom + shadowPadding.bottom);
}
/**
« no previous file with comments | « chrome/android/java/res/layout/new_tab_page_layout.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698