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.ValueAnimator; | 9 import android.animation.ValueAnimator; |
10 import android.animation.ValueAnimator.AnimatorUpdateListener; | 10 import android.animation.ValueAnimator.AnimatorUpdateListener; |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 if (getCurrentTab() == null) return ConnectionSecurityLevel.NONE; | 490 if (getCurrentTab() == null) return ConnectionSecurityLevel.NONE; |
491 return getCurrentTab().getSecurityLevel(); | 491 return getCurrentTab().getSecurityLevel(); |
492 } | 492 } |
493 | 493 |
494 @Override | 494 @Override |
495 public void updateSecurityIcon(int securityLevel) { | 495 public void updateSecurityIcon(int securityLevel) { |
496 if (mState == STATE_TITLE_ONLY) return; | 496 if (mState == STATE_TITLE_ONLY) return; |
497 | 497 |
498 mSecurityIconType = securityLevel; | 498 mSecurityIconType = securityLevel; |
499 | 499 |
500 boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext()); | |
500 boolean isOfflinePage = getCurrentTab() != null && getCurrentTab().isOff linePage(); | 501 boolean isOfflinePage = getCurrentTab() != null && getCurrentTab().isOff linePage(); |
501 boolean showSecurityButton = securityLevel != ConnectionSecurityLevel.NO NE || isOfflinePage; | |
502 | 502 |
503 if (securityLevel == ConnectionSecurityLevel.NONE) { | 503 int id = LocationBarLayout.getSecurityIconResource( |
504 if (isOfflinePage && mShowsOfflinePage != isOfflinePage) { | 504 securityLevel, isSmallDevice, isOfflinePage); |
505 TintedDrawable bolt = TintedDrawable.constructTintedDrawable( | 505 boolean showSecurityButton = true; |
506 getResources(), R.drawable.offline_pin); | 506 if (id == 0) { |
507 bolt.setTint(mUseDarkColors ? mDarkModeTint : mLightModeTint); | 507 // Hide the button if we don't have an actual icon to display. |
508 mSecurityButton.setImageDrawable(bolt); | 508 showSecurityButton = false; |
509 } | 509 mSecurityButton.setImageDrawable(null); |
510 } else { | 510 } else { |
511 boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext()); | 511 // ImageView#setImageResource is no-op if given resource is the curr ent one. |
512 int id = LocationBarLayout.getSecurityIconResource(securityLevel, is SmallDevice); | 512 mSecurityButton.setImageResource(id); |
513 if (id == 0) { | 513 mSecurityButton.setTint( |
514 // Hide the button if we don't have an actual icon to display. | 514 LocationBarLayout.getColorStateList(securityLevel, getToolba rDataProvider(), |
515 showSecurityButton = false; | 515 getResources(), ColorUtils.shouldUseOpaqueTextboxBac kground( |
Ted C
2016/10/24 17:19:45
why the change for the last param? we never show
fgorski
2016/10/24 22:34:14
For some reason when testing it on Friday I saw im
| |
516 } else { | 516 getToolbarDataProvider().get PrimaryColor()))); |
517 // ImageView#setImageResource is no-op if given resource is the current one. | |
518 mSecurityButton.setImageResource(id); | |
519 mSecurityButton.setTint( | |
520 LocationBarLayout.getColorStateList(securityLevel, getTo olbarDataProvider(), | |
521 getResources(), false /* omnibox is not opaque * /)); | |
522 } | |
523 } | 517 } |
524 | 518 |
525 mShowsOfflinePage = isOfflinePage; | 519 mShowsOfflinePage = isOfflinePage; |
526 | 520 |
527 if (showSecurityButton) { | 521 if (showSecurityButton) { |
528 mAnimDelegate.showSecurityButton(); | 522 mAnimDelegate.showSecurityButton(); |
529 } else { | 523 } else { |
530 mAnimDelegate.hideSecurityButton(); | 524 mAnimDelegate.hideSecurityButton(); |
531 } | 525 } |
532 | 526 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 | 756 |
763 @Override | 757 @Override |
764 protected void setAppMenuUpdateBadgeToVisible(boolean animate) {} | 758 protected void setAppMenuUpdateBadgeToVisible(boolean animate) {} |
765 | 759 |
766 @Override | 760 @Override |
767 public View getMenuButtonWrapper() { | 761 public View getMenuButtonWrapper() { |
768 // This class has no menu button wrapper, so return the menu button inst ead. | 762 // This class has no menu button wrapper, so return the menu button inst ead. |
769 return mMenuButton; | 763 return mMenuButton; |
770 } | 764 } |
771 } | 765 } |
OLD | NEW |