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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 public boolean onTouchEvent(MotionEvent event) { | 102 public boolean onTouchEvent(MotionEvent event) { |
103 mGestureDetector.onTouchEvent(event); | 103 mGestureDetector.onTouchEvent(event); |
104 return super.onTouchEvent(event); | 104 return super.onTouchEvent(event); |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 private static final int TITLE_ANIM_DELAY_MS = 800; | 108 private static final int TITLE_ANIM_DELAY_MS = 800; |
109 private static final int STATE_DOMAIN_ONLY = 0; | 109 private static final int STATE_DOMAIN_ONLY = 0; |
110 private static final int STATE_TITLE_ONLY = 1; | 110 private static final int STATE_TITLE_ONLY = 1; |
111 private static final int STATE_DOMAIN_AND_TITLE = 2; | 111 private static final int STATE_DOMAIN_AND_TITLE = 2; |
112 private static final int STATE_DOMAIN_AND_TITLE_NO_ANIM = 3; | |
112 | 113 |
113 private View mLocationBarFrameLayout; | 114 private View mLocationBarFrameLayout; |
114 private View mTitleUrlContainer; | 115 private View mTitleUrlContainer; |
115 private UrlBar mUrlBar; | 116 private UrlBar mUrlBar; |
116 private TextView mTitleBar; | 117 private TextView mTitleBar; |
117 private TintedImageButton mSecurityButton; | 118 private TintedImageButton mSecurityButton; |
118 private ImageButton mCustomActionButton; | 119 private ImageButton mCustomActionButton; |
119 private int mSecurityIconType; | 120 private int mSecurityIconType; |
120 private ImageButton mCloseButton; | 121 private ImageButton mCloseButton; |
121 | 122 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 | 253 |
253 @Override | 254 @Override |
254 public boolean shouldEmphasizeHttpsScheme() { | 255 public boolean shouldEmphasizeHttpsScheme() { |
255 int securityLevel = getSecurityLevel(); | 256 int securityLevel = getSecurityLevel(); |
256 return securityLevel == ConnectionSecurityLevel.DANGEROUS | 257 return securityLevel == ConnectionSecurityLevel.DANGEROUS |
257 || securityLevel == ConnectionSecurityLevel.SECURE_WITH_POLICY_I NSTALLED_CERT; | 258 || securityLevel == ConnectionSecurityLevel.SECURE_WITH_POLICY_I NSTALLED_CERT; |
258 } | 259 } |
259 | 260 |
260 @Override | 261 @Override |
261 public void setShowTitle(boolean showTitle) { | 262 public void setShowTitle(boolean showTitle) { |
263 if (mState == STATE_DOMAIN_AND_TITLE_NO_ANIM) return; | |
264 | |
262 if (showTitle) { | 265 if (showTitle) { |
263 mState = STATE_DOMAIN_AND_TITLE; | 266 mState = STATE_DOMAIN_AND_TITLE; |
264 mAnimDelegate.prepareTitleAnim(mUrlBar, mTitleBar); | 267 mAnimDelegate.prepareTitleAnim(mUrlBar, mTitleBar); |
265 } else { | 268 } else { |
266 mState = STATE_DOMAIN_ONLY; | 269 mState = STATE_DOMAIN_ONLY; |
267 } | 270 } |
268 } | 271 } |
269 | 272 |
270 @Override | 273 @Override |
271 public void setUrlBarHidden(boolean hideUrlBar) { | 274 public void setUrlBarHidden(boolean hideUrlBar) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 DomDistillerUrlUtils.getValueForKeyInUrl(url, "entry_id" )); | 378 DomDistillerUrlUtils.getValueForKeyInUrl(url, "entry_id" )); |
376 displayText = | 379 displayText = |
377 DomDistillerTabUtils.getFormattedUrlFromOriginalDistille rUrl(originalUrl); | 380 DomDistillerTabUtils.getFormattedUrlFromOriginalDistille rUrl(originalUrl); |
378 } else if (DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url) != null) { | 381 } else if (DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url) != null) { |
379 String originalUrl = DomDistillerUrlUtils.getOriginalUrlFromDist illerUrl(url); | 382 String originalUrl = DomDistillerUrlUtils.getOriginalUrlFromDist illerUrl(url); |
380 displayText = | 383 displayText = |
381 DomDistillerTabUtils.getFormattedUrlFromOriginalDistille rUrl(originalUrl); | 384 DomDistillerTabUtils.getFormattedUrlFromOriginalDistille rUrl(originalUrl); |
382 } | 385 } |
383 } | 386 } |
384 | 387 |
385 if (mUrlBar.setUrl(url, displayText)) { | 388 boolean showUrl = true; |
389 | |
390 // For media viewer, title animation is disabled. Hence, set the URL and title bars to their | |
391 // final size. | |
392 if (mState == STATE_DOMAIN_AND_TITLE_NO_ANIM) { | |
393 mUrlBar.setTextSize(TypedValue.COMPLEX_UNIT_PX, | |
394 getResources().getDimension(R.dimen.custom_tabs_url_text_siz e)); | |
395 mTitleBar.setTextSize(TypedValue.COMPLEX_UNIT_PX, | |
396 getResources().getDimension(R.dimen.custom_tabs_title_text_s ize)); | |
397 mUrlBar.setVisibility(View.VISIBLE); | |
398 mTitleBar.setVisibility(View.VISIBLE); | |
399 | |
400 // Show both url and title at the same time, or none if not availabl e yet. | |
401 if (TextUtils.isEmpty(getCurrentTab().getTitle())) { | |
Ian Wen
2017/01/10 20:04:52
How can we guarantee that the urlbar will be shown
| |
402 showUrl = false; | |
403 } | |
404 } | |
405 | |
406 if (showUrl && mUrlBar.setUrl(url, displayText)) { | |
386 mUrlBar.deEmphasizeUrl(); | 407 mUrlBar.deEmphasizeUrl(); |
387 mUrlBar.emphasizeUrl(); | 408 mUrlBar.emphasizeUrl(); |
388 } | 409 } |
389 } | 410 } |
390 | 411 |
391 private boolean isStoredArticle(String url) { | 412 private boolean isStoredArticle(String url) { |
392 DomDistillerService domDistillerService = | 413 DomDistillerService domDistillerService = |
393 DomDistillerServiceFactory.getForProfile(Profile.getLastUsedProf ile()); | 414 DomDistillerServiceFactory.getForProfile(Profile.getLastUsedProf ile()); |
394 String entryIdFromUrl = DomDistillerUrlUtils.getValueForKeyInUrl(url, "e ntry_id"); | 415 String entryIdFromUrl = DomDistillerUrlUtils.getValueForKeyInUrl(url, "e ntry_id"); |
395 if (TextUtils.isEmpty(entryIdFromUrl)) return false; | 416 if (TextUtils.isEmpty(entryIdFromUrl)) return false; |
(...skipping 23 matching lines...) Expand all Loading... | |
419 if (!ColorUtils.isUsingDefaultToolbarColor(getResources(), | 440 if (!ColorUtils.isUsingDefaultToolbarColor(getResources(), |
420 getBackground().getColor())) { | 441 getBackground().getColor())) { |
421 getProgressBar().setThemeColor(getBackground().getColor(), false ); | 442 getProgressBar().setThemeColor(getBackground().getColor(), false ); |
422 } else { | 443 } else { |
423 getProgressBar().setBackgroundColor(ApiCompatibilityUtils.getCol or(resources, | 444 getProgressBar().setBackgroundColor(ApiCompatibilityUtils.getCol or(resources, |
424 R.color.progress_bar_background)); | 445 R.color.progress_bar_background)); |
425 getProgressBar().setForegroundColor(ApiCompatibilityUtils.getCol or(resources, | 446 getProgressBar().setForegroundColor(ApiCompatibilityUtils.getCol or(resources, |
426 R.color.progress_bar_foreground)); | 447 R.color.progress_bar_foreground)); |
427 } | 448 } |
428 } | 449 } |
450 | |
451 if (mState == STATE_DOMAIN_AND_TITLE_NO_ANIM) { | |
452 getProgressBar().setVisibility(View.INVISIBLE); | |
453 } | |
429 } | 454 } |
430 | 455 |
431 private void updateButtonsTint() { | 456 private void updateButtonsTint() { |
432 mMenuButton.setTint(mUseDarkColors ? mDarkModeTint : mLightModeTint); | 457 mMenuButton.setTint(mUseDarkColors ? mDarkModeTint : mLightModeTint); |
433 if (mCloseButton.getDrawable() instanceof TintedDrawable) { | 458 if (mCloseButton.getDrawable() instanceof TintedDrawable) { |
434 ((TintedDrawable) mCloseButton.getDrawable()).setTint( | 459 ((TintedDrawable) mCloseButton.getDrawable()).setTint( |
435 mUseDarkColors ? mDarkModeTint : mLightModeTint); | 460 mUseDarkColors ? mDarkModeTint : mLightModeTint); |
436 } | 461 } |
437 if (mCustomActionButton.getDrawable() instanceof TintedDrawable) { | 462 if (mCustomActionButton.getDrawable() instanceof TintedDrawable) { |
438 ((TintedDrawable) mCustomActionButton.getDrawable()).setTint( | 463 ((TintedDrawable) mCustomActionButton.getDrawable()).setTint( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 @Override | 504 @Override |
480 public ColorDrawable getBackground() { | 505 public ColorDrawable getBackground() { |
481 return (ColorDrawable) super.getBackground(); | 506 return (ColorDrawable) super.getBackground(); |
482 } | 507 } |
483 | 508 |
484 @Override | 509 @Override |
485 public void initializeControls(WindowDelegate windowDelegate, ActionBarDeleg ate delegate, | 510 public void initializeControls(WindowDelegate windowDelegate, ActionBarDeleg ate delegate, |
486 WindowAndroid windowAndroid) { | 511 WindowAndroid windowAndroid) { |
487 } | 512 } |
488 | 513 |
514 public void disableTitleAnimation() { | |
Ian Wen
2017/01/10 20:04:52
javadoc on public method. Besides, I would move th
| |
515 mState = STATE_DOMAIN_AND_TITLE_NO_ANIM; | |
516 } | |
517 | |
489 private int getSecurityLevel() { | 518 private int getSecurityLevel() { |
490 if (getCurrentTab() == null) return ConnectionSecurityLevel.NONE; | 519 if (getCurrentTab() == null) return ConnectionSecurityLevel.NONE; |
491 return getCurrentTab().getSecurityLevel(); | 520 return getCurrentTab().getSecurityLevel(); |
492 } | 521 } |
493 | 522 |
494 @Override | 523 @Override |
495 public void updateSecurityIcon(int securityLevel) { | 524 public void updateSecurityIcon(int securityLevel) { |
496 if (mState == STATE_TITLE_ONLY) return; | 525 if (mState == STATE_TITLE_ONLY) return; |
497 | 526 |
498 mSecurityIconType = securityLevel; | 527 mSecurityIconType = securityLevel; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 | 784 |
756 @Override | 785 @Override |
757 protected void setAppMenuUpdateBadgeToVisible(boolean animate) {} | 786 protected void setAppMenuUpdateBadgeToVisible(boolean animate) {} |
758 | 787 |
759 @Override | 788 @Override |
760 public View getMenuButtonWrapper() { | 789 public View getMenuButtonWrapper() { |
761 // This class has no menu button wrapper, so return the menu button inst ead. | 790 // This class has no menu button wrapper, so return the menu button inst ead. |
762 return mMenuButton; | 791 return mMenuButton; |
763 } | 792 } |
764 } | 793 } |
OLD | NEW |