| 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.content.res.ColorStateList; | |
| 10 import android.util.AttributeSet; | 9 import android.util.AttributeSet; |
| 11 import android.view.View; | 10 import android.view.View; |
| 12 import android.view.View.OnClickListener; | 11 import android.view.View.OnClickListener; |
| 13 import android.widget.ImageButton; | 12 import android.widget.ImageButton; |
| 14 | 13 |
| 15 import org.chromium.base.ApiCompatibilityUtils; | 14 import org.chromium.base.ApiCompatibilityUtils; |
| 16 import org.chromium.base.CommandLine; | 15 import org.chromium.base.CommandLine; |
| 17 import org.chromium.base.metrics.RecordUserAction; | 16 import org.chromium.base.metrics.RecordUserAction; |
| 18 import org.chromium.chrome.R; | 17 import org.chromium.chrome.R; |
| 19 import org.chromium.chrome.browser.ChromeSwitches; | 18 import org.chromium.chrome.browser.ChromeSwitches; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 284 } |
| 286 | 285 |
| 287 @Override | 286 @Override |
| 288 public void onTabOrModelChanged() { | 287 public void onTabOrModelChanged() { |
| 289 super.onTabOrModelChanged(); | 288 super.onTabOrModelChanged(); |
| 290 boolean incognito = isIncognito(); | 289 boolean incognito = isIncognito(); |
| 291 if (mUseLightColorAssets == null || mUseLightColorAssets != incognito) { | 290 if (mUseLightColorAssets == null || mUseLightColorAssets != incognito) { |
| 292 setBackgroundResource(incognito | 291 setBackgroundResource(incognito |
| 293 ? R.color.incognito_primary_color : R.color.default_primary_
color); | 292 ? R.color.incognito_primary_color : R.color.default_primary_
color); |
| 294 | 293 |
| 295 ColorStateList dark = | 294 mMenuButton.setTint(incognito ? mLightModeTint : mDarkModeTint); |
| 296 ApiCompatibilityUtils.getColorStateList(getResources(), R.co
lor.dark_mode_tint); | 295 mHomeButton.setTint(incognito ? mLightModeTint : mDarkModeTint); |
| 297 ColorStateList white = ApiCompatibilityUtils.getColorStateList(getRe
sources(), | 296 mBackButton.setTint(incognito ? mLightModeTint : mDarkModeTint); |
| 298 R.color.light_mode_tint); | 297 mForwardButton.setTint(incognito ? mLightModeTint : mDarkModeTint); |
| 299 mMenuButton.setTint(incognito ? white : dark); | |
| 300 mHomeButton.setTint(incognito ? white : dark); | |
| 301 mBackButton.setTint(incognito ? white : dark); | |
| 302 mForwardButton.setTint(incognito ? white : dark); | |
| 303 if (incognito) { | 298 if (incognito) { |
| 304 mLocationBar.getContainerView().getBackground().setAlpha( | 299 mLocationBar.getContainerView().getBackground().setAlpha( |
| 305 ToolbarPhone.LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA); | 300 ToolbarPhone.LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA); |
| 306 } else { | 301 } else { |
| 307 mLocationBar.getContainerView().getBackground().setAlpha(255); | 302 mLocationBar.getContainerView().getBackground().setAlpha(255); |
| 308 } | 303 } |
| 309 mAccessibilitySwitcherButton.setImageDrawable( | 304 mAccessibilitySwitcherButton.setImageDrawable( |
| 310 incognito ? mTabSwitcherButtonDrawableLight : mTabSwitcherBu
ttonDrawable); | 305 incognito ? mTabSwitcherButtonDrawableLight : mTabSwitcherBu
ttonDrawable); |
| 311 mLocationBar.updateVisualsForState(); | 306 mLocationBar.updateVisualsForState(); |
| 312 mUseLightColorAssets = incognito; | 307 mUseLightColorAssets = incognito; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 332 protected void updateReloadButtonVisibility(boolean isReloading) { | 327 protected void updateReloadButtonVisibility(boolean isReloading) { |
| 333 if (isReloading) { | 328 if (isReloading) { |
| 334 mReloadButton.setImageResource(R.drawable.btn_close); | 329 mReloadButton.setImageResource(R.drawable.btn_close); |
| 335 mReloadButton.setContentDescription(getContext().getString( | 330 mReloadButton.setContentDescription(getContext().getString( |
| 336 R.string.accessibility_btn_stop_loading)); | 331 R.string.accessibility_btn_stop_loading)); |
| 337 } else { | 332 } else { |
| 338 mReloadButton.setImageResource(R.drawable.btn_toolbar_reload); | 333 mReloadButton.setImageResource(R.drawable.btn_toolbar_reload); |
| 339 mReloadButton.setContentDescription(getContext().getString( | 334 mReloadButton.setContentDescription(getContext().getString( |
| 340 R.string.accessibility_btn_refresh)); | 335 R.string.accessibility_btn_refresh)); |
| 341 } | 336 } |
| 342 ColorStateList dark = ApiCompatibilityUtils.getColorStateList(getResourc
es(), | 337 mReloadButton.setTint(isIncognito() ? mLightModeTint : mDarkModeTint); |
| 343 R.color.dark_mode_tint); | |
| 344 ColorStateList white = ApiCompatibilityUtils.getColorStateList(getResour
ces(), | |
| 345 R.color.light_mode_tint); | |
| 346 mReloadButton.setTint(isIncognito() ? white : dark); | |
| 347 mReloadButton.setEnabled(!mInTabSwitcherwMode); | 338 mReloadButton.setEnabled(!mInTabSwitcherwMode); |
| 348 } | 339 } |
| 349 | 340 |
| 350 @Override | 341 @Override |
| 351 protected void updateBookmarkButton(boolean isBookmarked, boolean editingAll
owed) { | 342 protected void updateBookmarkButton(boolean isBookmarked, boolean editingAll
owed) { |
| 352 int tintColor = isIncognito() ? R.color.light_mode_tint : R.color.dark_m
ode_tint; | |
| 353 if (isBookmarked) { | 343 if (isBookmarked) { |
| 354 mBookmarkButton.setImageResource(R.drawable.btn_star_filled); | 344 mBookmarkButton.setImageResource(R.drawable.btn_star_filled); |
| 355 // Non-incognito mode shows a blue filled star. | 345 // Non-incognito mode shows a blue filled star. |
| 356 if (!isIncognito()) tintColor = R.color.blue_mode_tint; | 346 mBookmarkButton.setTint(isIncognito() |
| 347 ? mLightModeTint |
| 348 : ApiCompatibilityUtils.getColorStateList( |
| 349 getResources(), R.color.blue_mode_tint)); |
| 357 } else { | 350 } else { |
| 358 mBookmarkButton.setImageResource(R.drawable.btn_star); | 351 mBookmarkButton.setImageResource(R.drawable.btn_star); |
| 352 mBookmarkButton.setTint(isIncognito() ? mLightModeTint : mDarkModeTi
nt); |
| 359 } | 353 } |
| 360 ColorStateList tint = ApiCompatibilityUtils.getColorStateList(getResourc
es(), tintColor); | |
| 361 mBookmarkButton.setTint(tint); | |
| 362 mBookmarkButton.setEnabled(editingAllowed); | 354 mBookmarkButton.setEnabled(editingAllowed); |
| 363 } | 355 } |
| 364 | 356 |
| 365 @Override | 357 @Override |
| 366 protected void setTabSwitcherMode( | 358 protected void setTabSwitcherMode( |
| 367 boolean inTabSwitcherMode, boolean showToolbar, boolean delayAnimati
on) { | 359 boolean inTabSwitcherMode, boolean showToolbar, boolean delayAnimati
on) { |
| 368 if (mShowTabStack && inTabSwitcherMode) { | 360 if (mShowTabStack && inTabSwitcherMode) { |
| 369 mInTabSwitcherwMode = true; | 361 mInTabSwitcherwMode = true; |
| 370 mBackButton.setEnabled(false); | 362 mBackButton.setEnabled(false); |
| 371 mForwardButton.setEnabled(false); | 363 mForwardButton.setEnabled(false); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 protected void onHomeButtonUpdate(boolean homeButtonEnabled) { | 399 protected void onHomeButtonUpdate(boolean homeButtonEnabled) { |
| 408 mHomeButton.setVisibility(homeButtonEnabled ? VISIBLE : GONE); | 400 mHomeButton.setVisibility(homeButtonEnabled ? VISIBLE : GONE); |
| 409 } | 401 } |
| 410 | 402 |
| 411 @Override | 403 @Override |
| 412 public LocationBar getLocationBar() { | 404 public LocationBar getLocationBar() { |
| 413 return mLocationBar; | 405 return mLocationBar; |
| 414 } | 406 } |
| 415 | 407 |
| 416 } | 408 } |
| OLD | NEW |