Show panorama thumbs in Gallery grid view

Bug: 7362229
Bug: 7378208

In addition to showing pano thumbs, this CL also removes the video play
icon on the top-level album view thumbnails.

Change-Id: I950bc66c38575036d5ad7464a2fd9a5dea9fae4b
diff --git a/res/drawable-hdpi/ic_360pano_holo_light.png b/res/drawable-hdpi/ic_360pano_holo_light.png
new file mode 100644
index 0000000..9873c17
--- /dev/null
+++ b/res/drawable-hdpi/ic_360pano_holo_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_360pano_holo_light.png b/res/drawable-mdpi/ic_360pano_holo_light.png
new file mode 100644
index 0000000..7de1ec9
--- /dev/null
+++ b/res/drawable-mdpi/ic_360pano_holo_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_360pano_holo_light.png b/res/drawable-xhdpi/ic_360pano_holo_light.png
new file mode 100644
index 0000000..0ea4310
--- /dev/null
+++ b/res/drawable-xhdpi/ic_360pano_holo_light.png
Binary files differ
diff --git a/src/com/android/gallery3d/ui/AbstractSlotRenderer.java b/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
index c36847d..10b710d 100644
--- a/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
@@ -25,7 +25,7 @@
 
     private final ResourceTexture mVideoOverlay;
     private final ResourceTexture mVideoPlayIcon;
-    private final NinePatchTexture mPanoramaBorder;
+    private final ResourceTexture mPanoramaIcon;
     private final NinePatchTexture mFramePressed;
     private final NinePatchTexture mFrameSelected;
     private FadeOutTexture mFramePressedUp;
@@ -33,7 +33,7 @@
     protected AbstractSlotRenderer(Context context) {
         mVideoOverlay = new ResourceTexture(context, R.drawable.ic_video_thumb);
         mVideoPlayIcon = new ResourceTexture(context, R.drawable.ic_gallery_play);
-        mPanoramaBorder = new NinePatchTexture(context, R.drawable.ic_pan_thumb);
+        mPanoramaIcon = new ResourceTexture(context, R.drawable.ic_360pano_holo_light);
         mFramePressed = new NinePatchTexture(context, R.drawable.grid_pressed);
         mFrameSelected = new NinePatchTexture(context, R.drawable.grid_selected);
     }
@@ -74,14 +74,10 @@
         mVideoPlayIcon.draw(canvas, (width - s) / 2, (height - s) / 2, s, s);
     }
 
