From b71ec3a67d425fb44621fe75086fec3bcc33eae7 Mon Sep 17 00:00:00 2001 From: Ruben Brunk Date: Mon, 1 Apr 2013 16:55:05 -0700 Subject: Change panels organization. Also fixes border updates handling. Change-Id: If96754e821b1e80238d2a04e65f1b57ee9683efe --- .../gallery3d/filtershow/FilterShowActivity.java | 9 ++++- .../filtershow/filters/BaseFiltersManager.java | 4 +++ .../gallery3d/filtershow/presets/ImagePreset.java | 39 ++++++++++++++++------ 3 files changed, 40 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 8c5d7a4a6..3cd4262fa 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -402,7 +402,15 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, private void setupBorders() { LinearLayout list = (LinearLayout) findViewById(R.id.listBorders); Vector borders = new Vector(); + ImageButton borderButton = (ImageButton) findViewById(R.id.borderButton); + + // The "no border" implementation borders.add(new FilterImageBorderRepresentation(0)); + + // Google-build borders + FiltersManager.getManager().addBorders(borders); + + // Regular borders borders.add(new FilterImageBorderRepresentation(R.drawable.filtershow_border_4x5)); borders.add(new FilterImageBorderRepresentation(R.drawable.filtershow_border_brush)); borders.add(new FilterImageBorderRepresentation(R.drawable.filtershow_border_grunge)); @@ -424,7 +432,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, if (i == 0) { filter.setName(getString(R.string.none)); } - ImageButton borderButton = (ImageButton) findViewById(R.id.borderButton); FilterIconButton b = setupFilterRepresentationButton(filter, list, borderButton); if (i == 0) { mNullBorderFilter = b; diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java index b5c4de048..232de6460 100644 --- a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java +++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java @@ -108,6 +108,10 @@ public abstract class BaseFiltersManager { filters.add(ImageFilterGeometry.class); } + public void addBorders(Vector representations) { + // Override + } + public void addLooks(Vector representations) { // Override } diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java index b2dd6b711..a35a18a7d 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java @@ -117,15 +117,24 @@ public class ImagePreset { if (filterRepresentation == null) { return null; } - int position = getPositionForRepresentation(filterRepresentation); - if (position == -1) { - return null; - } FilterRepresentation representation = null; - try { - representation = mFilters.elementAt(position).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); + if ((mBorder != null) + && (mBorder.getFilterClass() == filterRepresentation.getFilterClass())) { + // TODO: instead of special casing for border, we should correctly implements "filters priority set" + representation = mBorder; + } else { + int position = getPositionForRepresentation(filterRepresentation); + if (position == -1) { + return null; + } + representation = mFilters.elementAt(position); + } + if (representation != null) { + try { + representation = representation.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } } return representation; } @@ -138,9 +147,17 @@ public class ImagePreset { if (representation instanceof GeometryMetadata) { setGeometry((GeometryMetadata) representation); } else { - int position = getPositionForRepresentation(representation); - FilterRepresentation old = mFilters.elementAt(position); - old.updateTempParametersFrom(representation); + if ((mBorder != null) + && (mBorder.getFilterClass() == representation.getFilterClass())) { + mBorder.updateTempParametersFrom(representation); + } else { + int position = getPositionForRepresentation(representation); + if (position == -1) { + return; + } + FilterRepresentation old = mFilters.elementAt(position); + old.updateTempParametersFrom(representation); + } } } MasterImage.getImage().invalidatePreview(); -- cgit v1.2.3