From cccb63219fc92b7f6a6e322746f276e6f07c7dd0 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 27 Jun 2012 15:28:07 +0800 Subject: Don't use Display.getSize(). Change-Id: I9b5c9021bae2b58d2815a909c97104f215d4d2e8 --- src/com/android/gallery3d/app/Wallpaper.java | 18 ++++++++++++++++-- src/com/android/gallery3d/util/GalleryUtils.java | 2 -- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/com/android/gallery3d/app/Wallpaper.java b/src/com/android/gallery3d/app/Wallpaper.java index c08c1d705..d64eecdcf 100644 --- a/src/com/android/gallery3d/app/Wallpaper.java +++ b/src/com/android/gallery3d/app/Wallpaper.java @@ -16,11 +16,14 @@ package com.android.gallery3d.app; +import android.annotation.TargetApi; import android.app.Activity; import android.content.Intent; import android.graphics.Point; import android.net.Uri; +import android.os.Build; import android.os.Bundle; +import android.view.Display; /** * Wallpaper picker for the gallery application. This just redirects to the @@ -57,6 +60,18 @@ public class Wallpaper extends Activity { } } + @SuppressWarnings("deprecation") + @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) + private Point getDefaultDisplaySize(Point size) { + Display d = getWindowManager().getDefaultDisplay(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { + d.getSize(size); + } else { + size.set(d.getWidth(), d.getHeight()); + } + return size; + } + @SuppressWarnings("fallthrough") @Override protected void onResume() { @@ -78,8 +93,7 @@ public class Wallpaper extends Activity { case STATE_PHOTO_PICKED: { int width = getWallpaperDesiredMinimumWidth(); int height = getWallpaperDesiredMinimumHeight(); - Point size = new Point(); - getWindowManager().getDefaultDisplay().getSize(size); + Point size = getDefaultDisplaySize(new Point()); float spotlightX = (float) size.x / width; float spotlightY = (float) size.y / height; Intent request = new Intent(CropImage.ACTION_CROP) diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java index 1d70914ce..1291ee9f7 100644 --- a/src/com/android/gallery3d/util/GalleryUtils.java +++ b/src/com/android/gallery3d/util/GalleryUtils.java @@ -16,7 +16,6 @@ package com.android.gallery3d.util; -import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; @@ -24,7 +23,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.content.res.Resources; import android.net.Uri; import android.os.ConditionVariable; import android.os.Environment; -- cgit v1.2.3