Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java

Issue 2574003002: Android: Remove MobileStartup.Toolbar* histograms (Closed)
Patch Set: Remove one more. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.animation.Animator; 7 import android.animation.Animator;
8 import android.animation.AnimatorListenerAdapter; 8 import android.animation.AnimatorListenerAdapter;
9 import android.animation.AnimatorSet; 9 import android.animation.AnimatorSet;
10 import android.annotation.SuppressLint; 10 import android.annotation.SuppressLint;
11 import android.content.Context; 11 import android.content.Context;
12 import android.content.res.ColorStateList; 12 import android.content.res.ColorStateList;
13 import android.graphics.Bitmap;
14 import android.graphics.Canvas;
15 import android.graphics.Rect; 13 import android.graphics.Rect;
16 import android.graphics.drawable.Drawable; 14 import android.graphics.drawable.Drawable;
17 import android.os.SystemClock;
18 import android.util.AttributeSet; 15 import android.util.AttributeSet;
19 import android.view.Gravity; 16 import android.view.Gravity;
20 import android.view.MotionEvent; 17 import android.view.MotionEvent;
21 import android.view.View; 18 import android.view.View;
22 import android.view.ViewGroup; 19 import android.view.ViewGroup;
23 import android.widget.FrameLayout; 20 import android.widget.FrameLayout;
24 import android.widget.ImageView; 21 import android.widget.ImageView;
25 import android.widget.ProgressBar; 22 import android.widget.ProgressBar;
26 23
27 import org.chromium.base.ApiCompatibilityUtils; 24 import org.chromium.base.ApiCompatibilityUtils;
(...skipping 13 matching lines...) Expand all
41 import org.chromium.ui.widget.Toast; 38 import org.chromium.ui.widget.Toast;
42 39
43 import javax.annotation.Nullable; 40 import javax.annotation.Nullable;
44 41
45 /** 42 /**
46 * Layout class that contains the base shared logic for manipulating the toolbar component. For 43 * Layout class that contains the base shared logic for manipulating the toolbar component. For
47 * interaction that are not from Views inside Toolbar hierarchy all interactions should be done 44 * interaction that are not from Views inside Toolbar hierarchy all interactions should be done
48 * through {@link Toolbar} rather than using this class directly. 45 * through {@link Toolbar} rather than using this class directly.
49 */ 46 */
50 abstract class ToolbarLayout extends FrameLayout implements Toolbar { 47 abstract class ToolbarLayout extends FrameLayout implements Toolbar {
51 protected static final int BACKGROUND_TRANSITION_DURATION_MS = 400;
52
53 private Invalidator mInvalidator; 48 private Invalidator mInvalidator;
54 49
55 private final int[] mTempPosition = new int[2]; 50 private final int[] mTempPosition = new int[2];
56 51
57 /** 52 /**
58 * The ImageButton view that represents the menu button. 53 * The ImageButton view that represents the menu button.
59 */ 54 */
60 protected TintedImageButton mMenuButton; 55 protected TintedImageButton mMenuButton;
61 protected ImageView mMenuBadge; 56 protected ImageView mMenuBadge;
62 protected View mMenuButtonWrapper; 57 protected View mMenuButtonWrapper;
63 private AppMenuButtonHelper mAppMenuButtonHelper; 58 private AppMenuButtonHelper mAppMenuButtonHelper;
64 59
65 protected final ColorStateList mDarkModeTint; 60 protected final ColorStateList mDarkModeTint;
66 protected final ColorStateList mLightModeTint; 61 protected final ColorStateList mLightModeTint;
67 62
68 private ToolbarDataProvider mToolbarDataProvider; 63 private ToolbarDataProvider mToolbarDataProvider;
69 private ToolbarTabController mToolbarTabController; 64 private ToolbarTabController mToolbarTabController;
70 @Nullable 65 @Nullable
71 private ToolbarProgressBar mProgressBar; 66 private ToolbarProgressBar mProgressBar;
72 67
73 private boolean mNativeLibraryReady; 68 private boolean mNativeLibraryReady;
74 private boolean mUrlHasFocus; 69 private boolean mUrlHasFocus;
75 70
76 private long mFirstDrawTimeMs;
77
78 protected final int mToolbarHeightWithoutShadow; 71 protected final int mToolbarHeightWithoutShadow;
79 72
80 private boolean mFindInPageToolbarShowing; 73 private boolean mFindInPageToolbarShowing;
81 74
82 protected boolean mShowMenuBadge; 75 protected boolean mShowMenuBadge;
83 private AnimatorSet mMenuBadgeAnimatorSet; 76 private AnimatorSet mMenuBadgeAnimatorSet;
84 private boolean mIsMenuBadgeAnimationRunning; 77 private boolean mIsMenuBadgeAnimationRunning;
85 78
86 /** 79 /**
87 * Basic constructor for {@link ToolbarLayout}. 80 * Basic constructor for {@link ToolbarLayout}.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 225 }
233 226
234 /** 227 /**
235 * @return Whether or not the native library is loaded and ready. 228 * @return Whether or not the native library is loaded and ready.
236 */ 229 */
237 protected boolean isNativeLibraryReady() { 230 protected boolean isNativeLibraryReady() {
238 return mNativeLibraryReady; 231 return mNativeLibraryReady;
239 } 232 }
240 233
241 @Override 234 @Override
242 protected void onDraw(Canvas canvas) {
243 super.onDraw(canvas);
244 recordFirstDrawTime();
245 }
246
247 @Override
248 protected void onAttachedToWindow() { 235 protected void onAttachedToWindow() {
249 super.onAttachedToWindow(); 236 super.onAttachedToWindow();
250 if (mProgressBar != null) { 237 if (mProgressBar != null) {
251 ViewGroup controlContainer = 238 ViewGroup controlContainer =
252 (ViewGroup) getRootView().findViewById(R.id.control_containe r); 239 (ViewGroup) getRootView().findViewById(R.id.control_containe r);
253 int progressBarPosition = UiUtils.insertAfter( 240 int progressBarPosition = UiUtils.insertAfter(
254 controlContainer, mProgressBar, (View) getParent()); 241 controlContainer, mProgressBar, (View) getParent());
255 assert progressBarPosition >= 0; 242 assert progressBarPosition >= 0;
256 mProgressBar.setControlContainer(controlContainer); 243 mProgressBar.setControlContainer(controlContainer);
257 } 244 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 */ 429 */
443 protected void onPrimaryColorChanged(boolean shouldAnimate) { } 430 protected void onPrimaryColorChanged(boolean shouldAnimate) { }
444 431
445 /** 432 /**
446 * Sets the icon drawable that the close button in the toolbar (if any) shou ld show. 433 * Sets the icon drawable that the close button in the toolbar (if any) shou ld show.
447 */ 434 */
448 public void setCloseButtonImageResource(Drawable drawable) { } 435 public void setCloseButtonImageResource(Drawable drawable) { }
449 436
450 /** 437 /**
451 * Sets/adds a custom action button to the {@link ToolbarLayout} if it is su pported. 438 * Sets/adds a custom action button to the {@link ToolbarLayout} if it is su pported.
439 * @param drawable The {@link Drawable} to use as the background for the but ton.
452 * @param description The content description for the button. 440 * @param description The content description for the button.
453 * @param listener The {@link OnClickListener} to use for clicks to the button. 441 * @param listener The {@link OnClickListener} to use for clicks to the button.
454 * @param buttonSource The {@link Bitmap} resource to use as the source for the button.
455 */ 442 */
456 public void setCustomActionButton(Drawable drawable, String description, 443 public void setCustomActionButton(Drawable drawable, String description,
457 OnClickListener listener) { } 444 OnClickListener listener) { }
458 445
459 /** 446 /**
460 * @return The height of the tab strip. Return 0 for toolbars that do not ha ve a tabstrip. 447 * @return The height of the tab strip. Return 0 for toolbars that do not ha ve a tabstrip.
461 */ 448 */
462 public int getTabStripHeight() { 449 public int getTabStripHeight() {
463 return getResources().getDimensionPixelSize(R.dimen.tab_strip_height); 450 return getResources().getDimensionPixelSize(R.dimen.tab_strip_height);
464 } 451 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 536
550 /** 537 /**
551 * Triggered when the URL input field has gained or lost focus. 538 * Triggered when the URL input field has gained or lost focus.
552 * @param hasFocus Whether the URL field has gained focus. 539 * @param hasFocus Whether the URL field has gained focus.
553 */ 540 */
554 protected void onUrlFocusChange(boolean hasFocus) { 541 protected void onUrlFocusChange(boolean hasFocus) {
555 mUrlHasFocus = hasFocus; 542 mUrlHasFocus = hasFocus;
556 } 543 }
557 544
558 /** 545 /**
559 * Keeps track of the first time the toolbar is drawn.
560 */
561 private void recordFirstDrawTime() {
562 if (mFirstDrawTimeMs == 0) mFirstDrawTimeMs = SystemClock.elapsedRealtim e();
563 }
564
565 /**
566 * Returns the elapsed realtime in ms of the time at which first draw for th e toolbar occurred.
567 */
568 public long getFirstDrawTime() {
569 return mFirstDrawTimeMs;
570 }
571
572 /**
573 * Notified when a navigation to a different page has occurred. 546 * Notified when a navigation to a different page has occurred.
574 */ 547 */
575 protected void onNavigatedToDifferentPage() { 548 protected void onNavigatedToDifferentPage() {
576 } 549 }
577 550
578 /** 551 /**
579 * Starts load progress. 552 * Starts load progress.
580 */ 553 */
581 protected void startLoadProgress() { 554 protected void startLoadProgress() {
582 if (mProgressBar != null) { 555 if (mProgressBar != null) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible) { 761 protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible) {
789 if (isUpdateBadgeVisible) { 762 if (isUpdateBadgeVisible) {
790 mMenuButton.setContentDescription(getResources().getString( 763 mMenuButton.setContentDescription(getResources().getString(
791 R.string.accessibility_toolbar_btn_menu_update)); 764 R.string.accessibility_toolbar_btn_menu_update));
792 } else { 765 } else {
793 mMenuButton.setContentDescription(getResources().getString( 766 mMenuButton.setContentDescription(getResources().getString(
794 R.string.accessibility_toolbar_btn_menu)); 767 R.string.accessibility_toolbar_btn_menu));
795 } 768 }
796 } 769 }
797 } 770 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698