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.ui.base; | 5 package org.chromium.ui.base; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.content.ClipData; | 8 import android.content.ClipData; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.os.Build; | 10 import android.os.Build; |
11 import android.view.PointerIcon; | |
11 import android.view.View; | 12 import android.view.View; |
12 import android.view.ViewGroup; | 13 import android.view.ViewGroup; |
13 import android.widget.FrameLayout.LayoutParams; | 14 import android.widget.FrameLayout.LayoutParams; |
14 import android.widget.ImageView; | 15 import android.widget.ImageView; |
15 | 16 |
16 import org.chromium.base.ApiCompatibilityUtils; | 17 import org.chromium.base.ApiCompatibilityUtils; |
17 import org.chromium.base.annotations.CalledByNative; | 18 import org.chromium.base.annotations.CalledByNative; |
18 import org.chromium.base.annotations.JNINamespace; | 19 import org.chromium.base.annotations.JNINamespace; |
20 import org.chromium.blink_public.web.WebCursorInfoType; | |
19 | 21 |
20 /** | 22 /** |
21 * Class to acquire, position, and remove anchor views from the implementing Vie w. | 23 * Class to acquire, position, and remove anchor views from the implementing Vie w. |
22 */ | 24 */ |
23 @JNINamespace("ui") | 25 @JNINamespace("ui") |
24 public abstract class ViewAndroidDelegate { | 26 public abstract class ViewAndroidDelegate { |
25 /** | 27 /** |
26 * @return An anchor view that can be used to anchor decoration views like A utofill popup. | 28 * @return An anchor view that can be used to anchor decoration views like A utofill popup. |
27 */ | 29 */ |
28 @CalledByNative | 30 @CalledByNative |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 if (containerView == null) return false; | 94 if (containerView == null) return false; |
93 | 95 |
94 ImageView imageView = new ImageView(containerView.getContext()); | 96 ImageView imageView = new ImageView(containerView.getContext()); |
95 imageView.setImageBitmap(shadowImage); | 97 imageView.setImageBitmap(shadowImage); |
96 imageView.layout(0, 0, shadowImage.getWidth(), shadowImage.getHeight()); | 98 imageView.layout(0, 0, shadowImage.getWidth(), shadowImage.getHeight()); |
97 | 99 |
98 return containerView.startDragAndDrop(ClipData.newPlainText(null, text), | 100 return containerView.startDragAndDrop(ClipData.newPlainText(null, text), |
99 new View.DragShadowBuilder(imageView), null, View.DRAG_FLAG_GLOB AL); | 101 new View.DragShadowBuilder(imageView), null, View.DRAG_FLAG_GLOB AL); |
100 } | 102 } |
101 | 103 |
104 @CalledByNative | |
105 private void onCursorChangedToCustom(Bitmap customCursorBitmap, int hotspotX , int hotspotY) { | |
106 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
107 getContainerView().getRootView().setPointerIcon( | |
boliu
2017/05/24 18:24:07
same issue here
jaebaek
2017/05/29 12:40:03
Done.
| |
108 PointerIcon.create(customCursorBitmap, hotspotX, hotspotY)); | |
109 } | |
110 } | |
111 | |
112 @CalledByNative | |
113 public void onCursorChanged(int cursorType) { | |
boliu
2017/05/24 18:24:07
private
jaebaek
2017/05/29 12:40:03
Done.
| |
114 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return; | |
115 | |
116 int pointerIconType = PointerIcon.TYPE_ARROW; | |
117 switch (cursorType) { | |
118 case WebCursorInfoType.TYPE_NONE: | |
119 pointerIconType = PointerIcon.TYPE_NULL; | |
120 break; | |
121 case WebCursorInfoType.TYPE_POINTER: | |
122 pointerIconType = PointerIcon.TYPE_ARROW; | |
123 break; | |
124 case WebCursorInfoType.TYPE_CONTEXT_MENU: | |
125 pointerIconType = PointerIcon.TYPE_CONTEXT_MENU; | |
126 break; | |
127 case WebCursorInfoType.TYPE_HAND: | |
128 pointerIconType = PointerIcon.TYPE_HAND; | |
129 break; | |
130 case WebCursorInfoType.TYPE_HELP: | |
131 pointerIconType = PointerIcon.TYPE_HELP; | |
132 break; | |
133 case WebCursorInfoType.TYPE_WAIT: | |
134 pointerIconType = PointerIcon.TYPE_WAIT; | |
135 break; | |
136 case WebCursorInfoType.TYPE_CELL: | |
137 pointerIconType = PointerIcon.TYPE_CELL; | |
138 break; | |
139 case WebCursorInfoType.TYPE_CROSS: | |
140 pointerIconType = PointerIcon.TYPE_CROSSHAIR; | |
141 break; | |
142 case WebCursorInfoType.TYPE_I_BEAM: | |
143 pointerIconType = PointerIcon.TYPE_TEXT; | |
144 break; | |
145 case WebCursorInfoType.TYPE_VERTICAL_TEXT: | |
146 pointerIconType = PointerIcon.TYPE_VERTICAL_TEXT; | |
147 break; | |
148 case WebCursorInfoType.TYPE_ALIAS: | |
149 pointerIconType = PointerIcon.TYPE_ALIAS; | |
150 break; | |
151 case WebCursorInfoType.TYPE_COPY: | |
152 pointerIconType = PointerIcon.TYPE_COPY; | |
153 break; | |
154 case WebCursorInfoType.TYPE_NO_DROP: | |
155 pointerIconType = PointerIcon.TYPE_NO_DROP; | |
156 break; | |
157 case WebCursorInfoType.TYPE_COLUMN_RESIZE: | |
158 pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW; | |
159 break; | |
160 case WebCursorInfoType.TYPE_ROW_RESIZE: | |
161 pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW; | |
162 break; | |
163 case WebCursorInfoType.TYPE_NORTH_EAST_SOUTH_WEST_RESIZE: | |
164 pointerIconType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARR OW; | |
165 break; | |
166 case WebCursorInfoType.TYPE_NORTH_WEST_SOUTH_EAST_RESIZE: | |
167 pointerIconType = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARRO W; | |
168 break; | |
169 case WebCursorInfoType.TYPE_ZOOM_IN: | |
170 pointerIconType = PointerIcon.TYPE_ZOOM_IN; | |
171 break; | |
172 case WebCursorInfoType.TYPE_ZOOM_OUT: | |
173 pointerIconType = PointerIcon.TYPE_ZOOM_OUT; | |
174 break; | |
175 case WebCursorInfoType.TYPE_GRAB: | |
176 pointerIconType = PointerIcon.TYPE_GRAB; | |
177 break; | |
178 case WebCursorInfoType.TYPE_GRABBING: | |
179 pointerIconType = PointerIcon.TYPE_GRABBING; | |
180 break; | |
181 // TODO(jaebaek): set types correctly | |
182 // after fixing http://crbug.com/584424. | |
183 case WebCursorInfoType.TYPE_EAST_WEST_RESIZE: | |
184 pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW; | |
185 break; | |
186 case WebCursorInfoType.TYPE_NORTH_SOUTH_RESIZE: | |
187 pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW; | |
188 break; | |
189 case WebCursorInfoType.TYPE_EAST_RESIZE: | |
190 pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW; | |
191 break; | |
192 case WebCursorInfoType.TYPE_NORTH_RESIZE: | |
193 pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW; | |
194 break; | |
195 case WebCursorInfoType.TYPE_NORTH_EAST_RESIZE: | |
196 pointerIconType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARR OW; | |
197 break; | |
198 case WebCursorInfoType.TYPE_NORTH_WEST_RESIZE: | |
199 pointerIconType = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARRO W; | |
200 break; | |
201 case WebCursorInfoType.TYPE_SOUTH_RESIZE: | |
202 pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW; | |
203 break; | |
204 case WebCursorInfoType.TYPE_SOUTH_EAST_RESIZE: | |
205 pointerIconType = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARRO W; | |
206 break; | |
207 case WebCursorInfoType.TYPE_SOUTH_WEST_RESIZE: | |
208 pointerIconType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARR OW; | |
209 break; | |
210 case WebCursorInfoType.TYPE_WEST_RESIZE: | |
211 pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW; | |
212 break; | |
213 case WebCursorInfoType.TYPE_PROGRESS: | |
214 pointerIconType = PointerIcon.TYPE_WAIT; | |
215 break; | |
216 case WebCursorInfoType.TYPE_NOT_ALLOWED: | |
217 pointerIconType = PointerIcon.TYPE_NO_DROP; | |
218 break; | |
219 case WebCursorInfoType.TYPE_EAST_PANNING: | |
220 case WebCursorInfoType.TYPE_NORTH_PANNING: | |
221 case WebCursorInfoType.TYPE_NORTH_EAST_PANNING: | |
222 case WebCursorInfoType.TYPE_NORTH_WEST_PANNING: | |
223 case WebCursorInfoType.TYPE_SOUTH_PANNING: | |
224 case WebCursorInfoType.TYPE_SOUTH_EAST_PANNING: | |
225 case WebCursorInfoType.TYPE_SOUTH_WEST_PANNING: | |
226 case WebCursorInfoType.TYPE_WEST_PANNING: | |
227 assert false : "These pointer icon types are not supported"; | |
aelias_OOO_until_Jul13
2017/05/24 19:03:56
As Java asserts are not stripped even in release b
boliu
2017/05/24 19:14:02
Actually, agrieve made java asserts work just like
jaebaek
2017/05/29 12:40:03
Ok, then I will keep this assert. Thank you for th
| |
228 break; | |
229 case WebCursorInfoType.TYPE_MOVE: | |
aelias_OOO_until_Jul13
2017/05/24 19:03:56
Please map MOVE and MIDDLE_PANNING to "TYPE_ALL_SC
jaebaek
2017/05/29 12:40:03
Done.
| |
230 case WebCursorInfoType.TYPE_MIDDLE_PANNING: | |
231 case WebCursorInfoType.TYPE_CUSTOM: | |
232 assert false : "onCursorChangedToCustom must be called instead"; | |
233 break; | |
234 } | |
235 updatePointerIcon(pointerIconType); | |
236 } | |
237 | |
238 public void updatePointerIcon(int type) { | |
boliu
2017/05/24 18:24:07
methods that embedders override should be no-op
d
jaebaek
2017/05/29 12:40:03
Done.
| |
239 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
240 ViewGroup containerView = getContainerView(); | |
241 containerView.getRootView().setPointerIcon( | |
242 PointerIcon.getSystemIcon(containerView.getContext(), type)) ; | |
243 } | |
244 } | |
245 | |
102 /** | 246 /** |
103 * Called whenever the background color of the page changes as notified by B link. | 247 * Called whenever the background color of the page changes as notified by B link. |
104 * @param color The new ARGB color of the page background. | 248 * @param color The new ARGB color of the page background. |
105 */ | 249 */ |
106 @CalledByNative | 250 @CalledByNative |
107 public void onBackgroundColorChanged(int color) {} | 251 public void onBackgroundColorChanged(int color) {} |
108 | 252 |
109 /** | 253 /** |
110 * Notify the client of the position of the top controls. | 254 * Notify the client of the position of the top controls. |
111 * @param topControlsOffsetY The Y offset of the top controls in physical pi xels. | 255 * @param topControlsOffsetY The Y offset of the top controls in physical pi xels. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 return this; | 298 return this; |
155 } | 299 } |
156 | 300 |
157 @Override | 301 @Override |
158 public ViewGroup getContainerView() { | 302 public ViewGroup getContainerView() { |
159 return mContainerView; | 303 return mContainerView; |
160 } | 304 } |
161 }.init(containerView); | 305 }.init(containerView); |
162 } | 306 } |
163 } | 307 } |
OLD | NEW |