OSDN Git Service

Fix UI stuff
authornicolasroard <nicolasroard@google.com>
Wed, 17 Oct 2012 19:47:53 +0000 (12:47 -0700)
committernicolasroard <nicolasroard@google.com>
Wed, 17 Oct 2012 20:07:58 +0000 (13:07 -0700)
bug:7354368
bug:7362027
bug:7344915
Change-Id: I2efd5de0971e5dfbc989d60860348280c03b3db4

res/layout/filtershow_activity.xml
res/values-sw600dp/dimensions.xml [new file with mode: 0644]
res/values-sw800dp/dimensions.xml [new file with mode: 0644]
res/values/dimensions.xml
res/values/filtershow_color.xml
src/com/android/gallery3d/filtershow/FilterShowActivity.java
src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
src/com/android/gallery3d/filtershow/imageshow/ImageSmallBorder.java
src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java

index 8a51d89..1bdabe0 100644 (file)
@@ -18,7 +18,7 @@
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@color/background_main_toolbar" >
+    android:background="@color/background_screen" >
 
     <LinearLayout
         android:id="@+id/imageStatePanel"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:layout_gravity="center"
+              android:background="@color/background_main_toolbar"
               custom:max_width="600dip"
               android:orientation="vertical">
 
             <LinearLayout
                 android:id="@+id/filterButtonsList"
                 android:layout_width="fill_parent"
-                android:layout_height="96dip"
+                android:layout_height="@dimen/thumbnail_size"
                 android:background="@color/background_main_toolbar"
                 android:orientation="horizontal"
                 android:visibility="gone" >
             <HorizontalScrollView
                 android:id="@+id/fxList"
                 android:layout_width="match_parent"
-                android:layout_height="96dip"
+                android:layout_height="@dimen/thumbnail_size"
                 android:scrollbars="none" >
 
                 <LinearLayout
                     android:id="@+id/listFilters"
                     android:layout_width="wrap_content"
                     android:layout_height="match_parent"
+                    android:layout_marginLeft="@dimen/thumbnail_margin"
                     android:orientation="horizontal" >
                 </LinearLayout>
             </HorizontalScrollView>
             <HorizontalScrollView
                 android:id="@+id/bordersList"
                 android:layout_width="match_parent"
-                android:layout_height="96dip"
+                android:layout_height="@dimen/thumbnail_size"
                 android:visibility="gone"
                 android:scrollbars="none" >
 
                     android:id="@+id/listBorders"
                     android:layout_width="wrap_content"
                     android:layout_height="match_parent"
+                    android:layout_marginLeft="@dimen/thumbnail_margin"
                     android:orientation="horizontal" >
                 </LinearLayout>
             </HorizontalScrollView>
             <HorizontalScrollView
                 android:id="@+id/geometryList"
                 android:layout_width="fill_parent"
-                android:layout_height="96dip"
+                android:layout_height="@dimen/thumbnail_size"
                 android:background="@color/background_main_toolbar"
                 android:visibility="gone"
                 android:scrollbars="none" >
             <HorizontalScrollView
                 android:id="@+id/colorsFxList"
                 android:layout_width="fill_parent"
-                android:layout_height="96dip"
+                android:layout_height="@dimen/thumbnail_size"
                 android:background="@color/background_main_toolbar"
                 android:visibility="gone"
                 android:scrollbars="none" >
                     android:id="@+id/listColorsFx"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/thumbnail_margin"
                     android:orientation="horizontal" >
 
                     <com.android.gallery3d.filtershow.ui.ImageButtonTitle
 
             <ImageButton
                 android:id="@+id/fxButton"
-                android:layout_width="wrap_content"
+                android:layout_width="@dimen/thumbnail_size"
                 android:layout_height="match_parent"
                 android:layout_weight="1"
                 android:background="@drawable/filtershow_button_background"
 
             <ImageButton
                 android:id="@+id/borderButton"
-                android:layout_width="wrap_content"
+                android:layout_width="@dimen/thumbnail_size"
                 android:layout_height="match_parent"
                 android:layout_weight="1"
                 android:background="@drawable/filtershow_button_background"
 
             <ImageButton
                 android:id="@+id/geometryButton"
