OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.toolbar; | 5 package org.chromium.chrome.browser.toolbar; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.support.v7.widget.Toolbar; | |
8 import android.util.AttributeSet; | 9 import android.util.AttributeSet; |
9 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
10 | 11 |
11 import org.chromium.chrome.R; | 12 import org.chromium.chrome.R; |
12 import org.chromium.chrome.browser.widget.BottomSheet; | 13 import org.chromium.chrome.browser.widget.BottomSheet; |
13 import org.chromium.chrome.browser.widget.BottomSheetObserver; | 14 import org.chromium.chrome.browser.widget.BottomSheetObserver; |
14 | 15 |
15 /** | 16 /** |
16 * Phone specific toolbar that exists at the bottom of the screen. | 17 * Phone specific toolbar that exists at the bottom of the screen. |
17 */ | 18 */ |
18 public class BottomToolbarPhone extends ToolbarPhone implements BottomSheetObser ver { | 19 public class BottomToolbarPhone extends ToolbarPhone implements BottomSheetObser ver { |
19 /** A handle to the bottom sheet. */ | 20 /** A handle to the bottom sheet. */ |
20 private BottomSheet mBottomSheet; | 21 private BottomSheet mBottomSheet; |
21 | 22 |
22 /** | 23 /** |
23 * Whether the end toolbar buttons should be hidden regardless of whether th e URL bar is | 24 * Whether the end toolbar buttons should be hidden regardless of whether th e URL bar is |
24 * focused. | 25 * focused. |
25 */ | 26 */ |
26 private boolean mShouldHideEndToolbarButtons; | 27 private boolean mShouldHideEndToolbarButtons; |
27 | 28 |
28 /** | 29 /** |
29 * This tracks the height fraction of the bottom bar to determine if it is m oving up or down. | 30 * This tracks the height fraction of the bottom bar to determine if it is m oving up or down. |
30 */ | 31 */ |
31 private float mLastHeightFraction; | 32 private float mLastHeightFraction; |
32 | 33 |
33 /** | 34 /** |
35 * Sets the height and title text appearance of the provided toolbar so that its style is | |
36 * consistent with BottomToolbarPhone. | |
37 * @param toolbar The toolbar to style. | |
38 */ | |
39 public static void setToolbarStyle(Toolbar toolbar) { | |
40 // Android's Toolbar class typically changes its height based on device orientation. | |
41 // BottomToolbarPhone has a fixed height. Update |toolbar| to match. | |
42 toolbar.getLayoutParams().height = | |
43 toolbar.getResources().getDimensionPixelOffset(R.dimen.toolbar_h eight_no_shadow); | |
Theresa
2017/03/14 16:29:43
This will also change to bottom_control_container_
mdjones
2017/03/14 20:08:36
I'm going to try to land a patch that adds getHeig
| |
44 | |
45 // Android Toolbar action buttons are aligned based on the minimum heigh t. | |
46 toolbar.setMinimumHeight( | |
47 toolbar.getResources().getDimensionPixelOffset(R.dimen.toolbar_h eight_no_shadow)); | |
Theresa
2017/03/14 16:29:43
The toolbar will get bottom_toolbar_top_margin as
| |
48 | |
49 toolbar.setTitleTextAppearance(toolbar.getContext(), R.style.BottomSheet ContentTitle); | |
50 toolbar.requestLayout(); | |
51 } | |
52 | |
53 /** | |
34 * Constructs a BottomToolbarPhone object. | 54 * Constructs a BottomToolbarPhone object. |
35 * @param context The Context in which this View object is created. | 55 * @param context The Context in which this View object is created. |
36 * @param attrs The AttributeSet that was specified with this View. | 56 * @param attrs The AttributeSet that was specified with this View. |
37 */ | 57 */ |
38 public BottomToolbarPhone(Context context, AttributeSet attrs) { | 58 public BottomToolbarPhone(Context context, AttributeSet attrs) { |
39 super(context, attrs); | 59 super(context, attrs); |
40 } | 60 } |
41 | 61 |
42 @Override | 62 @Override |
43 protected int getProgressBarTopMargin() { | 63 protected int getProgressBarTopMargin() { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 boolean isMovingDown = heightFraction < mLastHeightFraction; | 135 boolean isMovingDown = heightFraction < mLastHeightFraction; |
116 mLastHeightFraction = heightFraction; | 136 mLastHeightFraction = heightFraction; |
117 | 137 |
118 // The only time the omnibox should have focus is when the sheet is full y expanded. Any | 138 // The only time the omnibox should have focus is when the sheet is full y expanded. Any |
119 // movement of the sheet should unfocus it. | 139 // movement of the sheet should unfocus it. |
120 if (isMovingDown && getLocationBar().isUrlBarFocused()) { | 140 if (isMovingDown && getLocationBar().isUrlBarFocused()) { |
121 getLocationBar().setUrlBarFocus(false); | 141 getLocationBar().setUrlBarFocus(false); |
122 } | 142 } |
123 } | 143 } |
124 } | 144 } |
OLD | NEW |