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.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
11 import android.annotation.SuppressLint; | 11 import android.annotation.SuppressLint; |
12 import android.content.Context; | 12 import android.content.Context; |
13 import android.content.res.ColorStateList; | 13 import android.content.res.ColorStateList; |
14 import android.content.res.Configuration; | 14 import android.content.res.Configuration; |
15 import android.content.res.Resources; | 15 import android.content.res.Resources; |
16 import android.graphics.Bitmap; | 16 import android.graphics.Bitmap; |
17 import android.graphics.drawable.BitmapDrawable; | 17 import android.graphics.drawable.BitmapDrawable; |
18 import android.graphics.drawable.ColorDrawable; | 18 import android.graphics.drawable.ColorDrawable; |
19 import android.text.TextUtils; | 19 import android.text.TextUtils; |
20 import android.text.TextUtils.TruncateAt; | |
21 import android.util.AttributeSet; | 20 import android.util.AttributeSet; |
22 import android.util.Pair; | 21 import android.util.Pair; |
23 import android.util.TypedValue; | 22 import android.util.TypedValue; |
24 import android.view.KeyEvent; | 23 import android.view.KeyEvent; |
25 import android.view.MotionEvent; | 24 import android.view.MotionEvent; |
26 import android.view.View; | 25 import android.view.View; |
27 import android.widget.ImageButton; | 26 import android.widget.ImageButton; |
28 import android.widget.ImageView; | 27 import android.widget.ImageView; |
29 import android.widget.TextView; | 28 import android.widget.TextView; |
30 | 29 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // ImageView#setImageResource is no-op if given resource is the current
one. | 362 // ImageView#setImageResource is no-op if given resource is the current
one. |
364 mSecurityButton.setImageResource(LocationBarLayout.getSecurityIconResour
ce( | 363 mSecurityButton.setImageResource(LocationBarLayout.getSecurityIconResour
ce( |
365 securityLevel, !shouldEmphasizeHttpsScheme())); | 364 securityLevel, !shouldEmphasizeHttpsScheme())); |
366 | 365 |
367 if (mSecurityIconType == securityLevel) return; | 366 if (mSecurityIconType == securityLevel) return; |
368 mSecurityIconType = securityLevel; | 367 mSecurityIconType = securityLevel; |
369 | 368 |
370 if (securityLevel == ConnectionSecurityLevel.NONE) { | 369 if (securityLevel == ConnectionSecurityLevel.NONE) { |
371 // TODO(yusufo): Add an animator for hiding as well. | 370 // TODO(yusufo): Add an animator for hiding as well. |
372 mSecurityButton.setVisibility(GONE); | 371 mSecurityButton.setVisibility(GONE); |
373 } else { | 372 } else if (mSecurityButton.getVisibility() != View.VISIBLE) { |
374 if (mSecurityButtonShowAnimator.isRunning()) mSecurityButtonShowAnim
ator.cancel(); | 373 if (mSecurityButtonShowAnimator.isRunning()) mSecurityButtonShowAnim
ator.cancel(); |
375 mSecurityButtonShowAnimator.start(); | 374 mSecurityButtonShowAnimator.start(); |
376 mUrlBar.deEmphasizeUrl(); | 375 mUrlBar.deEmphasizeUrl(); |
377 } | 376 } |
378 mUrlBar.emphasizeUrl(); | 377 mUrlBar.emphasizeUrl(); |
379 mUrlBar.invalidate(); | 378 mUrlBar.invalidate(); |
380 } | 379 } |
381 | 380 |
382 /** | 381 /** |
383 * For extending classes to override and carry out the changes related with
the primary color | 382 * For extending classes to override and carry out the changes related with
the primary color |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | 464 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
466 updateLayoutParams(); | 465 updateLayoutParams(); |
467 super.onMeasure(widthMeasureSpec, heightMeasureSpec); | 466 super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
468 } | 467 } |
469 | 468 |
470 @Override | 469 @Override |
471 public LocationBar getLocationBar() { | 470 public LocationBar getLocationBar() { |
472 return this; | 471 return this; |
473 } | 472 } |
474 | 473 |
475 @Override | |
476 protected void onLayout(boolean changed, int left, int top, int right, int b
ottom) { | |
477 if (changed) { | |
478 final int availWidth = mUrlInfoContainer.getMeasuredWidth() | |
479 - ApiCompatibilityUtils.getPaddingStart(mTitleBar) | |
480 - ApiCompatibilityUtils.getPaddingEnd(mTitleBar); | |
481 String currentText = mTitleBar.getText().toString(); | |
482 String currentTitle; | |
483 Tab currentTab = getToolbarDataProvider().getTab(); | |
484 if (currentTab == null || TextUtils.isEmpty(currentTab.getTitle()))
{ | |
485 currentTitle = ""; | |
486 } else { | |
487 currentTitle = currentTab.getTitle(); | |
488 } | |
489 String ellipsizedText = TextUtils.ellipsize(currentTitle, | |
490 mTitleBar.getPaint(), availWidth, TruncateAt.END).toString()
; | |
491 if (!ellipsizedText.equals(currentText)) mTitleBar.setText(ellipsize
dText); | |
492 } | |
493 super.onLayout(changed, left, top, right, bottom); | |
494 } | |
495 | |
496 // Toolbar and LocationBar calls that are not relevant here. | 474 // Toolbar and LocationBar calls that are not relevant here. |
497 | 475 |
498 @Override | 476 @Override |
499 public void setToolbarDataProvider(ToolbarDataProvider model) { } | 477 public void setToolbarDataProvider(ToolbarDataProvider model) { } |
500 | 478 |
501 @Override | 479 @Override |
502 public void onUrlPreFocusChanged(boolean gainFocus) { | 480 public void onUrlPreFocusChanged(boolean gainFocus) { |
503 } | 481 } |
504 | 482 |
505 @Override | 483 @Override |
(...skipping 23 matching lines...) Expand all Loading... |
529 public void onTabLoadingNTP(NewTabPage ntp) { | 507 public void onTabLoadingNTP(NewTabPage ntp) { |
530 } | 508 } |
531 | 509 |
532 @Override | 510 @Override |
533 public void setAutocompleteProfile(Profile profile) { | 511 public void setAutocompleteProfile(Profile profile) { |
534 } | 512 } |
535 | 513 |
536 @Override | 514 @Override |
537 public void backKeyPressed() { } | 515 public void backKeyPressed() { } |
538 } | 516 } |
OLD | NEW |