OLD | NEW |
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; |
(...skipping 13 matching lines...) Expand all Loading... |
24 import android.widget.ProgressBar; | 24 import android.widget.ProgressBar; |
25 | 25 |
26 import org.chromium.base.ApiCompatibilityUtils; | 26 import org.chromium.base.ApiCompatibilityUtils; |
27 import org.chromium.chrome.R; | 27 import org.chromium.chrome.R; |
28 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; | 28 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; |
29 import org.chromium.chrome.browser.compositor.Invalidator; | 29 import org.chromium.chrome.browser.compositor.Invalidator; |
30 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; | 30 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; |
31 import org.chromium.chrome.browser.ntp.NewTabPage; | 31 import org.chromium.chrome.browser.ntp.NewTabPage; |
32 import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; | 32 import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; |
33 import org.chromium.chrome.browser.omnibox.LocationBar; | 33 import org.chromium.chrome.browser.omnibox.LocationBar; |
| 34 import org.chromium.chrome.browser.omnibox.UrlContainer; |
34 import org.chromium.chrome.browser.tab.Tab; | 35 import org.chromium.chrome.browser.tab.Tab; |
35 import org.chromium.chrome.browser.util.ViewUtils; | 36 import org.chromium.chrome.browser.util.ViewUtils; |
36 import org.chromium.chrome.browser.widget.TintedImageButton; | 37 import org.chromium.chrome.browser.widget.TintedImageButton; |
37 import org.chromium.chrome.browser.widget.ToolbarProgressBar; | 38 import org.chromium.chrome.browser.widget.ToolbarProgressBar; |
38 import org.chromium.ui.UiUtils; | 39 import org.chromium.ui.UiUtils; |
39 import org.chromium.ui.widget.Toast; | 40 import org.chromium.ui.widget.Toast; |
40 | 41 |
| 42 import javax.annotation.Nullable; |
| 43 |
41 /** | 44 /** |
42 * Layout class that contains the base shared logic for manipulating the toolbar
component. For | 45 * Layout class that contains the base shared logic for manipulating the toolbar
component. For |
43 * interaction that are not from Views inside Toolbar hierarchy all interactions
should be done | 46 * interaction that are not from Views inside Toolbar hierarchy all interactions
should be done |
44 * through {@link Toolbar} rather than using this class directly. | 47 * through {@link Toolbar} rather than using this class directly. |
45 */ | 48 */ |
46 abstract class ToolbarLayout extends FrameLayout implements Toolbar { | 49 abstract class ToolbarLayout extends FrameLayout implements Toolbar { |
47 protected static final int BACKGROUND_TRANSITION_DURATION_MS = 400; | 50 protected static final int BACKGROUND_TRANSITION_DURATION_MS = 400; |
48 | 51 |
49 private Invalidator mInvalidator; | 52 private Invalidator mInvalidator; |
50 | 53 |
51 private final int[] mTempPosition = new int[2]; | 54 private final int[] mTempPosition = new int[2]; |
52 | 55 |
53 /** | 56 /** |
54 * The ImageButton view that represents the menu button. | 57 * The ImageButton view that represents the menu button. |
55 */ | 58 */ |
56 protected TintedImageButton mMenuButton; | 59 protected TintedImageButton mMenuButton; |
57 protected ImageView mMenuBadge; | 60 protected ImageView mMenuBadge; |
58 protected View mMenuButtonWrapper; | 61 protected View mMenuButtonWrapper; |
| 62 @Nullable |
| 63 private UrlContainer mUrlContainer; |
59 private AppMenuButtonHelper mAppMenuButtonHelper; | 64 private AppMenuButtonHelper mAppMenuButtonHelper; |
60 | 65 |
61 protected final ColorStateList mDarkModeTint; | 66 protected final ColorStateList mDarkModeTint; |
62 protected final ColorStateList mLightModeTint; | 67 protected final ColorStateList mLightModeTint; |
63 | 68 |
64 private ToolbarDataProvider mToolbarDataProvider; | 69 private ToolbarDataProvider mToolbarDataProvider; |
65 private ToolbarTabController mToolbarTabController; | 70 private ToolbarTabController mToolbarTabController; |
| 71 @Nullable |
66 private ToolbarProgressBar mProgressBar; | 72 private ToolbarProgressBar mProgressBar; |
67 | 73 |
68 private boolean mNativeLibraryReady; | 74 private boolean mNativeLibraryReady; |
69 private boolean mUrlHasFocus; | 75 private boolean mUrlHasFocus; |
70 | 76 |
71 private long mFirstDrawTimeMs; | 77 private long mFirstDrawTimeMs; |
72 | 78 |
73 protected final int mToolbarHeightWithoutShadow; | 79 protected final int mToolbarHeightWithoutShadow; |
74 | 80 |
75 private boolean mFindInPageToolbarShowing; | 81 private boolean mFindInPageToolbarShowing; |
(...skipping 24 matching lines...) Expand all Loading... |
100 removeView(mProgressBar); | 106 removeView(mProgressBar); |
101 getFrameLayoutParams(mProgressBar).topMargin = mToolbarHeightWithout
Shadow | 107 getFrameLayoutParams(mProgressBar).topMargin = mToolbarHeightWithout
Shadow |
102 - getFrameLayoutParams(mProgressBar).height; | 108 - getFrameLayoutParams(mProgressBar).height; |
103 if (isNativeLibraryReady()) mProgressBar.initializeAnimation(); | 109 if (isNativeLibraryReady()) mProgressBar.initializeAnimation(); |
104 } | 110 } |
105 | 111 |
106 mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); | 112 mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); |
107 mMenuBadge = (ImageView) findViewById(R.id.menu_badge); | 113 mMenuBadge = (ImageView) findViewById(R.id.menu_badge); |
108 mMenuButtonWrapper = findViewById(R.id.menu_button_wrapper); | 114 mMenuButtonWrapper = findViewById(R.id.menu_button_wrapper); |
109 | 115 |
| 116 mUrlContainer = (UrlContainer) findViewById(R.id.url_container); |
| 117 |
110 // Initialize the provider to an empty version to avoid null checking ev
erywhere. | 118 // Initialize the provider to an empty version to avoid null checking ev
erywhere. |
111 mToolbarDataProvider = new ToolbarDataProvider() { | 119 mToolbarDataProvider = new ToolbarDataProvider() { |
112 @Override | 120 @Override |
113 public boolean isIncognito() { | 121 public boolean isIncognito() { |
114 return false; | 122 return false; |
115 } | 123 } |
116 | 124 |
117 @Override | 125 @Override |
118 public Tab getTab() { | 126 public Tab getTab() { |
119 return null; | 127 return null; |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 * Returns the elapsed realtime in ms of the time at which first draw for th
e toolbar occurred. | 547 * Returns the elapsed realtime in ms of the time at which first draw for th
e toolbar occurred. |
540 */ | 548 */ |
541 public long getFirstDrawTime() { | 549 public long getFirstDrawTime() { |
542 return mFirstDrawTimeMs; | 550 return mFirstDrawTimeMs; |
543 } | 551 } |
544 | 552 |
545 /** | 553 /** |
546 * Notified when a navigation to a different page has occurred. | 554 * Notified when a navigation to a different page has occurred. |
547 */ | 555 */ |
548 protected void onNavigatedToDifferentPage() { | 556 protected void onNavigatedToDifferentPage() { |
| 557 if (mUrlContainer != null) mUrlContainer.setTrailingTextVisible(true); |
549 } | 558 } |
550 | 559 |
551 /** | 560 /** |
552 * Starts load progress. | 561 * Starts load progress. |
553 */ | 562 */ |
554 protected void startLoadProgress() { | 563 protected void startLoadProgress() { |
555 if (mProgressBar != null) { | 564 if (mProgressBar != null) { |
556 mProgressBar.start(); | 565 mProgressBar.start(); |
557 } | 566 } |
558 } | 567 } |
(...skipping 10 matching lines...) Expand all Loading... |
569 | 578 |
570 /** | 579 /** |
571 * Finishes load progress. | 580 * Finishes load progress. |
572 * @param delayed Whether hiding progress bar should be delayed to give enou
gh time for user to | 581 * @param delayed Whether hiding progress bar should be delayed to give enou
gh time for user to |
573 * recognize the last state. | 582 * recognize the last state. |
574 */ | 583 */ |
575 protected void finishLoadProgress(boolean delayed) { | 584 protected void finishLoadProgress(boolean delayed) { |
576 if (mProgressBar != null) { | 585 if (mProgressBar != null) { |
577 mProgressBar.finish(delayed); | 586 mProgressBar.finish(delayed); |
578 } | 587 } |
| 588 if (mUrlContainer != null) mUrlContainer.setTrailingTextVisible(false); |
579 } | 589 } |
580 | 590 |
581 /** | 591 /** |
582 * Finish any toolbar animations. | 592 * Finish any toolbar animations. |
583 */ | 593 */ |
584 public void finishAnimations() { } | 594 public void finishAnimations() { } |
585 | 595 |
586 /** | 596 /** |
587 * @return The current View showing in the Tab. | 597 * @return The current View showing in the Tab. |
588 */ | 598 */ |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 } else { | 768 } else { |
759 mMenuButton.setContentDescription(getResources().getString( | 769 mMenuButton.setContentDescription(getResources().getString( |
760 R.string.accessibility_toolbar_btn_menu)); | 770 R.string.accessibility_toolbar_btn_menu)); |
761 } | 771 } |
762 } | 772 } |
763 | 773 |
764 @Override | 774 @Override |
765 public void setReturnButtonListener(View.OnClickListener listener) { | 775 public void setReturnButtonListener(View.OnClickListener listener) { |
766 } | 776 } |
767 } | 777 } |
OLD | NEW |