-    protected void drawPanoramaBorder(GLCanvas canvas, int width, int height) {
-        float scale = (float) width / mPanoramaBorder.getWidth();
-        int w = Math.round(scale * mPanoramaBorder.getWidth());
-        int h = Math.round(scale * mPanoramaBorder.getHeight());
-        // draw at the top
-        mPanoramaBorder.draw(canvas, 0, 0, w, h);
-        // draw at the bottom
-        mPanoramaBorder.draw(canvas, 0, height - h, w, h);
+    protected void drawPanoramaIcon(GLCanvas canvas, int width, int height) {
+        int iconSize = Math.min(width, height) / 6;
+        mPanoramaIcon.draw(canvas, (width - iconSize) / 2, (height - iconSize) / 2,
+                iconSize, iconSize);
     }
 
     protected boolean isPressedUpFrameFinished() {
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
index e32ec51..d95a523 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
@@ -31,7 +31,6 @@
 import com.android.gallery3d.data.Path;
 import com.android.gallery3d.util.Future;
 import com.android.gallery3d.util.FutureListener;
-import com.android.gallery3d.util.GalleryUtils;
 import com.android.gallery3d.util.ThreadPool;
 
 public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
@@ -80,8 +79,6 @@
         public int cacheFlag;
         public int cacheStatus;
         public int rotation;
-        public int mediaType;
-        public boolean isPanorama;
         public boolean isWaitLoadingDisplayed;
         public long setDataVersion;
         public long coverDataVersion;
@@ -271,9 +268,7 @@
         entry.coverItem = cover;
         if (getDataVersion(cover) != entry.coverDataVersion) {
             entry.coverDataVersion = getDataVersion(cover);
-            entry.isPanorama = GalleryUtils.isPanorama(cover);
             entry.rotation = (cover == null) ? 0 : cover.getRotation();
-            entry.mediaType = (cover == null) ? 0 : cover.getMediaType();
             if (entry.coverLoader != null) {
                 entry.coverLoader.recycle();
                 entry.coverLoader = null;
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
index 9b3f29f..233a800 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
@@ -170,14 +170,6 @@
             renderRequestFlags |= SlotView.RENDER_MORE_FRAME;
         }
 
-        if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
-            drawVideoOverlay(canvas, width, height);
-        }
-
-        if (entry.isPanorama) {
-            drawPanoramaBorder(canvas, width, height);
-        }
-
         return renderRequestFlags;
     }
 
diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
index e4d636a..d3ad304 100644
--- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
@@ -24,10 +24,11 @@
 import com.android.gallery3d.common.Utils;
 import com.android.gallery3d.data.BitmapPool;
 import com.android.gallery3d.data.MediaItem;
+import com.android.gallery3d.data.MediaObject;
 import com.android.gallery3d.data.Path;
+import com.android.gallery3d.data.MediaObject.PanoramaSupportCallback;
 import com.android.gallery3d.util.Future;
 import com.android.gallery3d.util.FutureListener;
-import com.android.gallery3d.util.GalleryUtils;
 import com.android.gallery3d.util.JobLimiter;
 
 public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
@@ -52,6 +53,7 @@
         public BitmapTexture bitmapTexture;
         public Texture content;
         private BitmapLoader contentLoader;
+        private PanoSupportListener mPanoSupportListener;
     }
 
     private final AlbumDataLoader mSource;
@@ -73,6 +75,18 @@
     private int mActiveRequestCount = 0;
     private boolean mIsActive = false;
 
+    private class PanoSupportListener implements PanoramaSupportCallback {
+        public final AlbumEntry mEntry;
+        public PanoSupportListener (AlbumEntry entry) {
+            mEntry = entry;
+        }
+        @Override
+        public void panoramaInfoAvailable(MediaObject mediaObject, boolean isPanorama,
+                boolean isPanorama360) {
+            if (mEntry != null) mEntry.isPanorama = isPanorama;
+        }
+    }
+
     public AlbumSlidingWindow(AbstractGalleryActivity activity,
             AlbumDataLoader source, int cacheSize) {
         source.setDataListener(this);
@@ -213,6 +227,10 @@
         AlbumEntry entry = mData[slotIndex % mData.length];
         if (entry.content != null || entry.item == null) return false;
 
+        // Set up the panorama callback
+        entry.mPanoSupportListener = new PanoSupportListener(entry);
+        entry.item.getPanoramaSupport(entry.mPanoSupportListener);
+
         entry.contentLoader.startLoad();
         return entry.contentLoader.isRequestInProgress();
     }
@@ -245,7 +263,6 @@
         AlbumEntry entry = new AlbumEntry();
         MediaItem item = mSource.get(slotIndex); // item could be null;
         entry.item = item;
-        entry.isPanorama = GalleryUtils.isPanorama(entry.item);
         entry.mediaType = (item == null)
                 ? MediaItem.MEDIA_TYPE_UNKNOWN
                 : entry.item.getMediaType();
diff --git a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
index d9e3fb7..4bf10e7 100644
--- a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
@@ -123,7 +123,7 @@
         }
 
         if (entry.isPanorama) {
-            drawPanoramaBorder(canvas, width, height);
+            drawPanoramaIcon(canvas, width, height);
         }
 
         renderRequestFlags |= renderOverlay(canvas, index, entry, width, height);