-                android:layout_width="wrap_content"
+                android:layout_width="@dimen/thumbnail_size"
                 android:layout_height="match_parent"
                 android:layout_weight="1"
                 android:background="@drawable/filtershow_button_background"
 
             <ImageButton
                 android:id="@+id/colorsButton"
-                android:layout_width="wrap_content"
+                android:layout_width="@dimen/thumbnail_size"
                 android:layout_height="match_parent"
                 android:layout_weight="1"
                 android:background="@drawable/filtershow_button_background"
diff --git a/res/values-sw600dp/dimensions.xml b/res/values-sw600dp/dimensions.xml
new file mode 100644 (file)
index 0000000..ff04de7
--- /dev/null
@@ -0,0 +1,20 @@
+<?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>
+    <!--  configuration for filtershow UI -->
+    <dimen name="thumbnail_size">128dip</dimen>
+    <dimen name="thumbnail_margin">3dip</dimen>
+</resources>
diff --git a/res/values-sw800dp/dimensions.xml b/res/values-sw800dp/dimensions.xml
new file mode 100644 (file)
index 0000000..ff04de7
--- /dev/null
@@ -0,0 +1,20 @@
+<?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>
+    <!--  configuration for filtershow UI -->
+    <dimen name="thumbnail_size">128dip</dimen>
+    <dimen name="thumbnail_margin">3dip</dimen>
+</resources>
index 5d8d172..dc9e8c3 100644 (file)
@@ -46,4 +46,8 @@
 
     <!-- for manage cache bar -->
     <dimen name="manage_cache_bottom_height">48dp</dimen>
+
+    <!--  configuration for filtershow UI -->
+    <dimen name="thumbnail_size">96dip</dimen>
+    <dimen name="thumbnail_margin">3dip</dimen>
 </resources>
index b8a1822..bbf24d8 100644 (file)
@@ -19,6 +19,7 @@
     <color name="red">#FF0000</color>
     <color name="blue">#0000FF</color>
     <color name="text_toolbar">#FFFFFF</color>
+    <color name="background_screen">#000000</color>
     <color name="background_toolbar">#363949</color>
     <color name="background_main_toolbar">#1e2028</color>
     <color name="toolbar_separation_line">#333333</color>
index 0746751..162d2c1 100644 (file)
@@ -121,12 +121,13 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
 
         ImageFilterRS.setRenderScriptContext(this);
 
+        ImageShow.setDefaultBackgroundColor(getResources().getColor(R.color.background_screen));
         // TODO: get those values from XML.
         ImageShow.setTextSize((int) getPixelsFromDip(12));
         ImageShow.setTextPadding((int) getPixelsFromDip(10));
         ImageButtonTitle.setTextSize((int) getPixelsFromDip(12));
         ImageButtonTitle.setTextPadding((int) getPixelsFromDip(10));
-        ImageSmallFilter.setMargin((int) getPixelsFromDip(6));
+        ImageSmallFilter.setMargin((int) getPixelsFromDip(3));
         ImageSmallFilter.setTextMargin((int) getPixelsFromDip(4));
         mImageBorderSize = (int) getPixelsFromDip(20);
         Drawable curveHandle = getResources().getDrawable(R.drawable.camera_crop_holo);
@@ -535,7 +536,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
         filter.setSelected(true);
         mCurrentImageSmallFilter = filter;
 
-        filter.setPreviousImageSmallFilter(null);
         filter.setImageFilter(new ImageFilterFx(null,getString(R.string.ffx_original)));
 
         filter.setController(this);
@@ -553,8 +553,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
 
         for (int i = 0; i < p; i++) {
             filter = new ImageSmallFilter(this);
-
-            filter.setPreviousImageSmallFilter(previousFilter);
             filter.setImageFilter(fxArray[i]);
             filter.setController(this);
             filter.setImageLoader(mImageLoader);
@@ -587,7 +585,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
         ImageSmallFilter previousFilter = null;
         for (int i = 0; i < p; i++) {
             ImageSmallBorder filter = new ImageSmallBorder(this);
-            filter.setPreviousImageSmallFilter(previousFilter);
             filter.setImageFilter(borders[i]);
             filter.setController(this);
             filter.setBorder(true);
index b7d3b1e..3b074bf 100644 (file)
@@ -19,6 +19,7 @@ package com.android.gallery3d.filtershow.imageshow;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
+import android.graphics.Color;
 import android.graphics.Paint;
 import android.graphics.Rect;
 import android.graphics.RectF;
@@ -57,7 +58,10 @@ public class ImageShow extends View implements SliderListener, OnSeekBarChangeLi
     private boolean mDirtyGeometry = true;
 
     private Bitmap mBackgroundImage = null;
- // TODO: remove protected here, it should be private
+    private final boolean USE_BACKGROUND_IMAGE = false;
+    private static int mBackgroundColor = Color.RED;
+
+    // TODO: remove protected here, it should be private
     protected Bitmap mForegroundImage = null;
     protected Bitmap mFilteredImage = null;
 
@@ -88,6 +92,10 @@ public class ImageShow extends View implements SliderListener, OnSeekBarChangeLi
     private SeekBar mSeekBar = null;
     private PanelController mController = null;
 
+    public static void setDefaultBackgroundColor(int value) {
+        mBackgroundColor = value;
+    }
+
     public static void setTextSize(int value) {
         mTextSize = value;
     }
@@ -355,14 +363,18 @@ public class ImageShow extends View implements SliderListener, OnSeekBarChangeLi
     }
 
     public void drawBackground(Canvas canvas) {
-        if (mBackgroundImage == null) {
-            mBackgroundImage = mImageLoader.getBackgroundBitmap(getResources());
-        }
-        if (mBackgroundImage != null) {
-            Rect s = new Rect(0, 0, mBackgroundImage.getWidth(),
-                    mBackgroundImage.getHeight());
-            Rect d = new Rect(0, 0, getWidth(), getHeight());
-            canvas.drawBitmap(mBackgroundImage, s, d, mPaint);
+        if (USE_BACKGROUND_IMAGE) {
+            if (mBackgroundImage == null) {
+                mBackgroundImage = mImageLoader.getBackgroundBitmap(getResources());
+            }
+            if (mBackgroundImage != null) {
+                Rect s = new Rect(0, 0, mBackgroundImage.getWidth(),
+                        mBackgroundImage.getHeight());
+                Rect d = new Rect(0, 0, getWidth(), getHeight());
+                canvas.drawBitmap(mBackgroundImage, s, d, mPaint);
+            }
+        } else {
+            canvas.drawColor(mBackgroundColor);
         }
     }
 
index 90986f9..25112ad 100644 (file)
@@ -31,14 +31,16 @@ public class ImageSmallBorder extends ImageSmallFilter {
     @Override
     public void onDraw(Canvas canvas) {
         getFilteredImage();
-        if (mIsSelected) {
-            canvas.drawColor(mSelectedBackgroundColor);
-        } else {
-            canvas.drawColor(mBackgroundColor);
-        }
+        canvas.drawColor(mBackgroundColor);
         // TODO: simplify & make faster...
         mPaint.setColor(mInnerBorderColor);
-        RectF border = new RectF(mMargin, mMargin, getWidth() - mMargin - 1, getHeight() - mMargin);
+        RectF border = new RectF(mMargin, 2*mMargin, getWidth() - mMargin - 1, getWidth());
+
+        if (mIsSelected) {
+            mPaint.setColor(mSelectedBackgroundColor);
+            canvas.drawRect(0, mMargin, getWidth(), getWidth() + mMargin, mPaint);
+        }
+
         canvas.drawLine(0, 0, getWidth(), 0, mPaint);
         mPaint.setStrokeWidth(mInnerBorderWidth);
         Path path = new Path();
@@ -47,7 +49,7 @@ public class ImageSmallBorder extends ImageSmallFilter {
         canvas.drawPath(path, mPaint);
         mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
         canvas.save();
-        canvas.clipRect(mMargin + 1, mMargin, getWidth() - mMargin - 2, getHeight() - mMargin - 1,
+        canvas.clipRect(mMargin + 1, 2*mMargin, getWidth() - mMargin - 2, getWidth() - 1,
                 Region.Op.INTERSECT);
         canvas.translate(mMargin, mMargin + 1);
         canvas.scale(mImageScaleFactor, mImageScaleFactor);
index a5d99a0..5783458 100644 (file)
@@ -23,8 +23,6 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener
     private boolean mSetBorder = false;
     protected final Paint mPaint = new Paint();
     protected boolean mIsSelected = false;
-    protected boolean mNextIsSelected = false;
-    private ImageSmallFilter mPreviousImageSmallFilter = null;
 
     // TODO: move this to xml.
     protected static int mMargin = 12;
@@ -58,28 +56,14 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener
         mImagePreset.add(mImageFilter);
     }
 
-    public void setPreviousImageSmallFilter(ImageSmallFilter previous) {
-        mPreviousImageSmallFilter = previous;
-    }
-
     @Override
     public void setSelected(boolean value) {
         if (mIsSelected != value) {
             invalidate();
-            if (mPreviousImageSmallFilter != null) {
-                mPreviousImageSmallFilter.setNextSelected(value);
-            }
         }
         mIsSelected = value;
     }
 
-    public void setNextSelected(boolean value) {
-        if (mNextIsSelected != value) {
-            invalidate();
-        }
-        mNextIsSelected = value;
-    }
-
     public void setBorder(boolean value) {
         mSetBorder = value;
     }
@@ -146,37 +130,40 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener
     public void onDraw(Canvas canvas) {
         getFilteredImage();
         canvas.drawColor(mBackgroundColor);
-        Rect d = new Rect(0, mMargin, getWidth() - mMargin, getWidth());
         float textWidth = mPaint.measureText(getImagePreset().name());
         int h = mTextSize + 2 * mTextPadding;
         int x = (int) ((getWidth() - textWidth) / 2);
         int y = getHeight();
         if (mIsSelected) {
             mPaint.setColor(mSelectedBackgroundColor);
-            canvas.drawRect(0, 0, getWidth(), getWidth() + mMargin, mPaint);
-        }
-        if (mNextIsSelected) {
-            mPaint.setColor(mSelectedBackgroundColor);
-            canvas.drawRect(getWidth() - mMargin, 0, getWidth(), getWidth() + mMargin, mPaint);
+            canvas.drawRect(0, mMargin, getWidth(), getWidth() + mMargin, mPaint);
         }
-        drawImage(canvas, mFilteredImage, d);
+        Rect destination = new Rect(mMargin, 2*mMargin, getWidth() - mMargin, getWidth());
+        drawImage(canvas, mFilteredImage, destination);
         mPaint.setTextSize(mTextSize);
         mPaint.setColor(mTextColor);
         canvas.drawText(getImagePreset().name(), x, y - mTextMargin, mPaint);
     }
 
-    public void drawImage(Canvas canvas, Bitmap image, Rect d) {
+    public void drawImage(Canvas canvas, Bitmap image, Rect destination) {
         if (image != null) {
             int iw = image.getWidth();
             int ih = image.getHeight();
-            int iy = (int) ((ih - iw) / 2.0f);
-            int ix = 0;
+            int x = 0;
+            int y = 0;
+            int size = 0;
+            Rect source = null;
             if (iw > ih) {
-                iy = 0;
-                ix = (int) ((iw - ih) / 2.0f);
+                size = ih;
+                x = (int) ((iw - size) / 2.0f);
+                y = 0;
+            } else {
+                size = iw;
+                x = 0;
+                y = (int) ((ih - size) / 2.0f);
             }
-            Rect s = new Rect(ix, iy, ix + iw, iy + iw);
-            canvas.drawBitmap(image, s, d, mPaint);
+            source = new Rect(x, y, x + size, y + size);
+            canvas.drawBitmap(image, source, destination, mPaint);
         }
     }