summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/category
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/filtershow/category')
-rw-r--r--src/com/android/gallery3d/filtershow/category/Action.java186
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryAdapter.java182
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryPanel.java108
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryTrack.java77
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryView.java176
-rw-r--r--src/com/android/gallery3d/filtershow/category/MainPanel.java239
6 files changed, 0 insertions, 968 deletions
diff --git a/src/com/android/gallery3d/filtershow/category/Action.java b/src/com/android/gallery3d/filtershow/category/Action.java
deleted file mode 100644
index 332ca18b0..000000000
--- a/src/com/android/gallery3d/filtershow/category/Action.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2013 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.category;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.widget.ArrayAdapter;
-import android.widget.ListAdapter;
-import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
-import com.android.gallery3d.filtershow.pipeline.RenderingRequest;
-import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller;
-import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.pipeline.ImagePreset;
-
-public class Action implements RenderingRequestCaller {
-
- private static final String LOGTAG = "Action";
- private FilterRepresentation mRepresentation;
- private String mName;
- private Rect mImageFrame;
- private Bitmap mImage;
- private ArrayAdapter mAdapter;
- public static final int FULL_VIEW = 0;
- public static final int CROP_VIEW = 1;
- private int mType = CROP_VIEW;
- private Bitmap mPortraitImage;
- private Bitmap mOverlayBitmap;
- private Context mContext;
-
- public Action(Context context, FilterRepresentation representation, int type) {
- mContext = context;
- setRepresentation(representation);
- setType(type);
- }
-
- public Action(Context context, FilterRepresentation representation) {
- this(context, representation, CROP_VIEW);
- }
-
- public FilterRepresentation getRepresentation() {
- return mRepresentation;
- }
-
- public void setRepresentation(FilterRepresentation representation) {
- mRepresentation = representation;
- mName = representation.getName();
- }
-
- public String getName() {
- return mName;
- }
-
- public void setName(String name) {
- mName = name;
- }
-
- public void setImageFrame(Rect imageFrame, int orientation) {
- if (mImageFrame != null && mImageFrame.equals(imageFrame)) {
- return;
- }
- Bitmap bitmap = MasterImage.getImage().getLargeThumbnailBitmap();
- if (bitmap != null) {
- mImageFrame = imageFrame;
- int w = mImageFrame.width();
- int h = mImageFrame.height();
- if (orientation == CategoryView.VERTICAL
- && mType == CROP_VIEW) {
- w /= 2;
- }
- Bitmap bitmapCrop = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- drawCenteredImage(bitmap, bitmapCrop, true);
-
- postNewIconRenderRequest(bitmapCrop);
- }
- }
-
- public Bitmap getImage() {
- return mImage;
- }
-
- public void setImage(Bitmap image) {
- mImage = image;
- }
-
- public void setAdapter(ArrayAdapter adapter) {
- mAdapter = adapter;
- }
-
- public void setType(int type) {
- mType = type;
- }
-
- private void postNewIconRenderRequest(Bitmap bitmap) {
- if (bitmap != null && mRepresentation != null) {
- ImagePreset preset = new ImagePreset();
- preset.addFilter(mRepresentation);
- RenderingRequest.post(mContext, bitmap,
- preset, RenderingRequest.ICON_RENDERING, this);
- }
- }
-
- private void drawCenteredImage(Bitmap source, Bitmap destination, boolean scale) {
- RectF image = new RectF(0, 0, source.getWidth(), source.getHeight());
- int border = 0;
- if (!scale) {
- border = destination.getWidth() - destination.getHeight();
- if (border < 0) {
- border = 0;
- }
- }
- RectF frame = new RectF(border, 0,
- destination.getWidth() - border,
- destination.getHeight());
- Matrix m = new Matrix();
- m.setRectToRect(frame, image, Matrix.ScaleToFit.CENTER);
- image.set(frame);
- m.mapRect(image);
- m.setRectToRect(image, frame, Matrix.ScaleToFit.FILL);
- Canvas canvas = new Canvas(destination);
- canvas.drawBitmap(source, m, new Paint(Paint.FILTER_BITMAP_FLAG));
- }
-
- @Override
- public void available(RenderingRequest request) {
- mImage = request.getBitmap();
- if (mImage == null) {
- return;
- }
- if (mRepresentation.getOverlayId() != 0 && mOverlayBitmap == null) {
- mOverlayBitmap = BitmapFactory.decodeResource(
- mContext.getResources(),
- mRepresentation.getOverlayId());
- }
- if (mOverlayBitmap != null) {
- if (getRepresentation().getFilterType() == FilterRepresentation.TYPE_BORDER) {
- Canvas canvas = new Canvas(mImage);
- canvas.drawBitmap(mOverlayBitmap, new Rect(0, 0, mOverlayBitmap.getWidth(), mOverlayBitmap.getHeight()),
- new Rect(0, 0, mImage.getWidth(), mImage.getHeight()), new Paint());
- } else {
- Canvas canvas = new Canvas(mImage);
- canvas.drawARGB(128, 0, 0, 0);
- drawCenteredImage(mOverlayBitmap, mImage, false);
- }
- }
- if (mAdapter != null) {
- mAdapter.notifyDataSetChanged();
- }
- }
-
- public void setPortraitImage(Bitmap portraitImage) {
- mPortraitImage = portraitImage;
- }
-
- public Bitmap getPortraitImage() {
- return mPortraitImage;
- }
-
- public Bitmap getOverlayBitmap() {
- return mOverlayBitmap;
- }
-
- public void setOverlayBitmap(Bitmap overlayBitmap) {
- mOverlayBitmap = overlayBitmap;
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
deleted file mode 100644
index 6451c39df..000000000
--- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2013 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.category;
-
-import android.content.Context;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.filters.FilterTinyPlanetRepresentation;
-import com.android.gallery3d.filtershow.pipeline.ImagePreset;
-
-public class CategoryAdapter extends ArrayAdapter<Action> {
-
- private static final String LOGTAG = "CategoryAdapter";
- private int mItemHeight;
- private View mContainer;
- private int mItemWidth = ListView.LayoutParams.MATCH_PARENT;
- private int mSelectedPosition;
- int mCategory;
- private int mOrientation;
-
- public CategoryAdapter(Context context, int textViewResourceId) {
- super(context, textViewResourceId);
- mItemHeight = (int) (context.getResources().getDisplayMetrics().density * 100);
- }
-
- public CategoryAdapter(Context context) {
- this(context, 0);
- }
-
- public void setItemHeight(int height) {
- mItemHeight = height;
- }
-
- public void setItemWidth(int width) {
- mItemWidth = width;
- }
-
- @Override
- public void add(Action action) {
- super.add(action);
- action.setAdapter(this);
- }
-
- public void initializeSelection(int category) {
- mCategory = category;
- mSelectedPosition = -1;
- if (category == MainPanel.LOOKS) {
- mSelectedPosition = 0;
- }
- if (category == MainPanel.BORDERS) {
- mSelectedPosition = 0;
- }
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- 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;
- }
-
- public void setSelected(View v) {
- int old = mSelectedPosition;
- mSelectedPosition = (Integer) v.getTag();
- if (old != -1) {
- invalidateView(old);
- }
- invalidateView(mSelectedPosition);
- }
-
- public boolean isSelected(View v) {
- return (Integer) v.getTag() == mSelectedPosition;
- }
-
- private void invalidateView(int position) {
- View child = null;
- if (mContainer instanceof ListView) {
- ListView lv = (ListView) mContainer;
- child = lv.getChildAt(position - lv.getFirstVisiblePosition());
- } else {
- CategoryTrack ct = (CategoryTrack) mContainer;
- child = ct.getChildAt(position);
- }
- if (child != null) {
- child.invalidate();
- }
- }
-
- public void setContainer(View container) {
- mContainer = container;
- }
-
- public void imageLoaded() {
- notifyDataSetChanged();
- }
-
- public FilterRepresentation getTinyPlanet() {
- for (int i = 0; i < getCount(); i++) {
- Action action = getItem(i);
- if (action.getRepresentation() != null
- && action.getRepresentation()
- instanceof FilterTinyPlanetRepresentation) {
- return action.getRepresentation();
- }
- }
- return null;
- }
-
- public void removeTinyPlanet() {
- for (int i = 0; i < getCount(); i++) {
- Action action = getItem(i);
- if (action.getRepresentation() != null
- && action.getRepresentation()
- instanceof FilterTinyPlanetRepresentation) {
- remove(action);
- return;
- }
- }
- }
-
- public void setOrientation(int orientation) {
- mOrientation = orientation;
- }
-
- public void reflectImagePreset(ImagePreset preset) {
- if (preset == null) {
- return;
- }
- 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;
- break;
- }
- }
- }
- 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
deleted file mode 100644
index de2481f3f..000000000
--- a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2013 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.category;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import android.widget.ListView;
-import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.FilterShowActivity;
-
-public class CategoryPanel extends Fragment {
-
- public static final String FRAGMENT_TAG = "CategoryPanel";
- private static final String PARAMETER_TAG = "currentPanel";
-
- private int mCurrentAdapter = MainPanel.LOOKS;
- private CategoryAdapter mAdapter;
-
- public void setAdapter(int value) {
- mCurrentAdapter = value;
- }
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- loadAdapter(mCurrentAdapter);
- }
-
- private void loadAdapter(int adapter) {
- FilterShowActivity activity = (FilterShowActivity) getActivity();
- switch (adapter) {
- case MainPanel.LOOKS: {
- mAdapter = activity.getCategoryLooksAdapter();
- mAdapter.initializeSelection(MainPanel.LOOKS);
- activity.updateCategories();
- break;
- }
- case MainPanel.BORDERS: {
- mAdapter = activity.getCategoryBordersAdapter();
- mAdapter.initializeSelection(MainPanel.BORDERS);
- activity.updateCategories();
- break;
- }
- case MainPanel.GEOMETRY: {
- mAdapter = activity.getCategoryGeometryAdapter();
- mAdapter.initializeSelection(MainPanel.GEOMETRY);
- break;
- }
- case MainPanel.FILTERS: {
- mAdapter = activity.getCategoryFiltersAdapter();
- mAdapter.initializeSelection(MainPanel.FILTERS);
- break;
- }
- }
- }
-
- @Override
- public void onSaveInstanceState(Bundle state) {
- super.onSaveInstanceState(state);
- state.putInt(PARAMETER_TAG, mCurrentAdapter);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- LinearLayout main = (LinearLayout) inflater.inflate(
- R.layout.filtershow_category_panel_new, container,
- false);
-
- if (savedInstanceState != null) {
- int selectedPanel = savedInstanceState.getInt(PARAMETER_TAG);
- loadAdapter(selectedPanel);
- }
-
- View panelView = main.findViewById(R.id.listItems);
- if (panelView instanceof CategoryTrack) {
- CategoryTrack panel = (CategoryTrack) panelView;
- mAdapter.setOrientation(CategoryView.HORIZONTAL);
- panel.setAdapter(mAdapter);
- mAdapter.setContainer(panel);
- } else {
- ListView panel = (ListView) main.findViewById(R.id.listItems);
- panel.setAdapter(mAdapter);
- mAdapter.setContainer(panel);
- }
- return main;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryTrack.java b/src/com/android/gallery3d/filtershow/category/CategoryTrack.java
deleted file mode 100644
index ac8245a3b..000000000
--- a/src/com/android/gallery3d/filtershow/category/CategoryTrack.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2013 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.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;
-
-public class CategoryTrack extends LinearLayout {
-
- private CategoryAdapter mAdapter;
- private int mElemSize;
- private DataSetObserver mDataSetObserver = new DataSetObserver() {
- @Override
- public void onChanged() {
- super.onChanged();
- invalidate();
- }
- @Override
- public void onInvalidated() {
- super.onInvalidated();
- fillContent();
- }
- };
-
- public CategoryTrack(Context context, AttributeSet attrs) {
- super(context, attrs);
- TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CategoryTrack);
- mElemSize = a.getDimensionPixelSize(R.styleable.CategoryTrack_iconSize, 0);
- }
-
- public void setAdapter(CategoryAdapter adapter) {
- mAdapter = adapter;
- mAdapter.registerDataSetObserver(mDataSetObserver);
- fillContent();
- }
-
- public void fillContent() {
- removeAllViews();
- mAdapter.setItemWidth(mElemSize);
- mAdapter.setItemHeight(LayoutParams.MATCH_PARENT);
- int n = mAdapter.getCount();
- for (int i = 0; i < n; i++) {
- View view = mAdapter.getView(i, null, this);
- addView(view, i);
- }
- 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
deleted file mode 100644
index c456dc207..000000000
--- a/src/com/android/gallery3d/filtershow/category/CategoryView.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2013 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.category;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.Typeface;
-import android.view.View;
-import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-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();
- private int mMargin = 16;
- private int mTextSize = 32;
- private int mTextColor;
- private int mBackgroundColor;
- private Paint mSelectPaint;
- CategoryAdapter mAdapter;
- private int mSelectionStroke;
- private Paint mBorderPaint;
- private int mBorderStroke;
- private int mOrientation = VERTICAL;
-
- public CategoryView(Context context) {
- super(context);
- setOnClickListener(this);
- Resources res = getResources();
- mBackgroundColor = res.getColor(R.color.filtershow_categoryview_background);
- mTextColor = res.getColor(R.color.filtershow_categoryview_text);
- mSelectionStroke = res.getDimensionPixelSize(R.dimen.thumbnail_margin);
- mTextSize = res.getDimensionPixelSize(R.dimen.category_panel_text_size);
- mMargin = res.getDimensionPixelOffset(R.dimen.category_panel_margin);
- mSelectPaint = new Paint();
- mSelectPaint.setStyle(Paint.Style.FILL);
- mSelectPaint.setColor(res.getColor(R.color.filtershow_category_selection));
- mBorderPaint = new Paint(mSelectPaint);
- mBorderPaint.setColor(Color.BLACK);
- mBorderStroke = mSelectionStroke / 3;
- }
-
- private void computeTextPosition(String text) {
- if (text == null) {
- return;
- }
- mPaint.setTextSize(mTextSize);
- if (mOrientation == VERTICAL) {
- text = text.toUpperCase();
- // TODO: set this in xml
- mPaint.setTypeface(Typeface.DEFAULT_BOLD);
- }
- mPaint.getTextBounds(text, 0, text.length(), mTextBounds);
- }
-
- public void drawText(Canvas canvas, String text) {
- if (text == null) {
- return;
- }
- float textWidth = mPaint.measureText(text);
- int x = (int) (canvas.getWidth() - textWidth - mMargin);
- if (mOrientation == HORIZONTAL) {
- x = (int) ((canvas.getWidth() - textWidth) / 2.0f);
- }
- if (x < 0) {
- // If the text takes more than the view width,
- // justify to the left.
- x = mMargin;
- }
- int y = canvas.getHeight() - mMargin;
- canvas.drawText(text, x, y, mPaint);
- }
-
- @Override
- public CharSequence getContentDescription () {
- if (mAction != null) {
- return mAction.getName();
- }
- return null;
- }
-
- @Override
- public void onDraw(Canvas canvas) {
- canvas.drawColor(mBackgroundColor);
- if (mAction != null) {
- mPaint.reset();
- mPaint.setAntiAlias(true);
- computeTextPosition(mAction.getName());
- if (mAction.getImage() == null) {
- mAction.setImageFrame(new Rect(0, 0, getWidth(), getHeight()), mOrientation);
- } else {
- Bitmap bitmap = mAction.getImage();
- canvas.save();
- Rect clipRect = new Rect(mSelectionStroke, mSelectionStroke,
- getWidth() - mSelectionStroke,
- getHeight() - 2* mMargin - mTextSize);
- int offsetx = 0;
- int offsety = 0;
- if (mOrientation == HORIZONTAL) {
- canvas.clipRect(clipRect);
- offsetx = - (bitmap.getWidth() - clipRect.width()) / 2;
- offsety = - (bitmap.getHeight() - clipRect.height()) / 2;
- }
- canvas.drawBitmap(bitmap, offsetx, offsety, mPaint);
- canvas.restore();
- if (mAdapter.isSelected(this)) {
- if (mOrientation == HORIZONTAL) {
- SelectionRenderer.drawSelection(canvas, 0, 0,
- getWidth(), getHeight() - mMargin - mTextSize,
- mSelectionStroke, mSelectPaint, mBorderStroke, mBorderPaint);
- } else {
- SelectionRenderer.drawSelection(canvas, 0, 0,
- Math.min(bitmap.getWidth(), getWidth()),
- Math.min(bitmap.getHeight(), getHeight()),
- mSelectionStroke, mSelectPaint, mBorderStroke, mBorderPaint);
- }
- }
- }
- mPaint.setColor(mBackgroundColor);
- mPaint.setStyle(Paint.Style.STROKE);
- mPaint.setStrokeWidth(3);
- drawText(canvas, mAction.getName());
- mPaint.setColor(mTextColor);
- mPaint.setStyle(Paint.Style.FILL);
- mPaint.setStrokeWidth(1);
- drawText(canvas, mAction.getName());
- }
- }
-
- public void setAction(Action action, CategoryAdapter adapter) {
- mAction = action;
- mAdapter = adapter;
- invalidate();
- }
-
- public FilterRepresentation getRepresentation() {
- return mAction.getRepresentation();
- }
-
- @Override
- public void onClick(View view) {
- FilterShowActivity activity = (FilterShowActivity) getContext();
- activity.showRepresentation(mAction.getRepresentation());
- mAdapter.setSelected(this);
- }
-
- public void setOrientation(int orientation) {
- mOrientation = orientation;
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java
deleted file mode 100644
index 9a64ffbf3..000000000
--- a/src/com/android/gallery3d/filtershow/category/MainPanel.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Copyright (C) 2013 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.category;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentTransaction;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.state.StatePanel;
-
-public class MainPanel extends Fragment {
-
- private static final String LOGTAG = "MainPanel";
-
- private LinearLayout mMainView;
- private ImageButton looksButton;
- private ImageButton bordersButton;
- private ImageButton geometryButton;
- private ImageButton filtersButton;
-
- public static final String FRAGMENT_TAG = "MainPanel";
- public static final int LOOKS = 0;
- public static final int BORDERS = 1;
- public static final int GEOMETRY = 2;
- public static final int FILTERS = 3;
-
- private int mCurrentSelected = -1;
-
- private void selection(int position, boolean value) {
- if (value) {
- FilterShowActivity activity = (FilterShowActivity) getActivity();
- activity.setCurrentPanel(position);
- }
- switch (position) {
- case LOOKS: {
- looksButton.setSelected(value);
- break;
- }
- case BORDERS: {
- bordersButton.setSelected(value);
- break;
- }
- case GEOMETRY: {
- geometryButton.setSelected(value);
- break;
- }
- case FILTERS: {
- filtersButton.setSelected(value);
- break;
- }
- }
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- if (mMainView != null) {
- if (mMainView.getParent() != null) {
- ViewGroup parent = (ViewGroup) mMainView.getParent();
- parent.removeView(mMainView);
- }
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- mMainView = (LinearLayout) inflater.inflate(
- R.layout.filtershow_main_panel, null, false);
-
- looksButton = (ImageButton) mMainView.findViewById(R.id.fxButton);
- bordersButton = (ImageButton) mMainView.findViewById(R.id.borderButton);
- geometryButton = (ImageButton) mMainView.findViewById(R.id.geometryButton);
- filtersButton = (ImageButton) mMainView.findViewById(R.id.colorsButton);
-
- looksButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showPanel(LOOKS);
- }
- });
- bordersButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showPanel(BORDERS);
- }
- });
- geometryButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showPanel(GEOMETRY);
- }
- });
- filtersButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showPanel(FILTERS);
- }
- });
-
- FilterShowActivity activity = (FilterShowActivity) getActivity();
- showImageStatePanel(activity.isShowingImageStatePanel());
- showPanel(activity.getCurrentPanel());
- return mMainView;
- }
-
- private boolean isRightAnimation(int newPos) {
- if (newPos < mCurrentSelected) {
- return false;
- }
- return true;
- }
-
- private void setCategoryFragment(CategoryPanel category, boolean fromRight) {
- FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
- if (fromRight) {
- transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_right);
- } else {
- transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left);
- }
- transaction.replace(R.id.category_panel_container, category, CategoryPanel.FRAGMENT_TAG);
- transaction.commit();
- }
-
- public void loadCategoryLookPanel() {
- if (mCurrentSelected == LOOKS) {
- return;
- }
- boolean fromRight = isRightAnimation(LOOKS);
- selection(mCurrentSelected, false);
- CategoryPanel categoryPanel = new CategoryPanel();
- categoryPanel.setAdapter(LOOKS);
- setCategoryFragment(categoryPanel, fromRight);
- mCurrentSelected = LOOKS;
- selection(mCurrentSelected, true);
- }
-
- public void loadCategoryBorderPanel() {
- if (mCurrentSelected == BORDERS) {
- return;
- }
- boolean fromRight = isRightAnimation(BORDERS);
- selection(mCurrentSelected, false);
- CategoryPanel categoryPanel = new CategoryPanel();
- categoryPanel.setAdapter(BORDERS);
- setCategoryFragment(categoryPanel, fromRight);
- mCurrentSelected = BORDERS;
- selection(mCurrentSelected, true);
- }
-
- public void loadCategoryGeometryPanel() {
- if (mCurrentSelected == GEOMETRY) {
- return;
- }
- boolean fromRight = isRightAnimation(GEOMETRY);
- selection(mCurrentSelected, false);
- CategoryPanel categoryPanel = new CategoryPanel();
- categoryPanel.setAdapter(GEOMETRY);
- setCategoryFragment(categoryPanel, fromRight);
- mCurrentSelected = GEOMETRY;
- selection(mCurrentSelected, true);
- }
-
- public void loadCategoryFiltersPanel() {
- if (mCurrentSelected == FILTERS) {
- return;
- }
- boolean fromRight = isRightAnimation(FILTERS);
- selection(mCurrentSelected, false);
- CategoryPanel categoryPanel = new CategoryPanel();
- categoryPanel.setAdapter(FILTERS);
- setCategoryFragment(categoryPanel, fromRight);
- mCurrentSelected = FILTERS;
- selection(mCurrentSelected, true);
- }
-
- public void showPanel(int currentPanel) {
- switch (currentPanel) {
- case LOOKS: {
- loadCategoryLookPanel();
- break;
- }
- case BORDERS: {
- loadCategoryBorderPanel();
- break;
- }
- case GEOMETRY: {
- loadCategoryGeometryPanel();
- break;
- }
- case FILTERS: {
- loadCategoryFiltersPanel();
- break;
- }
- }
- }
-
- public void showImageStatePanel(boolean show) {
- if (mMainView.findViewById(R.id.state_panel_container) == null) {
- return;
- }
- FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
- final View container = mMainView.findViewById(R.id.state_panel_container);
- if (show) {
- container.setVisibility(View.VISIBLE);
- StatePanel statePanel = new StatePanel();
- transaction.replace(R.id.state_panel_container, statePanel, StatePanel.FRAGMENT_TAG);
- } else {
- container.setVisibility(View.GONE);
- Fragment statePanel = getChildFragmentManager().findFragmentByTag(StatePanel.FRAGMENT_TAG);
- if (statePanel != null) {
- transaction.remove(statePanel);
- }
- }
- transaction.commit();
- }
-}