OSDN Git Service

New UI for Gallery.
authorChih-Chung Chang <chihchung@google.com>
Wed, 14 Sep 2011 12:50:28 +0000 (20:50 +0800)
committerChih-Chung Chang <chihchung@google.com>
Fri, 16 Sep 2011 07:23:49 +0000 (15:23 +0800)
Change-Id: I5f243c00ebac55a9b333a9e13d0cc9c371a85005

21 files changed:
src/com/android/gallery3d/app/AlbumPage.java
src/com/android/gallery3d/app/AlbumSetDataAdapter.java
src/com/android/gallery3d/app/AlbumSetPage.java
src/com/android/gallery3d/app/Config.java
src/com/android/gallery3d/app/ManageCachePage.java
src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
src/com/android/gallery3d/ui/AlbumSetView.java
src/com/android/gallery3d/ui/AlbumSlidingWindow.java
src/com/android/gallery3d/ui/AlbumView.java
src/com/android/gallery3d/ui/DisplayItem.java
src/com/android/gallery3d/ui/FilmStripView.java
src/com/android/gallery3d/ui/GLDetailsView.java
src/com/android/gallery3d/ui/GridDrawer.java
src/com/android/gallery3d/ui/HighlightDrawer.java
src/com/android/gallery3d/ui/IconDrawer.java
src/com/android/gallery3d/ui/ManageCacheDrawer.java
src/com/android/gallery3d/ui/MultiLineTexture.java
src/com/android/gallery3d/ui/SelectionDrawer.java
src/com/android/gallery3d/ui/SlotView.java
src/com/android/gallery3d/ui/StringTexture.java
src/com/android/gallery3d/ui/StripDrawer.java

index 672c0da..7d70548 100644 (file)
@@ -357,8 +357,8 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
         mSelectionManager.setSelectionListener(this);
         mGridDrawer = new GridDrawer((Context) mActivity, mSelectionManager);
         Config.AlbumPage config = Config.AlbumPage.get((Context) mActivity);
