| 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.util.AttributeSet; | 9 import android.util.AttributeSet; |
| 10 import android.view.View; | 10 import android.view.View; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 private TintedImageButton mHomeButton; | 33 private TintedImageButton mHomeButton; |
| 34 private TintedImageButton mBackButton; | 34 private TintedImageButton mBackButton; |
| 35 private TintedImageButton mForwardButton; | 35 private TintedImageButton mForwardButton; |
| 36 private TintedImageButton mReloadButton; | 36 private TintedImageButton mReloadButton; |
| 37 private TintedImageButton mBookmarkButton; | 37 private TintedImageButton mBookmarkButton; |
| 38 private ImageButton mAccessibilitySwitcherButton; | 38 private ImageButton mAccessibilitySwitcherButton; |
| 39 | 39 |
| 40 private OnClickListener mBookmarkListener; | 40 private OnClickListener mBookmarkListener; |
| 41 private OnClickListener mTabSwitcherListener; | 41 private OnClickListener mTabSwitcherListener; |
| 42 | 42 |
| 43 private boolean mInTabSwitcherwMode = false; | 43 private boolean mIsInTabSwitcherMode = false; |
| 44 | 44 |
| 45 private boolean mShowTabStack; | 45 private boolean mShowTabStack; |
| 46 | 46 |
| 47 |
| 47 private NavigationPopup mNavigationPopup; | 48 private NavigationPopup mNavigationPopup; |
| 48 | 49 |
| 49 private TabSwitcherDrawable mTabSwitcherButtonDrawable; | 50 private TabSwitcherDrawable mTabSwitcherButtonDrawable; |
| 50 private TabSwitcherDrawable mTabSwitcherButtonDrawableLight; | 51 private TabSwitcherDrawable mTabSwitcherButtonDrawableLight; |
| 51 | 52 |
| 52 private Boolean mUseLightColorAssets; | 53 private Boolean mUseLightColorAssets; |
| 53 private LocationBar mLocationBar; | 54 private LocationBar mLocationBar; |
| 54 | 55 |
| 55 /** | 56 /** |
| 56 * Constructs a ToolbarTablet object. | 57 * Constructs a ToolbarTablet object. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 78 mTabSwitcherButtonDrawableLight = | 79 mTabSwitcherButtonDrawableLight = |
| 79 TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), tr
ue); | 80 TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), tr
ue); |
| 80 | 81 |
| 81 mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switc
her_button); | 82 mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switc
her_button); |
| 82 mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable
); | 83 mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable
); |
| 83 updateSwitcherButtonVisibility(mShowTabStack); | 84 updateSwitcherButtonVisibility(mShowTabStack); |
| 84 | 85 |
| 85 mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button)
; | 86 mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button)
; |
| 86 | 87 |
| 87 mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); | 88 mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); |
| 88 mMenuButton.setVisibility( | 89 mMenuButtonWrapper.setVisibility( |
| 89 shouldShowMenuButton() ? View.VISIBLE : View.GONE); | 90 shouldShowMenuButton() ? View.VISIBLE : View.GONE); |
| 90 | 91 |
| 91 if (mAccessibilitySwitcherButton.getVisibility() == View.GONE | 92 if (mAccessibilitySwitcherButton.getVisibility() == View.GONE |
| 92 && mMenuButton.getVisibility() == View.GONE) { | 93 && mMenuButtonWrapper.getVisibility() == View.GONE) { |
| 93 ApiCompatibilityUtils.setPaddingRelative((View) mMenuButton.getParen
t(), 0, 0, | 94 ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.g
etParent(), 0, 0, |
| 94 getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_
end_padding), 0); | 95 getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_
end_padding), 0); |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 | 98 |
| 98 /** | 99 /** |
| 99 * Sets up key listeners after native initialization is complete, so that we
can invoke | 100 * Sets up key listeners after native initialization is complete, so that we
can invoke |
| 100 * native functions. | 101 * native functions. |
| 101 */ | 102 */ |
| 102 @Override | 103 @Override |
| 103 public void onNativeLibraryReady() { | 104 public void onNativeLibraryReady() { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 mAccessibilitySwitcherButton.setImageDrawable( | 305 mAccessibilitySwitcherButton.setImageDrawable( |
| 305 incognito ? mTabSwitcherButtonDrawableLight : mTabSwitcherBu
ttonDrawable); | 306 incognito ? mTabSwitcherButtonDrawableLight : mTabSwitcherBu
ttonDrawable); |
| 306 mLocationBar.updateVisualsForState(); | 307 mLocationBar.updateVisualsForState(); |
| 307 mUseLightColorAssets = incognito; | 308 mUseLightColorAssets = incognito; |
| 308 } | 309 } |
| 309 mLocationBar.setUrlBarFocus(false); | 310 mLocationBar.setUrlBarFocus(false); |
| 310 } | 311 } |
| 311 | 312 |
| 312 @Override | 313 @Override |
| 313 protected void updateBackButtonVisibility(boolean canGoBack) { | 314 protected void updateBackButtonVisibility(boolean canGoBack) { |
| 314 boolean enableButton = canGoBack && !mInTabSwitcherwMode; | 315 boolean enableButton = canGoBack && !mIsInTabSwitcherMode; |
| 315 mBackButton.setEnabled(enableButton); | 316 mBackButton.setEnabled(enableButton); |
| 316 mBackButton.setFocusable(enableButton); | 317 mBackButton.setFocusable(enableButton); |
| 317 } | 318 } |
| 318 | 319 |
| 319 @Override | 320 @Override |
| 320 protected void updateForwardButtonVisibility(boolean canGoForward) { | 321 protected void updateForwardButtonVisibility(boolean canGoForward) { |
| 321 boolean enableButton = canGoForward && !mInTabSwitcherwMode; | 322 boolean enableButton = canGoForward && !mIsInTabSwitcherMode; |
| 322 mForwardButton.setEnabled(enableButton); | 323 mForwardButton.setEnabled(enableButton); |
| 323 mForwardButton.setFocusable(enableButton); | 324 mForwardButton.setFocusable(enableButton); |
| 324 } | 325 } |
| 325 | 326 |
| 326 @Override | 327 @Override |
| 327 protected void updateReloadButtonVisibility(boolean isReloading) { | 328 protected void updateReloadButtonVisibility(boolean isReloading) { |
| 328 if (isReloading) { | 329 if (isReloading) { |
| 329 mReloadButton.setImageResource(R.drawable.btn_close); | 330 mReloadButton.setImageResource(R.drawable.btn_close); |
| 330 mReloadButton.setContentDescription(getContext().getString( | 331 mReloadButton.setContentDescription(getContext().getString( |
| 331 R.string.accessibility_btn_stop_loading)); | 332 R.string.accessibility_btn_stop_loading)); |
| 332 } else { | 333 } else { |
| 333 mReloadButton.setImageResource(R.drawable.btn_toolbar_reload); | 334 mReloadButton.setImageResource(R.drawable.btn_toolbar_reload); |
| 334 mReloadButton.setContentDescription(getContext().getString( | 335 mReloadButton.setContentDescription(getContext().getString( |
| 335 R.string.accessibility_btn_refresh)); | 336 R.string.accessibility_btn_refresh)); |
| 336 } | 337 } |
| 337 mReloadButton.setTint(isIncognito() ? mLightModeTint : mDarkModeTint); | 338 mReloadButton.setTint(isIncognito() ? mLightModeTint : mDarkModeTint); |
| 338 mReloadButton.setEnabled(!mInTabSwitcherwMode); | 339 mReloadButton.setEnabled(!mIsInTabSwitcherMode); |
| 339 } | 340 } |
| 340 | 341 |
| 341 @Override | 342 @Override |
| 342 protected void updateBookmarkButton(boolean isBookmarked, boolean editingAll
owed) { | 343 protected void updateBookmarkButton(boolean isBookmarked, boolean editingAll
owed) { |
| 343 if (isBookmarked) { | 344 if (isBookmarked) { |
| 344 mBookmarkButton.setImageResource(R.drawable.btn_star_filled); | 345 mBookmarkButton.setImageResource(R.drawable.btn_star_filled); |
| 345 // Non-incognito mode shows a blue filled star. | 346 // Non-incognito mode shows a blue filled star. |
| 346 mBookmarkButton.setTint(isIncognito() | 347 mBookmarkButton.setTint(isIncognito() |
| 347 ? mLightModeTint | 348 ? mLightModeTint |
| 348 : ApiCompatibilityUtils.getColorStateList( | 349 : ApiCompatibilityUtils.getColorStateList( |
| 349 getResources(), R.color.blue_mode_tint)); | 350 getResources(), R.color.blue_mode_tint)); |
| 350 } else { | 351 } else { |
| 351 mBookmarkButton.setImageResource(R.drawable.btn_star); | 352 mBookmarkButton.setImageResource(R.drawable.btn_star); |
| 352 mBookmarkButton.setTint(isIncognito() ? mLightModeTint : mDarkModeTi
nt); | 353 mBookmarkButton.setTint(isIncognito() ? mLightModeTint : mDarkModeTi
nt); |
| 353 } | 354 } |
| 354 mBookmarkButton.setEnabled(editingAllowed); | 355 mBookmarkButton.setEnabled(editingAllowed); |
| 355 } | 356 } |
| 356 | 357 |
| 357 @Override | 358 @Override |
| 358 protected void setTabSwitcherMode( | 359 protected void setTabSwitcherMode( |
| 359 boolean inTabSwitcherMode, boolean showToolbar, boolean delayAnimati
on) { | 360 boolean inTabSwitcherMode, boolean showToolbar, boolean delayAnimati
on) { |
| 360 if (mShowTabStack && inTabSwitcherMode) { | 361 if (mShowTabStack && inTabSwitcherMode) { |
| 361 mInTabSwitcherwMode = true; | 362 mIsInTabSwitcherMode = true; |
| 362 mBackButton.setEnabled(false); | 363 mBackButton.setEnabled(false); |
| 363 mForwardButton.setEnabled(false); | 364 mForwardButton.setEnabled(false); |
| 364 mReloadButton.setEnabled(false); | 365 mReloadButton.setEnabled(false); |
| 365 mLocationBar.getContainerView().setVisibility(View.INVISIBLE); | 366 mLocationBar.getContainerView().setVisibility(View.INVISIBLE); |
| 367 if (mShowMenuBadge && mUnbadgedMenuButtonDrawable != null) { |
| 368 mMenuButton.setImageDrawable(mUnbadgedMenuButtonDrawable); |
| 369 mMenuBadge.setVisibility(View.GONE); |
| 370 } |
| 366 } else { | 371 } else { |
| 367 mInTabSwitcherwMode = false; | 372 mIsInTabSwitcherMode = false; |
| 368 mLocationBar.getContainerView().setVisibility(View.VISIBLE); | 373 mLocationBar.getContainerView().setVisibility(View.VISIBLE); |
| 374 if (mShowMenuBadge) { |
| 375 setAppMenuUpdateBadgeToVisible(); |
| 376 } |
| 369 } | 377 } |
| 370 } | 378 } |
| 371 | 379 |
| 372 @Override | 380 @Override |
| 373 protected void updateTabCountVisuals(int numberOfTabs) { | 381 protected void updateTabCountVisuals(int numberOfTabs) { |
| 374 mAccessibilitySwitcherButton.setContentDescription( | 382 mAccessibilitySwitcherButton.setContentDescription( |
| 375 getResources().getString(R.string.accessibility_toolbar_btn_tabs
witcher_toggle, | 383 getResources().getString(R.string.accessibility_toolbar_btn_tabs
witcher_toggle, |
| 376 numberOfTabs)); | 384 numberOfTabs)); |
| 377 mTabSwitcherButtonDrawable.updateForTabCount(numberOfTabs, isIncognito()
); | 385 mTabSwitcherButtonDrawable.updateForTabCount(numberOfTabs, isIncognito()
); |
| 378 mTabSwitcherButtonDrawableLight.updateForTabCount(numberOfTabs, isIncogn
ito()); | 386 mTabSwitcherButtonDrawableLight.updateForTabCount(numberOfTabs, isIncogn
ito()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 398 @Override | 406 @Override |
| 399 protected void onHomeButtonUpdate(boolean homeButtonEnabled) { | 407 protected void onHomeButtonUpdate(boolean homeButtonEnabled) { |
| 400 mHomeButton.setVisibility(homeButtonEnabled ? VISIBLE : GONE); | 408 mHomeButton.setVisibility(homeButtonEnabled ? VISIBLE : GONE); |
| 401 } | 409 } |
| 402 | 410 |
| 403 @Override | 411 @Override |
| 404 public LocationBar getLocationBar() { | 412 public LocationBar getLocationBar() { |
| 405 return mLocationBar; | 413 return mLocationBar; |
| 406 } | 414 } |
| 407 | 415 |
| 416 @Override |
| 417 public void showAppMenuUpdateBadge() { |
| 418 super.showAppMenuUpdateBadge(); |
| 419 if (!mIsInTabSwitcherMode) { |
| 420 setAppMenuUpdateBadgeToVisible(); |
| 421 } |
| 422 } |
| 408 } | 423 } |
| OLD | NEW |