diff options
| author | 2014-09-02 10:45:30 -0700 | |
|---|---|---|
| committer | 2014-09-02 10:45:30 -0700 | |
| commit | 376d10e99e7db597fdff8a4e8f396161017c243c (patch) | |
| tree | 30fe16261fee809197f21e50dd9d2d35920b2d40 | |
| parent | bd6937841983230bd65dc08548367caa7d409238 (diff) | |
Update pointer hotspots to scale for DPI
Also updates the bitmap resources, which weren't scaled correctly
for their respective DPI buckets.
BUG: 16459309
Change-Id: Iedc781e2ee47a8b960390fea718cb08bcfb84ae3
20 files changed, 16 insertions, 41 deletions
diff --git a/core/java/android/view/PointerIcon.java b/core/java/android/view/PointerIcon.java index 063a08d1397f..7dcad6861669 100644 --- a/core/java/android/view/PointerIcon.java +++ b/core/java/android/view/PointerIcon.java @@ -149,9 +149,9 @@ public final class PointerIcon implements Parcelable { * Creates a custom pointer from the given bitmap and hotspot information. * * @param bitmap The bitmap for the icon. - * @param hotspotX The X offset of the pointer icon hotspot in the bitmap. + * @param hotSpotX The X offset of the pointer icon hotspot in the bitmap. * Must be within the [0, bitmap.getWidth()) range. - * @param hotspotY The Y offset of the pointer icon hotspot in the bitmap. + * @param hotSpotY The Y offset of the pointer icon hotspot in the bitmap. * Must be within the [0, bitmap.getHeight()) range. * @return A pointer icon for this bitmap. * @@ -374,18 +374,18 @@ public final class PointerIcon implements Parcelable { } private void loadResource(Context context, Resources resources, int resourceId) { - XmlResourceParser parser = resources.getXml(resourceId); + final XmlResourceParser parser = resources.getXml(resourceId); final int bitmapRes; final float hotSpotX; final float hotSpotY; try { XmlUtils.beginDocument(parser, "pointer-icon"); - TypedArray a = resources.obtainAttributes( + final TypedArray a = resources.obtainAttributes( parser, com.android.internal.R.styleable.PointerIcon); bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0); - hotSpotX = a.getFloat(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0); - hotSpotY = a.getFloat(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0); + hotSpotX = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0); + hotSpotY = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0); a.recycle(); } catch (Exception ex) { throw new IllegalArgumentException("Exception parsing pointer icon resource.", ex); diff --git a/core/res/res/drawable-hdpi/pointer_spot_anchor.png b/core/res/res/drawable-hdpi/pointer_spot_anchor.png Binary files differindex d7aca3677085..bdb5311d5f21 100644 --- a/core/res/res/drawable-hdpi/pointer_spot_anchor.png +++ b/core/res/res/drawable-hdpi/pointer_spot_anchor.png diff --git a/core/res/res/drawable-hdpi/pointer_spot_anchor_icon.xml b/core/res/res/drawable-hdpi/pointer_spot_anchor_icon.xml deleted file mode 100644 index 2222b8e023e2..000000000000 --- a/core/res/res/drawable-hdpi/pointer_spot_anchor_icon.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" - android:bitmap="@drawable/pointer_spot_anchor" - android:hotSpotX="33" - android:hotSpotY="33" /> diff --git a/core/res/res/drawable-hdpi/pointer_spot_hover.png b/core/res/res/drawable-hdpi/pointer_spot_hover.png Binary files differindex 5041aa3a022f..e7f2a0ca27c9 100644 --- a/core/res/res/drawable-hdpi/pointer_spot_hover.png +++ b/core/res/res/drawable-hdpi/pointer_spot_hover.png diff --git a/core/res/res/drawable-hdpi/pointer_spot_hover_icon.xml b/core/res/res/drawable-hdpi/pointer_spot_hover_icon.xml deleted file mode 100644 index dc62a696eb3b..000000000000 --- a/core/res/res/drawable-hdpi/pointer_spot_hover_icon.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" - android:bitmap="@drawable/pointer_spot_hover" - android:hotSpotX="33" - android:hotSpotY="33" /> diff --git a/core/res/res/drawable-hdpi/pointer_spot_touch.png b/core/res/res/drawable-hdpi/pointer_spot_touch.png Binary files differindex 64a42a18f2c3..0326f91bdb00 100644 --- a/core/res/res/drawable-hdpi/pointer_spot_touch.png +++ b/core/res/res/drawable-hdpi/pointer_spot_touch.png diff --git a/core/res/res/drawable-hdpi/pointer_spot_touch_icon.xml b/core/res/res/drawable-hdpi/pointer_spot_touch_icon.xml deleted file mode 100644 index 4bffee6ab58b..000000000000 --- a/core/res/res/drawable-hdpi/pointer_spot_touch_icon.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" - android:bitmap="@drawable/pointer_spot_touch" - android:hotSpotX="24" - android:hotSpotY="24" /> diff --git a/core/res/res/drawable-mdpi/pointer_arrow_icon.xml b/core/res/res/drawable-mdpi/pointer_arrow_icon.xml deleted file mode 100644 index 2f5676f38aed..000000000000 --- a/core/res/res/drawable-mdpi/pointer_arrow_icon.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" - android:bitmap="@drawable/pointer_arrow" - android:hotSpotX="6" - android:hotSpotY="6" /> diff --git a/core/res/res/drawable-mdpi/pointer_spot_anchor.png b/core/res/res/drawable-mdpi/pointer_spot_anchor.png Binary files differindex d7aca3677085..4e282e7f14cd 100644 --- a/core/res/res/drawable-mdpi/pointer_spot_anchor.png +++ b/core/res/res/drawable-mdpi/pointer_spot_anchor.png diff --git a/core/res/res/drawable-mdpi/pointer_spot_hover.png b/core/res/res/drawable-mdpi/pointer_spot_hover.png Binary files differindex 5041aa3a022f..67d0b066341b 100644 --- a/core/res/res/drawable-mdpi/pointer_spot_hover.png +++ b/core/res/res/drawable-mdpi/pointer_spot_hover.png diff --git a/core/res/res/drawable-mdpi/pointer_spot_touch.png b/core/res/res/drawable-mdpi/pointer_spot_touch.png Binary files differindex 64a42a18f2c3..45dc5c08f932 100644 --- a/core/res/res/drawable-mdpi/pointer_spot_touch.png +++ b/core/res/res/drawable-mdpi/pointer_spot_touch.png diff --git a/core/res/res/drawable-xhdpi/pointer_arrow_icon.xml b/core/res/res/drawable-xhdpi/pointer_arrow_icon.xml deleted file mode 100644 index 2fbe45a2e9f2..000000000000 --- a/core/res/res/drawable-xhdpi/pointer_arrow_icon.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" - android:bitmap="@drawable/pointer_arrow" - android:hotSpotX="12" - android:hotSpotY="12" /> diff --git a/core/res/res/drawable-xhdpi/pointer_spot_anchor.png b/core/res/res/drawable-xhdpi/pointer_spot_anchor.png Binary files differindex ad41c9785db4..fa9226e943ad 100644 --- a/core/res/res/drawable-xhdpi/pointer_spot_anchor.png +++ b/core/res/res/drawable-xhdpi/pointer_spot_anchor.png diff --git a/core/res/res/drawable-xhdpi/pointer_spot_hover.png b/core/res/res/drawable-xhdpi/pointer_spot_hover.png Binary files differindex e9b98f6d4b90..f09a778e6b93 100644 --- a/core/res/res/drawable-xhdpi/pointer_spot_hover.png +++ b/core/res/res/drawable-xhdpi/pointer_spot_hover.png diff --git a/core/res/res/drawable-xhdpi/pointer_spot_touch.png b/core/res/res/drawable-xhdpi/pointer_spot_touch.png Binary files differindex e10d99809161..53d7a20406f7 100644 --- a/core/res/res/drawable-xhdpi/pointer_spot_touch.png +++ b/core/res/res/drawable-xhdpi/pointer_spot_touch.png diff --git a/core/res/res/drawable-hdpi/pointer_arrow_icon.xml b/core/res/res/drawable/pointer_arrow_icon.xml index a4cce5c631c0..8f7d658c9f3a 100644 --- a/core/res/res/drawable-hdpi/pointer_arrow_icon.xml +++ b/core/res/res/drawable/pointer_arrow_icon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" android:bitmap="@drawable/pointer_arrow" - android:hotSpotX="9" - android:hotSpotY="9" /> + android:hotSpotX="6dp" + android:hotSpotY="6dp" /> diff --git a/core/res/res/drawable-mdpi/pointer_spot_anchor_icon.xml b/core/res/res/drawable/pointer_spot_anchor_icon.xml index 2222b8e023e2..73c0c11d99fa 100644 --- a/core/res/res/drawable-mdpi/pointer_spot_anchor_icon.xml +++ b/core/res/res/drawable/pointer_spot_anchor_icon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" android:bitmap="@drawable/pointer_spot_anchor" - android:hotSpotX="33" - android:hotSpotY="33" /> + android:hotSpotX="22dp" + android:hotSpotY="22dp" /> diff --git a/core/res/res/drawable-mdpi/pointer_spot_hover_icon.xml b/core/res/res/drawable/pointer_spot_hover_icon.xml index dc62a696eb3b..1d7440b3f6d9 100644 --- a/core/res/res/drawable-mdpi/pointer_spot_hover_icon.xml +++ b/core/res/res/drawable/pointer_spot_hover_icon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" android:bitmap="@drawable/pointer_spot_hover" - android:hotSpotX="33" - android:hotSpotY="33" /> + android:hotSpotX="22dp" + android:hotSpotY="22dp" /> diff --git a/core/res/res/drawable-mdpi/pointer_spot_touch_icon.xml b/core/res/res/drawable/pointer_spot_touch_icon.xml index 4bffee6ab58b..f4f0639d49d8 100644 --- a/core/res/res/drawable-mdpi/pointer_spot_touch_icon.xml +++ b/core/res/res/drawable/pointer_spot_touch_icon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" android:bitmap="@drawable/pointer_spot_touch" - android:hotSpotX="24" - android:hotSpotY="24" /> + android:hotSpotX="16dp" + android:hotSpotY="16dp" /> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index a798d2e78a87..ce2bc8526713 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -7112,9 +7112,9 @@ <!-- Drawable to use as the icon bitmap. --> <attr name="bitmap" format="reference" /> <!-- X coordinate of the icon hot spot. --> - <attr name="hotSpotX" format="float" /> + <attr name="hotSpotX" format="dimension" /> <!-- Y coordinate of the icon hot spot. --> - <attr name="hotSpotY" format="float" /> + <attr name="hotSpotY" format="dimension" /> </declare-styleable> <declare-styleable name="Storage"> |