Commit b343e316 authored by Troy Hildebrandt's avatar Troy Hildebrandt Committed by Commit Bot

Revert "Bring the URL action container to LocationBarTablet."

This reverts commit cb5a488e.

Reason for revert: Forgot to remove the #getUrlContainerViewsForMargin to avoid overlap with the action container. Will create another patch that fixes this.

Original change's description:
> Bring the URL action container to LocationBarTablet.
> 
> On tablets, the layout for the location bar is overridden by the XML
> in layout-sw600dp, which means instead of the url_action_container used
> elsewhere, it's a series of FrameLayouts for action buttons with
> manually calculated margins.
> 
> This CL breaks the url_action_container into its own file to be included
> on both phone and tablet, and gets rid of the tablet-specific layout
> update for calculating the margin of the action buttons.
> 
> Bug: 820273
> Change-Id: I104551325f49dbee0931e9a55c105d61e55f7796
> Reviewed-on: https://chromium-review.googlesource.com/971404
> Reviewed-by: Matthew Jones <mdjones@chromium.org>
> Reviewed-by: Yusuf Ozuysal <yusufo@chromium.org>
> Commit-Queue: Troy Hildebrandt <thildebr@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#548580}

TBR=yusufo@chromium.org,mdjones@chromium.org,thildebr@chromium.org

