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.content.Context; | 10 import android.content.Context; |
(...skipping 16 matching lines...) Expand all Loading... |
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.fullscreen.BrowserStateBrowserControlsVisibil
ityDelegate; | 31 import org.chromium.chrome.browser.fullscreen.BrowserStateBrowserControlsVisibil
ityDelegate; |
32 import org.chromium.chrome.browser.ntp.NewTabPage; | 32 import org.chromium.chrome.browser.ntp.NewTabPage; |
33 import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; | 33 import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; |
34 import org.chromium.chrome.browser.omnibox.LocationBar; | 34 import org.chromium.chrome.browser.omnibox.LocationBar; |
35 import org.chromium.chrome.browser.tab.Tab; | 35 import org.chromium.chrome.browser.tab.Tab; |
36 import org.chromium.chrome.browser.util.ViewUtils; | 36 import org.chromium.chrome.browser.util.ViewUtils; |
| 37 import org.chromium.chrome.browser.widget.PulseDrawable; |
37 import org.chromium.chrome.browser.widget.TintedImageButton; | 38 import org.chromium.chrome.browser.widget.TintedImageButton; |
38 import org.chromium.chrome.browser.widget.ToolbarProgressBar; | 39 import org.chromium.chrome.browser.widget.ToolbarProgressBar; |
39 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet; | 40 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet; |
40 import org.chromium.ui.UiUtils; | 41 import org.chromium.ui.UiUtils; |
41 import org.chromium.ui.widget.Toast; | 42 import org.chromium.ui.widget.Toast; |
42 | 43 |
43 import javax.annotation.Nullable; | 44 import javax.annotation.Nullable; |
44 | 45 |
45 /** | 46 /** |
46 * Layout class that contains the base shared logic for manipulating the toolbar
component. For | 47 * Layout class that contains the base shared logic for manipulating the toolbar
component. For |
(...skipping 23 matching lines...) Expand all Loading... |
70 @Nullable | 71 @Nullable |
71 protected ToolbarProgressBar mProgressBar; | 72 protected ToolbarProgressBar mProgressBar; |
72 | 73 |
73 private boolean mNativeLibraryReady; | 74 private boolean mNativeLibraryReady; |
74 private boolean mUrlHasFocus; | 75 private boolean mUrlHasFocus; |
75 | 76 |
76 private long mFirstDrawTimeMs; | 77 private long mFirstDrawTimeMs; |
77 | 78 |
78 private boolean mFindInPageToolbarShowing; | 79 private boolean mFindInPageToolbarShowing; |
79 | 80 |
| 81 protected boolean mHighlightingMenu; |
| 82 private PulseDrawable mHighlightDrawable; |
| 83 |
80 protected boolean mShowMenuBadge; | 84 protected boolean mShowMenuBadge; |
81 private AnimatorSet mMenuBadgeAnimatorSet; | 85 private AnimatorSet mMenuBadgeAnimatorSet; |
82 private boolean mIsMenuBadgeAnimationRunning; | 86 private boolean mIsMenuBadgeAnimationRunning; |
83 | 87 |
84 /** | 88 /** |
85 * Basic constructor for {@link ToolbarLayout}. | 89 * Basic constructor for {@link ToolbarLayout}. |
86 */ | 90 */ |
87 public ToolbarLayout(Context context, AttributeSet attrs) { | 91 public ToolbarLayout(Context context, AttributeSet attrs) { |
88 super(context, attrs); | 92 super(context, attrs); |
89 mDarkModeTint = | 93 mDarkModeTint = |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 protected boolean isIncognito() { | 651 protected boolean isIncognito() { |
648 return mToolbarDataProvider.isIncognito(); | 652 return mToolbarDataProvider.isIncognito(); |
649 } | 653 } |
650 | 654 |
651 /** | 655 /** |
652 * @return {@link LocationBar} object this {@link ToolbarLayout} contains. | 656 * @return {@link LocationBar} object this {@link ToolbarLayout} contains. |
653 */ | 657 */ |
654 public abstract LocationBar getLocationBar(); | 658 public abstract LocationBar getLocationBar(); |
655 | 659 |
656 /** | 660 /** |
| 661 * @return Whether or not this toolbar should use light or dark assets based
on the theme. |
| 662 */ |
| 663 public abstract boolean useLightDrawables(); |
| 664 |
| 665 /** |
657 * Navigates the current Tab back. | 666 * Navigates the current Tab back. |
658 * @return Whether or not the current Tab did go back. | 667 * @return Whether or not the current Tab did go back. |
659 */ | 668 */ |
660 protected boolean back() { | 669 protected boolean back() { |
661 getLocationBar().hideSuggestions(); | 670 getLocationBar().hideSuggestions(); |
662 return mToolbarTabController != null ? mToolbarTabController.back() : fa
lse; | 671 return mToolbarTabController != null ? mToolbarTabController.back() : fa
lse; |
663 } | 672 } |
664 | 673 |
665 /** | 674 /** |
666 * Navigates the current Tab forward. | 675 * Navigates the current Tab forward. |
(...skipping 17 matching lines...) Expand all Loading... |
684 | 693 |
685 /** | 694 /** |
686 * Opens hompage in the current tab. | 695 * Opens hompage in the current tab. |
687 */ | 696 */ |
688 protected void openHomepage() { | 697 protected void openHomepage() { |
689 getLocationBar().hideSuggestions(); | 698 getLocationBar().hideSuggestions(); |
690 if (mToolbarTabController != null) mToolbarTabController.openHomepage(); | 699 if (mToolbarTabController != null) mToolbarTabController.openHomepage(); |
691 } | 700 } |
692 | 701 |
693 @Override | 702 @Override |
| 703 public void setMenuButtonHighlight(boolean highlight) { |
| 704 mHighlightingMenu = highlight; |
| 705 setMenuButtonHighlightDrawable(mHighlightingMenu); |
| 706 } |
| 707 |
| 708 @Override |
694 public void showAppMenuUpdateBadge() { | 709 public void showAppMenuUpdateBadge() { |
695 mShowMenuBadge = true; | 710 mShowMenuBadge = true; |
696 } | 711 } |
697 | 712 |
698 @Override | 713 @Override |
699 public boolean isShowingAppMenuUpdateBadge() { | 714 public boolean isShowingAppMenuUpdateBadge() { |
700 return mShowMenuBadge; | 715 return mShowMenuBadge; |
701 } | 716 } |
702 | 717 |
703 @Override | 718 @Override |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 /** | 803 /** |
789 * Sets the update menu badge drawable to the light or dark asset. | 804 * Sets the update menu badge drawable to the light or dark asset. |
790 * @param useLightDrawable Whether the light drawable should be used. | 805 * @param useLightDrawable Whether the light drawable should be used. |
791 */ | 806 */ |
792 protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawable) { | 807 protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawable) { |
793 mMenuBadge.setImageResource(useLightDrawable ? R.drawable.badge_update_l
ight | 808 mMenuBadge.setImageResource(useLightDrawable ? R.drawable.badge_update_l
ight |
794 : R.drawable.badge_update_dark); | 809 : R.drawable.badge_update_dark); |
795 } | 810 } |
796 | 811 |
797 /** | 812 /** |
| 813 * Sets the menu button's background depending on whether or not we are high
lighting and whether |
| 814 * or not we are using light or dark assets. |
| 815 * @param highlighting Whether or not the menu button should be highlighted. |
| 816 */ |
| 817 protected void setMenuButtonHighlightDrawable(boolean highlighting) { |
| 818 if (highlighting) { |
| 819 if (mHighlightDrawable == null) { |
| 820 mHighlightDrawable = PulseDrawable.createCircle(); |
| 821 mHighlightDrawable.setInset(ApiCompatibilityUtils.getPaddingStar
t(mMenuButton), |
| 822 mMenuButton.getPaddingTop(), |
| 823 ApiCompatibilityUtils.getPaddingEnd(mMenuButton), |
| 824 mMenuButton.getPaddingBottom()); |
| 825 } |
| 826 mHighlightDrawable.setUseLightPulseColor(useLightDrawables()); |
| 827 mMenuButtonWrapper.setBackground(mHighlightDrawable); |
| 828 mHighlightDrawable.start(); |
| 829 } else { |
| 830 mMenuButtonWrapper.setBackground(null); |
| 831 } |
| 832 } |
| 833 |
| 834 /** |
798 * Sets the content description for the menu button. | 835 * Sets the content description for the menu button. |
799 * @param isUpdateBadgeVisible Whether the update menu badge is visible. | 836 * @param isUpdateBadgeVisible Whether the update menu badge is visible. |
800 */ | 837 */ |
801 protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible)
{ | 838 protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible)
{ |
802 if (isUpdateBadgeVisible) { | 839 if (isUpdateBadgeVisible) { |
803 mMenuButton.setContentDescription(getResources().getString( | 840 mMenuButton.setContentDescription(getResources().getString( |
804 R.string.accessibility_toolbar_btn_menu_update)); | 841 R.string.accessibility_toolbar_btn_menu_update)); |
805 } else { | 842 } else { |
806 mMenuButton.setContentDescription(getResources().getString( | 843 mMenuButton.setContentDescription(getResources().getString( |
807 R.string.accessibility_toolbar_btn_menu)); | 844 R.string.accessibility_toolbar_btn_menu)); |
808 } | 845 } |
809 } | 846 } |
810 | 847 |
811 @Override | 848 @Override |
812 public void setBottomSheet(BottomSheet sheet) {} | 849 public void setBottomSheet(BottomSheet sheet) {} |
813 } | 850 } |
OLD | NEW |