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.util.AttributeSet; | 8 import android.util.AttributeSet; |
9 | 9 |
10 import org.chromium.chrome.R; | 10 import org.chromium.chrome.R; |
| 11 import org.chromium.chrome.browser.widget.BottomSheet; |
11 | 12 |
12 /** | 13 /** |
13 * Phone specific toolbar that exists at the bottom of the screen. | 14 * Phone specific toolbar that exists at the bottom of the screen. |
14 */ | 15 */ |
15 public class BottomToolbarPhone extends ToolbarPhone { | 16 public class BottomToolbarPhone extends ToolbarPhone { |
| 17 |
| 18 /** A handle to the bottom sheet. */ |
| 19 private BottomSheet mBottomSheet; |
| 20 |
| 21 /** The state of the bottom sheet before the URL bar was focused. */ |
| 22 private int mStateBeforeUrlFocus; |
| 23 |
16 /** | 24 /** |
17 * Constructs a BottomToolbarPhone object. | 25 * Constructs a BottomToolbarPhone object. |
18 * @param context The Context in which this View object is created. | 26 * @param context The Context in which this View object is created. |
19 * @param attrs The AttributeSet that was specified with this View. | 27 * @param attrs The AttributeSet that was specified with this View. |
20 */ | 28 */ |
21 public BottomToolbarPhone(Context context, AttributeSet attrs) { | 29 public BottomToolbarPhone(Context context, AttributeSet attrs) { |
22 super(context, attrs); | 30 super(context, attrs); |
23 } | 31 } |
24 | 32 |
25 @Override | 33 @Override |
26 protected int getProgressBarTopMargin() { | 34 protected int getProgressBarTopMargin() { |
27 // In the case where the toolbar is at the bottom of the screen, the pro
gress bar should | 35 // In the case where the toolbar is at the bottom of the screen, the pro
gress bar should |
28 // be at the top of the toolbar. | 36 // be at the top of the toolbar. |
29 return getContext().getResources().getDimensionPixelSize(R.dimen.toolbar
_shadow_height); | 37 return getContext().getResources().getDimensionPixelSize(R.dimen.toolbar
_shadow_height); |
30 } | 38 } |
| 39 |
| 40 @Override |
| 41 protected void triggerUrlFocusAnimation(final boolean hasFocus) { |
| 42 super.triggerUrlFocusAnimation(hasFocus); |
| 43 |
| 44 if (mBottomSheet == null) return; |
| 45 |
| 46 if (hasFocus) mStateBeforeUrlFocus = mBottomSheet.getSheetState(); |
| 47 mBottomSheet.setSheetState( |
| 48 hasFocus ? BottomSheet.SHEET_STATE_FULL : mStateBeforeUrlFocus,
true); |
| 49 } |
| 50 |
| 51 @Override |
| 52 public void setBottomSheet(BottomSheet sheet) { |
| 53 mBottomSheet = sheet; |
| 54 } |
31 } | 55 } |
OLD | NEW |