Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.res.Resources; | 8 import android.content.res.Resources; |
| 9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
| 10 import android.graphics.Canvas; | 10 import android.graphics.Canvas; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 import android.view.View; | 27 import android.view.View; |
| 28 import android.view.animation.Interpolator; | 28 import android.view.animation.Interpolator; |
| 29 import android.view.animation.OvershootInterpolator; | 29 import android.view.animation.OvershootInterpolator; |
| 30 | 30 |
| 31 import org.chromium.content.R; | 31 import org.chromium.content.R; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * PopupZoomer is used to show the on-demand link zooming popup. It handles mani pulation of the | 34 * PopupZoomer is used to show the on-demand link zooming popup. It handles mani pulation of the |
| 35 * canvas and touch events to display the on-demand zoom magnifier. | 35 * canvas and touch events to display the on-demand zoom magnifier. |
| 36 */ | 36 */ |
| 37 class PopupZoomer extends View { | 37 class PopupZoomer extends View { |
|
newt (away)
2014/10/20 22:20:53
actually the PopupZoomer doesn't appear in accessi
wajahat
2014/10/21 14:34:56
Done.
| |
| 38 private static final String LOGTAG = "PopupZoomer"; | 38 private static final String LOGTAG = "PopupZoomer"; |
| 39 | 39 |
| 40 // The padding between the edges of the view and the popup. Note that there is a mirror | 40 // The padding between the edges of the view and the popup. Note that there is a mirror |
| 41 // constant in content/renderer/render_view_impl.cc which should be kept in sync if | 41 // constant in content/renderer/render_view_impl.cc which should be kept in sync if |
| 42 // this is changed. | 42 // this is changed. |
| 43 private static final int ZOOM_BOUNDS_MARGIN = 25; | 43 private static final int ZOOM_BOUNDS_MARGIN = 25; |
| 44 // Time it takes for the animation to finish in ms. | 44 // Time it takes for the animation to finish in ms. |
| 45 private static final long ANIMATION_DURATION = 300; | 45 private static final long ANIMATION_DURATION = 300; |
| 46 | 46 |
| 47 /** | 47 /** |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 74 private static Rect sOverlayPadding; | 74 private static Rect sOverlayPadding; |
| 75 // The radius of the overlay bubble, used for rounding the bitmap to draw un derneath it. | 75 // The radius of the overlay bubble, used for rounding the bitmap to draw un derneath it. |
| 76 private static float sOverlayCornerRadius; | 76 private static float sOverlayCornerRadius; |
| 77 | 77 |
| 78 private final Interpolator mShowInterpolator = new OvershootInterpolator(); | 78 private final Interpolator mShowInterpolator = new OvershootInterpolator(); |
| 79 private final Interpolator mHideInterpolator = new ReverseInterpolator(mShow Interpolator); | 79 private final Interpolator mHideInterpolator = new ReverseInterpolator(mShow Interpolator); |
| 80 | 80 |
| 81 private boolean mAnimating = false; | 81 private boolean mAnimating = false; |
| 82 private boolean mShowing = false; | 82 private boolean mShowing = false; |
| 83 private long mAnimationStartTime = 0; | 83 private long mAnimationStartTime = 0; |
| 84 private boolean mDownTouch = false; | |
| 84 | 85 |
| 85 // The time that was left for the outwards animation to finish. | 86 // The time that was left for the outwards animation to finish. |
| 86 // This is used in the case that the zoomer is cancelled while it is still a nimating outwards, | 87 // This is used in the case that the zoomer is cancelled while it is still a nimating outwards, |
| 87 // to avoid having it jump to full size then animate closed. | 88 // to avoid having it jump to full size then animate closed. |
| 88 private long mTimeLeft = 0; | 89 private long mTimeLeft = 0; |
| 89 | 90 |
| 90 // initDimensions() needs to be called in onDraw(). | 91 // initDimensions() needs to be called in onDraw(). |
| 91 private boolean mNeedsToInitDimensions; | 92 private boolean mNeedsToInitDimensions; |
| 92 | 93 |
| 93 // Available view area after accounting for ZOOM_BOUNDS_MARGIN. | 94 // Available view area after accounting for ZOOM_BOUNDS_MARGIN. |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 /** | 535 /** |
| 535 * Returns true if the point is inside the final drawable area for this popu p zoomer. | 536 * Returns true if the point is inside the final drawable area for this popu p zoomer. |
| 536 */ | 537 */ |
| 537 private boolean isTouchOutsideArea(float x, float y) { | 538 private boolean isTouchOutsideArea(float x, float y) { |
| 538 return !mClipRect.contains(x, y); | 539 return !mClipRect.contains(x, y); |
| 539 } | 540 } |
| 540 | 541 |
| 541 @Override | 542 @Override |
| 542 public boolean onTouchEvent(MotionEvent event) { | 543 public boolean onTouchEvent(MotionEvent event) { |
| 543 mGestureDetector.onTouchEvent(event); | 544 mGestureDetector.onTouchEvent(event); |
| 545 // Listening for the down and up touch events | |
| 546 // to enable accessibility services for a user | |
| 547 // who cannot click touch screen. | |
| 548 switch (event.getAction()) { | |
| 549 case MotionEvent.ACTION_DOWN: | |
| 550 mDownTouch = true; | |
| 551 break; | |
| 552 case MotionEvent.ACTION_UP: | |
| 553 if (mDownTouch) { | |
| 554 mDownTouch = false; | |
| 555 performClick(); | |
| 556 } | |
| 557 } | |
| 544 return true; | 558 return true; |
| 545 } | 559 } |
| 546 | 560 |
| 561 @Override | |
| 562 public boolean performClick() { | |
| 563 super.performClick(); | |
| 564 return true; | |
| 565 } | |
| 566 | |
| 547 private static class ReverseInterpolator implements Interpolator { | 567 private static class ReverseInterpolator implements Interpolator { |
| 548 private final Interpolator mInterpolator; | 568 private final Interpolator mInterpolator; |
| 549 | 569 |
| 550 public ReverseInterpolator(Interpolator i) { | 570 public ReverseInterpolator(Interpolator i) { |
| 551 mInterpolator = i; | 571 mInterpolator = i; |
| 552 } | 572 } |
| 553 | 573 |
| 554 @Override | 574 @Override |
| 555 public float getInterpolation(float input) { | 575 public float getInterpolation(float input) { |
| 556 input = 1.0f - input; | 576 input = 1.0f - input; |
| 557 if (mInterpolator == null) return input; | 577 if (mInterpolator == null) return input; |
| 558 return mInterpolator.getInterpolation(input); | 578 return mInterpolator.getInterpolation(input); |
| 559 } | 579 } |
| 560 } | 580 } |
| 561 } | 581 } |
| OLD | NEW |