diff options
author | nicolasroard <nicolasroard@google.com> | 2012-12-07 13:51:20 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-12-07 13:51:20 -0800 |
commit | e9559a23576135fb899f30056187f6097929b8bc (patch) | |
tree | f147a2da9f55180418dbf2b1732561c8a2c7b700 | |
parent | e879326d76734277469ca2f387f436fd0e922c87 (diff) | |
parent | 116fc29a3f893813b95d7f55799d2947e09e512a (diff) | |
download | android_packages_apps_Gallery2-e9559a23576135fb899f30056187f6097929b8bc.tar.gz android_packages_apps_Gallery2-e9559a23576135fb899f30056187f6097929b8bc.tar.bz2 android_packages_apps_Gallery2-e9559a23576135fb899f30056187f6097929b8bc.zip |
Merge "More refactoring. Makes it easy to specify how the button should look like (overlay img or not)." into gb-ub-photos-bryce
5 files changed, 48 insertions, 91 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 724511a59..356a0a074 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -60,6 +60,7 @@ import com.android.gallery3d.filtershow.filters.ImageFilter; import com.android.gallery3d.filtershow.filters.ImageFilterBorder; import com.android.gallery3d.filtershow.filters.ImageFilterBwFilter; import com.android.gallery3d.filtershow.filters.ImageFilterContrast; +import com.android.gallery3d.filtershow.filters.ImageFilterCurves; import com.android.gallery3d.filtershow.filters.ImageFilterExposure; import com.android.gallery3d.filtershow.filters.ImageFilterFx; import com.android.gallery3d.filtershow.filters.ImageFilterHue; @@ -82,7 +83,6 @@ import com.android.gallery3d.filtershow.imageshow.ImageSmallBorder; import com.android.gallery3d.filtershow.imageshow.ImageSmallFilter; import com.android.gallery3d.filtershow.imageshow.ImageStraighten; import com.android.gallery3d.filtershow.imageshow.ImageTinyPlanet; -import com.android.gallery3d.filtershow.imageshow.ImageWithIcon; import com.android.gallery3d.filtershow.imageshow.ImageZoom; import com.android.gallery3d.filtershow.presets.ImagePreset; import com.android.gallery3d.filtershow.provider.SharedImageProvider; @@ -303,9 +303,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, new ImageFilterContrast(), new ImageFilterShadows(), new ImageFilterVibrance(), - // TODO: move sharpen and curves here - // sharpen - // curves + new ImageFilterSharpen(), + new ImageFilterCurves(), new ImageFilterHue(), new ImageFilterSaturated(), new ImageFilterBwFilter() @@ -319,47 +318,15 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, fView.setController(this); fView.setImageLoader(mImageLoader); fView.setId(filters[i].getButtonId()); + if (filters[i].getOverlayBitmaps() != 0) { + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), + filters[i].getOverlayBitmaps()); + fView.setOverlayBitmap(bitmap); + } mPanelController.addComponent(mColorsButton, fView); listColors.addView(fView); } - int[] overlayIDs = { - R.id.sharpenButton, - R.id.curvesButtonRGB - }; - int[] overlayBitmaps = { - R.drawable.filtershow_button_colors_sharpen, - R.drawable.filtershow_button_colors_curve - }; - int[] overlayNames = { - R.string.sharpness, - R.string.curvesRGB - }; - - for (int i = 0; i < overlayIDs.length; i++) { - ImageWithIcon fView = new ImageWithIcon(this); - View v = listColors.findViewById(overlayIDs[i]); - int pos = listColors.indexOfChild(v); - listColors.removeView(v); - final int sid = overlayNames[i]; - ImageFilterExposure efilter = new ImageFilterExposure() { - { - mName = getString(sid); - } - }; - efilter.setParameter(-300); - Bitmap bitmap = BitmapFactory.decodeResource(getResources(), - overlayBitmaps[i]); - - fView.setIcon(bitmap); - fView.setImageFilter(efilter); - fView.setController(this); - fView.setImageLoader(mImageLoader); - fView.setId(overlayIDs[i]); - mPanelController.addComponent(mColorsButton, fView); - listColors.addView(fView, pos); - } - mPanelController.addView(findViewById(R.id.applyEffect)); mPanelController.addView(findViewById(R.id.pickCurvesChannel)); mPanelController.addView(findViewById(R.id.aspect)); diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java index 89641d103..dda969965 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java @@ -18,6 +18,7 @@ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; +import com.android.gallery3d.R; import com.android.gallery3d.filtershow.ui.Spline; public class ImageFilterCurves extends ImageFilter { @@ -31,6 +32,21 @@ public class ImageFilterCurves extends ImageFilter { } @Override + public int getButtonId() { + return R.id.curvesButtonRGB; + } + + @Override + public int getTextId() { + return R.string.curvesRGB; + } + + @Override + public int getOverlayBitmaps() { + return R.drawable.filtershow_button_colors_curve; + } + + @Override public ImageFilter clone() throws CloneNotSupportedException { ImageFilterCurves filter = (ImageFilterCurves) super.clone(); for (int i = 0; i < 4; i++) { diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java index db29a8a91..b551c5137 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java @@ -33,6 +33,16 @@ public class ImageFilterSharpen extends ImageFilterRS { } @Override + public int getTextId() { + return R.string.sharpness; + } + + @Override + public int getOverlayBitmaps() { + return R.drawable.filtershow_button_colors_sharpen; + } + + @Override public void createFilter(android.content.res.Resources res, float scaleFactor, boolean highQuality) { int w = mInPixelsAllocation.getType().getX(); diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java b/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java index 6a79e18a1..358f4fbe8 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java @@ -47,6 +47,13 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener protected final int mTextColor = Color.WHITE; private ImageSmallFilter mNullFilter; + private Bitmap mOverlayBitmap = null; + private final int mOverlayTint = Color.argb(100, 0, 0, 0); + + public void setOverlayBitmap(Bitmap bitmap){ + mOverlayBitmap = bitmap; + } + public static void setMargin(int value) { mMargin = value; } @@ -188,6 +195,13 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener mPaint.setTextSize(mTextSize); mPaint.setColor(mTextColor); canvas.drawText(mImageFilter.getName(), x, y - mTextMargin, mPaint); + if (mOverlayBitmap != null) { + mPaint.setColor(mOverlayTint); + canvas.drawRect(0, mMargin, getWidth(), getWidth() + mMargin, mPaint); + Rect d = new Rect(0, mMargin, getWidth() - mMargin, getWidth()); + mPaint.setColor(Color.BLACK); + drawImage(canvas, mOverlayBitmap, d); + } } public void drawImage(Canvas canvas, Bitmap image, Rect destination) { diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java b/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java deleted file mode 100644 index a332fa72a..000000000 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - */ - -package com.android.gallery3d.filtershow.imageshow; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Rect; - -/** - * TODO: Insert description here. (generated by hoford) - */ -public class ImageWithIcon extends ImageSmallFilter { - /** - * @param context - */ - public ImageWithIcon(Context context) { - super(context); - // TODO(hoford): Auto-generated constructor stub - } - - private Bitmap bitmap; - - public void setIcon(Bitmap bitmap){ - this.bitmap = bitmap; - } - - @Override - public void onDraw(Canvas canvas) { - super.onDraw(canvas); - if (bitmap != null) { - Rect d = new Rect(0, mMargin, getWidth() - mMargin, getWidth()); - drawImage(canvas, bitmap, d); - } - } -} |