diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2009-12-08 21:50:14 -0800 |
|---|---|---|
| committer | Jeff Sharkey <jsharkey@android.com> | 2009-12-21 14:18:09 -0800 |
| commit | a503f6f7cf09c64bde708e3bcfb7103378ddfcff (patch) | |
| tree | 9b5bb84fa9b5b73675d0d89dfcefa4f910918ff0 /core/java/android/widget/RemoteViews.java | |
| parent | afbe1259d7932da809c7c9888a5321cec9c78f4e (diff) | |
Adjust for compatibility mode before setSourceBounds().
When invoked from an anyDensity="false" or pre-Donut app,
View.getLocationOnScreen() returns values in compatibility
mode. This change fixes QuickContact and RemoteViews to
always adjust based on CompatibilityInfo.applicationScale.
Also deprecates an extra previously being used to pass
Rect for QuickContact windows.
Fixes http://b/2306495
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index b847e574362d..c1150733e282 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -137,11 +137,21 @@ public class RemoteViews implements Parcelable, Filter { if (target != null && pendingIntent != null) { OnClickListener listener = new OnClickListener() { public void onClick(View v) { - int[] pos = new int[2]; + // Find target view location in screen coordinates and + // fill into PendingIntent before sending. + final float appScale = v.getContext().getResources() + .getCompatibilityInfo().applicationScale; + final int[] pos = new int[2]; v.getLocationOnScreen(pos); - Intent intent = new Intent(); - intent.setSourceBounds(new Rect(pos[0], pos[1], - pos[0]+v.getWidth(), pos[1]+v.getHeight())); + + final Rect rect = new Rect(); + rect.left = (int) (pos[0] * appScale + 0.5f); + rect.top = (int) (pos[1] * appScale + 0.5f); + rect.right = (int) ((pos[0] + v.getWidth()) * appScale + 0.5f); + rect.bottom = (int) ((pos[1] + v.getHeight()) * appScale + 0.5f); + + final Intent intent = new Intent(); + intent.setSourceBounds(rect); try { // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT? v.getContext().startIntentSender( |
