diff options
| author | John Hoford <hoford@google.com> | 2012-10-11 21:33:48 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2012-10-11 21:33:48 -0700 |
| commit | d0fa497e9d7b848691df3a3a9f708bf847cd3007 (patch) | |
| tree | 2a16bc22181d406934924f017e2713978b9b686f | |
| parent | 017065fa1e05885146cbb044fcd1f3de3f3f69e0 (diff) | |
| parent | ea5df36ac1cdfbb569e6ba725c2df433d614d0f5 (diff) | |
| download | android_packages_apps_Gallery2-d0fa497e9d7b848691df3a3a9f708bf847cd3007.tar.gz android_packages_apps_Gallery2-d0fa497e9d7b848691df3a3a9f708bf847cd3007.tar.bz2 android_packages_apps_Gallery2-d0fa497e9d7b848691df3a3a9f708bf847cd3007.zip | |
am ea5df36a: layouts, image icons, and layer behavour
* commit 'ea5df36ac1cdfbb569e6ba725c2df433d614d0f5':
layouts, image icons, and layer behavour
| -rw-r--r-- | res/layout/filtershow_activity.xml | 28 | ||||
| -rw-r--r-- | res/values/attrs.xml | 3 | ||||
| -rw-r--r-- | src/com/android/gallery3d/filtershow/CenteredLinearLayout.java | 36 | ||||
| -rw-r--r-- | src/com/android/gallery3d/filtershow/FilterShowActivity.java | 89 | ||||
| -rw-r--r-- | src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java | 34 |
5 files changed, 187 insertions, 3 deletions
diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml index f9d04aacc..0e157328d 100644 --- a/res/layout/filtershow_activity.xml +++ b/res/layout/filtershow_activity.xml @@ -17,7 +17,8 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent" > + android:layout_height="match_parent" + android:background="@color/background_main_toolbar" > <LinearLayout android:id="@+id/imageStatePanel" @@ -170,6 +171,15 @@ android:visibility="gone" /> </FrameLayout> + <com.android.gallery3d.filtershow.CenteredLinearLayout + xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d" + android:id="@+id/mainPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + custom:max_width="600dip" + android:orientation="vertical"> + <FrameLayout android:id="@+id/secondRowPanel" android:layout_width="fill_parent" @@ -235,7 +245,8 @@ android:id="@+id/listGeometry" android:layout_width="wrap_content" android:layout_height="fill_parent" - android:orientation="horizontal" > + android:layout_gravity="center" + android:orientation="horizontal"> <com.android.gallery3d.filtershow.ui.ImageButtonTitle android:id="@+id/straightenButton" @@ -349,6 +360,15 @@ </HorizontalScrollView> </FrameLayout> + <com.android.gallery3d.filtershow.CenteredLinearLayout + xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d" + android:id="@+id/mainPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + custom:max_width="400dip" + android:orientation="vertical"> + <LinearLayout android:layout_width="match_parent" android:layout_height="48dip" @@ -393,6 +413,10 @@ android:scaleType="centerInside" android:src="@drawable/ic_photoeditor_color" /> </LinearLayout> + + </com.android.gallery3d.filtershow.CenteredLinearLayout> + + </com.android.gallery3d.filtershow.CenteredLinearLayout> </LinearLayout> </FrameLayout> diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 94d5b72de..f8ebd0592 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -18,4 +18,7 @@ <attr name="listPreferredItemHeightSmall" format="dimension" /> <attr name="switchStyle" format="reference" /> </declare-styleable> + <declare-styleable name="CenteredLinearLayout"> + <attr name="max_width" format="dimension" /> + </declare-styleable> </resources> diff --git a/src/com/android/gallery3d/filtershow/CenteredLinearLayout.java b/src/com/android/gallery3d/filtershow/CenteredLinearLayout.java new file mode 100644 index 000000000..16b969535 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/CenteredLinearLayout.java @@ -0,0 +1,36 @@ +package com.android.gallery3d.filtershow; + +import android.content.Context; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.View.MeasureSpec; +import android.widget.LinearLayout; + +import com.android.gallery3d.R; + +public class CenteredLinearLayout extends LinearLayout { + private final int mMaxWidth; + + public CenteredLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CenteredLinearLayout); + mMaxWidth = a.getDimensionPixelSize(R.styleable.CenteredLinearLayout_max_width, 0); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int parentWidth = MeasureSpec.getSize(widthMeasureSpec); + int parentHeight = MeasureSpec.getSize(heightMeasureSpec); + Resources r = getContext().getResources(); + float value = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, parentWidth, + r.getDisplayMetrics()); + if (mMaxWidth > 0 && parentWidth > mMaxWidth) { + int measureMode = MeasureSpec.getMode(widthMeasureSpec); + widthMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxWidth, measureMode); + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + +} diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 5553a3c20..f2b817c17 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -36,9 +36,17 @@ import com.android.gallery3d.R; import com.android.gallery3d.filtershow.cache.ImageLoader; import com.android.gallery3d.filtershow.filters.ImageFilter; import com.android.gallery3d.filtershow.filters.ImageFilterBorder; +import com.android.gallery3d.filtershow.filters.ImageFilterContrast; +import com.android.gallery3d.filtershow.filters.ImageFilterExposure; import com.android.gallery3d.filtershow.filters.ImageFilterFx; +import com.android.gallery3d.filtershow.filters.ImageFilterHue; import com.android.gallery3d.filtershow.filters.ImageFilterParametricBorder; import com.android.gallery3d.filtershow.filters.ImageFilterRS; +import com.android.gallery3d.filtershow.filters.ImageFilterSaturated; +import com.android.gallery3d.filtershow.filters.ImageFilterShadows; +import com.android.gallery3d.filtershow.filters.ImageFilterVibrance; +import com.android.gallery3d.filtershow.filters.ImageFilterVignette; +import com.android.gallery3d.filtershow.filters.ImageFilterWBalance; import com.android.gallery3d.filtershow.imageshow.ImageBorder; import com.android.gallery3d.filtershow.imageshow.ImageCrop; import com.android.gallery3d.filtershow.imageshow.ImageFlip; @@ -47,6 +55,7 @@ import com.android.gallery3d.filtershow.imageshow.ImageShow; 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.ImageWithIcon; import com.android.gallery3d.filtershow.imageshow.ImageZoom; import com.android.gallery3d.filtershow.presets.ImagePreset; import com.android.gallery3d.filtershow.provider.SharedImageProvider; @@ -124,6 +133,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, LinearLayout listFilters = (LinearLayout) findViewById(R.id.listFilters); LinearLayout listBorders = (LinearLayout) findViewById(R.id.listBorders); + LinearLayout listColors = (LinearLayout) findViewById(R.id.listColorsFx); mImageShow = (ImageShow) findViewById(R.id.imageShow); mImageCurves = (ImageCurves) findViewById(R.id.imageCurves); @@ -199,7 +209,84 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mPanelController.addComponent(mGeometryButton, findViewById(R.id.flipButton)); mPanelController.addPanel(mColorsButton, mListColors, 3); - mPanelController.addComponent(mColorsButton, findViewById(R.id.vignetteButton)); + + int []recastIDs = { + R.id.vignetteButton, + R.id.vibranceButton, + R.id.contrastButton, + R.id.saturationButton, + R.id.wbalanceButton, + R.id.hueButton, + R.id.exposureButton, + R.id.shadowRecoveryButton + }; + ImageFilter []filters = { + new ImageFilterVignette(), + new ImageFilterVibrance(), + new ImageFilterContrast(), + new ImageFilterSaturated(), + new ImageFilterWBalance(), + new ImageFilterHue(), + new ImageFilterExposure(), + new ImageFilterShadows() + }; + + + for (int i = 0; i < filters.length; i++) { + + ImageSmallFilter fView = new ImageSmallFilter(this); + View v = listColors.findViewById(recastIDs[i]); + int pos = listColors.indexOfChild(v); + listColors.removeView(v); + + filters[i].setParameter(100); + fView.setImageFilter(filters[i]); + fView.setController(this); + fView.setImageLoader(mImageLoader); + fView.setId(recastIDs[i]); + + mPanelController.addComponent(mColorsButton, fView); + listColors.addView(fView,pos); + } + + 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.sharpen, + 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.addComponent(mColorsButton, findViewById(R.id.curvesButtonRGB)); mPanelController.addComponent(mColorsButton, findViewById(R.id.sharpenButton)); mPanelController.addComponent(mColorsButton, findViewById(R.id.vibranceButton)); diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java b/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java new file mode 100644 index 000000000..2666cb73d --- /dev/null +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java @@ -0,0 +1,34 @@ +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); + } + } +} |
