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.util.AttributeSet; | 14 import android.util.AttributeSet; |
14 import android.view.View; | 15 import android.view.View; |
15 import android.view.ViewGroup; | 16 import android.view.ViewGroup; |
16 import android.widget.ImageView; | 17 import android.widget.ImageView; |
17 | 18 |
18 import org.chromium.base.ApiCompatibilityUtils; | 19 import org.chromium.base.ApiCompatibilityUtils; |
19 import org.chromium.chrome.R; | 20 import org.chromium.chrome.R; |
20 import org.chromium.chrome.browser.widget.BottomSheet; | 21 import org.chromium.chrome.browser.widget.BottomSheet; |
21 import org.chromium.chrome.browser.widget.BottomSheetObserver; | 22 import org.chromium.chrome.browser.widget.BottomSheetObserver; |
22 | 23 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 public void onSheetOffsetChanged(float heightFraction) { | 224 public void onSheetOffsetChanged(float heightFraction) { |
224 boolean isMovingDown = heightFraction < mLastHeightFraction; | 225 boolean isMovingDown = heightFraction < mLastHeightFraction; |
225 mLastHeightFraction = heightFraction; | 226 mLastHeightFraction = heightFraction; |
226 | 227 |
227 // The only time the omnibox should have focus is when the sheet is full
y expanded. Any | 228 // The only time the omnibox should have focus is when the sheet is full
y expanded. Any |
228 // movement of the sheet should unfocus it. | 229 // movement of the sheet should unfocus it. |
229 if (isMovingDown && getLocationBar().isUrlBarFocused()) { | 230 if (isMovingDown && getLocationBar().isUrlBarFocused()) { |
230 getLocationBar().setUrlBarFocus(false); | 231 getLocationBar().setUrlBarFocus(false); |
231 } | 232 } |
232 } | 233 } |
| 234 |
| 235 /** |
| 236 * Sets the height and title text appearance of the provided toolbar so that
its style is |
| 237 * consistent with BottomToolbarPhone. |
| 238 * @param otherToolbar The other {@link Toolbar} to style. |
| 239 */ |
| 240 public void setOtherToolbarStyle(Toolbar otherToolbar) { |
| 241 // Android's Toolbar class typically changes its height based on device
orientation. |
| 242 // BottomToolbarPhone has a fixed height. Update |toolbar| to match. |
| 243 otherToolbar.getLayoutParams().height = getHeight(); |
| 244 |
| 245 // Android Toolbar action buttons are aligned based on the minimum heigh
t. |
| 246 int extraTopMargin = getExtraTopMargin(); |
| 247 otherToolbar.setMinimumHeight(getHeight() - extraTopMargin); |
| 248 |
| 249 otherToolbar.setTitleTextAppearance( |
| 250 otherToolbar.getContext(), R.style.BottomSheetContentTitle); |
| 251 ApiCompatibilityUtils.setPaddingRelative(otherToolbar, |
| 252 ApiCompatibilityUtils.getPaddingStart(otherToolbar), |
| 253 otherToolbar.getPaddingTop() + extraTopMargin, |
| 254 ApiCompatibilityUtils.getPaddingEnd(otherToolbar), otherToolbar.
getPaddingBottom()); |
| 255 |
| 256 otherToolbar.requestLayout(); |
| 257 } |
233 } | 258 } |
OLD | NEW |