}
public void loadEditorPanel(FilterRepresentation representation,
- Editor currentEditor) {
+ final Editor currentEditor) {
if (representation.getEditorId() == ImageOnlyEditor.ID) {
currentEditor.getImageShow().select();
currentEditor.reflectCurrentFilter();
return;
}
- EditorPanel panel = new EditorPanel();
- panel.setEditor(currentEditor.getID());
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
- transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
- transaction.commit();
+ final int currentId = currentEditor.getID();
+ Runnable showEditor = new Runnable() {
+ @Override
+ public void run() {
+ EditorPanel panel = new EditorPanel();
+ panel.setEditor(currentId);
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
+ transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
+ transaction.commit();
+ }
+ };
+ Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
+ boolean doAnimation = false;
+ if (mShowingImageStatePanel
+ && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ doAnimation = true;
+ }
+ if (doAnimation && main != null && main instanceof MainPanel) {
+ MainPanel mainPanel = (MainPanel) main;
+ View container = mainPanel.getView().findViewById(R.id.category_panel_container);
+ View bottom = mainPanel.getView().findViewById(R.id.bottom_panel);
+ int panelHeight = container.getHeight() + bottom.getHeight();
+ mainPanel.getView().animate().translationY(panelHeight).withEndAction(showEditor).start();
+ } else {
+ showEditor.run();
+ }
}
private void loadXML() {
if (representation.getTextId() != 0) {
representation.setName(getString(representation.getTextId()));
}
- mCategoryBordersAdapter.add(new Action(this, representation));
+ mCategoryBordersAdapter.add(new Action(this, representation, Action.FULL_VIEW));
}
}
mCategoryLooksAdapter = new CategoryAdapter(this);
int verticalItemHeight = (int) getResources().getDimension(R.dimen.action_item_height);
mCategoryLooksAdapter.setItemHeight(verticalItemHeight);
- mCategoryLooksAdapter.add(new Action(this, nullFx, Action.CROP_VIEW));
+ mCategoryLooksAdapter.add(new Action(this, nullFx, Action.FULL_VIEW));
for (FilterRepresentation representation : filtersRepresentations) {
mCategoryLooksAdapter.add(new Action(this, representation, Action.FULL_VIEW));
}
mRepresentation.getOverlayId());
}
if (mOverlayBitmap != null) {
- drawCenteredImage(mOverlayBitmap, mImage, false);
+ if (getRepresentation().getPriority() == 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();
return;
}
text = text.toUpperCase();
- mPaint.reset();
- mPaint.setColor(mTextColor);
mPaint.setTextSize(sTextSize);
mPaint.setTypeface(Typeface.DEFAULT_BOLD);
- mPaint.setAntiAlias(true);
float textWidth = mPaint.measureText(text);
mPaint.getTextBounds(text, 0, text.length(), mTextBounds);
int x = (int) (canvas.getWidth() - textWidth - sMargin);
public void onDraw(Canvas canvas) {
canvas.drawColor(mBackgroundColor);
if (mAction != null) {
- drawText(canvas, mAction.getName());
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
if (mAction.getImage() == null) {
mAction.setImageFrame(new Rect(0, 0, canvas.getWidth(), canvas.getHeight()));
} else {
Bitmap bitmap = mAction.getImage();
canvas.drawBitmap(bitmap, 0, 0, mPaint);
}
+ 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());
}
}
mControl = (Control) c.newInstance();
p.setController(mControl);
mControl.setUp((ViewGroup) editControl, p, this);
-
-
} catch (Exception e) {
Log.e(LOGTAG, "Error in loading Control ", e);
}
}
public boolean supportsPartialRendering() {
- return mSupportsPartialRendering;
+ return false && mSupportsPartialRendering; // disable for now
}
public void setSupportsPartialRendering(boolean value) {
if (imageStateAdapter == null) {
return;
}
- imageStateAdapter.clear();
- imageStateAdapter.addOriginal();
+ Vector<State> states = new Vector<State>();
// TODO: supports Geometry representations in the state panel.
if (false && mGeoData != null && mGeoData.hasModifications()) {
State geo = new State("Geometry");
geo.setFilterRepresentation(mGeoData);
- imageStateAdapter.add(geo);
+ states.add(geo);
+ }
+ for (FilterRepresentation filter : mFilters) {
+ State state = new State(filter.getName());
+ state.setFilterRepresentation(filter);
+ states.add(state);
}
- imageStateAdapter.addAll(mFilters);
if (mBorder != null) {
State border = new State(mBorder.getName());
border.setFilterRepresentation(mBorder);
- imageStateAdapter.add(border);
+ states.add(border);
}
+ imageStateAdapter.fill(states);
}
public void setPartialRendering(boolean partialRendering, Rect bounds) {
this(text, StateView.DEFAULT);
}
- State(String text, int type) {
+ public State(String text, int type) {
mText = text;
mType = type;
}
+ public boolean equals(State state) {
+ if (mFilterRepresentation.getFilterClass()
+ != state.mFilterRepresentation.getFilterClass()) {
+ return false;
+ }
+ return true;
+ }
+
public boolean isDraggable() {
return mFilterRepresentation != null;
}
package com.android.gallery3d.filtershow.state;
import android.content.Context;
+import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
public class StateAdapter extends ArrayAdapter<State> {
+ private static final String LOGTAG = "StateAdapter";
private int mOrientation;
- private PanelTrack mListener;
private String mOriginalText;
private String mResultText;
mOrientation = orientation;
}
- @Override
- public void notifyDataSetChanged() {
- if (mListener != null) {
- mListener.fillContent(false);
- }
- }
-
public void addOriginal() {
add(new State(mOriginalText));
}
- public void addAll(Vector<FilterRepresentation> filters) {
- for (FilterRepresentation filter : filters) {
- State state = new State(filter.getName());
- state.setFilterRepresentation(filter);
- add(state);
+ public boolean same(Vector<State> states) {
+ // we have the original state in addition
+ if (states.size() + 1 != getCount()) {
+ return false;
}
- notifyDataSetChanged();
+ for (int i = 1; i < getCount(); i++) {
+ State state = getItem(i);
+ if (!state.equals(states.elementAt(i-1))) {
+ return false;
+ }
+ }
+ return true;
}
- void setListener(PanelTrack listener) {
- mListener = listener;
+ public void fill(Vector<State> states) {
+ if (same(states)) {
+ return;
+ }
+ clear();
+ addOriginal();
+ addAll(states);
+ notifyDataSetChanged();
}
@Override
import android.animation.LayoutTransition;
import android.content.Context;
import android.content.res.TypedArray;
+import android.database.DataSetObserver;
+import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.AttributeSet;
private long mTouchTime;
private int mMaxTouchDelay = 300; // 300ms delay for touch
private static final boolean ALLOWS_DRAG = false;
+ private DataSetObserver mObserver = new DataSetObserver() {
+ @Override
+ public void onChanged() {
+ super.onChanged();
+ fillContent(false);
+ }
+
+ @Override
+ public void onInvalidated() {
+ super.onInvalidated();
+ fillContent(false);
+ }
+ };
public StatePanelTrack(Context context, AttributeSet attrs) {
super(context, attrs);
public void setAdapter(StateAdapter adapter) {
mAdapter = adapter;
- mAdapter.setListener(this);
+ mAdapter.registerDataSetObserver(mObserver);
mAdapter.setOrientation(getOrientation());
fillContent(false);
requestLayout();
&& event.getActionMasked() == MotionEvent.ACTION_UP
&& System.currentTimeMillis() - mTouchTime < mMaxTouchDelay) {
FilterRepresentation representation = mCurrentView.getState().getFilterRepresentation();
+ mCurrentView.setSelected(true);
if (representation != MasterImage.getImage().getCurrentFilterRepresentation()) {
FilterShowActivity activity = (FilterShowActivity) getContext();
activity.showRepresentation(representation);
- }
- if (representation.getEditorId() != ImageOnlyEditor.ID) {
- mCurrentView.setSelected(true);
+ mCurrentView.setSelected(false);
}
}
if (event.getActionMasked() == MotionEvent.ACTION_UP
|| (!mStartedDrag && event.getActionMasked() == MotionEvent.ACTION_CANCEL)) {
checkEndState();
+ if (mCurrentView != null) {
+ FilterRepresentation representation = mCurrentView.getState().getFilterRepresentation();
+ if (representation.getEditorId() == ImageOnlyEditor.ID) {
+ mCurrentView.setSelected(false);
+ }
+ }
}
return true;
}
public void onDraw(Canvas canvas) {
canvas.drawARGB(0, 0, 0, 0);
+ mPaint.reset();
mPath.reset();
float w = canvas.getWidth();