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; |
11 import android.content.res.ColorStateList; | 11 import android.content.res.ColorStateList; |
12 import android.graphics.Bitmap; | 12 import android.graphics.Bitmap; |
13 import android.graphics.Canvas; | 13 import android.graphics.Canvas; |
14 import android.graphics.Rect; | 14 import android.graphics.Rect; |
15 import android.graphics.drawable.Drawable; | 15 import android.graphics.drawable.Drawable; |
16 import android.os.SystemClock; | 16 import android.os.SystemClock; |
17 import android.util.AttributeSet; | 17 import android.util.AttributeSet; |
18 import android.view.Gravity; | 18 import android.view.Gravity; |
19 import android.view.View; | 19 import android.view.View; |
20 import android.view.ViewGroup; | 20 import android.view.ViewGroup; |
21 import android.widget.FrameLayout; | 21 import android.widget.FrameLayout; |
22 import android.widget.ImageView; | 22 import android.widget.ImageView; |
23 import android.widget.ProgressBar; | 23 import android.widget.ProgressBar; |
24 | 24 |
25 import org.chromium.base.ApiCompatibilityUtils; | 25 import org.chromium.base.ApiCompatibilityUtils; |
26 import org.chromium.base.VisibleForTesting; | 26 import org.chromium.base.VisibleForTesting; |
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.appmenu.IconHighlightDrawable; | |
29 import org.chromium.chrome.browser.compositor.Invalidator; | 30 import org.chromium.chrome.browser.compositor.Invalidator; |
30 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; | 31 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; |
31 import org.chromium.chrome.browser.fullscreen.BrowserStateBrowserControlsVisibil ityDelegate; | 32 import org.chromium.chrome.browser.fullscreen.BrowserStateBrowserControlsVisibil ityDelegate; |
32 import org.chromium.chrome.browser.ntp.NewTabPage; | 33 import org.chromium.chrome.browser.ntp.NewTabPage; |
33 import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; | 34 import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; |
34 import org.chromium.chrome.browser.omnibox.LocationBar; | 35 import org.chromium.chrome.browser.omnibox.LocationBar; |
35 import org.chromium.chrome.browser.tab.Tab; | 36 import org.chromium.chrome.browser.tab.Tab; |
36 import org.chromium.chrome.browser.util.ViewUtils; | 37 import org.chromium.chrome.browser.util.ViewUtils; |
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; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after 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; | |
80 protected boolean mShowMenuBadge; | 82 protected boolean mShowMenuBadge; |
81 private AnimatorSet mMenuBadgeAnimatorSet; | 83 private AnimatorSet mMenuBadgeAnimatorSet; |
82 private boolean mIsMenuBadgeAnimationRunning; | 84 private boolean mIsMenuBadgeAnimationRunning; |
83 | 85 |
84 /** | 86 /** |
85 * Basic constructor for {@link ToolbarLayout}. | 87 * Basic constructor for {@link ToolbarLayout}. |
86 */ | 88 */ |
87 public ToolbarLayout(Context context, AttributeSet attrs) { | 89 public ToolbarLayout(Context context, AttributeSet attrs) { |
88 super(context, attrs); | 90 super(context, attrs); |
89 mDarkModeTint = | 91 mDarkModeTint = |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
684 | 686 |
685 /** | 687 /** |
686 * Opens hompage in the current tab. | 688 * Opens hompage in the current tab. |
687 */ | 689 */ |
688 protected void openHomepage() { | 690 protected void openHomepage() { |
689 getLocationBar().hideSuggestions(); | 691 getLocationBar().hideSuggestions(); |
690 if (mToolbarTabController != null) mToolbarTabController.openHomepage(); | 692 if (mToolbarTabController != null) mToolbarTabController.openHomepage(); |
691 } | 693 } |
692 | 694 |
693 @Override | 695 @Override |
696 public void setMenuButtonHighlight(boolean highlight) { | |
697 mHighlightingMenu = highlight; | |
698 setAppMenuButtonHighlight(highlight, true /* useLightDrawable*/); | |
Ted C
2017/03/31 19:01:47
should we expose uselightdrawable (mUseLightColorA
| |
699 } | |
700 | |
701 @Override | |
694 public void showAppMenuUpdateBadge() { | 702 public void showAppMenuUpdateBadge() { |
695 mShowMenuBadge = true; | 703 mShowMenuBadge = true; |
696 } | 704 } |
697 | 705 |
698 @Override | 706 @Override |
699 public boolean isShowingAppMenuUpdateBadge() { | 707 public boolean isShowingAppMenuUpdateBadge() { |
700 return mShowMenuBadge; | 708 return mShowMenuBadge; |
701 } | 709 } |
702 | 710 |
703 @Override | 711 @Override |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
788 /** | 796 /** |
789 * Sets the update menu badge drawable to the light or dark asset. | 797 * Sets the update menu badge drawable to the light or dark asset. |
790 * @param useLightDrawable Whether the light drawable should be used. | 798 * @param useLightDrawable Whether the light drawable should be used. |
791 */ | 799 */ |
792 protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawable) { | 800 protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawable) { |
793 mMenuBadge.setImageResource(useLightDrawable ? R.drawable.badge_update_l ight | 801 mMenuBadge.setImageResource(useLightDrawable ? R.drawable.badge_update_l ight |
794 : R.drawable.badge_update_dark); | 802 : R.drawable.badge_update_dark); |
795 } | 803 } |
796 | 804 |
797 /** | 805 /** |
806 * Sets whether or not the menu button should be highlighted (and whether or not to use the | |
807 * light or dark resources. | |
808 * @param highlighting Whether or not the menu button should be highligh ted. | |
809 * @param useLightDrawable Whether or not the light colors should be used. | |
810 */ | |
811 protected void setAppMenuButtonHighlight(boolean highlighting, boolean useLi ghtDrawable) { | |
812 IconHighlightDrawable drawable = null; | |
813 if (highlighting) { | |
814 int colorRes = useLightDrawable ? R.color.google_grey_100 : R.color. google_blue_500; | |
815 int color = ApiCompatibilityUtils.getColor(getContext().getResources (), colorRes); | |
816 | |
817 drawable = new IconHighlightDrawable(color); | |
818 | |
819 drawable.setMargin(ApiCompatibilityUtils.getPaddingStart(mMenuButton ), | |
820 mMenuButton.getPaddingTop(), ApiCompatibilityUtils.getPaddin gEnd(mMenuButton), | |
821 mMenuButton.getPaddingBottom()); | |
822 } | |
823 mMenuButtonWrapper.setBackground(drawable); | |
824 } | |
825 | |
826 /** | |
798 * Sets the content description for the menu button. | 827 * Sets the content description for the menu button. |
799 * @param isUpdateBadgeVisible Whether the update menu badge is visible. | 828 * @param isUpdateBadgeVisible Whether the update menu badge is visible. |
800 */ | 829 */ |
801 protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible) { | 830 protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible) { |
802 if (isUpdateBadgeVisible) { | 831 if (isUpdateBadgeVisible) { |
803 mMenuButton.setContentDescription(getResources().getString( | 832 mMenuButton.setContentDescription(getResources().getString( |
804 R.string.accessibility_toolbar_btn_menu_update)); | 833 R.string.accessibility_toolbar_btn_menu_update)); |
805 } else { | 834 } else { |
806 mMenuButton.setContentDescription(getResources().getString( | 835 mMenuButton.setContentDescription(getResources().getString( |
807 R.string.accessibility_toolbar_btn_menu)); | 836 R.string.accessibility_toolbar_btn_menu)); |
808 } | 837 } |
809 } | 838 } |
810 | 839 |
811 @Override | 840 @Override |
812 public void setBottomSheet(BottomSheet sheet) {} | 841 public void setBottomSheet(BottomSheet sheet) {} |
813 } | 842 } |
OLD | NEW |