Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarControlContainer.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarControlContainer.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarControlContainer.java |
index eb6c5ef8a688ac8a972d51393c9f880f13511c2d..98fad833e65acf09540c6873c531c146375e565f 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarControlContainer.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarControlContainer.java |
@@ -33,7 +33,7 @@ public class ToolbarControlContainer extends FrameLayout implements ControlConta |
private final float mTabStripHeight; |
private Toolbar mToolbar; |
- private ToolbarViewResourceFrameLayout mToolbarContainer; |
+ private ViewResourceFrameLayout mToolbarContainer; |
private View mMenuBtn; |
private final SwipeRecognizer mSwipeRecognizer; |
@@ -74,11 +74,10 @@ public class ToolbarControlContainer extends FrameLayout implements ControlConta |
@Override |
public void onFinishInflate() { |
mToolbar = (Toolbar) findViewById(R.id.toolbar); |
- mToolbarContainer = (ToolbarViewResourceFrameLayout) findViewById(R.id.toolbar_container); |
mMenuBtn = findViewById(R.id.menu_button); |
- // TODO(yusufo): Get rid of the calls below and avoid casting to the layout without making |
- // the interface bigger. |
+ // TODO(yusufo): Get rid of the calls below and avoid casting to any layout. |
+ mToolbarContainer = (ViewResourceFrameLayout) mToolbar; |
SmoothProgressBar progressView = ((ToolbarLayout) mToolbar).getProgressBar(); |
if (progressView != null) { |
mProgressResourceAdapter = new ProgressViewResourceAdapter(progressView); |
@@ -104,37 +103,6 @@ public class ToolbarControlContainer extends FrameLayout implements ControlConta |
((ToolbarViewResourceAdapter) getToolbarResourceAdapter()).forceInvalidate(); |
} |
- /** |
- * Update whether the control container is ready to have the bitmap representation of |
- * itself be captured. |
- */ |
- public void setReadyForBitmapCapture(boolean ready) { |
- mToolbarContainer.mReadyForBitmapCapture = ready; |
- } |
- |
- /** |
- * The layout that handles generating the toolbar view resource. |
- */ |
- // Only publicly visible due to lint warnings. |
- public static class ToolbarViewResourceFrameLayout extends ViewResourceFrameLayout { |
- private boolean mReadyForBitmapCapture; |
- |
- public ToolbarViewResourceFrameLayout(Context context, AttributeSet attrs) { |
- super(context, attrs); |
- } |
- |
- @Override |
- protected ViewResourceAdapter createResourceAdapter() { |
- return new ToolbarViewResourceAdapter( |
- this, (Toolbar) findViewById(R.id.toolbar)); |
- } |
- |
- @Override |
- protected boolean isReadyForCapture() { |
- return mReadyForBitmapCapture; |
- } |
- } |
- |
private static class ProgressViewResourceAdapter extends ViewResourceAdapter |
implements ProgressChangeListener { |
@@ -227,74 +195,6 @@ public class ToolbarControlContainer extends FrameLayout implements ControlConta |
} |
} |
- private static class ToolbarViewResourceAdapter extends ViewResourceAdapter { |
- private final int mToolbarActualHeightPx; |
- private final int[] mTempPosition = new int[2]; |
- |
- private final View mToolbarContainer; |
- private final Toolbar mToolbar; |
- |
- /** Builds the resource adapter for the toolbar. */ |
- public ToolbarViewResourceAdapter(View toolbarContainer, Toolbar toolbar) { |
- super(toolbarContainer); |
- |
- mToolbarContainer = toolbarContainer; |
- mToolbar = toolbar; |
- mToolbarActualHeightPx = toolbarContainer.getResources().getDimensionPixelSize( |
- R.dimen.control_container_height); |
- } |
- |
- /** |
- * Force this resource to be recaptured in full, ignoring the checks |
- * {@link #invalidate(Rect)} does. |
- */ |
- public void forceInvalidate() { |
- super.invalidate(null); |
- } |
- |
- @Override |
- public boolean isDirty() { |
- return mToolbar != null && mToolbar.isReadyForTextureCapture() && super.isDirty(); |
- } |
- |
- @Override |
- protected void onCaptureStart(Canvas canvas, Rect dirtyRect) { |
- // Erase the shadow component of the bitmap if the clip rect included shadow. Because |
- // this region is not opaque painting twice would be bad. |
- if (dirtyRect.intersects( |
- 0, mToolbarActualHeightPx, |
- mToolbarContainer.getWidth(), mToolbarContainer.getHeight())) { |
- canvas.save(); |
- canvas.clipRect( |
- 0, mToolbarActualHeightPx, |
- mToolbarContainer.getWidth(), mToolbarContainer.getHeight()); |
- canvas.drawColor(0, PorterDuff.Mode.CLEAR); |
- canvas.restore(); |
- } |
- |
- mToolbar.setTextureCaptureMode(true); |
- |
- super.onCaptureStart(canvas, dirtyRect); |
- } |
- |
- @Override |
- protected void onCaptureEnd() { |
- mToolbar.setTextureCaptureMode(false); |
- } |
- |
- @Override |
- protected void computeContentPadding(Rect outContentPadding) { |
- outContentPadding.set(0, 0, mToolbarContainer.getWidth(), mToolbarActualHeightPx); |
- } |
- |
- @Override |
- protected void computeContentAperture(Rect outContentAperture) { |
- mToolbar.getLocationBarContentRect(outContentAperture); |
- mToolbar.getPositionRelativeToContainer(mToolbarContainer, mTempPosition); |
- outContentAperture.offset(mTempPosition[0], mTempPosition[1]); |
- } |
- } |
- |
@Override |
public boolean onTouchEvent(MotionEvent event) { |
// Don't eat the event if we don't have a handler. |