Skip to content

Commit

Permalink
[Snowflake] Make button and chip widget min height 48dp
Browse files Browse the repository at this point in the history
+ Add attribute "verticalInset" to specify the vertical inset of the
  background drawable of the widget
+ Adjust some vertical margins on button/chip usage

Bug: 902484
Change-Id: I7788c83519622b91ede8e3d44019c9ceedeac130
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1650205
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Reviewed-by: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668017}
  • Loading branch information
Becky Zhou authored and Commit Bot committed Jun 11, 2019
1 parent 194bd25 commit 2979769
Show file tree
Hide file tree
Showing 40 changed files with 138 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="@dimen/autofill_assistant_button_height"
android:minHeight="@dimen/min_touch_target_size"
app:chipColor="@color/filled_button_bg"
app:rippleColor="@color/filled_button_ripple_color"
app:cornerRadius="@dimen/autofill_assistant_button_corner_radius"
app:primaryTextAppearance="@style/TextAppearance.WhiteButtonText"
app:iconWidth="24dp"
app:iconHeight="24dp"
app:chipBorderWidth="@dimen/autofill_assistant_filled_button_border_width"/>
app:chipBorderWidth="@dimen/autofill_assistant_filled_button_border_width"
app:verticalInset="@dimen/autofill_assistant_button_bg_vertical_inset" />
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="@dimen/autofill_assistant_button_height"
android:minHeight="@dimen/min_touch_target_size"
style="@style/AssistiveChip"
app:chipColor="@color/default_text_color_inverse"
app:cornerRadius="@dimen/autofill_assistant_button_corner_radius"
app:iconWidth="24dp"
app:iconHeight="24dp"/>
app:iconHeight="24dp"
app:verticalInset="@dimen/autofill_assistant_button_bg_vertical_inset" />

Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
android:id="@+id/button_init_not_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="36dp"
android:minWidth="120dp"
android:singleLine="true"
android:gravity="center"
Expand All @@ -120,7 +119,6 @@
android:id="@+id/button_init_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="36dp"
android:minWidth="120dp"
android:singleLine="true"
android:gravity="center"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
<attr name="secondaryTextAppearance" format="reference"/>
<attr name="rippleColor"/>
<attr name="chipBorderWidth" format="reference"/>
<attr name="verticalInset"/>
</declare-styleable>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
<dimen name="autofill_assistant_info_box_spacing">16dp</dimen>
<dimen name="autofill_assistant_poodle_view_size">34dp</dimen>
<dimen name="autofill_assistant_filled_button_border_width">0dp</dimen>
<dimen name="autofill_assistant_button_height">40dp</dimen>
<dimen name="autofill_assistant_button_corner_radius">40dp</dimen>
<!-- Sets drawable inset to 4dp so that min height of the button background drawable is 40dp
while maintaining a 48dp min height of the button. -->
<dimen name="autofill_assistant_button_bg_vertical_inset">4dp</dimen>
<dimen name="autofill_assistant_suggestions_spacing">16dp</dimen>
<dimen name="autofill_assistant_actions_spacing">8dp</dimen>
<dimen name="autofill_assistant_actions_shadow_width">8dp</dimen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public AssistantActionsCarouselCoordinator(Context context, AssistantCarouselMod
// height of the view. We add the sheet vertical spacing twice as the item decoration will
// add this space above and below each chip.
mView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
context.getResources().getDimensionPixelSize(
R.dimen.autofill_assistant_button_height)
context.getResources().getDimensionPixelSize(R.dimen.min_touch_target_size)
+ 2
* context.getResources().getDimensionPixelSize(
org.chromium.chrome.autofill_assistant.R.dimen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ private ButtonView(Context context, AttributeSet attrs, @StyleRes int themeOverl
org.chromium.chrome.R.style.TextAppearance_ChipText);
int borderWidth = a.getResourceId(R.styleable.ButtonView_chipBorderWidth,
org.chromium.chrome.R.dimen.chip_border_width);
int verticalInset = a.getDimensionPixelSize(R.styleable.ButtonView_verticalInset,
getResources().getDimensionPixelSize(
org.chromium.ui.R.dimen.chip_bg_vertical_inset));
a.recycle();

mIcon = new ChromeImageView(getContext());
Expand All @@ -94,8 +97,9 @@ private ButtonView(Context context, AttributeSet attrs, @StyleRes int themeOverl
setPrimaryTextMargins(4);

// Reset icon and background:
mRippleBackgroundHelper = new RippleBackgroundHelper(this, chipColorId, rippleColorId,
cornerRadius, org.chromium.chrome.R.color.chip_stroke_color, borderWidth);
mRippleBackgroundHelper =
new RippleBackgroundHelper(this, chipColorId, rippleColorId, cornerRadius,
org.chromium.chrome.R.color.chip_stroke_color, borderWidth, verticalInset);
setIcon(INVALID_ICON_ID, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
<org.chromium.ui.widget.ButtonCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:layout_height="@dimen/keyboard_accessory_bar_item_height"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingEnd="@dimen/keyboard_accessory_suggestion_padding"
android:paddingStart="@dimen/keyboard_accessory_suggestion_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_half_padding"
android:layout_marginTop="@dimen/keyboard_accessory_half_padding"
android:textAlignment="center"
style="@style/FilledButton.Flat" />
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
<org.chromium.ui.widget.ButtonCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:layout_height="@dimen/keyboard_accessory_bar_item_height"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:minHeight="0dp"
android:minWidth="0dp"
android:paddingEnd="@dimen/keyboard_accessory_suggestion_padding"
android:paddingStart="@dimen/keyboard_accessory_suggestion_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_half_padding"
android:layout_marginTop="@dimen/keyboard_accessory_half_padding"
android:layout_marginEnd="@dimen/keyboard_accessory_bar_item_padding"
android:textAlignment="center"
style="@style/FilledButton.Flat" />
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
android:minHeight="0dp"
android:minWidth="0dp"
android:paddingBottom="0dp"
android:paddingEnd="@dimen/keyboard_accessory_half_padding"
android:paddingStart="@dimen/keyboard_accessory_half_padding"
android:paddingEnd="@dimen/keyboard_accessory_horizontal_padding"
android:paddingStart="@dimen/keyboard_accessory_horizontal_padding"
android:paddingTop="0dp"
android:layout_marginBottom="@dimen/keyboard_accessory_half_padding"
android:layout_marginTop="@dimen/keyboard_accessory_half_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_chip_vertical_margin"
android:layout_marginTop="@dimen/keyboard_accessory_chip_vertical_margin"
android:elevation="2dp"
android:textAppearance="@style/TextAppearance.BlackTitle2"
android:background="@drawable/autofill_chip_inset"/>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<LinearLayout
android:id="@+id/accessory_bar_contents"
android:layout_width="match_parent"
android:minHeight="@dimen/keyboard_accessory_bar_item_height"
android:minHeight="@dimen/keyboard_accessory_height"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:orientation="horizontal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
android:paddingStart="@dimen/keyboard_accessory_suggestion_padding"
android:paddingEnd="@dimen/keyboard_accessory_suggestion_padding"
android:layout_marginTop="@dimen/keyboard_accessory_sheet_top_margin"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_bottom_margin"
android:orientation="vertical">

<LinearLayout
android:gravity="center_vertical|start"
android:fillViewport="true"
android:layout_height="@dimen/keyboard_accessory_suggestion_height"
android:paddingTop="@dimen/keyboard_accessory_sheet_padding"
android:paddingBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="match_parent"
android:orientation="horizontal">

Expand Down Expand Up @@ -50,26 +48,20 @@
<org.chromium.ui.widget.ChipView
android:id="@+id/company_name"
android:gravity="center_vertical|start"
android:layout_marginTop="@dimen/keyboard_accessory_sheet_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/InputChip" />

<org.chromium.ui.widget.ChipView
android:id="@+id/address_home_line_1"
android:gravity="center_vertical|start"
android:layout_marginTop="@dimen/keyboard_accessory_sheet_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/InputChip" />

<org.chromium.ui.widget.ChipView
android:id="@+id/address_home_line_2"
android:gravity="center_vertical|start"
android:layout_marginTop="@dimen/keyboard_accessory_sheet_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/InputChip" />
Expand All @@ -78,8 +70,6 @@
android:gravity="center_vertical|start"
android:fillViewport="true"
android:layout_height="@dimen/keyboard_accessory_suggestion_height"
android:paddingTop="@dimen/keyboard_accessory_sheet_padding"
android:paddingBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="match_parent"
android:orientation="horizontal">

Expand Down Expand Up @@ -116,17 +106,13 @@
<org.chromium.ui.widget.ChipView
android:id="@+id/phone_home_whole_number"
android:gravity="center_vertical|start"
android:layout_marginTop="@dimen/keyboard_accessory_sheet_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/InputChip" />

<org.chromium.ui.widget.ChipView
android:id="@+id/email_address"
android:gravity="center_vertical|start"
android:layout_marginTop="@dimen/keyboard_accessory_sheet_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/InputChip" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
android:paddingStart="@dimen/keyboard_accessory_suggestion_padding"
android:paddingEnd="@dimen/keyboard_accessory_suggestion_padding"
android:layout_marginTop="@dimen/keyboard_accessory_sheet_top_margin"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_bottom_margin"
android:orientation="horizontal">

<LinearLayout
android:gravity="center_vertical|start"
android:fillViewport="true"
android:layout_height="wrap_content"
android:paddingTop="@dimen/keyboard_accessory_sheet_padding"
android:paddingBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical">
Expand All @@ -37,8 +35,6 @@
android:gravity="center_vertical|start"
android:fillViewport="true"
android:layout_height="@dimen/keyboard_accessory_suggestion_height"
android:paddingTop="@dimen/keyboard_accessory_sheet_padding"
android:paddingBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="match_parent"
android:orientation="horizontal">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
android:paddingStart="@dimen/keyboard_accessory_suggestion_padding"
android:paddingEnd="@dimen/keyboard_accessory_suggestion_padding"
android:layout_marginTop="@dimen/keyboard_accessory_sheet_top_margin"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_bottom_margin"
android:orientation="vertical">


<LinearLayout
android:gravity="center_vertical|start"
android:fillViewport="true"
android:layout_height="@dimen/keyboard_accessory_suggestion_height"
android:paddingTop="@dimen/keyboard_accessory_sheet_padding"
android:paddingBottom="@dimen/keyboard_accessory_sheet_padding"
android:layout_width="match_parent"
android:orientation="horizontal">

Expand Down Expand Up @@ -51,8 +49,6 @@
android:gravity="center_vertical|start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/keyboard_accessory_sheet_padding"
android:layout_marginBottom="@dimen/keyboard_accessory_sheet_padding"
style="@style/InputChip" />

</org.chromium.chrome.browser.keyboard_accessory.sheet_tabs.PasswordAccessoryInfoView>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@
android:gravity="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="@dimen/keyboard_accessory_suggestion_top_bottom_margin"
android:layout_marginTop="@dimen/keyboard_accessory_suggestion_top_bottom_margin"
app:iconWidth="@dimen/keyboard_accessory_bar_item_cc_icon_width"
style="@style/AssistiveChip" />
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
<!-- Autofill keyboard accessory dimensions -->
<dimen name="keyboard_accessory_bar_item_height">36dp</dimen>
<dimen name="keyboard_accessory_bar_item_padding">8dp</dimen>
<dimen name="keyboard_accessory_half_padding">6dp</dimen>
<dimen name="keyboard_accessory_horizontal_padding">6dp</dimen>
<dimen name="keyboard_accessory_height">48dp</dimen>
<!--dimen name="keyboard_accessory_height_with_shadow">56dp</dimen-->
<dimen name="keyboard_accessory_image_top_padding">12dp</dimen>
<dimen name="keyboard_accessory_shadow">5dp</dimen>
<dimen name="keyboard_accessory_chip_vertical_margin">8dp</dimen>
<!--dimen name="keyboard_accessory_sheet_height">330dp</dimen-->
<dimen name="keyboard_accessory_sheet_padding">8dp</dimen>
<dimen name="keyboard_accessory_sheet_top_margin">16dp</dimen>
<dimen name="keyboard_accessory_sheet_bottom_margin">8dp</dimen>
<dimen name="keyboard_accessory_suggestion_padding">16dp</dimen>
<dimen name="keyboard_accessory_suggestion_top_bottom_margin">8dp</dimen>
<dimen name="keyboard_accessory_suggestion_offset">12dp</dimen>
<dimen name="keyboard_accessory_suggestion_height">48dp</dimen>
<dimen name="keyboard_accessory_suggestion_icon_size">20dp</dimen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ private void initializeHorizontalRecyclerView(RecyclerView recyclerView) {
recyclerView.setLayoutManager(
new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));

int pad = getResources().getDimensionPixelSize(R.dimen.keyboard_accessory_half_padding);
int pad =
getResources().getDimensionPixelSize(R.dimen.keyboard_accessory_horizontal_padding);
// Create margins between every element.
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY)) {
recyclerView.addItemDecoration(new HorizontalDividerItemDecoration(pad));
Expand Down
6 changes: 3 additions & 3 deletions chrome/android/java/res/layout/account_signin_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<org.chromium.ui.widget.ButtonCompat
android:id="@+id/negative_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_height="wrap_content"
android:paddingStart="@dimen/fre_button_padding"
android:paddingEnd="@dimen/fre_button_padding"
style="@style/TextButton" />
Expand All @@ -201,15 +201,15 @@
<org.chromium.ui.widget.ButtonCompat
android:id="@+id/positive_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_height="wrap_content"
android:paddingStart="@dimen/fre_button_padding"
android:paddingEnd="@dimen/fre_button_padding"
style="@style/FilledButton.Flat" />

<org.chromium.ui.widget.ButtonCompat
android:id="@+id/more_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_height="wrap_content"
android:drawableEnd="@drawable/down_arrow"
android:drawablePadding="8dp"
android:visibility="gone"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
android:layout_height="wrap_content"
android:paddingStart="@dimen/pref_autofill_field_horizontal_padding"
android:paddingEnd="@dimen/pref_autofill_field_horizontal_padding"
android:paddingTop="@dimen/editor_dialog_section_large_spacing"
android:paddingBottom="@dimen/editor_dialog_section_large_spacing"
android:paddingTop="@dimen/editor_dialog_section_buttons_vertical_padding"
android:paddingBottom="@dimen/editor_dialog_section_buttons_vertical_padding"
android:background="@color/modern_primary_color"
app:stackedMargin="@dimen/infobar_margin_between_stacked_buttons"
app:primaryButtonText="@string/done"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
android:id="@+id/button_preference"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:minHeight="40dp"
android:focusable="false"
style="@style/FilledButton" />
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
<org.chromium.ui.widget.ButtonCompat
android:id="@+id/button_primary"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginBottom="16dp"
android:layout_marginBottom="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="22dp"
android:paddingStart="@dimen/fre_button_padding"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
<org.chromium.ui.widget.ButtonCompat
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginBottom="16dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_gravity="bottom|center_horizontal"
android:paddingStart="@dimen/fre_button_padding"
android:paddingEnd="@dimen/fre_button_padding"
Expand Down
4 changes: 2 additions & 2 deletions chrome/android/java/res/layout/fre_tosanduma.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
<org.chromium.ui.widget.ButtonCompat
android:id="@+id/terms_accept"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginBottom="16dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_gravity="bottom|center_horizontal"
android:paddingStart="@dimen/fre_button_padding"
android:paddingEnd="@dimen/fre_button_padding"
Expand Down
Loading

0 comments on commit 2979769

Please sign in to comment.