From 28ae21ac552db858b73c2491cb4f1718e8d82646 Mon Sep 17 00:00:00 2001 From: Christopher Eby Date: Sun, 7 Mar 2010 21:25:10 -0600 Subject: [PATCH] Target API 7 Now we must handle scaling ourselves --- AndroidManifest.xml | 2 +- default.properties | 4 +++- src/org/kreed/vanilla/CoverView.java | 15 ++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 686e8c08..d77a8115 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -36,7 +36,7 @@ - + \ No newline at end of file diff --git a/default.properties b/default.properties index 4513a1e4..128c6ef1 100644 --- a/default.properties +++ b/default.properties @@ -7,5 +7,7 @@ # "build.properties", and override values to adapt the script to your # project structure. +# Indicates whether an apk should be generated for each density. +split.density=false # Project target. -target=android-3 +target=android-7 diff --git a/src/org/kreed/vanilla/CoverView.java b/src/org/kreed/vanilla/CoverView.java index a40a79b9..a10ab110 100644 --- a/src/org/kreed/vanilla/CoverView.java +++ b/src/org/kreed/vanilla/CoverView.java @@ -36,14 +36,17 @@ import android.os.Handler; import android.os.Message; import android.os.RemoteException; import android.util.AttributeSet; +import android.util.DisplayMetrics; +import android.util.TypedValue; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; +import android.view.ViewConfiguration; import android.widget.Scroller; public class CoverView extends View { - private static final int SNAP_VELOCITY = 1000; private static final int STORE_SIZE = 3; + private final int SNAP_VELOCITY; private Scroller mScroller; private VelocityTracker mVelocityTracker; @@ -62,6 +65,7 @@ public class CoverView extends View { super(context, attributes); mScroller = new Scroller(context); + SNAP_VELOCITY = ViewConfiguration.get(context).getScaledMinimumFlingVelocity(); IntentFilter filter = new IntentFilter(); filter.addAction(PlaybackService.EVENT_LOADED); @@ -151,7 +155,7 @@ public class CoverView extends View { return bitmap; } - public static Bitmap createBitmap(Song song, int width, int height) + public Bitmap createBitmap(Song song, int width, int height) { if (song == null || width < 1 || height < 1) return null; @@ -164,9 +168,10 @@ public class CoverView extends View { String artist = song.artist == null ? "" : song.artist; Bitmap cover = song.coverPath == null ? null : BitmapFactory.decodeFile(song.coverPath); - float titleSize = 20; - float subSize = 14; - float padding = 10; + DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); + float titleSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, metrics); + float subSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, metrics); + float padding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, metrics); paint.setTextSize(titleSize); float titleWidth = paint.measureText(title);