OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 10 matching lines...) Expand all Loading... |
21 import android.graphics.drawable.ColorDrawable; | 21 import android.graphics.drawable.ColorDrawable; |
22 import android.graphics.drawable.Drawable; | 22 import android.graphics.drawable.Drawable; |
23 import android.os.SystemClock; | 23 import android.os.SystemClock; |
24 import android.util.Log; | 24 import android.util.Log; |
25 import android.view.GestureDetector; | 25 import android.view.GestureDetector; |
26 import android.view.MotionEvent; | 26 import android.view.MotionEvent; |
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.app.AppResource; | 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 { |
38 private static String LOGTAG = "PopupZoomer"; | 38 private static 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 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Since we sometimes overflow the bounds of the mViewClipRect, we need to a
llow scrolling. | 103 // Since we sometimes overflow the bounds of the mViewClipRect, we need to a
llow scrolling. |
104 // Current scroll position. | 104 // Current scroll position. |
105 private float mPopupScrollX, mPopupScrollY; | 105 private float mPopupScrollX, mPopupScrollY; |
106 // Scroll bounds. | 106 // Scroll bounds. |
107 private float mMinScrollX, mMaxScrollX; | 107 private float mMinScrollX, mMaxScrollX; |
108 private float mMinScrollY, mMaxScrollY; | 108 private float mMinScrollY, mMaxScrollY; |
109 | 109 |
110 private GestureDetector mGestureDetector; | 110 private GestureDetector mGestureDetector; |
111 | 111 |
112 private static float getOverlayCornerRadius(Context context) { | 112 private static float getOverlayCornerRadius(Context context) { |
113 // TODO(leandrogracia): restore an assertion for the resource id != 0 | 113 if (sOverlayCornerRadius == 0) |
114 // here after fixing crbug.com/136704 | |
115 // assert AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS != 0; | |
116 if (sOverlayCornerRadius == 0 && AppResource.DIMENSION_LINK_PREVIEW_OVER
LAY_RADIUS != 0) | |
117 sOverlayCornerRadius = context.getResources().getDimension( | 114 sOverlayCornerRadius = context.getResources().getDimension( |
118 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS); | 115 R.dimen.link_preview_overlay_radius); |
119 return sOverlayCornerRadius; | 116 return sOverlayCornerRadius; |
120 } | 117 } |
121 | 118 |
122 /** | 119 /** |
123 * Gets the drawable that should be used to frame the zooming popup, loading | 120 * Gets the drawable that should be used to frame the zooming popup, loading |
124 * it from the resource bundle if not already cached. | 121 * it from the resource bundle if not already cached. |
125 */ | 122 */ |
126 private static Drawable getOverlayDrawable(Context context) { | 123 private static Drawable getOverlayDrawable(Context context) { |
127 if (sOverlayDrawable == null) { | 124 if (sOverlayDrawable == null) { |
128 try { | 125 try { |
129 sOverlayDrawable = context.getResources().getDrawable( | 126 sOverlayDrawable = context.getResources().getDrawable( |
130 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY); | 127 R.drawable.ondemand_overlay); |
131 } catch (Resources.NotFoundException e) { | 128 } catch (Resources.NotFoundException e) { |
132 Log.w(LOGTAG, "No drawable resource for PopupZoomer overlay foun
d."); | 129 Log.w(LOGTAG, "No drawable resource for PopupZoomer overlay foun
d."); |
133 sOverlayDrawable = new ColorDrawable(); | 130 sOverlayDrawable = new ColorDrawable(); |
134 } | 131 } |
135 sOverlayPadding = new Rect(); | 132 sOverlayPadding = new Rect(); |
136 sOverlayDrawable.getPadding(sOverlayPadding); | 133 sOverlayDrawable.getPadding(sOverlayPadding); |
137 } | 134 } |
138 return sOverlayDrawable; | 135 return sOverlayDrawable; |
139 } | 136 } |
140 | 137 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 } | 498 } |
502 | 499 |
503 @Override | 500 @Override |
504 public float getInterpolation(float input) { | 501 public float getInterpolation(float input) { |
505 input = 1.0f - input; | 502 input = 1.0f - input; |
506 if (mInterpolator == null) return input; | 503 if (mInterpolator == null) return input; |
507 return mInterpolator.getInterpolation(input); | 504 return mInterpolator.getInterpolation(input); |
508 } | 505 } |
509 } | 506 } |
510 } | 507 } |
OLD | NEW |