Commit 709ea442 authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Update the search widget for the new modern UI.

BUG=866639

Change-Id: If645b1f9f57f64d87b30f49e62a5063b12f1ce08
Reviewed-on: https://chromium-review.googlesource.com/1169766
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583744}
parent 1cdb65b8
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
android:paddingTop="3dp" android:paddingTop="3dp"
android:paddingBottom="3dp" > android:paddingBottom="3dp" >
<EditText <EditText
style="@style/TextAppearance.NewTabPageSearchBoxText"
android:id="@+id/search_box_text" android:id="@+id/search_box_text"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
...@@ -57,8 +58,7 @@ ...@@ -57,8 +58,7 @@
android:focusable="false" android:focusable="false"
android:gravity="center_vertical" android:gravity="center_vertical"
android:inputType="text" android:inputType="text"
android:singleLine="true" android:singleLine="true" />
android:textAppearance="@style/TextAppearance.NewTabPageSearchBoxText" />
<org.chromium.chrome.browser.widget.TintedImageView <org.chromium.chrome.browser.widget.TintedImageView
android:id="@+id/voice_search_button" android:id="@+id/voice_search_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -17,15 +17,6 @@ ...@@ -17,15 +17,6 @@
android:background="@android:color/white" android:background="@android:color/white"
android:layout="@layout/omnibox_results_container" /> android:layout="@layout/omnibox_results_container" />
<ImageView
android:id="@+id/toolbar_shadow"
android:src="@drawable/toolbar_shadow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/toolbar_height_no_shadow"
android:scaleType="fitXY"
tools:ignore="ContentDescription" />
<FrameLayout <FrameLayout
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -38,8 +29,10 @@ ...@@ -38,8 +29,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/search_activity_location_bar_margin_start" android:layout_marginTop="@dimen/location_bar_vertical_margin"
android:layout_marginEnd="@dimen/search_activity_location_bar_margin_end" /> android:layout_marginBottom="@dimen/location_bar_vertical_margin"
android:layout_marginStart="@dimen/modern_toolbar_background_focused_left_margin"
android:layout_marginEnd="@dimen/modern_toolbar_background_focused_left_margin" />
</FrameLayout> </FrameLayout>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:alpha="0.9" android:alpha="0.9"
android:background="@drawable/card_single" android:background="@drawable/modern_toolbar_background_white"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" > android:orientation="horizontal" >
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
and sits in a 48dp x 48dp box. This means there's an implied 12dp of padding and sits in a 48dp x 48dp box. This means there's an implied 12dp of padding
around the entire microphone. --> around the entire microphone. -->
<TextView <TextView
style="@style/TextAppearance.NewTabPageSearchBoxText"
android:id="@+id/title" android:id="@+id/title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="48dp" android:layout_height="48dp"
...@@ -31,9 +32,7 @@ ...@@ -31,9 +32,7 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:singleLine="true" android:singleLine="true"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:text="@string/search_widget_default" android:hint="@string/search_widget_default" />
android:textColor="@color/google_grey_600"
android:textSize="17sp" />
<ImageView <ImageView
android:id="@+id/microphone_icon" android:id="@+id/microphone_icon"
......
...@@ -43,10 +43,6 @@ ...@@ -43,10 +43,6 @@
<!-- Payments UI --> <!-- Payments UI -->
<dimen name="payments_ui_max_dialog_width">600dp</dimen> <dimen name="payments_ui_max_dialog_width">600dp</dimen>
<!-- Search widget dimensions -->
<dimen name="search_activity_location_bar_margin_start">0dp</dimen>
<dimen name="search_activity_location_bar_margin_end">4dp</dimen>
<!-- Clear browsing data preferences dimensions --> <!-- Clear browsing data preferences dimensions -->
<dimen name="clear_browsing_data_button_margin">16dp</dimen> <dimen name="clear_browsing_data_button_margin">16dp</dimen>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<!-- Extend MainThemeBase rather than MainTheme to avoid values-v27 navigation bar colors from <!-- Extend MainThemeBase rather than MainTheme to avoid values-v27 navigation bar colors from
being applied --> being applied -->
<style name="SearchActivityTheme" parent="MainThemeBase"> <style name="SearchActivityTheme" parent="MainThemeBase">
<item name="android:windowBackground">@color/google_grey_500</item> <item name="android:windowBackground">@android:color/white</item>
</style> </style>
<style name="TabbedModeThemeBase" parent="MainTheme"> <style name="TabbedModeThemeBase" parent="MainTheme">
...@@ -615,6 +615,11 @@ ...@@ -615,6 +615,11 @@
<style name="NewTabPageRecyclerView"> <style name="NewTabPageRecyclerView">
<item name="android:colorEdgeEffect" tools:targetApi="21">@color/google_grey_300</item> <item name="android:colorEdgeEffect" tools:targetApi="21">@color/google_grey_300</item>
</style> </style>
<!-- Use style="..." for the following search box style as textColorHint
can not use android:textAppearance="...". textColorHint is defined
in a parent theme therefore can not be overridden by appearance.
-->
<style name="TextAppearance.NewTabPageSearchBoxText"> <style name="TextAppearance.NewTabPageSearchBoxText">
<item name="android:textSize">@dimen/location_bar_url_text_size</item> <item name="android:textSize">@dimen/location_bar_url_text_size</item>
<item name="android:textColorHint">@color/search_box_hint</item> <item name="android:textColorHint">@color/search_box_hint</item>
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
<color name="modern_light_grey">#F1F3F4</color> <color name="modern_light_grey">#F1F3F4</color>
<color name="modern_grey_800">#3C4043</color> <color name="modern_grey_800">#3C4043</color>
<color name="modern_grey_700">#5F6368</color>
<color name="modern_grey_500">#9AA0A6</color> <color name="modern_grey_500">#9AA0A6</color>
<!-- Old color palette --> <!-- Old color palette -->
...@@ -56,7 +57,6 @@ ...@@ -56,7 +57,6 @@
<color name="google_grey_200">#EEEEEE</color> <color name="google_grey_200">#EEEEEE</color>
<color name="google_grey_300">#E0E0E0</color> <color name="google_grey_300">#E0E0E0</color>
<color name="google_grey_400">#BDBDBD</color> <color name="google_grey_400">#BDBDBD</color>
<color name="google_grey_500">#9E9E9E</color>
<color name="google_grey_600">#757575</color> <color name="google_grey_600">#757575</color>
<color name="light_grey">#CCCCCC</color> <color name="light_grey">#CCCCCC</color>
...@@ -221,7 +221,7 @@ ...@@ -221,7 +221,7 @@
<color name="toolbar_shadow_color">@color/black_alpha_11</color> <color name="toolbar_shadow_color">@color/black_alpha_11</color>
<color name="bottom_system_nav_color">@android:color/white</color> <color name="bottom_system_nav_color">@android:color/white</color>
<color name="bottom_system_nav_divider_color">@color/black_alpha_12</color> <color name="bottom_system_nav_divider_color">@color/black_alpha_12</color>
<color name="search_box_hint">@color/black_alpha_54</color> <color name="search_box_hint">@color/modern_grey_700</color>
<color name="placeholder_thumbnail_bg_color">#DADCE0</color> <color name="placeholder_thumbnail_bg_color">#DADCE0</color>
<color name="clear_browsing_data_selected_tab_color">@color/modern_blue_600</color> <color name="clear_browsing_data_selected_tab_color">@color/modern_blue_600</color>
......
...@@ -550,10 +550,6 @@ ...@@ -550,10 +550,6 @@
<!-- Divider Dimensions --> <!-- Divider Dimensions -->
<dimen name="divider_height">1dp</dimen> <dimen name="divider_height">1dp</dimen>
<!-- Search widget dimensions -->
<dimen name="search_activity_location_bar_margin_start">16dp</dimen>
<dimen name="search_activity_location_bar_margin_end">8dp</dimen>
<!-- Reader Mode dimensions --> <!-- Reader Mode dimensions -->
<!-- Padding surrounding the message. --> <!-- Padding surrounding the message. -->
<dimen name="reader_mode_infobar_text_padding">8dp</dimen> <dimen name="reader_mode_infobar_text_padding">8dp</dimen>
......
...@@ -316,7 +316,10 @@ class SuggestionView extends ViewGroup { ...@@ -316,7 +316,10 @@ class SuggestionView extends ViewGroup {
.getDimension(R.dimen.omnibox_suggestion_second_line_text_size)); .getDimension(R.dimen.omnibox_suggestion_second_line_text_size));
mRefineViewOffsetPx = useModernDesign ? mRefineViewModernEndPadding : 0; mRefineViewOffsetPx = useModernDesign ? mRefineViewModernEndPadding : 0;
mSuggestionViewStartOffset = useModernDesign ? mSuggestionListModernOffset : 0; mSuggestionViewStartOffset =
useModernDesign && !mLocationBar.mustQueryUrlBarLocationForSuggestions()
? mSuggestionListModernOffset
: 0;
// Suggestions with attached answers are rendered with rich results regardless of which // Suggestions with attached answers are rendered with rich results regardless of which
// suggestion type they are. // suggestion type they are.
......
...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.searchwidget; ...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.searchwidget;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
...@@ -20,6 +21,7 @@ import org.chromium.chrome.browser.omnibox.UrlBar; ...@@ -20,6 +21,7 @@ import org.chromium.chrome.browser.omnibox.UrlBar;
import org.chromium.chrome.browser.omnibox.UrlBarCoordinator.SelectionState; import org.chromium.chrome.browser.omnibox.UrlBarCoordinator.SelectionState;
import org.chromium.chrome.browser.omnibox.UrlBarData; import org.chromium.chrome.browser.omnibox.UrlBarData;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.toolbar.ToolbarPhone;
import org.chromium.ui.UiUtils; import org.chromium.ui.UiUtils;
import java.util.List; import java.util.List;
...@@ -42,6 +44,25 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout { ...@@ -42,6 +44,25 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
public SearchActivityLocationBarLayout(Context context, AttributeSet attrs) { public SearchActivityLocationBarLayout(Context context, AttributeSet attrs) {
super(context, attrs, R.layout.location_bar_base); super(context, attrs, R.layout.location_bar_base);
setUrlBarFocusable(true); setUrlBarFocusable(true);
setBackground(ToolbarPhone.createModernLocationBarBackground(getResources()));
// Now you might ask yourself what these paddings are doing? Great question, really glad
// you asked...OH MY...LOOK BEHIND YOU!!!
//
// <Sounds of original author running away>
//
// These numbers were chosen at a single snapshot in time where they roughly equated to
// the padding used in the modern tabbed mode focused omnibox. There is minimal rhyme or
// reason to this, but using something that approximated the toolbar logic looked even
// worse.
//
// Shrug. Once that layout logic is cleaned up, this should be universally replaced with
// something sane.
int toolbarSidePadding = getResources().getDimensionPixelSize(R.dimen.toolbar_edge_padding);
int backgroundSidePadding = getResources().getDimensionPixelSize(
R.dimen.modern_toolbar_background_focused_left_margin);
ViewCompat.setPaddingRelative(this, backgroundSidePadding + toolbarSidePadding,
getPaddingTop(), backgroundSidePadding, getPaddingBottom());
mPendingSearchPromoDecision = LocaleManager.getInstance().needToCheckForSearchEnginePromo(); mPendingSearchPromoDecision = LocaleManager.getInstance().needToCheckForSearchEnginePromo();
} }
...@@ -163,6 +184,6 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout { ...@@ -163,6 +184,6 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
@Override @Override
public boolean useModernDesign() { public boolean useModernDesign() {
return false; return true;
} }
} }
...@@ -284,7 +284,7 @@ public class SearchWidgetProvider extends AppWidgetProvider { ...@@ -284,7 +284,7 @@ public class SearchWidgetProvider extends AppWidgetProvider {
String text = TextUtils.isEmpty(engineName) || !shouldShowFullString() String text = TextUtils.isEmpty(engineName) || !shouldShowFullString()
? context.getString(R.string.search_widget_default) ? context.getString(R.string.search_widget_default)
: context.getString(R.string.search_with_product, engineName); : context.getString(R.string.search_with_product, engineName);
views.setTextViewText(R.id.title, text); views.setCharSequence(R.id.title, "setHint", text);
return views; return views;
} }
......
...@@ -419,7 +419,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -419,7 +419,7 @@ public class ToolbarPhone extends ToolbarLayout
Resources res = getResources(); Resources res = getResources();
mModernLocationBarBackgroundHeight = mModernLocationBarBackgroundHeight =
res.getDimensionPixelSize(R.dimen.modern_toolbar_background_size); res.getDimensionPixelSize(R.dimen.modern_toolbar_background_size);
mLocationBarBackground = createModernLocationBarBackground(); mLocationBarBackground = createModernLocationBarBackground(getResources());
mLocationBarBackground.getPadding(mLocationBarBackgroundPadding); mLocationBarBackground.getPadding(mLocationBarBackgroundPadding);
mLocationBarBackground.mutate(); mLocationBarBackground.mutate();
mLocationBar.setPadding(mLocationBarBackgroundPadding.left, mLocationBar.setPadding(mLocationBarBackgroundPadding.left,
...@@ -448,12 +448,12 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -448,12 +448,12 @@ public class ToolbarPhone extends ToolbarLayout
/** /**
* @return The drawable for the modern location bar background. * @return The drawable for the modern location bar background.
*/ */
public Drawable createModernLocationBarBackground() { public static Drawable createModernLocationBarBackground(Resources resources) {
Drawable drawable = ApiCompatibilityUtils.getDrawable( Drawable drawable = ApiCompatibilityUtils.getDrawable(
getResources(), R.drawable.modern_toolbar_background_white); resources, R.drawable.modern_toolbar_background_white);
drawable.mutate(); drawable.mutate();
drawable.setColorFilter( drawable.setColorFilter(
ApiCompatibilityUtils.getColor(getResources(), R.color.modern_light_grey), ApiCompatibilityUtils.getColor(resources, R.color.modern_light_grey),
PorterDuff.Mode.SRC_IN); PorterDuff.Mode.SRC_IN);
return drawable; return drawable;
} }
......
...@@ -249,7 +249,7 @@ public class SearchWidgetProviderTest { ...@@ -249,7 +249,7 @@ public class SearchWidgetProviderTest {
// Confirm that the string is correct. // Confirm that the string is correct.
TextView titleView = (TextView) view.findViewById(R.id.title); TextView titleView = (TextView) view.findViewById(R.id.title);
Assert.assertEquals(View.VISIBLE, titleView.getVisibility()); Assert.assertEquals(View.VISIBLE, titleView.getVisibility());
Assert.assertEquals(expectedString, titleView.getText()); Assert.assertEquals(expectedString, titleView.getHint());
// Confirm the visibility of the microphone. // Confirm the visibility of the microphone.
View microphoneView = view.findViewById(R.id.microphone_icon); View microphoneView = view.findViewById(R.id.microphone_icon);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment