OSDN Git Service

Ongoing reskin of Gallery app
authorBobby Georgescu <georgescu@google.com>
Thu, 23 Aug 2012 20:05:53 +0000 (13:05 -0700)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Sat, 25 Aug 2012 00:12:44 +0000 (17:12 -0700)
Bug: 7050303
Moved the majority of color settings from hardcoded to
colors.xml in order to allow rapid iteration with UX input.
Started changing some colors and layouts to reflect latest
UX mocks.

Change-Id: I300338e9f75c71f3ed3f36140d16e893387f3184

20 files changed:
res/values/colors.xml [new file with mode: 0644]
res/values/dimensions.xml
src/com/android/gallery3d/app/ActivityState.java
src/com/android/gallery3d/app/AlbumPage.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/app/PhotoPage.java
src/com/android/gallery3d/app/SlideshowPage.java
src/com/android/gallery3d/ui/AlbumLabelMaker.java
src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
src/com/android/gallery3d/ui/AlbumSlotRenderer.java
src/com/android/gallery3d/ui/BitmapScreenNail.java
src/com/android/gallery3d/ui/GLCanvas.java
src/com/android/gallery3d/ui/GLCanvasImpl.java
src/com/android/gallery3d/ui/ManageCacheDrawer.java
src/com/android/gallery3d/ui/PhotoView.java
src/com/android/gallery3d/ui/SlotView.java
src/com/android/gallery3d/util/GalleryUtils.java
tests/src/com/android/gallery3d/ui/GLCanvasStub.java

diff --git a/res/values/colors.xml b/res/values/colors.xml
new file mode 100644 (file)
index 0000000..96db243
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<resources>
+    <color name="default_background">#FF000000</color>
+
+    <!-- configuration for album set page -->
+    <color name="albumset_background">#FF000000</color>
+    <color name="albumset_placeholder">#FFDDDDDD</color>
+    <color name="albumset_label_background">#FFCCCCCC</color>
+    <color name="albumset_label_title">#FF000000</color>
+    <color name="albumset_label_count">#80000000</color>
+
+    <!-- configuration for album page -->
+    <color name="album_background">#FF000000</color>
+    <color name="album_placeholder">#FFDDDDDD</color>
+
+    <!-- configuration for photo page -->
+    <color name="photo_background">#FF000000</color>
+    <color name="photo_placeholder">#FF222222</color>
+
+    <!-- configuration for manage cache page -->
+    <color name="cache_background">#FF000000</color>
+    <color name="cache_placeholder">#FFDDDDDD</color>
+
+    <color name="bitmap_screennail_placeholder">#FF222222</color>
+
+    <color name="slideshow_background">#FF000000</color>
+</resources>
index 906dbdb..e586f93 100644 (file)
     <dimen name="stack_photo_height">120dp</dimen>
 
     <!-- configuration for album set page -->
-    <integer name="albumset_rows_land">1</integer>
-    <integer name="albumset_rows_port">2</integer>
-    <dimen name="albumset_padding_top">15dp</dimen>
-    <dimen name="albumset_padding_bottom">15dp</dimen>
-    <dimen name="albumset_slot_gap">12dp</dimen>
+    <integer name="albumset_rows_land">2</integer>
+    <integer name="albumset_rows_port">3</integer>
+    <dimen name="albumset_padding_top">7dp</dimen>
+    <dimen name="albumset_padding_bottom">7dp</dimen>
+    <dimen name="albumset_slot_gap">7dp</dimen>
 
-    <dimen name="albumset_label_background_height">45dp</dimen>
+    <dimen name="albumset_label_background_height">25dp</dimen>
     <dimen name="albumset_title_offset">10dp</dimen>
     <dimen name="albumset_count_offset">10dp</dimen>
-    <dimen name="albumset_title_font_size">20sp</dimen>
-    <dimen name="albumset_count_font_size">12sp</dimen>
+    <dimen name="albumset_title_font_size">12sp</dimen>
+    <dimen name="albumset_count_font_size">9sp</dimen>
     <dimen name="albumset_left_margin">6dp</dimen>
-    <dimen name="albumset_title_right_margin">30dp</dimen>
-    <dimen name="albumset_icon_size">20dp</dimen>
+    <dimen name="albumset_title_right_margin">20dp</dimen>
+    <dimen name="albumset_icon_size">15dp</dimen>
 
     <!-- configuration for album page -->
     <integer name="album_rows_land">2</integer>
index 13cd150..a86351b 100644 (file)
@@ -33,9 +33,11 @@ import android.view.MenuItem;
 import android.view.Window;
 import android.view.WindowManager;
 
+import com.android.gallery3d.R;
 import com.android.gallery3d.actionbar.ActionBarInterface;
 import com.android.gallery3d.actionbar.ActionBarUtils;
 import com.android.gallery3d.ui.GLView;
+import com.android.gallery3d.util.GalleryUtils;
 
 abstract public class ActivityState {
     protected static final int FLAG_HIDE_ACTION_BAR = 1;
@@ -105,7 +107,19 @@ abstract public class ActivityState {
     protected void onStateResult(int requestCode, int resultCode, Intent data) {
     }
 
+    protected float[] mBackgroundColor;
+
+    protected int getBackgroundColorId() {
+        return R.color.default_background;
+    }
+
+    protected float[] getBackgroundColor() {
+        return mBackgroundColor;
+    }
+
     protected void onCreate(Bundle data, Bundle storedState) {
+        mBackgroundColor = GalleryUtils.intColorToFloatARGBArray(
+                mActivity.getResources().getColor(getBackgroundColorId()));
     }
 
     protected void clearStateResult() {
index a391950..e44dae1 100644 (file)
@@ -136,12 +136,17 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
         }
     };
 
+    @Override
+    protected int getBackgroundColorId() {
+        return R.color.album_background;
+    }
+
     private final GLView mRootPane = new GLView() {
         private final float mMatrix[] = new float[16];
 
         @Override
         protected void renderBackground(GLCanvas view) {
-            view.clearBuffer();
+            view.clearBuffer(getBackgroundColor());
         }
 
         @Override
@@ -453,7 +458,8 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
         mSelectionManager.setSelectionListener(this);
         Config.AlbumPage config = Config.AlbumPage.get((Context) mActivity);
         mSlotView = new SlotView(mActivity, config.slotViewSpec);
-        mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView, mSelectionManager);
+        mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView,
+                mSelectionManager, config.placeholderColor);
         mSlotView.setSlotRenderer(mAlbumView);
         mRootPane.addComponent(mSlotView);
         mSlotView.setListener(new SlotView.SimpleListener() {
index 5d7d085..a5a2481 100644 (file)
@@ -109,12 +109,17 @@ public class AlbumSetPage extends ActivityState implements
     private int mLoadingBits = 0;
     private boolean mInitialSynced = false;
 
+    @Override
+    protected int getBackgroundColorId() {
+        return R.color.albumset_background;
+    }
+
     private final GLView mRootPane = new GLView() {
         private final float mMatrix[] = new float[16];
 
         @Override
         protected void renderBackground(GLCanvas view) {
-            view.clearBuffer();
+            view.clearBuffer(getBackgroundColor());
         }
 
         @Override
@@ -369,7 +374,8 @@ public class AlbumSetPage extends ActivityState implements
         mConfig = Config.AlbumSetPage.get((Context) mActivity);
         mSlotView = new SlotView(mActivity, mConfig.slotViewSpec);
         mAlbumSetView = new AlbumSetSlotRenderer(
-                mActivity, mSelectionManager, mSlotView, mConfig.labelSpec);
+                mActivity, mSelectionManager, mSlotView, mConfig.labelSpec,
+                mConfig.placeholderColor);
         mSlotView.setSlotRenderer(mAlbumSetView);
         mSlotView.setListener(new SlotView.SimpleListener() {
             @Override
index 6fb24ec..04b210e 100644 (file)
@@ -31,6 +31,7 @@ final class Config {
         public AlbumSetSlotRenderer.LabelSpec labelSpec;
         public int paddingTop;
         public int paddingBottom;
+        public int placeholderColor;
 
         public static synchronized AlbumSetPage get(Context context) {
             if (sInstance == null) {
@@ -42,10 +43,14 @@ final class Config {
         private AlbumSetPage(Context context) {
             Resources r = context.getResources();
 
+            placeholderColor = r.getColor(R.color.albumset_placeholder);
+
             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);
+            slotViewSpec.slotHeightAdditional = r.getDimensionPixelSize(
+                    R.dimen.albumset_label_background_height);
 
             paddingTop = r.getDimensionPixelSize(R.dimen.albumset_padding_top);
             paddingBottom = r.getDimensionPixelSize(R.dimen.albumset_padding_bottom);
@@ -67,6 +72,10 @@ final class Config {
                     R.dimen.albumset_title_right_margin);
             labelSpec.iconSize = r.getDimensionPixelSize(
                     R.dimen.albumset_icon_size);
+            labelSpec.backgroundColor = r.getColor(
+                    R.color.albumset_label_background);
+            labelSpec.titleColor = r.getColor(R.color.albumset_label_title);
+            labelSpec.countColor = r.getColor(R.color.albumset_label_count);
         }
     }
 
@@ -74,6 +83,7 @@ final class Config {
         private static AlbumPage sInstance;
 
         public SlotView.Spec slotViewSpec;
+        public int placeholderColor;
 
         public static synchronized AlbumPage get(Context context) {
             if (sInstance == null) {
@@ -85,6 +95,8 @@ final class Config {
         private AlbumPage(Context context) {
             Resources r = context.getResources();
 
+            placeholderColor = r.getColor(R.color.album_placeholder);
+
             slotViewSpec = new SlotView.Spec();
             slotViewSpec.rowsLand = r.getInteger(R.integer.album_rows_land);
             slotViewSpec.rowsPort = r.getInteger(R.integer.album_rows_port);
index b02d129..847adf6 100644 (file)
@@ -86,12 +86,17 @@ public class ManageCachePage extends ActivityState implements
     private Handler mHandler;
     private boolean mLayoutReady = false;
 
+    @Override
+    protected int getBackgroundColorId() {
+        return R.color.cache_background;
+    }
+
     private GLView mRootPane = new GLView() {
         private float mMatrix[] = new float[16];
 
         @Override
         protected void renderBackground(GLCanvas view) {
-            view.clearBuffer();
+            view.clearBuffer(getBackgroundColor());
         }
 
         @Override
index 2774440..8b38abb 100644 (file)
@@ -168,6 +168,11 @@ public class PhotoPage extends ActivityState implements
 
     private final FloatAnimation mBackgroundFade = new BackgroundFadeOut();
 
+    @Override
+    protected int getBackgroundColorId() {
+        return R.color.photo_background;
+    }
+
     private final GLView mRootPane = new GLView() {
         @Override
         protected void renderBackground(GLCanvas view) {
@@ -180,7 +185,7 @@ public class PhotoPage extends ActivityState implements
                 } else {
                     float fadeAlpha = mBackgroundFade.get();
                     if(fadeAlpha < 1f) {
-                        view.clearBuffer(0f, 0f, 0f, 1f);
+                        view.clearBuffer(getBackgroundColor());
                         view.setAlpha(fadeAlpha);
                     }
                     mFadeOutTexture.draw(view, 0, 0);
@@ -188,7 +193,7 @@ public class PhotoPage extends ActivityState implements
                     return;
                 }
             }
-            view.clearBuffer(0f, 0f, 0f, 1f);
+            view.clearBuffer(getBackgroundColor());
         }
 
         @Override
index c0e35be..09a239e 100644 (file)
@@ -24,6 +24,7 @@ import android.os.Handler;
 import android.os.Message;
 import android.view.MotionEvent;
 
+import com.android.gallery3d.R;
 import com.android.gallery3d.common.Utils;
 import com.android.gallery3d.data.ContentListener;
 import com.android.gallery3d.data.MediaItem;
@@ -83,6 +84,11 @@ public class SlideshowPage extends ActivityState {
     private boolean mIsActive = false;
     private final Intent mResultIntent = new Intent();
 
+    @Override
+    protected int getBackgroundColorId() {
+        return R.color.slideshow_background;
+    }
+
     private final GLView mRootPane = new GLView() {
         @Override
         protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
@@ -99,7 +105,7 @@ public class SlideshowPage extends ActivityState {
 
         @Override
         protected void renderBackground(GLCanvas canvas) {
-            canvas.clearBuffer(0f, 0f, 0f, 0f);
+            canvas.clearBuffer(getBackgroundColor());
         }
     };
 
index 4a1d545..cd6c778 100644 (file)
@@ -21,7 +21,6 @@ import android.graphics.Bitmap;
 import android.graphics.Bitmap.Config;
 import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
-import android.graphics.Color;
 import android.graphics.PorterDuff;
 import android.graphics.Typeface;
 import android.text.TextPaint;
@@ -34,11 +33,7 @@ import com.android.gallery3d.util.ThreadPool;
 import com.android.gallery3d.util.ThreadPool.JobContext;
 
 public class AlbumLabelMaker {
-    private static final int FONT_COLOR_TITLE = Color.BLACK;
-    private static final int FONT_COLOR_COUNT = 0x80000000;
-
     private static final int BORDER_SIZE = 0;
-    private static final int BACKGROUND_COLOR = 0xFFFFFFFF;
 
     private final AlbumSetSlotRenderer.LabelSpec mSpec;
     private final TextPaint mTitlePaint;
@@ -56,8 +51,8 @@ public class AlbumLabelMaker {
     public AlbumLabelMaker(Context context, AlbumSetSlotRenderer.LabelSpec spec) {
         mContext = context;
         mSpec = spec;
-        mTitlePaint = getTextPaint(spec.titleFontSize, FONT_COLOR_TITLE, false);
-        mCountPaint = getTextPaint(spec.countFontSize, FONT_COLOR_COUNT, false);
+        mTitlePaint = getTextPaint(spec.titleFontSize, spec.titleColor, false);
+        mCountPaint = getTextPaint(spec.countFontSize, spec.countColor, false);
 
         mLocalSetIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_folder);
         mPicasaIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_picasa);
@@ -174,7 +169,7 @@ public class AlbumLabelMaker {
             canvas.clipRect(BORDER_SIZE, BORDER_SIZE,
                     bitmap.getWidth() - BORDER_SIZE,
                     bitmap.getHeight() - BORDER_SIZE);
-            canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC);
+            canvas.drawColor(mSpec.backgroundColor, PorterDuff.Mode.SRC);
 
             canvas.translate(BORDER_SIZE, BORDER_SIZE);
 
index cee36d9..bdc0e67 100644 (file)
@@ -28,7 +28,7 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer {
     @SuppressWarnings("unused")
     private static final String TAG = "AlbumSetView";
     private static final int CACHE_SIZE = 96;
-    private static final int PLACEHOLDER_COLOR = 0xFFDDDDDD;
+    private final int mPlaceholderColor;
 
     private final ColorTexture mWaitLoadingTexture;
     private final GalleryActivity mActivity;
@@ -52,20 +52,23 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer {
         public int leftMargin;
         public int iconSize;
         public int titleRightMargin;
+        public int backgroundColor;
+        public int titleColor;
+        public int countColor;
+        public int borderSize;
     }
 
     public AlbumSetSlotRenderer(GalleryActivity activity, SelectionManager selectionManager,
-            SlotView slotView, LabelSpec labelSpec) {
+            SlotView slotView, LabelSpec labelSpec, int placeholderColor) {
         super ((Context) activity);
         mActivity = activity;
         mSelectionManager = selectionManager;
         mSlotView = slotView;
         mLabelSpec = labelSpec;
+        mPlaceholderColor = placeholderColor;
 
-        mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR);
+        mWaitLoadingTexture = new ColorTexture(mPlaceholderColor);
         mWaitLoadingTexture.setSize(1, 1);
-
-        Context context = activity.getAndroidContext();
     }
 
     public void setPressedIndex(int index) {
@@ -149,7 +152,7 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer {
             entry.isWaitLoadingDisplayed = true;
         } else if (entry.isWaitLoadingDisplayed) {
             entry.isWaitLoadingDisplayed = false;
-            content = new FadeInTexture(PLACEHOLDER_COLOR, entry.bitmapTexture);
+            content = new FadeInTexture(mPlaceholderColor, entry.bitmapTexture);
             entry.content = content;
         }
         drawContent(canvas, content, width, height, entry.rotation);
index dee9a0b..f6df3b3 100644 (file)
@@ -31,7 +31,7 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
         public boolean acceptSlot(int index);
     }
 
-    private static final int PLACEHOLDER_COLOR = 0xFFDDDDDD;
+    private final int mPlaceholderColor;
     private static final int CACHE_SIZE = 96;
 
     private AlbumSlidingWindow mDataWindow;
@@ -48,13 +48,14 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
     private SlotFilter mSlotFilter;
 
     public AlbumSlotRenderer(GalleryActivity activity, SlotView slotView,
-            SelectionManager selectionManager) {
+            SelectionManager selectionManager, int placeholderColor) {
         super((Context) activity);
         mActivity = activity;
         mSlotView = slotView;
         mSelectionManager = selectionManager;
+        mPlaceholderColor = placeholderColor;
 
-        mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR);
+        mWaitLoadingTexture = new ColorTexture(mPlaceholderColor);
         mWaitLoadingTexture.setSize(1, 1);
     }
 
@@ -110,7 +111,7 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
             entry.isWaitDisplayed = true;
         } else if (entry.isWaitDisplayed) {
             entry.isWaitDisplayed = false;
-            content = new FadeInTexture(PLACEHOLDER_COLOR, entry.bitmapTexture);
+            content = new FadeInTexture(mPlaceholderColor, entry.bitmapTexture);
             entry.content = content;
         }
         drawContent(canvas, content, width, height, entry.rotation);
index 57685e8..6fbcf01 100644 (file)
@@ -33,10 +33,9 @@ import com.android.gallery3d.data.MediaItem;
 public class BitmapScreenNail implements ScreenNail {
     @SuppressWarnings("unused")
     private static final String TAG = "BitmapScreenNail";
-    private static final int PLACEHOLDER_COLOR = 0xFF222222;
+
     // The duration of the fading animation in milliseconds
     private static final int DURATION = 180;
-    private static boolean mDrawPlaceholder = true;
 
     private static final int MAX_SIDE = 640;
 
@@ -63,6 +62,15 @@ public class BitmapScreenNail implements ScreenNail {
         setSize(width, height);
     }
 
+    // This gets overridden by bitmap_screennail_placeholder
+    // in GalleryUtils.initialize
+    private static int mPlaceholderColor = 0xFF222222;
+    private static boolean mDrawPlaceholder = true;
+
+    public static void setPlaceholderColor(int color) {
+        mPlaceholderColor = color;
+    }
+
     private void setSize(int width, int height) {
         if (width == 0 || height == 0) {
             width = 640;
@@ -155,7 +163,7 @@ public class BitmapScreenNail implements ScreenNail {
                 mAnimationStartTime = ANIMATION_NEEDED;
             }
             if(mDrawPlaceholder) {
-                canvas.fillRect(x, y, width, height, PLACEHOLDER_COLOR);
+                canvas.fillRect(x, y, width, height, mPlaceholderColor);
             }
             return;
         }
@@ -169,7 +177,7 @@ public class BitmapScreenNail implements ScreenNail {
         }
 
         if (isAnimating()) {
-            canvas.drawMixed(mTexture, PLACEHOLDER_COLOR, getRatio(), x, y,
+            canvas.drawMixed(mTexture, mPlaceholderColor, getRatio(), x, y,
                     width, height);
         } else {
             mTexture.draw(canvas, x, y, width, height);
@@ -180,7 +188,7 @@ public class BitmapScreenNail implements ScreenNail {
     public void draw(GLCanvas canvas, RectF source, RectF dest) {
         if (mBitmap == null) {
             canvas.fillRect(dest.left, dest.top, dest.width(), dest.height(),
-                    PLACEHOLDER_COLOR);
+                    mPlaceholderColor);
             return;
         }
 
index 6d9aa42..e3a32ef 100644 (file)
@@ -36,6 +36,7 @@ public interface GLCanvas {
 
     // Clear the drawing buffers. This should only be used by GLRoot.
     public void clearBuffer();
+    public void clearBuffer(float[] argb);
 
     // Sets and gets the current alpha, alpha must be in [0, 1].
     public void setAlpha(float alpha);
@@ -121,6 +122,4 @@ public interface GLCanvas {
     public void beginRenderTarget(RawTexture texture);
 
     public void endRenderTarget();
-
-    public void clearBuffer(float r, float g, float b, float a);
 }
index a254bcc..d83daf3 100644 (file)
@@ -649,15 +649,18 @@ public class GLCanvasImpl implements GLCanvas {
     }
 
     @Override
-    public void clearBuffer(float r, float g, float b, float a) {
-        mGL.glClearColor(r, g, b, a);
+    public void clearBuffer(float[] argb) {
+        if(argb != null && argb.length == 4) {
+            mGL.glClearColor(argb[1], argb[2], argb[3], argb[0]);
+        } else {
+            mGL.glClearColor(0, 0, 0, 1);
+        }
         mGL.glClear(GL10.GL_COLOR_BUFFER_BIT);
     }
 
     @Override
     public void clearBuffer() {
-        // TODO: Make this grey background color constant
-        clearBuffer(0.93f, 0.93f, 0.93f, 1);
+        clearBuffer(null);
     }
 
     private void setTextureCoords(RectF source) {
index ba31fc6..91dc7ac 100644 (file)
@@ -38,7 +38,8 @@ public class ManageCacheDrawer extends AlbumSetSlotRenderer {
 
     public ManageCacheDrawer(GalleryActivity activity, SelectionManager selectionManager,
             SlotView slotView, LabelSpec labelSpec, int cachePinSize, int cachePinMargin) {
-        super(activity, selectionManager, slotView, labelSpec);
+        super(activity, selectionManager, slotView, labelSpec,
+                activity.getResources().getColor(R.color.cache_placeholder));
         Context context = (Context) activity;
         mCheckedItem = new ResourceTexture(
                 context, R.drawable.btn_make_offline_normal_on_holo_dark);
index 0dee1b0..16d93ca 100644 (file)
@@ -39,7 +39,7 @@ import com.android.gallery3d.util.RangeArray;
 public class PhotoView extends GLView {
     @SuppressWarnings("unused")
     private static final String TAG = "PhotoView";
-    private static final int PLACEHOLDER_COLOR = 0xFF222222;
+    private final int mPlaceholderColor;
 
     public static final int INVALID_SIZE = -1;
     public static final long INVALID_DATA_VERSION =
@@ -236,6 +236,8 @@ public class PhotoView extends GLView {
         mTileView = new TileImageView(activity);
         addComponent(mTileView);
         Context context = activity.getAndroidContext();
+        mPlaceholderColor = context.getResources().getColor(
+                R.color.photo_placeholder);
         mEdgeView = new EdgeView(context);
         addComponent(mEdgeView);
         mUndoBar = new UndoBarView(context);
@@ -886,7 +888,7 @@ public class PhotoView extends GLView {
 
     // Draw a gray placeholder in the specified rectangle.
     private void drawPlaceHolder(GLCanvas canvas, Rect r) {
-        canvas.fillRect(r.left, r.top, r.width(), r.height(), PLACEHOLDER_COLOR);
+        canvas.fillRect(r.left, r.top, r.width(), r.height(), mPlaceholderColor);
     }
 
     // Draw the video play icon (in the place where the spinner was)
index 88a2e0d..1325aec 100644 (file)
@@ -386,6 +386,7 @@ public class SlotView extends GLView {
     public static class Spec {
         public int slotWidth = -1;
         public int slotHeight = -1;
+        public int slotHeightAdditional = 0;
 
         public int rowsLand = -1;
         public int rowsPort = -1;
@@ -501,7 +502,7 @@ public class SlotView extends GLView {
                 int rows = (mWidth > mHeight) ? mSpec.rowsLand : mSpec.rowsPort;
                 mSlotGap = mSpec.slotGap;
                 mSlotHeight = Math.max(1, (mHeight - (rows - 1) * mSlotGap) / rows);
-                mSlotWidth = mSlotHeight;
+                mSlotWidth = mSlotHeight - mSpec.slotHeightAdditional;
             }
 
             if (mRenderer != null) {
index 3b73d34..e750e27 100644 (file)
@@ -24,6 +24,8 @@ 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.graphics.Color;
 import android.net.Uri;
 import android.os.ConditionVariable;
 import android.os.Environment;
@@ -39,6 +41,7 @@ import com.android.gallery3d.app.PackagesMonitor;
 import com.android.gallery3d.common.ApiHelper;
 import com.android.gallery3d.data.DataManager;
 import com.android.gallery3d.data.MediaItem;
+import com.android.gallery3d.ui.BitmapScreenNail;
 import com.android.gallery3d.util.ThreadPool.CancelListener;
 import com.android.gallery3d.util.ThreadPool.JobContext;
 
@@ -76,6 +79,18 @@ public class GalleryUtils {
             wm.getDefaultDisplay().getMetrics(metrics);
             sPixelDensity = metrics.density;
         }
+        Resources r = context.getResources();
+        BitmapScreenNail.setPlaceholderColor(r.getColor(
+                R.color.bitmap_screennail_placeholder));
+    }
+
+    public static float[] intColorToFloatARGBArray(int from) {
+        return new float[] {
+            (float) Color.alpha(from) / 255f,
+            (float) Color.red(from) / 255f,
+            (float) Color.green(from) / 255f,
+            (float) Color.blue(from) / 255f
+        };
     }
 
     public static float dpToPixel(float dp) {
index f30b579..2f2d753 100644 (file)
@@ -23,7 +23,7 @@ import javax.microedition.khronos.opengles.GL11;
 public class GLCanvasStub implements GLCanvas {
     public void setSize(int width, int height) {}
     public void clearBuffer() {}
-    public void clearBuffer(float r, float g, float b, float a) {}
+    public void clearBuffer(float[] argb) {}
     public void setCurrentAnimationTimeMillis(long time) {}
     public long currentAnimationTimeMillis() {
         throw new UnsupportedOperationException();