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.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.graphics.Canvas; | 9 import android.graphics.Canvas; |
10 import android.graphics.Paint; | 10 import android.graphics.Paint; |
11 import android.graphics.Rect; | 11 import android.graphics.Rect; |
12 import android.graphics.RectF; | 12 import android.graphics.RectF; |
13 import android.support.v7.widget.Toolbar; | 13 import android.support.v7.widget.Toolbar; |
14 import android.util.AttributeSet; | 14 import android.util.AttributeSet; |
15 import android.view.View; | 15 import android.view.View; |
16 import android.view.ViewGroup; | 16 import android.view.ViewGroup; |
17 import android.widget.ImageView; | 17 import android.widget.ImageView; |
18 | 18 |
19 import org.chromium.base.ApiCompatibilityUtils; | 19 import org.chromium.base.ApiCompatibilityUtils; |
20 import org.chromium.chrome.R; | 20 import org.chromium.chrome.R; |
21 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet; | 21 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet; |
| 22 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.BottomSheetCon
tent; |
22 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetObserver; | 23 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetObserver; |
23 | 24 |
24 /** | 25 /** |
25 * Phone specific toolbar that exists at the bottom of the screen. | 26 * Phone specific toolbar that exists at the bottom of the screen. |
26 */ | 27 */ |
27 public class BottomToolbarPhone extends ToolbarPhone implements BottomSheetObser
ver { | 28 public class BottomToolbarPhone extends ToolbarPhone implements BottomSheetObser
ver { |
28 /** The white version of the toolbar handle; used for dark themes and incogn
ito. */ | 29 /** The white version of the toolbar handle; used for dark themes and incogn
ito. */ |
29 private final Bitmap mHandleLight; | 30 private final Bitmap mHandleLight; |
30 | 31 |
31 /** The dark version of the toolbar handle; this is the default handle to us
e. */ | 32 /** The dark version of the toolbar handle; this is the default handle to us
e. */ |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 boolean isMovingDown = heightFraction < mLastHeightFraction; | 226 boolean isMovingDown = heightFraction < mLastHeightFraction; |
226 mLastHeightFraction = heightFraction; | 227 mLastHeightFraction = heightFraction; |
227 | 228 |
228 // The only time the omnibox should have focus is when the sheet is full
y expanded. Any | 229 // The only time the omnibox should have focus is when the sheet is full
y expanded. Any |
229 // movement of the sheet should unfocus it. | 230 // movement of the sheet should unfocus it. |
230 if (isMovingDown && getLocationBar().isUrlBarFocused()) { | 231 if (isMovingDown && getLocationBar().isUrlBarFocused()) { |
231 getLocationBar().setUrlBarFocus(false); | 232 getLocationBar().setUrlBarFocus(false); |
232 } | 233 } |
233 } | 234 } |
234 | 235 |
| 236 @Override |
| 237 public void onSheetStateChanged(int newState) {} |
| 238 |
| 239 @Override |
| 240 public void onSheetContentChanged(BottomSheetContent newContent) {} |
| 241 |
235 /** | 242 /** |
236 * Sets the height and title text appearance of the provided toolbar so that
its style is | 243 * Sets the height and title text appearance of the provided toolbar so that
its style is |
237 * consistent with BottomToolbarPhone. | 244 * consistent with BottomToolbarPhone. |
238 * @param otherToolbar The other {@link Toolbar} to style. | 245 * @param otherToolbar The other {@link Toolbar} to style. |
239 */ | 246 */ |
240 public void setOtherToolbarStyle(Toolbar otherToolbar) { | 247 public void setOtherToolbarStyle(Toolbar otherToolbar) { |
241 // Android's Toolbar class typically changes its height based on device
orientation. | 248 // Android's Toolbar class typically changes its height based on device
orientation. |
242 // BottomToolbarPhone has a fixed height. Update |toolbar| to match. | 249 // BottomToolbarPhone has a fixed height. Update |toolbar| to match. |
243 otherToolbar.getLayoutParams().height = getHeight(); | 250 otherToolbar.getLayoutParams().height = getHeight(); |
244 | 251 |
245 // Android Toolbar action buttons are aligned based on the minimum heigh
t. | 252 // Android Toolbar action buttons are aligned based on the minimum heigh
t. |
246 int extraTopMargin = getExtraTopMargin(); | 253 int extraTopMargin = getExtraTopMargin(); |
247 otherToolbar.setMinimumHeight(getHeight() - extraTopMargin); | 254 otherToolbar.setMinimumHeight(getHeight() - extraTopMargin); |
248 | 255 |
249 otherToolbar.setTitleTextAppearance( | 256 otherToolbar.setTitleTextAppearance( |
250 otherToolbar.getContext(), R.style.BottomSheetContentTitle); | 257 otherToolbar.getContext(), R.style.BottomSheetContentTitle); |
251 ApiCompatibilityUtils.setPaddingRelative(otherToolbar, | 258 ApiCompatibilityUtils.setPaddingRelative(otherToolbar, |
252 ApiCompatibilityUtils.getPaddingStart(otherToolbar), | 259 ApiCompatibilityUtils.getPaddingStart(otherToolbar), |
253 otherToolbar.getPaddingTop() + extraTopMargin, | 260 otherToolbar.getPaddingTop() + extraTopMargin, |
254 ApiCompatibilityUtils.getPaddingEnd(otherToolbar), otherToolbar.
getPaddingBottom()); | 261 ApiCompatibilityUtils.getPaddingEnd(otherToolbar), otherToolbar.
getPaddingBottom()); |
255 | 262 |
256 otherToolbar.requestLayout(); | 263 otherToolbar.requestLayout(); |
257 } | 264 } |
258 } | 265 } |
OLD | NEW |