Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23054a0b authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge "PointerIcon: Ensure bitmap size and hotspot are scaled consistently" into main

parents f120014b 626edb8f
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -514,10 +514,14 @@ public final class PointerIcon implements Parcelable {
            final TypedArray a = resources.obtainAttributes(
            final TypedArray a = resources.obtainAttributes(
                    parser, com.android.internal.R.styleable.PointerIcon);
                    parser, com.android.internal.R.styleable.PointerIcon);
            bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0);
            bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0);
            hotSpotX = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0)
            // Cast the hotspot dimensions to int before scaling to match the scaling logic of
                    * pointerScale;
            // the bitmap, whose intrinsic size is also an int before it is scaled.
            hotSpotY = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0)
            final int unscaledHotSpotX =
                    * pointerScale;
                    (int) a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0);
            final int unscaledHotSpotY =
                    (int) a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0);
            hotSpotX = unscaledHotSpotX * pointerScale;
            hotSpotY = unscaledHotSpotY * pointerScale;
            a.recycle();
            a.recycle();
        } catch (Exception ex) {
        } catch (Exception ex) {
            throw new IllegalArgumentException("Exception parsing pointer icon resource.", ex);
            throw new IllegalArgumentException("Exception parsing pointer icon resource.", ex);