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( | |
108 PointerIcon.create(customCursorBitmap, hotspotX, hotspotY)); | |
109 } | |
110 } | |
111 | |
112 @CalledByNative | |
113 public void onCursorChanged(int cursorType) { | |
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_EAST_WEST_RESIZE: | |
aelias_OOO_until_Jul13
2017/05/23 22:43:25
These are supposed to look different so let's not
jaebaek
2017/05/24 11:26:15
Done.
| |
158 case WebCursorInfoType.TYPE_COLUMN_RESIZE: | |
159 pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW; | |
160 break; | |
161 case WebCursorInfoType.TYPE_NORTH_SOUTH_RESIZE: | |
162 case WebCursorInfoType.TYPE_ROW_RESIZE: | |
163 pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW; | |
164 break; | |
165 case WebCursorInfoType.TYPE_NORTH_EAST_SOUTH_WEST_RESIZE: | |
166 pointerIconType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARR OW; | |
167 break; | |
168 case WebCursorInfoType.TYPE_NORTH_WEST_SOUTH_EAST_RESIZE: | |
169 pointerIconType = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARRO W; | |
170 break; | |
171 case WebCursorInfoType.TYPE_ZOOM_IN: | |
172 pointerIconType = PointerIcon.TYPE_ZOOM_IN; | |
173 break; | |
174 case WebCursorInfoType.TYPE_ZOOM_OUT: | |
175 pointerIconType = PointerIcon.TYPE_ZOOM_OUT; | |
176 break; | |
177 case WebCursorInfoType.TYPE_GRAB: | |
178 pointerIconType = PointerIcon.TYPE_GRAB; | |
179 break; | |
180 case WebCursorInfoType.TYPE_GRABBING: | |
181 pointerIconType = PointerIcon.TYPE_GRABBING; | |
182 break; | |
183 case WebCursorInfoType.TYPE_EAST_RESIZE: | |
184 case WebCursorInfoType.TYPE_NORTH_RESIZE: | |
185 case WebCursorInfoType.TYPE_NORTH_EAST_RESIZE: | |
186 case WebCursorInfoType.TYPE_NORTH_WEST_RESIZE: | |
187 case WebCursorInfoType.TYPE_SOUTH_RESIZE: | |
188 case WebCursorInfoType.TYPE_SOUTH_EAST_RESIZE: | |
189 case WebCursorInfoType.TYPE_SOUTH_WEST_RESIZE: | |
190 case WebCursorInfoType.TYPE_WEST_RESIZE: | |
191 case WebCursorInfoType.TYPE_MIDDLE_PANNING: | |
192 case WebCursorInfoType.TYPE_EAST_PANNING: | |
193 case WebCursorInfoType.TYPE_NORTH_PANNING: | |
194 case WebCursorInfoType.TYPE_NORTH_EAST_PANNING: | |
195 case WebCursorInfoType.TYPE_NORTH_WEST_PANNING: | |
196 case WebCursorInfoType.TYPE_SOUTH_PANNING: | |
197 case WebCursorInfoType.TYPE_SOUTH_EAST_PANNING: | |
198 case WebCursorInfoType.TYPE_SOUTH_WEST_PANNING: | |
199 case WebCursorInfoType.TYPE_WEST_PANNING: | |
200 case WebCursorInfoType.TYPE_MOVE: | |
201 case WebCursorInfoType.TYPE_PROGRESS: | |
202 case WebCursorInfoType.TYPE_NOT_ALLOWED: | |
203 case WebCursorInfoType.TYPE_CUSTOM: | |
204 assert false : "onCursorChangedToCustom must be called instead"; | |
205 break; | |
206 default: | |
aelias_OOO_until_Jul13
2017/05/23 22:43:25
Please remove the "default:". It's better to have
jaebaek
2017/05/24 11:26:15
Done.
| |
207 assert false : "An exceptional pointer icon type"; | |
208 break; | |
209 } | |
210 ViewGroup containerView = getContainerView(); | |
211 containerView.getRootView().setPointerIcon( | |
212 PointerIcon.getSystemIcon(containerView.getContext(), pointerIco nType)); | |
213 } | |
214 | |
102 /** | 215 /** |
103 * Called whenever the background color of the page changes as notified by B link. | 216 * 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. | 217 * @param color The new ARGB color of the page background. |
105 */ | 218 */ |
106 @CalledByNative | 219 @CalledByNative |
107 public void onBackgroundColorChanged(int color) {} | 220 public void onBackgroundColorChanged(int color) {} |
108 | 221 |
109 /** | 222 /** |
110 * Notify the client of the position of the top controls. | 223 * Notify the client of the position of the top controls. |
111 * @param topControlsOffsetY The Y offset of the top controls in physical pi xels. | 224 * @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; | 267 return this; |
155 } | 268 } |
156 | 269 |
157 @Override | 270 @Override |
158 public ViewGroup getContainerView() { | 271 public ViewGroup getContainerView() { |
159 return mContainerView; | 272 return mContainerView; |
160 } | 273 } |
161 }.init(containerView); | 274 }.init(containerView); |
162 } | 275 } |
163 } | 276 } |
OLD | NEW |