Change-Id: I274354f53cfa71a235abbb475acaec88580dbfba
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 820273
Reviewed-on: https://chromium-review.googlesource.com/998593Reviewed-by: default avatarTroy Hildebrandt <thildebr@chromium.org>
Commit-Queue: Troy Hildebrandt <thildebr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548588}
parent f096fde9
......@@ -28,9 +28,7 @@
android:visibility="invisible"
android:contentDescription="@string/accessibility_toolbar_btn_site_info" />
</FrameLayout>
<include layout="@layout/location_bar_status" />
<include
android:id="@+id/url_bar"
android:layout_width="match_parent"
......@@ -42,7 +40,30 @@
android:layout_gravity="center_vertical"
android:nextFocusForward="@+id/menu_button"
layout="@layout/url_bar" />
<include layout="@layout/url_action_container" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/delete_button"
style="@style/LocationBarButtonTablet"
android:layout_marginEnd="44dp"
android:src="@drawable/btn_delete_24dp"
android:visibility="gone"
android:contentDescription="@string/accessibility_toolbar_btn_delete_url" />
<!-- delete_button and bookmark_button overlap, so they should have the same right margin -->
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/bookmark_button"
style="@style/LocationBarButtonTablet"
android:layout_marginEnd="40dp"
android:contentDescription="@string/accessibility_menu_bookmark" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/mic_button"
style="@style/LocationBarButtonTablet"
android:nextFocusForward="@+id/menu_button"
android:src="@drawable/btn_mic"
android:contentDescription="@string/accessibility_toolbar_btn_mic" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/save_offline_button"
style="@style/LocationBarButtonTablet"
android:nextFocusForward="@+id/menu_button"
android:src="@drawable/ic_file_download_white_24dp"
android:visibility="gone"
android:contentDescription="@string/download_page" />
</merge>
......@@ -45,6 +45,7 @@
<include layout="@layout/location_bar_status" />
<include
android:id="@+id/url_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="3dp"
......@@ -54,6 +55,33 @@
android:nextFocusForward="@+id/tab_switcher_button"
layout="@layout/url_bar" />
<include layout="@layout/url_action_container" />
<LinearLayout android:id="@+id/url_action_container"
android:layout_width="wrap_content"
android:layout_height="@dimen/toolbar_height_no_shadow"
android:layout_gravity="end|center_vertical"
android:orientation="horizontal"
android:visibility="gone" >
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/delete_button"
style="@style/LocationBarButton"
android:layout_width="@dimen/location_bar_icon_width"
android:layout_height="match_parent"
android:scaleType="center"
android:src="@drawable/btn_delete_24dp"
android:visibility="invisible"
android:contentDescription="@string/accessibility_toolbar_btn_delete_url" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/mic_button"
style="@style/LocationBarButton"
android:layout_width="@dimen/location_bar_icon_width"
android:layout_height="match_parent"
android:scaleType="center"
android:src="@drawable/btn_mic"
android:visibility="invisible"
android:contentDescription="@string/accessibility_toolbar_btn_mic" />
</LinearLayout>
</merge>
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/url_action_container"
android:layout_width="wrap_content"
android:layout_height="@dimen/toolbar_height_no_shadow"
android:layout_gravity="end|center_vertical"
android:orientation="horizontal" >
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/delete_button"
style="@style/LocationBarButton"
android:src="@drawable/btn_delete_24dp"
android:visibility="invisible"
android:contentDescription="@string/accessibility_toolbar_btn_delete_url" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/mic_button"
style="@style/LocationBarButton"
android:src="@drawable/btn_mic"
android:visibility="invisible"
android:contentDescription="@string/accessibility_toolbar_btn_mic" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/bookmark_button"
style="@style/LocationBarButton"
android:visibility="gone"
android:contentDescription="@string/accessibility_menu_bookmark" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/save_offline_button"
style="@style/LocationBarButton"
android:nextFocusForward="@+id/menu_button"
android:src="@drawable/ic_file_download_white_24dp"
android:visibility="gone"
android:contentDescription="@string/download_page" />
</LinearLayout>
</merge>
\ No newline at end of file
......@@ -546,6 +546,8 @@
<!-- Misc styles -->
<style name="LocationBarButton">
<item name="android:background">@null</item>
</style>
<style name="LocationBarButtonTablet" parent="LocationBarButton">
<item name="android:layout_width">@dimen/location_bar_icon_width</item>
<item name="android:layout_height">match_parent</item>
<item name="android:scaleType">center</item>
......
......@@ -88,6 +88,8 @@ public class LocationBarTablet extends LocationBarLayout {
// Whether the microphone and bookmark buttons should be shown in the location bar. These
// buttons are hidden if the window size is < 600dp.
private boolean mShouldShowButtonsWhenUnfocused;
private final int mUrlBarEndPaddingWithButtons;
private final int mUrlBarEndPaddingWithoutButtons;
// Variables needed for animating the location bar and toolbar buttons hiding/showing.
private final int mToolbarButtonsWidth;
......@@ -105,6 +107,12 @@ public class LocationBarTablet extends LocationBarLayout {
super(context, attrs);
mShouldShowButtonsWhenUnfocused = true;
// mUrlBar currently does not have any end padding when buttons are visible in the
// unfocused location bar.
mUrlBarEndPaddingWithButtons = 0;
mUrlBarEndPaddingWithoutButtons = getResources().getDimensionPixelOffset(
R.dimen.toolbar_edge_padding);
mToolbarButtonsWidth = getResources().getDimensionPixelOffset(R.dimen.toolbar_button_width)
* ToolbarTablet.HIDEABLE_BUTTON_COUNT;
mMicButtonWidth = getResources().getDimensionPixelOffset(R.dimen.location_bar_icon_width);
......@@ -236,6 +244,12 @@ public class LocationBarTablet extends LocationBarLayout {
public void setShouldShowButtonsWhenUnfocused(boolean shouldShowButtons) {
mShouldShowButtonsWhenUnfocused = shouldShowButtons;
updateButtonVisibility();
ApiCompatibilityUtils.setPaddingRelative(mUrlBar,
ApiCompatibilityUtils.getPaddingStart(mUrlBar),
mUrlBar.getPaddingTop(),
mShouldShowButtonsWhenUnfocused ? mUrlBarEndPaddingWithButtons :
mUrlBarEndPaddingWithoutButtons,
mUrlBar.getPaddingBottom());
}
/**
......@@ -269,6 +283,38 @@ public class LocationBarTablet extends LocationBarLayout {
}
}
@Override
protected void updateLayoutParams() {
// Calculate the bookmark/delete button margins.
int lastButtonSpace;
if (mSaveOfflineButton.getVisibility() == View.VISIBLE) {
MarginLayoutParams saveOfflineLayoutParams =
(MarginLayoutParams) mSaveOfflineButton.getLayoutParams();
lastButtonSpace = ApiCompatibilityUtils.getMarginEnd(saveOfflineLayoutParams);
} else {
MarginLayoutParams micLayoutParams = (MarginLayoutParams) mMicButton.getLayoutParams();
lastButtonSpace = ApiCompatibilityUtils.getMarginEnd(micLayoutParams);
}
if (mMicButton.getVisibility() == View.VISIBLE
|| mSaveOfflineButton.getVisibility() == View.VISIBLE) {
lastButtonSpace += mMicButtonWidth;
}
final MarginLayoutParams deleteLayoutParams =
(MarginLayoutParams) mDeleteButton.getLayoutParams();
final MarginLayoutParams bookmarkLayoutParams =
(MarginLayoutParams) mBookmarkButton.getLayoutParams();
ApiCompatibilityUtils.setMarginEnd(deleteLayoutParams, lastButtonSpace);
ApiCompatibilityUtils.setMarginEnd(bookmarkLayoutParams, lastButtonSpace);
mDeleteButton.setLayoutParams(deleteLayoutParams);
mBookmarkButton.setLayoutParams(bookmarkLayoutParams);
super.updateLayoutParams();
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
......@@ -452,7 +498,6 @@ public class LocationBarTablet extends LocationBarLayout {
*/
private void setWidthChangeAnimationPercent(float percent) {
mWidthChangePercent = percent;
float offset = (mToolbarButtonsWidth + mToolbarStartPaddingDifference) * percent;
if (LocalizationUtils.isLayoutRtl()) {
......
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