-        mAlbumView = new AlbumView(mActivity,
-                config.slotWidth, config.slotHeight, config.displayItemSize);
+        mAlbumView = new AlbumView(mActivity, config.slotViewSpec,
+                0 /* don't cache thumbnail */);
         mAlbumView.setSelectionDrawer(mGridDrawer);
         mRootPane.addComponent(mAlbumView);
         mAlbumView.setListener(new SlotView.SimpleListener() {
index 85f3bf5..8322d2b 100644 (file)
@@ -41,7 +41,7 @@ public class AlbumSetDataAdapter implements AlbumSetView.Model {
     private static final int INDEX_NONE = -1;
 
     private static final int MIN_LOAD_COUNT = 4;
-    private static final int MAX_COVER_COUNT = 4;
+    private static final int MAX_COVER_COUNT = 1;
 
     private static final int MSG_LOAD_START = 1;
     private static final int MSG_LOAD_FINISH = 2;
index 0970572..b9f7a1a 100644 (file)
@@ -313,9 +313,7 @@ public class AlbumSetPage extends ActivityState implements
         mGridDrawer = new GridDrawer((Context) mActivity, mSelectionManager);
         Config.AlbumSetPage config = Config.AlbumSetPage.get((Context) mActivity);
         mAlbumSetView = new AlbumSetView(mActivity, mGridDrawer,
-                config.slotWidth, config.slotHeight,
-                config.displayItemSize, config.labelFontSize,
-                config.labelOffsetY, config.labelMargin);
+                config.slotViewSpec, config.labelSpec);
         mAlbumSetView.setListener(new SlotView.SimpleListener() {
             @Override
             public void onSingleTapUp(int slotIndex) {
index 4586235..0cea6c8 100644 (file)
@@ -17,6 +17,8 @@
 package com.android.gallery3d.app;
 
 import com.android.gallery3d.R;
+import com.android.gallery3d.ui.SlotView;
+import com.android.gallery3d.ui.AlbumSetView;
 
 import android.content.Context;
 import android.content.res.Resources;
@@ -25,12 +27,8 @@ final class Config {
     public static class AlbumSetPage {
         private static AlbumSetPage sInstance;
 
-        public final int slotWidth;
-        public final int slotHeight;
-        public final int displayItemSize;
-        public final int labelFontSize;
-        public final int labelOffsetY;
-        public final int labelMargin;
+        public SlotView.Spec slotViewSpec;
+        public AlbumSetView.LabelSpec labelSpec;
 
         public static synchronized AlbumSetPage get(Context context) {
             if (sInstance == null) {
@@ -41,21 +39,34 @@ final class Config {
 
         private AlbumSetPage(Context context) {
             Resources r = context.getResources();
-            slotWidth = r.getDimensionPixelSize(R.dimen.albumset_slot_width);
-            slotHeight = r.getDimensionPixelSize(R.dimen.albumset_slot_height);
-            displayItemSize = r.getDimensionPixelSize(R.dimen.albumset_display_item_size);
-            labelFontSize = r.getDimensionPixelSize(R.dimen.albumset_label_font_size);
-            labelOffsetY = r.getDimensionPixelSize(R.dimen.albumset_label_offset_y);
-            labelMargin = r.getDimensionPixelSize(R.dimen.albumset_label_margin);
+
+            slotViewSpec = new SlotView.Spec();
+            slotViewSpec.rowsLand = r.getInteger(R.integer.albumset_rows_land);
+            slotViewSpec.rowsPort = r.getInteger(R.integer.albumset_rows_port);
+            slotViewSpec.slotGap = r.getDimensionPixelSize(R.dimen.albumset_slot_gap);
+
+            labelSpec = new AlbumSetView.LabelSpec();
+            labelSpec.darkStripHeight = r.getDimensionPixelSize(
+                    R.dimen.albumset_dark_strip_height);
+            labelSpec.titleOffset = r.getDimensionPixelSize(
+                    R.dimen.albumset_title_offset);
+            labelSpec.numberOffset = r.getDimensionPixelSize(
+                    R.dimen.albumset_number_offset);
+            labelSpec.titleFontSize = r.getDimensionPixelSize(
+                    R.dimen.albumset_title_font_size);
+            labelSpec.numberFontSize = r.getDimensionPixelSize(
+                    R.dimen.albumset_number_font_size);
+            labelSpec.leftMargin = r.getDimensionPixelSize(
+                    R.dimen.albumset_left_margin);
+            labelSpec.iconSize = r.getDimensionPixelSize(
+                    R.dimen.albumset_icon_size);
         }
     }
 
     public static class AlbumPage {
         private static AlbumPage sInstance;
 
-        public final int slotWidth;
-        public final int slotHeight;
-        public final int displayItemSize;
+        public SlotView.Spec slotViewSpec;
 
         public static synchronized AlbumPage get(Context context) {
             if (sInstance == null) {
@@ -66,9 +77,11 @@ final class Config {
 
         private AlbumPage(Context context) {
             Resources r = context.getResources();
-            slotWidth = r.getDimensionPixelSize(R.dimen.album_slot_width);
-            slotHeight = r.getDimensionPixelSize(R.dimen.album_slot_height);
-            displayItemSize = r.getDimensionPixelSize(R.dimen.album_display_item_size);
+
+            slotViewSpec = new SlotView.Spec();
+            slotViewSpec.rowsLand = r.getInteger(R.integer.album_rows_land);
+            slotViewSpec.rowsPort = r.getInteger(R.integer.album_rows_port);
+            slotViewSpec.slotGap = r.getDimensionPixelSize(R.dimen.album_slot_gap);
         }
     }
 
index 940f1be..7e301f2 100644 (file)
@@ -283,9 +283,7 @@ public class ManageCachePage extends ActivityState implements
                 (Context) mActivity, mSelectionManager);
         Config.ManageCachePage config = Config.ManageCachePage.get(activity);
         mAlbumSetView = new AlbumSetView(mActivity, mSelectionDrawer,
-                config.slotWidth, config.slotHeight,
-                config.displayItemSize, config.labelFontSize,
-                config.labelOffsetY, config.labelMargin);
+                config.slotViewSpec, config.labelSpec);
         mAlbumSetView.setListener(new SlotView.SimpleListener() {
             @Override
             public void onSingleTapUp(int slotIndex) {
index 92d8b41..9ad0937 100644 (file)
@@ -45,9 +45,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener {
 
     private final AlbumSetView.Model mSource;
     private int mSize;
-    private int mLabelWidth;
-    private int mDisplayItemSize;
-    private int mLabelFontSize;
+    private AlbumSetView.LabelSpec mLabelSpec;
 
     private int mContentStart = 0;
     private int mContentEnd = 0;
@@ -75,13 +73,11 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener {
         public int cacheStatus;
     }
 
-    public AlbumSetSlidingWindow(GalleryActivity activity, int labelWidth,
-            int displayItemSize, int labelFontSize, SelectionDrawer drawer,
+    public AlbumSetSlidingWindow(GalleryActivity activity,
+            AlbumSetView.LabelSpec labelSpec, SelectionDrawer drawer,
             AlbumSetView.Model source, int cacheSize) {
         source.setModelListener(this);
-        mLabelWidth = labelWidth;
-        mDisplayItemSize = displayItemSize;
-        mLabelFontSize = labelFontSize;
+        mLabelSpec = labelSpec;
         mLoadingLabel = activity.getAndroidContext().getString(R.string.loading);
         mSource = source;
         mSelectionDrawer = drawer;
@@ -367,20 +363,22 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener {
 
         private void updateContent(Texture content) {
             mContent = content;
+        }
 
-            int width = content.getWidth();
-            int height = content.getHeight();
+        @Override
+        public boolean render(GLCanvas canvas, int pass) {
+            // Fit the content into the box
+            int width = mContent.getWidth();
+            int height = mContent.getHeight();
 
-            float scale = (float) mDisplayItemSize / Math.max(width, height);
+            float scalex = mBoxWidth / (float) width;
+            float scaley = mBoxHeight / (float) height;
+            float scale = Math.min(scalex, scaley);
 
             width = (int) Math.floor(width * scale);
             height = (int) Math.floor(height * scale);
 
-            setSize(width, height);
-        }
-
-        @Override
-        public boolean render(GLCanvas canvas, int pass) {
+            // Now draw it
             int sourceType = SelectionDrawer.DATASOURCE_TYPE_NOT_CATEGORIZED;
             int cacheFlag = MediaSet.CACHE_FLAG_NO;
             int cacheStatus = MediaSet.CACHE_STATUS_NOT_CACHED;
@@ -392,8 +390,9 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener {
                 cacheStatus = set.cacheStatus;
             }
 
-            mSelectionDrawer.draw(canvas, mContent, mWidth, mHeight,
+            mSelectionDrawer.draw(canvas, mContent, width, height,
                     getRotation(), path, mCoverIndex, sourceType, mMediaType,
+                    mLabelSpec.darkStripHeight,
                     cacheFlag == MediaSet.CACHE_FLAG_FULL,
                     (cacheFlag == MediaSet.CACHE_FLAG_FULL)
                     && (cacheStatus != MediaSet.CACHE_STATUS_CACHED_FULL));
@@ -471,37 +470,61 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener {
     }
 
     private class LabelDisplayItem extends DisplayItem {
-        private static final int FONT_COLOR = Color.WHITE;
-
-        private StringTexture mTexture;
-        private String mLabel;
-        private String mPostfix;
+        private static final int FONT_COLOR_TITLE = Color.WHITE;
+        private static final int FONT_COLOR_NUMBER = 0x80FFFFFF;  // 50% white
+
+        private StringTexture mTextureTitle;
+        private StringTexture mTextureNumber;
+        private String mTitle;
+        private String mNumber;
+        private int mLastWidth;
         private final int mSlotIndex;
 
         public LabelDisplayItem(int slotIndex) {
             mSlotIndex = slotIndex;
-            updateContent();
         }
 
         public boolean updateContent() {
-            String label = mLoadingLabel;
-            String postfix = null;
+            String title = mLoadingLabel;
+            String number = "";
             MediaSet set = mSource.getMediaSet(mSlotIndex);
             if (set != null) {
-                label = Utils.ensureNotNull(set.getName());
-                postfix = " (" + set.getTotalMediaItemCount() + ")";
+                title = Utils.ensureNotNull(set.getName());
+                number = "" + set.getTotalMediaItemCount();
+            }
+            if (Utils.equals(title, mTitle)
+                    && Utils.equals(number, mNumber)
+                    && Utils.equals(mBoxWidth, mLastWidth)) {
+                    return false;
             }
-            if (Utils.equals(label, mLabel)
-                    && Utils.equals(postfix, mPostfix)) return false;
-            mTexture = StringTexture.newInstance(
-                    label, postfix, mLabelFontSize, FONT_COLOR, mLabelWidth, true);
-            setSize(mTexture.getWidth(), mTexture.getHeight());
+            mTitle = title;
+            mNumber = number;
+            mLastWidth = mBoxWidth;
+
+            AlbumSetView.LabelSpec s = mLabelSpec;
+            mTextureTitle = StringTexture.newInstance(
+                    title, s.titleFontSize, FONT_COLOR_TITLE,
+                    mBoxWidth - s.leftMargin, false);
+            mTextureNumber = StringTexture.newInstance(
+                    number, s.numberFontSize, FONT_COLOR_NUMBER,
+                    mBoxWidth - s.leftMargin, true);
+
             return true;
         }
 
         @Override
         public boolean render(GLCanvas canvas, int pass) {
-            mTexture.draw(canvas, -mWidth / 2, -mHeight / 2);
+            if (mBoxWidth != mLastWidth) {
+                updateContent();
+            }
+
+            AlbumSetView.LabelSpec s = mLabelSpec;
+            int x = -mBoxWidth / 2;
+            int y = (mBoxHeight + 1) / 2 - s.darkStripHeight;
+            y += s.titleOffset;
+            mTextureTitle.draw(canvas, x + s.leftMargin, y);
+            y += s.titleFontSize + s.numberOffset;
+            mTextureNumber.draw(canvas, x + s.iconSize, y);
             return false;
         }
 
index ef066b3..c122fe7 100644 (file)
@@ -40,11 +40,7 @@ public class AlbumSetView extends SlotView {
 
     private AlbumSetSlidingWindow mDataWindow;
     private final GalleryActivity mActivity;
-    private final int mSlotWidth;
-    private final int mDisplayItemSize;
-    private final int mLabelFontSize;
-    private final int mLabelOffsetY;
-    private final int mLabelMargin;
+    private final LabelSpec mLabelSpec;
 
     private SelectionDrawer mSelectionDrawer;
 
@@ -67,18 +63,23 @@ public class AlbumSetView extends SlotView {
         public long setDataVersion;
     }
 
+    public static class LabelSpec {
+        public int darkStripHeight;
+        public int titleOffset;
+        public int numberOffset;
+        public int titleFontSize;
+        public int numberFontSize;
+        public int leftMargin;
+        public int iconSize;
+    }
+
     public AlbumSetView(GalleryActivity activity, SelectionDrawer drawer,
-            int slotWidth, int slotHeight, int displayItemSize,
-            int labelFontSize, int labelOffsetY, int labelMargin) {
+            SlotView.Spec slotViewSpec, LabelSpec labelSpec) {
         super(activity.getAndroidContext());
         mActivity = activity;
         setSelectionDrawer(drawer);
-        setSlotSize(slotWidth, slotHeight);
-        mSlotWidth = slotWidth;
-        mDisplayItemSize = displayItemSize;
-        mLabelFontSize = labelFontSize;
-        mLabelOffsetY = labelOffsetY;
-        mLabelMargin = labelMargin;
+        setSlotSpec(slotViewSpec);
+        mLabelSpec = labelSpec;
     }
 
     public void setSelectionDrawer(SelectionDrawer drawer) {
@@ -95,8 +96,7 @@ public class AlbumSetView extends SlotView {
             mDataWindow = null;
         }
         if (model != null) {
-            mDataWindow = new AlbumSetSlidingWindow(mActivity,
-                    mSlotWidth - mLabelMargin * 2, mDisplayItemSize, mLabelFontSize,
+            mDataWindow = new AlbumSetSlidingWindow(mActivity, mLabelSpec,
                     mSelectionDrawer, model, CACHE_SIZE);
             mDataWindow.setListener(new MyCacheListener());
             setSlotCount(mDataWindow.size());
@@ -119,8 +119,7 @@ public class AlbumSetView extends SlotView {
 
         // Put the cover items in reverse order, so that the first item is on
         // top of the rest.
-        int labelY = y + mLabelOffsetY - entry.labelItem.getHeight() / 2;
-        Position position = new Position(x, labelY, 0f);
+        Position position = new Position(x, y, 0f);
         putDisplayItem(position, position, entry.labelItem);
 
         for (int i = 0, n = items.length; i < n; ++i) {
index 9b410e9..46d9e9e 100644 (file)
@@ -38,7 +38,6 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener {
 
     private static final int MSG_LOAD_BITMAP_DONE = 0;
     private static final int MSG_UPDATE_SLOT = 1;
-    private static final int MIN_THUMB_SIZE = 100;
     private static final int JOB_LIMIT = 2;
 
     public static interface Listener {
@@ -66,24 +65,20 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener {
 
     private SynchronizedHandler mHandler;
     private JobLimiter mThreadPool;
-    private int mSlotWidth, mSlotHeight;
 
     private int mActiveRequestCount = 0;
     private boolean mIsActive = false;
 
-    private int mDisplayItemSize;  // 0: disabled
+    private int mCacheThumbSize;  // 0: Don't cache the thumbnails
     private LruCache<Path, Bitmap> mImageCache = new LruCache<Path, Bitmap>(1000);
 
     public AlbumSlidingWindow(GalleryActivity activity,
             AlbumView.Model source, int cacheSize,
-            int slotWidth, int slotHeight, int displayItemSize) {
+            int cacheThumbSize) {
         source.setModelListener(this);
         mSource = source;
         mData = new AlbumDisplayItem[cacheSize];
         mSize = source.size();
-        mSlotWidth = slotWidth;
-        mSlotHeight = slotHeight;
-        mDisplayItemSize = displayItemSize;
 
         mWaitLoadingTexture = new ColorTexture(Color.TRANSPARENT);
         mWaitLoadingTexture.setSize(1, 1);
@@ -317,37 +312,37 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener {
 
         private void updateContent(Texture content) {
             mContent = content;
+        }
 
+        @Override
+        public boolean render(GLCanvas canvas, int pass) {
+            // Fit the content into the box
             int width = mContent.getWidth();
             int height = mContent.getHeight();
 
-            float scalex = mDisplayItemSize / (float) width;
-            float scaley = mDisplayItemSize / (float) height;
+            float scalex = mBoxWidth / (float) width;
+            float scaley = mBoxHeight / (float) height;
             float scale = Math.min(scalex, scaley);
 
             width = (int) Math.floor(width * scale);
             height = (int) Math.floor(height * scale);
 
-            setSize(width, height);
-        }
-
-        @Override
-        public boolean render(GLCanvas canvas, int pass) {
+            // Now draw it
             if (pass == 0) {
                 Path path = null;
                 if (mMediaItem != null) path = mMediaItem.getPath();
-                mSelectionDrawer.draw(canvas, mContent, mWidth, mHeight,
+                mSelectionDrawer.draw(canvas, mContent, width, height,
                         getRotation(), path, mMediaType);
                 return (mFocusIndex == mSlotIndex);
             } else if (pass == 1) {
-                mSelectionDrawer.drawFocus(canvas, mWidth, mHeight);
+                mSelectionDrawer.drawFocus(canvas, width, height);
             }
             return false;
         }
 
         @Override
         public void startLoadBitmap() {
-            if (mDisplayItemSize < MIN_THUMB_SIZE) {
+            if (mCacheThumbSize > 0) {
                 Path path = mMediaItem.getPath();
                 if (mImageCache.containsKey(path)) {
                     Bitmap bitmap = mImageCache.get(path);
@@ -368,7 +363,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener {
             Bitmap bitmap = job.run(jc);
             if (bitmap != null) {
                 bitmap = BitmapUtils.resizeDownBySideLength(
-                        bitmap, mDisplayItemSize, true);
+                        bitmap, mCacheThumbSize, true);
             }
             return bitmap;
         }
@@ -390,7 +385,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener {
             mFuture = null;
             Bitmap bitmap = future.get();
             boolean isCancelled = future.isCancelled();
-            if (mDisplayItemSize < MIN_THUMB_SIZE && (bitmap != null || !isCancelled)) {
+            if (mCacheThumbSize > 0 && (bitmap != null || !isCancelled)) {
                 Path path = mMediaItem.getPath();
                 mImageCache.put(path, bitmap);
             }
index 417611a..128259a 100644 (file)
@@ -33,8 +33,7 @@ public class AlbumView extends SlotView {
     private AlbumSlidingWindow mDataWindow;
     private final GalleryActivity mActivity;
     private SelectionDrawer mSelectionDrawer;
-    private int mSlotWidth, mSlotHeight;
-    private int mDisplayItemSize;
+    private int mCacheThumbSize;
 
     private boolean mIsActive = false;
 
@@ -50,13 +49,11 @@ public class AlbumView extends SlotView {
         public void onSizeChanged(int size);
     }
 
-    public AlbumView(GalleryActivity activity,
-            int slotWidth, int slotHeight, int displayItemSize) {
+    public AlbumView(GalleryActivity activity, SlotView.Spec spec,
+            int cacheThumbSize) {
         super(activity.getAndroidContext());
-        mSlotWidth = slotWidth;
-        mSlotHeight = slotHeight;
-        mDisplayItemSize = displayItemSize;
-        setSlotSize(slotWidth, slotHeight);
+        mCacheThumbSize = cacheThumbSize;
+        setSlotSpec(spec);
         mActivity = activity;
     }
 
@@ -74,7 +71,7 @@ public class AlbumView extends SlotView {
         if (model != null) {
             mDataWindow = new AlbumSlidingWindow(
                     mActivity, model, CACHE_SIZE,
-                    mSlotWidth, mSlotHeight, mDisplayItemSize);
+                    mCacheThumbSize);
             mDataWindow.setSelectionDrawer(mSelectionDrawer);
             mDataWindow.setListener(new MyDataModelListener());
             setSlotCount(model.size());
index 3038232..50264c4 100644 (file)
@@ -18,12 +18,15 @@ package com.android.gallery3d.ui;
 
 public abstract class DisplayItem {
 
-    protected int mWidth;
-    protected int mHeight;
-
-    protected void setSize(int width, int height) {
-        mWidth = width;
-        mHeight = height;
+    protected int mBoxWidth;
+    protected int mBoxHeight;
+
+    // setBox() specifies the box that the DisplayItem should render into. It
+    // should be called before first render(). It may be called again between
+    // render() calls to change the size of the box.
+    public void setBox(int width, int height) {
+        mBoxWidth = width;
+        mBoxHeight = height;
     }
 
     // returns true if more pass is needed
@@ -31,14 +34,6 @@ public abstract class DisplayItem {
 
     public abstract long getIdentity();
 
-    public int getWidth() {
-        return mWidth;
-    }
-
-    public int getHeight() {
-        return mHeight;
-    }
-
     public int getRotation() {
         return 0;
     }
index a6be2d1..6a80564 100644 (file)
@@ -73,7 +73,10 @@ public class FilmStripView extends GLView implements SlotView.Listener,
         mGripSize = gripSize;
 
         mStripDrawer = new StripDrawer((Context) activity);
-        mAlbumView = new AlbumView(activity, thumbSize, thumbSize, thumbSize);
+        SlotView.Spec spec = new SlotView.Spec();
+        spec.slotWidth = thumbSize;
+        spec.slotHeight = thumbSize;
+        mAlbumView = new AlbumView(activity, spec, thumbSize);
         mAlbumView.setOverscrollEffect(SlotView.OVERSCROLL_SYSTEM);
         mAlbumView.setSelectionDrawer(mStripDrawer);
         mAlbumView.setListener(this);
index cb98d4e..c0542e1 100644 (file)
@@ -34,6 +34,7 @@ import com.android.gallery3d.ui.DetailsHelper.CloseListener;
 import android.content.Context;
 import android.graphics.Color;
 import android.graphics.Rect;
+import android.text.Layout;
 import android.text.format.Formatter;
 import android.view.MotionEvent;
 import android.view.View.MeasureSpec;
@@ -259,7 +260,8 @@ public class GLDetailsView extends GLView implements DetailsViewContainer {
                             context, key), value);
                 }
                 Texture label = MultiLineTexture.newInstance(
-                        value, mMaxDetailLength, FONT_SIZE, FONT_COLOR);
+                        value, mMaxDetailLength, FONT_SIZE, FONT_COLOR,
+                        Layout.Alignment.ALIGN_NORMAL);
                 mItems.add(label);
             }
         }
@@ -274,7 +276,8 @@ public class GLDetailsView extends GLView implements DetailsViewContainer {
 
         public void onAddressAvailable(String address) {
             mItems.set(mLocationIndex, MultiLineTexture.newInstance(
-                    address, mMaxDetailLength, FONT_SIZE, FONT_COLOR));
+                    address, mMaxDetailLength, FONT_SIZE, FONT_COLOR,
+                    Layout.Alignment.ALIGN_NORMAL));
             GLDetailsView.this.invalidate();
         }
     }
index 54b175c..cc86184 100644 (file)
@@ -21,28 +21,23 @@ import com.android.gallery3d.data.Path;
 
 import android.content.Context;
 import android.graphics.Color;
+import android.text.Layout;
 
 public class GridDrawer extends IconDrawer {
-    private final NinePatchTexture mFrame;
     private final NinePatchTexture mFrameSelected;
-    private final NinePatchTexture mFrameSelectedTop;
-    private final NinePatchTexture mImportBackground;
     private Texture mImportLabel;
     private int mGridWidth;
     private final SelectionManager mSelectionManager;
     private final Context mContext;
-    private final int FONT_SIZE = 14;
-    private final int FONT_COLOR = Color.WHITE;
-    private final int IMPORT_LABEL_PADDING = 10;
+    private final int IMPORT_FONT_SIZE = 14;
+    private final int IMPORT_FONT_COLOR = Color.WHITE;
+    private final int IMPORT_LABEL_MARGIN = 10;
     private boolean mSelectionMode;
 
     public GridDrawer(Context context, SelectionManager selectionManager) {
         super(context);
         mContext = context;
-        mFrame = new NinePatchTexture(context, R.drawable.album_frame);
         mFrameSelected = new NinePatchTexture(context, R.drawable.grid_selected);
-        mFrameSelectedTop = new NinePatchTexture(context, R.drawable.grid_selected_top);
-        mImportBackground = new NinePatchTexture(context, R.drawable.import_translucent);
         mSelectionManager = selectionManager;
     }
 
@@ -54,7 +49,8 @@ public class GridDrawer extends IconDrawer {
     @Override
     public void draw(GLCanvas canvas, Texture content, int width, int height,
             int rotation, Path path, int topIndex, int dataSourceType,
-            int mediaType, boolean wantCache, boolean isCaching) {
+            int mediaType, int darkStripHeight, boolean wantCache,
+            boolean isCaching) {
 
         int x = -width / 2;
         int y = -height / 2;
@@ -72,37 +68,34 @@ public class GridDrawer extends IconDrawer {
 
         drawVideoOverlay(canvas, mediaType, x, y, width, height, topIndex);
 
-        NinePatchTexture frame;
         if (mSelectionMode && mSelectionManager.isItemSelected(path)) {
-            frame = topIndex == 0 ? mFrameSelectedTop : mFrameSelected;
-        } else {
-            frame = mFrame;
+            drawFrame(canvas, mFrameSelected, x, y, width, height);
         }
 
-        drawFrame(canvas, frame, x, y, width, height);
-
         if (topIndex == 0) {
-            ResourceTexture icon = getIcon(dataSourceType);
-            if (icon != null) {
-                IconDimension id = getIconDimension(icon, width, height);
-                if (dataSourceType == DATASOURCE_TYPE_MTP) {
-                    if (mImportLabel == null || mGridWidth != width) {
-                        mGridWidth = width;
-                        mImportLabel = MultiLineTexture.newInstance(
-                                mContext.getString(R.string.click_import),
-                                width - id.width - IMPORT_LABEL_PADDING, FONT_SIZE, FONT_COLOR);
-                    }
-                    int bgHeight = Math.max(id.height, mImportLabel.getHeight());
-                    mImportBackground.setSize(width, bgHeight);
-                    mImportBackground.draw(canvas, x, -y - bgHeight);
-                    mImportLabel.draw(canvas, x + id.width + IMPORT_LABEL_PADDING,
-                            -y - bgHeight + Math.abs(bgHeight - mImportLabel.getHeight()) / 2);
-                }
-                icon.draw(canvas, id.x, id.y, id.width, id.height);
+            drawDarkStrip(canvas, width, height, darkStripHeight);
+            drawIcon(canvas, width, height, dataSourceType);
+            if (dataSourceType == DATASOURCE_TYPE_MTP) {
+                drawImportLabel(canvas, width, height);
             }
         }
     }
 
+    // Draws the "click to import" label at the center of the frame
+    private void drawImportLabel(GLCanvas canvas, int width, int height) {
+        if (mImportLabel == null || mGridWidth != width) {
+            mGridWidth = width;
+            mImportLabel = MultiLineTexture.newInstance(
+                    mContext.getString(R.string.click_import),
+                    width - 2 * IMPORT_LABEL_MARGIN,
+                    IMPORT_FONT_SIZE, IMPORT_FONT_COLOR,
+                    Layout.Alignment.ALIGN_CENTER);
+        }
+        int w = mImportLabel.getWidth();
+        int h = mImportLabel.getHeight();
+        mImportLabel.draw(canvas, -w / 2, -h / 2);
+    }
+
     @Override
     public void drawFocus(GLCanvas canvas, int width, int height) {
     }
index 9d5868b..52c31f7 100644 (file)
@@ -21,17 +21,13 @@ import com.android.gallery3d.data.Path;
 import android.content.Context;
 
 public class HighlightDrawer extends IconDrawer {
-    private final NinePatchTexture mFrame;
     private final NinePatchTexture mFrameSelected;
-    private final NinePatchTexture mFrameSelectedTop;
     private SelectionManager mSelectionManager;
     private Path mHighlightItem;
 
     public HighlightDrawer(Context context) {
         super(context);
-        mFrame = new NinePatchTexture(context, R.drawable.album_frame);
         mFrameSelected = new NinePatchTexture(context, R.drawable.grid_selected);
-        mFrameSelectedTop = new NinePatchTexture(context, R.drawable.grid_selected_top);
     }
 
     public void setHighlightItem(Path item) {
@@ -40,7 +36,8 @@ public class HighlightDrawer extends IconDrawer {
 
     public void draw(GLCanvas canvas, Texture content, int width, int height,
             int rotation, Path path, int topIndex, int dataSourceType,
-            int mediaType, boolean wantCache, boolean isCaching) {
+            int mediaType, int darkStripHeight, boolean wantCache,
+            boolean isCaching) {
         int x = -width / 2;
         int y = -height / 2;
 
@@ -57,16 +54,12 @@ public class HighlightDrawer extends IconDrawer {
 
         drawVideoOverlay(canvas, mediaType, x, y, width, height, topIndex);
 
-        NinePatchTexture frame;
         if (path == mHighlightItem) {
-            frame = topIndex == 0 ? mFrameSelectedTop : mFrameSelected;
-        } else {
-            frame = mFrame;
+            drawFrame(canvas, mFrameSelected, x, y, width, height);
         }
 
-        drawFrame(canvas, frame, x, y, width, height);
-
         if (topIndex == 0) {
+            drawDarkStrip(canvas, width, height, darkStripHeight);
             drawIcon(canvas, width, height, dataSourceType);
         }
     }
index 91732d3..86fdf68 100644 (file)
@@ -21,13 +21,16 @@ import com.android.gallery3d.data.MediaObject;
 import android.content.Context;
 
 public abstract class IconDrawer extends SelectionDrawer {
-    private final String TAG = "IconDrawer";
+    private static final String TAG = "IconDrawer";
+    private static final int DARK_STRIP_COLOR = 0x99000000;  // 60% black
+
     private final ResourceTexture mLocalSetIcon;
     private final ResourceTexture mCameraIcon;
     private final ResourceTexture mPicasaIcon;
     private final ResourceTexture mMtpIcon;
     private final Texture mVideoOverlay;
     private final Texture mVideoPlayIcon;
+    private final int mIconSize;
 
     public static class IconDimension {
         int x;
@@ -37,14 +40,14 @@ public abstract class IconDrawer extends SelectionDrawer {
     }
 
     public IconDrawer(Context context) {
-        mLocalSetIcon = new ResourceTexture(context, R.drawable.ic_album_overlay_folder_holo);
-        mCameraIcon = new ResourceTexture(context, R.drawable.ic_album_overlay_camera_holo);
-        mPicasaIcon = new ResourceTexture(context, R.drawable.ic_album_overlay_picassa_holo);
+        mLocalSetIcon = new ResourceTexture(context, R.drawable.frame_overlay_gallery_folder);
+        mCameraIcon = new ResourceTexture(context, R.drawable.frame_overlay_gallery_camera);
+        mPicasaIcon = new ResourceTexture(context, R.drawable.frame_overlay_gallery_picasa);
         mMtpIcon = new ResourceTexture(context, R.drawable.ic_album_overlay_ptp_holo);
-        mVideoOverlay = new ResourceTexture(context,
-                R.drawable.thumbnail_album_video_overlay_holo);
-        mVideoPlayIcon = new ResourceTexture(context,
-                R.drawable.videooverlay);
+        mVideoOverlay = new ResourceTexture(context, R.drawable.ic_video_thumb);
+        mVideoPlayIcon = new ResourceTexture(context, R.drawable.ic_gallery_play);
+        mIconSize = context.getResources().getDimensionPixelSize(
+                R.dimen.albumset_icon_size);
     }
 
     @Override
@@ -88,9 +91,9 @@ public abstract class IconDrawer extends SelectionDrawer {
     protected IconDimension getIconDimension(ResourceTexture icon, int width,
             int height) {
         IconDimension id = new IconDimension();
-        float scale = 0.25f * width / icon.getWidth();
-        id.width = (int) (scale * icon.getWidth());
-        id.height = (int) (scale * icon.getHeight());
+        float scale = (float) mIconSize / icon.getWidth();
+        id.width = Math.round(scale * icon.getWidth());
+        id.height = Math.round(scale * icon.getHeight());
         id.x = -width / 2;
         id.y = height / 2 - id.height;
         return id;
@@ -99,13 +102,27 @@ public abstract class IconDrawer extends SelectionDrawer {
     protected void drawVideoOverlay(GLCanvas canvas, int mediaType,
             int x, int y, int width, int height, int topIndex) {
         if (mediaType != MediaObject.MEDIA_TYPE_VIDEO) return;
-        mVideoOverlay.draw(canvas, x, y, width, height);
+
+        // Scale the video overlay to the height of the thumbnail and put it
+        // on the left side.
+        float scale = (float) height / mVideoOverlay.getHeight();
+        int w = Math.round(scale * mVideoOverlay.getWidth());
+        int h = Math.round(scale * mVideoOverlay.getHeight());
+        mVideoOverlay.draw(canvas, x, y, w, h);
+
         if (topIndex == 0) {
             int side = Math.min(width, height) / 6;
             mVideoPlayIcon.draw(canvas, -side / 2, -side / 2, side, side);
         }
     }
 
+    protected void drawDarkStrip(GLCanvas canvas, int width, int height,
+            int darkStripHeight) {
+        int x = -width / 2;
+        int y = (height + 1) / 2 - darkStripHeight;
+        canvas.fillRect(x, y, width, darkStripHeight, DARK_STRIP_COLOR);
+    }
+
     @Override
     public void drawFocus(GLCanvas canvas, int width, int height) {
     }
index cf1e39e..e25e779 100644 (file)
@@ -25,7 +25,6 @@ import android.content.Context;
 public class ManageCacheDrawer extends IconDrawer {
     private static final int COLOR_CACHING_BACKGROUND = 0x7F000000;
     private static final int ICON_SIZE = 36;
-    private final NinePatchTexture mFrame;
     private final ResourceTexture mCheckedItem;
     private final ResourceTexture mUnCheckedItem;
     private final SelectionManager mSelectionManager;
@@ -35,7 +34,6 @@ public class ManageCacheDrawer extends IconDrawer {
 
     public ManageCacheDrawer(Context context, SelectionManager selectionManager) {
         super(context);
-        mFrame = new NinePatchTexture(context, R.drawable.manage_frame);
         mCheckedItem = new ResourceTexture(context, R.drawable.btn_make_offline_normal_on_holo_dark);
         mUnCheckedItem = new ResourceTexture(context, R.drawable.btn_make_offline_normal_off_holo_dark);
         mLocalAlbumIcon = new ResourceTexture(context, R.drawable.btn_make_offline_disabled_on_holo_dark);
@@ -55,7 +53,8 @@ public class ManageCacheDrawer extends IconDrawer {
     @Override
     public void draw(GLCanvas canvas, Texture content, int width, int height,
             int rotation, Path path, int topIndex, int dataSourceType,
-            int mediaType, boolean wantCache, boolean isCaching) {
+            int mediaType, int darkStripHeight, boolean wantCache,
+            boolean isCaching) {
 
         boolean selected = mSelectionManager.isItemSelected(path);
         boolean chooseToCache = wantCache ^ selected;
@@ -76,9 +75,8 @@ public class ManageCacheDrawer extends IconDrawer {
 
         drawVideoOverlay(canvas, mediaType, x, y, width, height, topIndex);
 
-        drawFrame(canvas, mFrame, x, y, width, height);
-
         if (topIndex == 0) {
+            drawDarkStrip(canvas, width, height, darkStripHeight);
             drawIcon(canvas, width, height, dataSourceType);
         }
 
@@ -94,8 +92,8 @@ public class ManageCacheDrawer extends IconDrawer {
 
             int w = ICON_SIZE;
             int h = ICON_SIZE;
-            x = width / 2 - w / 2;
-            y = -height / 2 - h / 2;
+            x = width / 2 - w;
+            y = -height / 2;
 
             icon.draw(canvas, x, y, w, h);
 
index be62d59..b0c3c2b 100644 (file)
@@ -35,10 +35,11 @@ class MultiLineTexture extends CanvasTexture {
     }
 
     public static MultiLineTexture newInstance(
-            String text, int maxWidth, float textSize, int color) {
+            String text, int maxWidth, float textSize, int color,
+            Layout.Alignment alignment) {
         TextPaint paint = StringTexture.getDefaultPaint(textSize, color);
         Layout layout = new StaticLayout(text, 0, text.length(), paint,
-                maxWidth, Layout.Alignment.ALIGN_NORMAL, 1, 0, true, null, 0);
+                maxWidth, alignment, 1, 0, true, null, 0);
 
         return new MultiLineTexture(layout);
     }
index 2655a22..05f346c 100644 (file)
@@ -35,14 +35,14 @@ public abstract class SelectionDrawer {
     public abstract void draw(GLCanvas canvas, Texture content,
             int width, int height, int rotation, Path path,
             int topIndex, int dataSourceType, int mediaType,
-            boolean wantCache, boolean isCaching);
+            int darkStripHeight, boolean wantCache, boolean isCaching);
     public abstract void drawFocus(GLCanvas canvas, int width, int height);
 
     public void draw(GLCanvas canvas, Texture content, int width, int height,
             int rotation, Path path, int mediaType) {
         draw(canvas, content, width, height, rotation, path, 0,
                 DATASOURCE_TYPE_NOT_CATEGORIZED, mediaType,
-                false, false);
+                0, false, false);
     }
 
     public static void drawWithRotation(GLCanvas canvas, Texture content,
index a8ca5f2..11dbfaa 100644 (file)
@@ -126,8 +126,8 @@ public class SlotView extends GLView {
         updateScrollPosition(position, false);
     }
 
-    public void setSlotSize(int slotWidth, int slotHeight) {
-        mLayout.setSlotSize(slotWidth, slotHeight);
+    public void setSlotSpec(Spec spec) {
+        mLayout.setSlotSpec(spec);
     }
 
     @Override
@@ -191,6 +191,7 @@ public class SlotView extends GLView {
     }
 
     public void putDisplayItem(Position target, Position base, DisplayItem item) {
+        item.setBox(mLayout.getSlotWidth(), mLayout.getSlotHeight());
         ItemEntry entry = new ItemEntry(item, target, base);
         mItemList.insertLast(entry);
         mItems.put(item, entry);
@@ -350,6 +351,41 @@ public class SlotView extends GLView {
         }
     }
 
+    // This Spec class is used to specify the size of each slot in the SlotView.
+    // There are two ways to do it:
+    //
+    // (1) Specify slotWidth and slotHeight: they specify the width and height
+    //     of each slot. The number of rows and the gap between slots will be
+    //     determined automatically.
+    // (2) Specify rowsLand, rowsPort, and slotGap: they specify the number
+    //     of rows in landscape/portrait mode and the gap between slots. The
+    //     width and height of each slot is determined automatically.
+    //
+    // The initial value of -1 means they are not specified.
+    public static class Spec {
+        public int slotWidth = -1;
+        public int slotHeight = -1;
+
+        public int rowsLand = -1;
+        public int rowsPort = -1;
+        public int slotGap = -1;
+
+        static Spec newWithSize(int width, int height) {
+            Spec s = new Spec();
+            s.slotWidth = width;
+            s.slotHeight = height;
+            return s;
+        }
+
+        static Spec newWithRows(int rowsLand, int rowsPort, int slotGap) {
+            Spec s = new Spec();
+            s.rowsLand = rowsLand;
+            s.rowsPort = rowsPort;
+            s.slotGap = slotGap;
+            return s;
+        }
+    }
+
     public static class Layout {
 
         private int mVisibleStart;
@@ -358,6 +394,9 @@ public class SlotView extends GLView {
         private int mSlotCount;
         private int mSlotWidth;
         private int mSlotHeight;
+        private int mSlotGap;
+
+        private Spec mSpec;
 
         private int mWidth;
         private int mHeight;
@@ -369,9 +408,8 @@ public class SlotView extends GLView {
         private int mVerticalPadding;
         private int mHorizontalPadding;
 
-        public void setSlotSize(int slotWidth, int slotHeight) {
-            mSlotWidth = slotWidth;
-            mSlotHeight = slotHeight;
+        public void setSlotSpec(Spec spec) {
+            mSpec = spec;
         }
 
         public boolean setSlotCount(int slotCount) {
@@ -392,11 +430,19 @@ public class SlotView extends GLView {
                 col = index - row * mUnitCount;
             }
 
-            int x = mHorizontalPadding + col * mSlotWidth;
-            int y = mVerticalPadding + row * mSlotHeight;
+            int x = mHorizontalPadding + col * (mSlotWidth + mSlotGap);
+            int y = mVerticalPadding + row * (mSlotHeight + mSlotGap);
             return new Rect(x, y, x + mSlotWidth, y + mSlotHeight);
         }
 
+        public int getSlotWidth() {
+            return mSlotWidth;
+        }
+
+        public int getSlotHeight() {
+            return mSlotHeight;
+        }
+
         public int getContentLength() {
             return mContentLength;
         }
@@ -417,17 +463,19 @@ public class SlotView extends GLView {
                 int majorLength, int minorLength,  /* The view width and height */
                 int majorUnitSize, int minorUnitSize,  /* The slot width and height */
                 int[] padding) {
-            int unitCount = minorLength / minorUnitSize;
+            int unitCount = (minorLength + mSlotGap) / (minorUnitSize + mSlotGap);
             if (unitCount == 0) unitCount = 1;
             mUnitCount = unitCount;
 
             // We put extra padding above and below the column.
             int availableUnits = Math.min(mUnitCount, mSlotCount);
-            padding[0] = (minorLength - availableUnits * minorUnitSize) / 2;
+            int usedMinorLength = availableUnits * minorUnitSize +
+                    (availableUnits - 1) * mSlotGap;
+            padding[0] = (minorLength - usedMinorLength) / 2;
 
             // Then calculate how many columns we need for all slots.
             int count = ((mSlotCount + mUnitCount - 1) / mUnitCount);
-            mContentLength = count * majorUnitSize;
+            mContentLength = count * majorUnitSize + (count - 1) * mSlotGap;
 
             // If the content length is less then the screen width, put
             // extra padding in left and right.
@@ -435,6 +483,18 @@ public class SlotView extends GLView {
         }
 
         private void initLayoutParameters() {
+            // Initialize mSlotWidth and mSlotHeight from mSpec
+            if (mSpec.slotWidth != -1) {
+                mSlotGap = 0;
+                mSlotWidth = mSpec.slotWidth;
+                mSlotHeight = mSpec.slotHeight;
+            } else {
+                int rows = (mWidth > mHeight) ? mSpec.rowsLand : mSpec.rowsPort;
+                mSlotGap = mSpec.slotGap;
+                mSlotHeight = Math.max(1, (mHeight - (rows - 1) * mSlotGap) / rows);
+                mSlotWidth = mSlotHeight;
+            }
+
             int[] padding = new int[2];
             if (WIDE) {
                 initLayoutParameters(mWidth, mHeight, mSlotWidth, mSlotHeight, padding);
@@ -458,14 +518,18 @@ public class SlotView extends GLView {
             int position = mScrollPosition;
 
             if (WIDE) {
-                int start = Math.max(0, (position / mSlotWidth) * mUnitCount);
-                int end = Math.min(mSlotCount, mUnitCount
-                        * (position + mWidth + mSlotWidth - 1) / mSlotWidth);
+                int startCol = position / (mSlotWidth + mSlotGap);
+                int start = Math.max(0, mUnitCount * startCol);
+                int endCol = (position + mWidth + mSlotWidth + mSlotGap - 1) /
+                        (mSlotWidth + mSlotGap);
+                int end = Math.min(mSlotCount, mUnitCount * endCol);
                 setVisibleRange(start, end);
             } else {
-                int start = Math.max(0, mUnitCount * (position / mSlotHeight));
-                int end = Math.min(mSlotCount, mUnitCount
-                        * (position + mHeight + mSlotHeight - 1) / mSlotHeight);
+                int startRow = position / (mSlotHeight + mSlotGap);
+                int start = Math.max(0, mUnitCount * startRow);
+                int endRow = (position + mHeight + mSlotHeight + mSlotGap - 1) /
+                        (mSlotHeight + mSlotGap);
+                int end = Math.min(mSlotCount, mUnitCount * endRow);
                 setVisibleRange(start, end);
             }
         }
@@ -495,21 +559,31 @@ public class SlotView extends GLView {
         }
 
         public int getSlotIndexByPosition(float x, float y) {
-            float absoluteX = x + (WIDE ? mScrollPosition : 0);
+            int absoluteX = Math.round(x) + (WIDE ? mScrollPosition : 0);
+            int absoluteY = Math.round(y) + (WIDE ? 0 : mScrollPosition);
+
             absoluteX -= mHorizontalPadding;
-            int columnIdx = (int) (absoluteX + 0.5) / mSlotWidth;
-            if ((absoluteX - mSlotWidth * columnIdx) < 0
-                    || (!WIDE && columnIdx >= mUnitCount)) {
+            absoluteY -= mVerticalPadding;
+
+            int columnIdx = absoluteX / (mSlotWidth + mSlotGap);
+            int rowIdx = absoluteY / (mSlotHeight + mSlotGap);
+
+            if (columnIdx < 0 || (!WIDE && columnIdx >= mUnitCount)) {
                 return INDEX_NONE;
             }
 
-            float absoluteY = y + (WIDE ? 0 : mScrollPosition);
-            absoluteY -= mVerticalPadding;
-            int rowIdx = (int) (absoluteY + 0.5) / mSlotHeight;
-            if (((absoluteY - mSlotHeight * rowIdx) < 0)
-                    || (WIDE && rowIdx >= mUnitCount)) {
+            if (rowIdx < 0 || (WIDE && rowIdx >= mUnitCount)) {
                 return INDEX_NONE;
             }
+
+            if (absoluteX % (mSlotWidth + mSlotGap) >= mSlotWidth) {
+                return INDEX_NONE;
+            }
+
+            if (absoluteY % (mSlotHeight + mSlotGap) >= mSlotHeight) {
+                return INDEX_NONE;
+            }
+
             int index = WIDE
                     ? (columnIdx * mUnitCount + rowIdx)
                     : (rowIdx * mUnitCount + columnIdx);
index 71ab9b3..f576c01 100644 (file)
@@ -56,21 +56,14 @@ class StringTexture extends CanvasTexture {
     }
 
     public static StringTexture newInstance(
-            String text, String postfix, float textSize, int color,
+            String text, float textSize, int color,
             float lengthLimit, boolean isBold) {
         TextPaint paint = getDefaultPaint(textSize, color);
         if (isBold) {
             paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
         }
-        if (postfix != null) {
-            lengthLimit = Math.max(0,
-                    lengthLimit - paint.measureText(postfix));
-            text = TextUtils.ellipsize(text, paint, lengthLimit,
-                    TextUtils.TruncateAt.END).toString() + postfix;
-        } else {
-            text = TextUtils.ellipsize(
-                    text, paint, lengthLimit, TextUtils.TruncateAt.END).toString();
-        }
+        text = TextUtils.ellipsize(
+                text, paint, lengthLimit, TextUtils.TruncateAt.END).toString();
         return newInstance(text, paint);
     }
 
index 0910612..be98ae0 100644 (file)
@@ -38,7 +38,8 @@ public class StripDrawer extends SelectionDrawer {
     @Override
     public void draw(GLCanvas canvas, Texture content, int width, int height,
             int rotation, Path path, int topIndex, int dataSourceType,
-            int mediaType, boolean wantCache, boolean isCaching) {
+            int mediaType, int darkStripHeight, boolean wantCache,
+            boolean isCaching) {
 
         int x = -width / 2;
         int y = -height / 2;