Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java

Issue 1221333007: Get rid of ToolbarViewResourceFrameLayout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.graphics.Canvas; 10 import android.graphics.Canvas;
11 import android.graphics.Rect; 11 import android.graphics.Rect;
12 import android.graphics.drawable.Drawable; 12 import android.graphics.drawable.Drawable;
13 import android.os.SystemClock; 13 import android.os.SystemClock;
14 import android.util.AttributeSet; 14 import android.util.AttributeSet;
15 import android.view.MotionEvent; 15 import android.view.MotionEvent;
16 import android.view.View; 16 import android.view.View;
17 import android.view.ViewGroup; 17 import android.view.ViewGroup;
18 import android.widget.FrameLayout; 18 import android.widget.FrameLayout;
19 import android.widget.ProgressBar; 19 import android.widget.ProgressBar;
20 20
21 import org.chromium.chrome.R; 21 import org.chromium.chrome.R;
22 import org.chromium.chrome.browser.Tab; 22 import org.chromium.chrome.browser.Tab;
23 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; 23 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
24 import org.chromium.chrome.browser.compositor.Invalidator; 24 import org.chromium.chrome.browser.compositor.Invalidator;
25 import org.chromium.chrome.browser.ntp.NewTabPage; 25 import org.chromium.chrome.browser.ntp.NewTabPage;
26 import org.chromium.chrome.browser.omnibox.LocationBar; 26 import org.chromium.chrome.browser.omnibox.LocationBar;
27 import org.chromium.chrome.browser.util.ViewUtils; 27 import org.chromium.chrome.browser.util.ViewUtils;
28 import org.chromium.chrome.browser.widget.SmoothProgressBar; 28 import org.chromium.chrome.browser.widget.SmoothProgressBar;
29 import org.chromium.chrome.browser.widget.TintedImageButton; 29 import org.chromium.chrome.browser.widget.TintedImageButton;
30 import org.chromium.chrome.browser.widget.ViewResourceFrameLayout;
30 import org.chromium.ui.UiUtils; 31 import org.chromium.ui.UiUtils;
32 import org.chromium.ui.resources.dynamics.ViewResourceAdapter;
31 33
32 /** 34 /**
33 * Layout class that contains the base shared logic for manipulating the toolbar component. For 35 * Layout class that contains the base shared logic for manipulating the toolbar component. For
34 * interaction that are not from Views inside Toolbar hierarchy all interactions should be done 36 * interaction that are not from Views inside Toolbar hierarchy all interactions should be done
35 * through {@link Toolbar} rather than using this class directly. 37 * through {@link Toolbar} rather than using this class directly.
36 */ 38 */
37 abstract class ToolbarLayout extends FrameLayout implements Toolbar { 39 abstract class ToolbarLayout extends ViewResourceFrameLayout implements Toolbar {
38 protected static final int BACKGROUND_TRANSITION_DURATION_MS = 400; 40 protected static final int BACKGROUND_TRANSITION_DURATION_MS = 400;
39 41
40 private Invalidator mInvalidator; 42 private Invalidator mInvalidator;
41 43
42 private final int[] mTempPosition = new int[2]; 44 private final int[] mTempPosition = new int[2];
43 45
44 /** 46 /**
45 * The ImageButton view that represents the menu button. 47 * The ImageButton view that represents the menu button.
46 */ 48 */
47 protected TintedImageButton mMenuButton; 49 protected TintedImageButton mMenuButton;
(...skipping 12 matching lines...) Expand all
60 62
61 private boolean mFindInPageToolbarShowing; 63 private boolean mFindInPageToolbarShowing;
62 64
63 /** 65 /**
64 * Basic constructor for {@link ToolbarLayout}. 66 * Basic constructor for {@link ToolbarLayout}.
65 */ 67 */
66 public ToolbarLayout(Context context, AttributeSet attrs) { 68 public ToolbarLayout(Context context, AttributeSet attrs) {
67 super(context, attrs); 69 super(context, attrs);
68 mToolbarHeightWithoutShadow = getResources().getDimensionPixelOffset( 70 mToolbarHeightWithoutShadow = getResources().getDimensionPixelOffset(
69 getToolbarHeightWithoutShadowResId()); 71 getToolbarHeightWithoutShadowResId());
72 setInitializedForCapture(false);
70 } 73 }
71 74
72 @Override 75 @Override
73 protected void onFinishInflate() { 76 protected void onFinishInflate() {
74 super.onFinishInflate(); 77 super.onFinishInflate();
75 78
76 mProgressBar = (SmoothProgressBar) findViewById(R.id.progress); 79 mProgressBar = (SmoothProgressBar) findViewById(R.id.progress);
77 if (mProgressBar != null) { 80 if (mProgressBar != null) {
78 removeView(mProgressBar); 81 removeView(mProgressBar);
79 Drawable progressDrawable = mProgressBar.getProgressDrawable(); 82 Drawable progressDrawable = mProgressBar.getProgressDrawable();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 protected void onTabContentViewChanged() { 355 protected void onTabContentViewChanged() {
353 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); 356 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
354 if (ntp != null) getLocationBar().onTabLoadingNTP(ntp); 357 if (ntp != null) getLocationBar().onTabLoadingNTP(ntp);
355 } 358 }
356 359
357 @Override 360 @Override
358 public boolean isReadyForTextureCapture() { 361 public boolean isReadyForTextureCapture() {
359 return true; 362 return true;
360 } 363 }
361 364
365 @Override
366 protected ViewResourceAdapter createResourceAdapter() {
367 return new ToolbarViewResourceAdapter((ViewGroup) getParent(), this);
368 }
369
362 /** 370 /**
363 * @param attached Whether or not the web content is attached to the view he irarchy. 371 * @param attached Whether or not the web content is attached to the view he irarchy.
364 */ 372 */
365 protected void setContentAttached(boolean attached) { } 373 protected void setContentAttached(boolean attached) { }
366 374
367 /** 375 /**
368 * Gives inheriting classes the chance to show or hide the TabSwitcher mode of this toolbar. 376 * Gives inheriting classes the chance to show or hide the TabSwitcher mode of this toolbar.
369 * @param inTabSwitcherMode Whether or not TabSwitcher mode should be shown or hidden. 377 * @param inTabSwitcherMode Whether or not TabSwitcher mode should be shown or hidden.
370 * @param showToolbar Whether or not to show the normal toolbar while ani mating. 378 * @param showToolbar Whether or not to show the normal toolbar while ani mating.
371 * @param delayAnimation Whether or not to delay the animation until after t he transition has 379 * @param delayAnimation Whether or not to delay the animation until after t he transition has
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 522 }
515 523
516 /** 524 /**
517 * Opens hompage in the current tab. 525 * Opens hompage in the current tab.
518 */ 526 */
519 protected void openHomepage() { 527 protected void openHomepage() {
520 getLocationBar().hideSuggestions(); 528 getLocationBar().hideSuggestions();
521 if (mToolbarTabController != null) mToolbarTabController.openHomepage(); 529 if (mToolbarTabController != null) mToolbarTabController.openHomepage();
522 } 530 }
523 } 531 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698