Commit 09a67769 authored by newt's avatar newt Committed by Commit bot

Max-width, floating infobars.

This adds a width restriction on infobars. If the webpage is wider than
the infobar max width (600dp), the infobars will "float" in the middle
bottom of the page with shadows on the left, top, and right edges of
each infobar.

BUG=396223

Review URL: https://codereview.chromium.org/1587403002

Cr-Commit-Position: refs/heads/master@{#370740}
parent fbdb86ee
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item> <item>
<bitmap <bitmap
android:src="@drawable/infobar_shadow" android:src="@drawable/infobar_shadow_top"
android:gravity="top|fill_horizontal" android:gravity="top|fill_horizontal"
android:tileMode="disabled" /> android:tileMode="disabled" />
</item> </item>
<item <item
android:top="10dp" android:top="@dimen/infobar_shadow_height"
android:drawable="@android:color/white" /> android:drawable="@android:color/white" />
</layer-list> </layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/infobar_bg"
android:minHeight="@dimen/infobar_peeking_height_with_shadow"
android:paddingTop="@dimen/infobar_shadow_height" />
...@@ -68,12 +68,20 @@ ...@@ -68,12 +68,20 @@
<dimen name="infobar_big_icon_message_size">18sp</dimen> <dimen name="infobar_big_icon_message_size">18sp</dimen>
<!-- Text size of descriptive controls on an infobar. --> <!-- Text size of descriptive controls on an infobar. -->
<dimen name="infobar_descriptive_text_size">14sp</dimen> <dimen name="infobar_descriptive_text_size">14sp</dimen>
<!-- Minimum width of an infobar. -->
<dimen name="infobar_min_width">220dp</dimen>
<!-- Padding surrounding the infobar. --> <!-- Padding surrounding the infobar. -->
<dimen name="infobar_padding">16dp</dimen> <dimen name="infobar_padding">16dp</dimen>
<!-- Margin between stacked buttons in an infobar. --> <!-- Margin between stacked buttons in an infobar. -->
<dimen name="infobar_margin_between_stacked_buttons">24dp</dimen> <dimen name="infobar_margin_between_stacked_buttons">24dp</dimen>
<!-- Minimum width of an infobar. -->
<dimen name="infobar_min_width">220dp</dimen>
<!-- Maximum width of an infobar. -->
<dimen name="infobar_max_width">600dp</dimen>
<!-- Width of side shadows on floating infobars. -->
<dimen name="infobar_shadow_width">8dp</dimen>
<!-- Height of top shadow on each infobar. -->
<dimen name="infobar_shadow_height">8dp</dimen>
<!-- Distance that a back infobar peeks out above the front infobar. -->
<dimen name="infobar_peeking_height">10dp</dimen>
<!-- Vertical margin applied between groups of controls. --> <!-- Vertical margin applied between groups of controls. -->
<dimen name="infobar_margin_above_control_groups">24dp</dimen> <dimen name="infobar_margin_above_control_groups">24dp</dimen>
...@@ -90,10 +98,6 @@ ...@@ -90,10 +98,6 @@
<dimen name="infobar_big_icon_size">48dp</dimen> <dimen name="infobar_big_icon_size">48dp</dimen>
<dimen name="infobar_big_icon_margin">16dp</dimen> <dimen name="infobar_big_icon_margin">16dp</dimen>
<dimen name="infobar_shadow_height">10dp</dimen>
<dimen name="infobar_peeking_height">10dp</dimen>
<dimen name="infobar_peeking_height_with_shadow">20dp</dimen>
<!-- Contextual search dimensions --> <!-- Contextual search dimensions -->
<dimen name="contextual_search_bar_height">56dp</dimen> <dimen name="contextual_search_bar_height">56dp</dimen>
<dimen name="contextual_search_text_size">18sp</dimen> <dimen name="contextual_search_text_size">18sp</dimen>
......
...@@ -115,7 +115,8 @@ public class InfoBarContainer extends SwipableOverlayView { ...@@ -115,7 +115,8 @@ public class InfoBarContainer extends SwipableOverlayView {
mParentView = parentView; mParentView = parentView;
mLayout = new InfoBarContainerLayout(context); mLayout = new InfoBarContainerLayout(context);
addView(mLayout); addView(mLayout, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
// Chromium's InfoBarContainer may add an InfoBar immediately during this initialization // Chromium's InfoBarContainer may add an InfoBar immediately during this initialization
// call, so make sure everything in the InfoBarContainer is completely ready beforehand. // call, so make sure everything in the InfoBarContainer is completely ready beforehand.
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.infobar;
import android.content.Context;
import android.content.res.Resources;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import org.chromium.chrome.R;
/**
* Layout that holds an infobar's contents and provides a background color and a top shadow.
*/
class InfoBarWrapper extends FrameLayout {
/**
* Constructor for inflating from Java.
*/
InfoBarWrapper(Context context) {
super(context);
Resources res = context.getResources();
int peekingHeight = res.getDimensionPixelSize(R.dimen.infobar_peeking_height);
int shadowHeight = res.getDimensionPixelSize(R.dimen.infobar_shadow_height);
setMinimumHeight(peekingHeight + shadowHeight);
// setBackgroundResource() changes the padding, so call setPadding() second.
setBackgroundResource(R.drawable.infobar_wrapper_bg);
setPadding(0, shadowHeight, 0, 0);
}
@Override
public void onViewAdded(View child) {
child.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
Gravity.TOP));
}
}
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