Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.view; |
| 18 | |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 20 | import android.annotation.UnsupportedAppUsage; |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 21 | import android.annotation.XmlRes; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 22 | import android.content.Context; |
| 23 | import android.content.res.Resources; |
| 24 | import android.content.res.TypedArray; |
| 25 | import android.content.res.XmlResourceParser; |
| 26 | import android.graphics.Bitmap; |
Leon Scroggins III | 2f1b06b | 2018-02-15 10:40:33 -0500 | [diff] [blame] | 27 | import android.graphics.Canvas; |
| 28 | import android.graphics.Paint; |
| 29 | import android.graphics.Rect; |
| 30 | import android.graphics.RectF; |
Jun Mukai | 808196f | 2015-10-28 16:46:44 -0700 | [diff] [blame] | 31 | import android.graphics.drawable.AnimationDrawable; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 32 | import android.graphics.drawable.BitmapDrawable; |
| 33 | import android.graphics.drawable.Drawable; |
Mathew Inwood | 45d2c25 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 34 | import android.os.Build; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 35 | import android.os.Parcel; |
| 36 | import android.os.Parcelable; |
| 37 | import android.util.Log; |
Aurimas Liutikas | 67e2ae8 | 2016-10-11 18:17:42 -0700 | [diff] [blame] | 38 | import android.util.SparseArray; |
| 39 | |
| 40 | import com.android.internal.util.XmlUtils; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * Represents an icon that can be used as a mouse pointer. |
| 44 | * <p> |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 45 | * Pointer icons can be provided either by the system using system types, |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 46 | * or by applications using bitmaps or application resources. |
| 47 | * </p> |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 48 | */ |
| 49 | public final class PointerIcon implements Parcelable { |
| 50 | private static final String TAG = "PointerIcon"; |
| 51 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 52 | /** {@hide} Type constant: Custom icon with a user-supplied bitmap. */ |
| 53 | public static final int TYPE_CUSTOM = -1; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 54 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 55 | /** Type constant: Null icon. It has no bitmap. */ |
| 56 | public static final int TYPE_NULL = 0; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 57 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 58 | /** Type constant: no icons are specified. If all views uses this, then falls back |
| 59 | * to the default type, but this is helpful to distinguish a view explicitly want |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 60 | * to have the default icon. |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 61 | * @hide |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 62 | */ |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 63 | public static final int TYPE_NOT_SPECIFIED = 1; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 64 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 65 | /** Type constant: Arrow icon. (Default mouse pointer) */ |
| 66 | public static final int TYPE_ARROW = 1000; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 67 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 68 | /** {@hide} Type constant: Spot hover icon for touchpads. */ |
| 69 | public static final int TYPE_SPOT_HOVER = 2000; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 70 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 71 | /** {@hide} Type constant: Spot touch icon for touchpads. */ |
| 72 | public static final int TYPE_SPOT_TOUCH = 2001; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 73 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 74 | /** {@hide} Type constant: Spot anchor icon for touchpads. */ |
| 75 | public static final int TYPE_SPOT_ANCHOR = 2002; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 76 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 77 | // Type constants for additional predefined icons for mice. |
| 78 | /** Type constant: context-menu. */ |
| 79 | public static final int TYPE_CONTEXT_MENU = 1001; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 80 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 81 | /** Type constant: hand. */ |
| 82 | public static final int TYPE_HAND = 1002; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 83 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 84 | /** Type constant: help. */ |
| 85 | public static final int TYPE_HELP = 1003; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 86 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 87 | /** Type constant: wait. */ |
| 88 | public static final int TYPE_WAIT = 1004; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 89 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 90 | /** Type constant: cell. */ |
| 91 | public static final int TYPE_CELL = 1006; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 92 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 93 | /** Type constant: crosshair. */ |
| 94 | public static final int TYPE_CROSSHAIR = 1007; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 95 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 96 | /** Type constant: text. */ |
| 97 | public static final int TYPE_TEXT = 1008; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 98 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 99 | /** Type constant: vertical-text. */ |
| 100 | public static final int TYPE_VERTICAL_TEXT = 1009; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 101 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 102 | /** Type constant: alias (indicating an alias of/shortcut to something is |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 103 | * to be created. */ |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 104 | public static final int TYPE_ALIAS = 1010; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 105 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 106 | /** Type constant: copy. */ |
| 107 | public static final int TYPE_COPY = 1011; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 108 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 109 | /** Type constant: no-drop. */ |
| 110 | public static final int TYPE_NO_DROP = 1012; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 111 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 112 | /** Type constant: all-scroll. */ |
| 113 | public static final int TYPE_ALL_SCROLL = 1013; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 114 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 115 | /** Type constant: horizontal double arrow mainly for resizing. */ |
| 116 | public static final int TYPE_HORIZONTAL_DOUBLE_ARROW = 1014; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 117 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 118 | /** Type constant: vertical double arrow mainly for resizing. */ |
| 119 | public static final int TYPE_VERTICAL_DOUBLE_ARROW = 1015; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 120 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 121 | /** Type constant: diagonal double arrow -- top-right to bottom-left. */ |
| 122 | public static final int TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 123 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 124 | /** Type constant: diagonal double arrow -- top-left to bottom-right. */ |
| 125 | public static final int TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 126 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 127 | /** Type constant: zoom-in. */ |
| 128 | public static final int TYPE_ZOOM_IN = 1018; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 129 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 130 | /** Type constant: zoom-out. */ |
| 131 | public static final int TYPE_ZOOM_OUT = 1019; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 132 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 133 | /** Type constant: grab. */ |
| 134 | public static final int TYPE_GRAB = 1020; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 135 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 136 | /** Type constant: grabbing. */ |
| 137 | public static final int TYPE_GRABBING = 1021; |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 138 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 139 | // OEM private types should be defined starting at this range to avoid |
| 140 | // conflicts with any system types that may be defined in the future. |
| 141 | private static final int TYPE_OEM_FIRST = 10000; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 142 | |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 143 | /** The default pointer icon. */ |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 144 | public static final int TYPE_DEFAULT = TYPE_ARROW; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 145 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 146 | private static final PointerIcon gNullIcon = new PointerIcon(TYPE_NULL); |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 147 | private static final SparseArray<PointerIcon> gSystemIcons = new SparseArray<PointerIcon>(); |
Jun Mukai | 1f3dbff | 2015-12-16 14:41:25 -0800 | [diff] [blame] | 148 | private static boolean sUseLargeIcons = false; |
Jun Mukai | e4e75da | 2015-12-15 16:19:20 -0800 | [diff] [blame] | 149 | |
Mathew Inwood | 45d2c25 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 150 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 151 | private final int mType; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 152 | private int mSystemIconResourceId; |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 153 | @UnsupportedAppUsage |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 154 | private Bitmap mBitmap; |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 155 | @UnsupportedAppUsage |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 156 | private float mHotSpotX; |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 157 | @UnsupportedAppUsage |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 158 | private float mHotSpotY; |
Jun Mukai | 808196f | 2015-10-28 16:46:44 -0700 | [diff] [blame] | 159 | // The bitmaps for the additional frame of animated pointer icon. Note that the first frame |
| 160 | // will be stored in mBitmap. |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 161 | @UnsupportedAppUsage |
Jun Mukai | 808196f | 2015-10-28 16:46:44 -0700 | [diff] [blame] | 162 | private Bitmap mBitmapFrames[]; |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 163 | @UnsupportedAppUsage |
Jun Mukai | 808196f | 2015-10-28 16:46:44 -0700 | [diff] [blame] | 164 | private int mDurationPerFrame; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 165 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 166 | private PointerIcon(int type) { |
| 167 | mType = type; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Gets a special pointer icon that has no bitmap. |
| 172 | * |
| 173 | * @return The null pointer icon. |
| 174 | * |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 175 | * @see #TYPE_NULL |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 176 | * @hide |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 177 | */ |
| 178 | public static PointerIcon getNullIcon() { |
| 179 | return gNullIcon; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Gets the default pointer icon. |
| 184 | * |
| 185 | * @param context The context. |
| 186 | * @return The default pointer icon. |
| 187 | * |
| 188 | * @throws IllegalArgumentException if context is null. |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 189 | * @hide |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 190 | */ |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 191 | public static PointerIcon getDefaultIcon(@NonNull Context context) { |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 192 | return getSystemIcon(context, TYPE_DEFAULT); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | /** |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 196 | * Gets a system pointer icon for the given type. |
| 197 | * If typeis not recognized, returns the default pointer icon. |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 198 | * |
| 199 | * @param context The context. |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 200 | * @param type The pointer icon type. |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 201 | * @return The pointer icon. |
| 202 | * |
| 203 | * @throws IllegalArgumentException if context is null. |
| 204 | */ |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 205 | public static PointerIcon getSystemIcon(@NonNull Context context, int type) { |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 206 | if (context == null) { |
| 207 | throw new IllegalArgumentException("context must not be null"); |
| 208 | } |
| 209 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 210 | if (type == TYPE_NULL) { |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 211 | return gNullIcon; |
| 212 | } |
| 213 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 214 | PointerIcon icon = gSystemIcons.get(type); |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 215 | if (icon != null) { |
| 216 | return icon; |
| 217 | } |
| 218 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 219 | int typeIndex = getSystemIconTypeIndex(type); |
| 220 | if (typeIndex == 0) { |
| 221 | typeIndex = getSystemIconTypeIndex(TYPE_DEFAULT); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 222 | } |
| 223 | |
Jun Mukai | e4e75da | 2015-12-15 16:19:20 -0800 | [diff] [blame] | 224 | int defStyle = sUseLargeIcons ? |
Jun Mukai | 19a5601 | 2015-11-24 11:25:52 -0800 | [diff] [blame] | 225 | com.android.internal.R.style.LargePointer : com.android.internal.R.style.Pointer; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 226 | TypedArray a = context.obtainStyledAttributes(null, |
| 227 | com.android.internal.R.styleable.Pointer, |
Jun Mukai | 19a5601 | 2015-11-24 11:25:52 -0800 | [diff] [blame] | 228 | 0, defStyle); |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 229 | int resourceId = a.getResourceId(typeIndex, -1); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 230 | a.recycle(); |
| 231 | |
| 232 | if (resourceId == -1) { |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 233 | Log.w(TAG, "Missing theme resources for pointer icon type " + type); |
| 234 | return type == TYPE_DEFAULT ? gNullIcon : getSystemIcon(context, TYPE_DEFAULT); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 237 | icon = new PointerIcon(type); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 238 | if ((resourceId & 0xff000000) == 0x01000000) { |
| 239 | icon.mSystemIconResourceId = resourceId; |
| 240 | } else { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 241 | icon.loadResource(context, context.getResources(), resourceId); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 242 | } |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 243 | gSystemIcons.append(type, icon); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 244 | return icon; |
| 245 | } |
| 246 | |
| 247 | /** |
Jun Mukai | 1f3dbff | 2015-12-16 14:41:25 -0800 | [diff] [blame] | 248 | * Updates wheter accessibility large icons are used or not. |
| 249 | * @hide |
| 250 | */ |
| 251 | public static void setUseLargeIcons(boolean use) { |
| 252 | sUseLargeIcons = use; |
| 253 | gSystemIcons.clear(); |
| 254 | } |
| 255 | |
| 256 | /** |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 257 | * Creates a custom pointer icon from the given bitmap and hotspot information. |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 258 | * |
| 259 | * @param bitmap The bitmap for the icon. |
Alan Viverette | 376d10e | 2014-09-02 10:45:30 -0700 | [diff] [blame] | 260 | * @param hotSpotX The X offset of the pointer icon hotspot in the bitmap. |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 261 | * Must be within the [0, bitmap.getWidth()) range. |
Alan Viverette | 376d10e | 2014-09-02 10:45:30 -0700 | [diff] [blame] | 262 | * @param hotSpotY The Y offset of the pointer icon hotspot in the bitmap. |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 263 | * Must be within the [0, bitmap.getHeight()) range. |
| 264 | * @return A pointer icon for this bitmap. |
| 265 | * |
| 266 | * @throws IllegalArgumentException if bitmap is null, or if the x/y hotspot |
| 267 | * parameters are invalid. |
| 268 | */ |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 269 | public static PointerIcon create(@NonNull Bitmap bitmap, float hotSpotX, float hotSpotY) { |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 270 | if (bitmap == null) { |
| 271 | throw new IllegalArgumentException("bitmap must not be null"); |
| 272 | } |
| 273 | validateHotSpot(bitmap, hotSpotX, hotSpotY); |
| 274 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 275 | PointerIcon icon = new PointerIcon(TYPE_CUSTOM); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 276 | icon.mBitmap = bitmap; |
| 277 | icon.mHotSpotX = hotSpotX; |
| 278 | icon.mHotSpotY = hotSpotY; |
| 279 | return icon; |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Loads a custom pointer icon from an XML resource. |
| 284 | * <p> |
| 285 | * The XML resource should have the following form: |
| 286 | * <code> |
| 287 | * <?xml version="1.0" encoding="utf-8"?> |
| 288 | * <pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" |
| 289 | * android:bitmap="@drawable/my_pointer_bitmap" |
| 290 | * android:hotSpotX="24" |
| 291 | * android:hotSpotY="24" /> |
| 292 | * </code> |
| 293 | * </p> |
| 294 | * |
| 295 | * @param resources The resources object. |
| 296 | * @param resourceId The resource id. |
| 297 | * @return The pointer icon. |
| 298 | * |
| 299 | * @throws IllegalArgumentException if resources is null. |
| 300 | * @throws Resources.NotFoundException if the resource was not found or the drawable |
| 301 | * linked in the resource was not found. |
| 302 | */ |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 303 | public static PointerIcon load(@NonNull Resources resources, @XmlRes int resourceId) { |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 304 | if (resources == null) { |
| 305 | throw new IllegalArgumentException("resources must not be null"); |
| 306 | } |
| 307 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 308 | PointerIcon icon = new PointerIcon(TYPE_CUSTOM); |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 309 | icon.loadResource(null, resources, resourceId); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 310 | return icon; |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * Loads the bitmap and hotspot information for a pointer icon, if it is not already loaded. |
| 315 | * Returns a pointer icon (not necessarily the same instance) with the information filled in. |
| 316 | * |
| 317 | * @param context The context. |
| 318 | * @return The loaded pointer icon. |
| 319 | * |
| 320 | * @throws IllegalArgumentException if context is null. |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 321 | * @hide |
| 322 | */ |
Mathew Inwood | 45d2c25 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 323 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 324 | public PointerIcon load(@NonNull Context context) { |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 325 | if (context == null) { |
| 326 | throw new IllegalArgumentException("context must not be null"); |
| 327 | } |
| 328 | |
| 329 | if (mSystemIconResourceId == 0 || mBitmap != null) { |
| 330 | return this; |
| 331 | } |
| 332 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 333 | PointerIcon result = new PointerIcon(mType); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 334 | result.mSystemIconResourceId = mSystemIconResourceId; |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 335 | result.loadResource(context, context.getResources(), mSystemIconResourceId); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 336 | return result; |
| 337 | } |
| 338 | |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 339 | /** @hide */ |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 340 | public int getType() { |
| 341 | return mType; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 342 | } |
| 343 | |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 344 | public static final Parcelable.Creator<PointerIcon> CREATOR |
| 345 | = new Parcelable.Creator<PointerIcon>() { |
| 346 | public PointerIcon createFromParcel(Parcel in) { |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 347 | int type = in.readInt(); |
| 348 | if (type == TYPE_NULL) { |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 349 | return getNullIcon(); |
| 350 | } |
| 351 | |
| 352 | int systemIconResourceId = in.readInt(); |
| 353 | if (systemIconResourceId != 0) { |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 354 | PointerIcon icon = new PointerIcon(type); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 355 | icon.mSystemIconResourceId = systemIconResourceId; |
| 356 | return icon; |
| 357 | } |
| 358 | |
| 359 | Bitmap bitmap = Bitmap.CREATOR.createFromParcel(in); |
| 360 | float hotSpotX = in.readFloat(); |
| 361 | float hotSpotY = in.readFloat(); |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 362 | return PointerIcon.create(bitmap, hotSpotX, hotSpotY); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | public PointerIcon[] newArray(int size) { |
| 366 | return new PointerIcon[size]; |
| 367 | } |
| 368 | }; |
| 369 | |
| 370 | public int describeContents() { |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | public void writeToParcel(Parcel out, int flags) { |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 375 | out.writeInt(mType); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 376 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 377 | if (mType != TYPE_NULL) { |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 378 | out.writeInt(mSystemIconResourceId); |
| 379 | if (mSystemIconResourceId == 0) { |
| 380 | mBitmap.writeToParcel(out, flags); |
| 381 | out.writeFloat(mHotSpotX); |
| 382 | out.writeFloat(mHotSpotY); |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | @Override |
| 388 | public boolean equals(Object other) { |
| 389 | if (this == other) { |
| 390 | return true; |
| 391 | } |
| 392 | |
| 393 | if (other == null || !(other instanceof PointerIcon)) { |
| 394 | return false; |
| 395 | } |
| 396 | |
| 397 | PointerIcon otherIcon = (PointerIcon) other; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 398 | if (mType != otherIcon.mType |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 399 | || mSystemIconResourceId != otherIcon.mSystemIconResourceId) { |
| 400 | return false; |
| 401 | } |
| 402 | |
| 403 | if (mSystemIconResourceId == 0 && (mBitmap != otherIcon.mBitmap |
| 404 | || mHotSpotX != otherIcon.mHotSpotX |
| 405 | || mHotSpotY != otherIcon.mHotSpotY)) { |
| 406 | return false; |
| 407 | } |
| 408 | |
| 409 | return true; |
| 410 | } |
| 411 | |
Leon Scroggins III | 2f1b06b | 2018-02-15 10:40:33 -0500 | [diff] [blame] | 412 | /** |
| 413 | * Get the Bitmap from the Drawable. |
| 414 | * |
| 415 | * If the Bitmap needed to be scaled up to account for density, BitmapDrawable |
| 416 | * handles this at draw time. But this class doesn't actually draw the Bitmap; |
| 417 | * it is just a holder for native code to access its SkBitmap. So this needs to |
| 418 | * get a version that is scaled to account for density. |
| 419 | */ |
| 420 | private Bitmap getBitmapFromDrawable(BitmapDrawable bitmapDrawable) { |
| 421 | Bitmap bitmap = bitmapDrawable.getBitmap(); |
| 422 | final int scaledWidth = bitmapDrawable.getIntrinsicWidth(); |
| 423 | final int scaledHeight = bitmapDrawable.getIntrinsicHeight(); |
| 424 | if (scaledWidth == bitmap.getWidth() && scaledHeight == bitmap.getHeight()) { |
| 425 | return bitmap; |
| 426 | } |
| 427 | |
| 428 | Rect src = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); |
| 429 | RectF dst = new RectF(0, 0, scaledWidth, scaledHeight); |
| 430 | |
| 431 | Bitmap scaled = Bitmap.createBitmap(scaledWidth, scaledHeight, bitmap.getConfig()); |
| 432 | Canvas canvas = new Canvas(scaled); |
| 433 | Paint paint = new Paint(); |
| 434 | paint.setFilterBitmap(true); |
| 435 | canvas.drawBitmap(bitmap, src, dst, paint); |
| 436 | return scaled; |
| 437 | } |
| 438 | |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 439 | private void loadResource(Context context, Resources resources, @XmlRes int resourceId) { |
Alan Viverette | 376d10e | 2014-09-02 10:45:30 -0700 | [diff] [blame] | 440 | final XmlResourceParser parser = resources.getXml(resourceId); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 441 | final int bitmapRes; |
| 442 | final float hotSpotX; |
| 443 | final float hotSpotY; |
| 444 | try { |
| 445 | XmlUtils.beginDocument(parser, "pointer-icon"); |
| 446 | |
Alan Viverette | 376d10e | 2014-09-02 10:45:30 -0700 | [diff] [blame] | 447 | final TypedArray a = resources.obtainAttributes( |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 448 | parser, com.android.internal.R.styleable.PointerIcon); |
| 449 | bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0); |
Alan Viverette | 376d10e | 2014-09-02 10:45:30 -0700 | [diff] [blame] | 450 | hotSpotX = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0); |
| 451 | hotSpotY = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 452 | a.recycle(); |
| 453 | } catch (Exception ex) { |
| 454 | throw new IllegalArgumentException("Exception parsing pointer icon resource.", ex); |
| 455 | } finally { |
| 456 | parser.close(); |
| 457 | } |
| 458 | |
| 459 | if (bitmapRes == 0) { |
| 460 | throw new IllegalArgumentException("<pointer-icon> is missing bitmap attribute."); |
| 461 | } |
| 462 | |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 463 | Drawable drawable; |
| 464 | if (context == null) { |
| 465 | drawable = resources.getDrawable(bitmapRes); |
| 466 | } else { |
| 467 | drawable = context.getDrawable(bitmapRes); |
| 468 | } |
Jun Mukai | 808196f | 2015-10-28 16:46:44 -0700 | [diff] [blame] | 469 | if (drawable instanceof AnimationDrawable) { |
| 470 | // Extract animation frame bitmaps. |
| 471 | final AnimationDrawable animationDrawable = (AnimationDrawable) drawable; |
| 472 | final int frames = animationDrawable.getNumberOfFrames(); |
| 473 | drawable = animationDrawable.getFrame(0); |
| 474 | if (frames == 1) { |
| 475 | Log.w(TAG, "Animation icon with single frame -- simply treating the first " |
| 476 | + "frame as a normal bitmap icon."); |
| 477 | } else { |
| 478 | // Assumes they have the exact duration. |
| 479 | mDurationPerFrame = animationDrawable.getDuration(0); |
| 480 | mBitmapFrames = new Bitmap[frames - 1]; |
| 481 | final int width = drawable.getIntrinsicWidth(); |
| 482 | final int height = drawable.getIntrinsicHeight(); |
| 483 | for (int i = 1; i < frames; ++i) { |
| 484 | Drawable drawableFrame = animationDrawable.getFrame(i); |
| 485 | if (!(drawableFrame instanceof BitmapDrawable)) { |
| 486 | throw new IllegalArgumentException("Frame of an animated pointer icon " |
| 487 | + "must refer to a bitmap drawable."); |
| 488 | } |
| 489 | if (drawableFrame.getIntrinsicWidth() != width || |
| 490 | drawableFrame.getIntrinsicHeight() != height) { |
| 491 | throw new IllegalArgumentException("The bitmap size of " + i + "-th frame " |
| 492 | + "is different. All frames should have the exact same size and " |
| 493 | + "share the same hotspot."); |
| 494 | } |
Leon Scroggins III | 2f1b06b | 2018-02-15 10:40:33 -0500 | [diff] [blame] | 495 | BitmapDrawable bitmapDrawableFrame = (BitmapDrawable) drawableFrame; |
| 496 | mBitmapFrames[i - 1] = getBitmapFromDrawable(bitmapDrawableFrame); |
Jun Mukai | 808196f | 2015-10-28 16:46:44 -0700 | [diff] [blame] | 497 | } |
| 498 | } |
| 499 | } |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 500 | if (!(drawable instanceof BitmapDrawable)) { |
| 501 | throw new IllegalArgumentException("<pointer-icon> bitmap attribute must " |
| 502 | + "refer to a bitmap drawable."); |
| 503 | } |
| 504 | |
Leon Scroggins III | 2f1b06b | 2018-02-15 10:40:33 -0500 | [diff] [blame] | 505 | BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; |
| 506 | final Bitmap bitmap = getBitmapFromDrawable(bitmapDrawable); |
Vladislav Kaznacheev | 44e7de3 | 2017-12-20 12:18:03 -0800 | [diff] [blame] | 507 | validateHotSpot(bitmap, hotSpotX, hotSpotY); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 508 | // Set the properties now that we have successfully loaded the icon. |
Vladislav Kaznacheev | 44e7de3 | 2017-12-20 12:18:03 -0800 | [diff] [blame] | 509 | mBitmap = bitmap; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 510 | mHotSpotX = hotSpotX; |
| 511 | mHotSpotY = hotSpotY; |
| 512 | } |
| 513 | |
| 514 | private static void validateHotSpot(Bitmap bitmap, float hotSpotX, float hotSpotY) { |
| 515 | if (hotSpotX < 0 || hotSpotX >= bitmap.getWidth()) { |
| 516 | throw new IllegalArgumentException("x hotspot lies outside of the bitmap area"); |
| 517 | } |
| 518 | if (hotSpotY < 0 || hotSpotY >= bitmap.getHeight()) { |
| 519 | throw new IllegalArgumentException("y hotspot lies outside of the bitmap area"); |
| 520 | } |
| 521 | } |
| 522 | |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 523 | private static int getSystemIconTypeIndex(int type) { |
| 524 | switch (type) { |
| 525 | case TYPE_ARROW: |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 526 | return com.android.internal.R.styleable.Pointer_pointerIconArrow; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 527 | case TYPE_SPOT_HOVER: |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 528 | return com.android.internal.R.styleable.Pointer_pointerIconSpotHover; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 529 | case TYPE_SPOT_TOUCH: |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 530 | return com.android.internal.R.styleable.Pointer_pointerIconSpotTouch; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 531 | case TYPE_SPOT_ANCHOR: |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 532 | return com.android.internal.R.styleable.Pointer_pointerIconSpotAnchor; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 533 | case TYPE_HAND: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 534 | return com.android.internal.R.styleable.Pointer_pointerIconHand; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 535 | case TYPE_CONTEXT_MENU: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 536 | return com.android.internal.R.styleable.Pointer_pointerIconContextMenu; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 537 | case TYPE_HELP: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 538 | return com.android.internal.R.styleable.Pointer_pointerIconHelp; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 539 | case TYPE_WAIT: |
Jun Mukai | 808196f | 2015-10-28 16:46:44 -0700 | [diff] [blame] | 540 | return com.android.internal.R.styleable.Pointer_pointerIconWait; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 541 | case TYPE_CELL: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 542 | return com.android.internal.R.styleable.Pointer_pointerIconCell; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 543 | case TYPE_CROSSHAIR: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 544 | return com.android.internal.R.styleable.Pointer_pointerIconCrosshair; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 545 | case TYPE_TEXT: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 546 | return com.android.internal.R.styleable.Pointer_pointerIconText; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 547 | case TYPE_VERTICAL_TEXT: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 548 | return com.android.internal.R.styleable.Pointer_pointerIconVerticalText; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 549 | case TYPE_ALIAS: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 550 | return com.android.internal.R.styleable.Pointer_pointerIconAlias; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 551 | case TYPE_COPY: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 552 | return com.android.internal.R.styleable.Pointer_pointerIconCopy; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 553 | case TYPE_ALL_SCROLL: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 554 | return com.android.internal.R.styleable.Pointer_pointerIconAllScroll; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 555 | case TYPE_NO_DROP: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 556 | return com.android.internal.R.styleable.Pointer_pointerIconNodrop; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 557 | case TYPE_HORIZONTAL_DOUBLE_ARROW: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 558 | return com.android.internal.R.styleable.Pointer_pointerIconHorizontalDoubleArrow; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 559 | case TYPE_VERTICAL_DOUBLE_ARROW: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 560 | return com.android.internal.R.styleable.Pointer_pointerIconVerticalDoubleArrow; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 561 | case TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 562 | return com.android.internal.R.styleable. |
| 563 | Pointer_pointerIconTopRightDiagonalDoubleArrow; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 564 | case TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 565 | return com.android.internal.R.styleable. |
| 566 | Pointer_pointerIconTopLeftDiagonalDoubleArrow; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 567 | case TYPE_ZOOM_IN: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 568 | return com.android.internal.R.styleable.Pointer_pointerIconZoomIn; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 569 | case TYPE_ZOOM_OUT: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 570 | return com.android.internal.R.styleable.Pointer_pointerIconZoomOut; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 571 | case TYPE_GRAB: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 572 | return com.android.internal.R.styleable.Pointer_pointerIconGrab; |
Michael Wright | e051f6f | 2016-05-13 17:44:16 +0100 | [diff] [blame] | 573 | case TYPE_GRABBING: |
Jun Mukai | 1db5397 | 2015-09-11 18:08:31 -0700 | [diff] [blame] | 574 | return com.android.internal.R.styleable.Pointer_pointerIconGrabbing; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 575 | default: |
| 576 | return 0; |
| 577 | } |
| 578 | } |
| 579 | } |