summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java6
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryAdapter.java43
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryPanel.java1
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryTrack.java18
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryView.java7
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java1
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java9
7 files changed, 84 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index a6b57a49f..863d2cb4f 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -488,6 +488,12 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
return mCurrentPanel;
}
+ public void updateCategories() {
+ ImagePreset preset = mMasterImage.getPreset();
+ mCategoryLooksAdapter.reflectImagePreset(preset);
+ mCategoryBordersAdapter.reflectImagePreset(preset);
+ }
+
private class LoadBitmapTask extends AsyncTask<Uri, Boolean, Boolean> {
int mBitmapSize;
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
index f08699dee..398c6785e 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
@@ -41,6 +41,7 @@ public class CategoryAdapter extends ArrayAdapter<Action> {
private boolean mUseFilterIconButton = false;
private int mSelectedPosition;
int mCategory;
+ private int mOrientation;
public CategoryAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
@@ -67,8 +68,13 @@ public class CategoryAdapter extends ArrayAdapter<Action> {
public void initializeSelection(int category) {
mCategory = category;
- // TODO: fix this
mSelectedPosition = -1;
+ if (category == MainPanel.LOOKS) {
+ mSelectedPosition = 0;
+ }
+ if (category == MainPanel.BORDERS) {
+ mSelectedPosition = 0;
+ }
}
@Override
@@ -95,10 +101,12 @@ public class CategoryAdapter extends ArrayAdapter<Action> {
convertView = new CategoryView(getContext());
}
CategoryView view = (CategoryView) convertView;
+ view.setOrientation(mOrientation);
view.setAction(getItem(position), this);
view.setLayoutParams(
new ListView.LayoutParams(mItemWidth, mItemHeight));
view.setTag(position);
+ view.invalidate();
return view;
}
@@ -168,4 +176,37 @@ public class CategoryAdapter extends ArrayAdapter<Action> {
}
}
}
+
+ public void setOrientation(int orientation) {
+ mOrientation = orientation;
+ }
+
+ public void reflectImagePreset(ImagePreset preset) {
+ int selected = 0; // if nothing found, select "none" (first element)
+ FilterRepresentation rep = null;
+ if (mCategory == MainPanel.LOOKS) {
+ int pos = preset.getPositionForType(FilterRepresentation.TYPE_FX);
+ if (pos != -1) {
+ rep = preset.getFilterRepresentation(pos);
+ }
+ } else if (mCategory == MainPanel.BORDERS) {
+ int pos = preset.getPositionForType(FilterRepresentation.TYPE_BORDER);
+ if (pos != -1) {
+ rep = preset.getFilterRepresentation(pos);
+ }
+ }
+ if (rep != null) {
+ for (int i = 0; i < getCount(); i++) {
+ if (rep.getName().equalsIgnoreCase(
+ getItem(i).getRepresentation().getName())) {
+ selected = i;
+ }
+ }
+ }
+ if (mSelectedPosition != selected) {
+ mSelectedPosition = selected;
+ this.notifyDataSetChanged();
+ }
+
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
index abae80f93..e78722187 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
@@ -92,6 +92,7 @@ public class CategoryPanel extends Fragment {
View panelView = main.findViewById(R.id.listItems);
if (panelView instanceof CategoryTrack) {
CategoryTrack panel = (CategoryTrack) panelView;
+ mAdapter.setOrientation(CategoryView.HORIZONTAL);
mAdapter.setUseFilterIconButton(true);
panel.setAdapter(mAdapter);
mAdapter.setContainer(panel);
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryTrack.java b/src/com/android/gallery3d/filtershow/category/CategoryTrack.java
index e0a8a2fab..f55431293 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryTrack.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryTrack.java
@@ -18,7 +18,9 @@ package com.android.gallery3d.filtershow.category;
import android.content.Context;
import android.content.res.TypedArray;
+import android.database.DataSetObserver;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import com.android.gallery3d.R;
@@ -27,6 +29,13 @@ public class CategoryTrack extends LinearLayout {
private CategoryAdapter mAdapter;
private int mElemSize;
+ private DataSetObserver mDataSetObserver = new DataSetObserver() {
+ @Override
+ public void onChanged() {
+ super.onChanged();
+ invalidate();
+ }
+ };
public CategoryTrack(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -38,6 +47,7 @@ public class CategoryTrack extends LinearLayout {
mAdapter = adapter;
mAdapter.setItemWidth(mElemSize);
mAdapter.setItemHeight(LayoutParams.MATCH_PARENT);
+ mAdapter.registerDataSetObserver(mDataSetObserver);
fillContent();
}
@@ -51,4 +61,12 @@ public class CategoryTrack extends LinearLayout {
requestLayout();
}
+ @Override
+ public void invalidate() {
+ for (int i = 0; i < this.getChildCount(); i++) {
+ View child = getChildAt(i);
+ child.invalidate();
+ }
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryView.java b/src/com/android/gallery3d/filtershow/category/CategoryView.java
index 059eb103d..e045cf452 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryView.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryView.java
@@ -34,6 +34,8 @@ import com.android.gallery3d.filtershow.ui.SelectionRenderer;
public class CategoryView extends View implements View.OnClickListener {
private static final String LOGTAG = "CategoryView";
+ public static final int VERTICAL = 0;
+ public static final int HORIZONTAL = 1;
private Paint mPaint = new Paint();
private Action mAction;
private Rect mTextBounds = new Rect();
@@ -46,6 +48,7 @@ public class CategoryView extends View implements View.OnClickListener {
private int mSelectionStroke;
private Paint mBorderPaint;
private int mBorderStroke;
+ private int mOrientation = VERTICAL;
public static void setTextSize(int size) {
sTextSize = size;
@@ -129,4 +132,8 @@ public class CategoryView extends View implements View.OnClickListener {
activity.showRepresentation(mAction.getRepresentation());
mAdapter.setSelected(this);
}
+
+ public void setOrientation(int orientation) {
+ mOrientation = orientation;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index f2e9b6308..c0d4601bc 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -160,6 +160,7 @@ public class MasterImage implements RenderingRequestCaller {
notifyGeometryChange();
}
mPreviousGeometry = new GeometryMetadata(geo);
+ mActivity.updateCategories();
}
private void setGeometry() {
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index 9c5e2ae65..808288f89 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -113,6 +113,15 @@ public class ImagePreset {
return null;
}
+ public int getPositionForType(int type) {
+ for (int i = 0; i < mFilters.size(); i++) {
+ if (mFilters.elementAt(i).getFilterType() == type) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
public FilterRepresentation getFilterRepresentationCopyFrom(FilterRepresentation filterRepresentation) {
// TODO: add concept of position in the filters (to allow multiple instances)
if (filterRepresentation == null) {