Use bigger thumbnails on xlarge. Use higher quality JPEG

Bug:3339040
Change-Id: I8fae930e63c661185e131f5c10419e92b9542d0b
diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml
new file mode 100644
index 0000000..6931fc8
--- /dev/null
+++ b/res/values-xlarge/dimens.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+**  Copyright 2010 Google Inc. All Rights Reserved.
+**
+-->
+
+<resources>
+    <!-- maximum size for album art. the real size of the albumart will be divided by two
+    until both width and height are below this value. -->
+    <dimen name="maximum_thumb_size">500dip</dimen>
+</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 0000000..7f76c3a
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+**  Copyright 2010 Google Inc. All Rights Reserved.
+**
+-->
+
+<resources>
+    <!-- maximum size for album art. the real size of the albumart will be divided by two
+    until both width and height are below this value. -->
+    <dimen name="maximum_thumb_size">320dip</dimen>
+</resources>
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index 58fbd96..3de00fa 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -31,6 +31,7 @@
 import android.content.OperationApplicationException;
 import android.content.ServiceConnection;
 import android.content.UriMatcher;
+import android.content.res.Resources;
 import android.database.Cursor;
 import android.database.DatabaseUtils;
 import android.database.MatrixCursor;
@@ -59,11 +60,11 @@
 import android.provider.MediaStore;
 import android.provider.MediaStore.Audio;
 import android.provider.MediaStore.Files;
+import android.provider.MediaStore.Files.FileColumns;
 import android.provider.MediaStore.Images;
+import android.provider.MediaStore.Images.ImageColumns;
 import android.provider.MediaStore.MediaColumns;
 import android.provider.MediaStore.Video;
-import android.provider.MediaStore.Files.FileColumns;
-import android.provider.MediaStore.Images.ImageColumns;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -3509,7 +3510,7 @@
                 outstream.write(compressed);
                 success = true;
             } else {
-                success = bm.compress(Bitmap.CompressFormat.JPEG, 75, outstream);
+                success = bm.compress(Bitmap.CompressFormat.JPEG, 85, outstream);
             }
 
             outstream.close();
@@ -3552,8 +3553,9 @@
             BitmapFactory.decodeByteArray(compressed, 0, compressed.length, opts);
 
             // request a reasonably sized output image
-            // TODO: don't hardcode the size
-            while (opts.outHeight > 320 || opts.outWidth > 320) {
+            final Resources r = getContext().getResources();
+            final int maximumThumbSize = r.getDimensionPixelSize(R.dimen.maximum_thumb_size);
+            while (opts.outHeight > maximumThumbSize || opts.outWidth > maximumThumbSize) {
                 opts.outHeight /= 2;
                 opts.outWidth /= 2;
                 opts.inSampleSize *= 2;