<item
android:id="@+id/manageUserPresets"
android:showAsAction="never"
- android:visible="true"
+ android:visible="false"
android:title="@string/filtershow_manage_preset" />
<item
android:id="@+id/exportFlattenButton"
getString(R.string.filtershow_version_current), current, -1);
mCategoryVersionsAdapter.add(
new Action(this, currentRep, Action.FULL_VIEW));
+ if (mVersions.size() > 0) {
+ mCategoryVersionsAdapter.add(new Action(this, Action.SPACER));
+ }
for (FilterUserPresetRepresentation rep : mVersions) {
mCategoryVersionsAdapter.add(
- new Action(this, rep, Action.FULL_VIEW));
+ new Action(this, rep, Action.FULL_VIEW, true));
}
mCategoryVersionsAdapter.notifyDataSetInvalidated();
}
return false;
}
+ public void addNewPreset() {
+ DialogFragment dialog = new PresetManagementDialog();
+ dialog.show(getSupportFragmentManager(), "NoticeDialogFragment");
+ }
+
private void manageUserPresets() {
DialogFragment dialog = new PresetManagementDialog();
dialog.show(getSupportFragmentManager(), "NoticeDialogFragment");
if (mCategoryLooksAdapter != null) {
fillLooks();
}
+ if (presets.size() > 0) {
+ mCategoryLooksAdapter.add(new Action(this, Action.SPACER));
+ }
mUserPresetsAdapter.clear();
for (int i = 0; i < presets.size(); i++) {
FilterUserPresetRepresentation representation = presets.get(i);
new Action(this, representation, Action.FULL_VIEW));
mUserPresetsAdapter.add(new Action(this, representation, Action.FULL_VIEW));
}
+ if (presets.size() > 0) {
+ mCategoryLooksAdapter.add(new Action(this, Action.ADD_ACTION));
+ }
mCategoryLooksAdapter.notifyDataSetInvalidated();
-
}
public void saveCurrentImagePreset() {
for (FilterRepresentation representation : filtersRepresentations) {
mCategoryLooksAdapter.add(new Action(this, representation, Action.FULL_VIEW));
}
+ if (mUserPresetsManager.getRepresentations() == null
+ || mUserPresetsManager.getRepresentations().size() == 0) {
+ mCategoryLooksAdapter.add(new Action(this, Action.ADD_ACTION));
+ }
}
public void setDefaultPreset() {
private ArrayAdapter mAdapter;
public static final int FULL_VIEW = 0;
public static final int CROP_VIEW = 1;
+ public static final int ADD_ACTION = 2;
+ public static final int SPACER = 3;
private int mType = CROP_VIEW;
private Bitmap mPortraitImage;
private Bitmap mOverlayBitmap;
private Context mContext;
+ private boolean mCanBeRemoved = false;
+
+ public Action(Context context, FilterRepresentation representation, int type,
+ boolean canBeRemoved) {
+ this(context, representation, type);
+ mCanBeRemoved = canBeRemoved;
+ }
public Action(Context context, FilterRepresentation representation, int type) {
- mContext = context;
+ this(context, type);
setRepresentation(representation);
+ }
+
+ public Action(Context context, int type) {
+ mContext = context;
setType(type);
}
this(context, representation, CROP_VIEW);
}
+ public boolean canBeRemoved() {
+ return mCanBeRemoved;
+ }
+
public int getType() {
return mType;
}
}
CategoryView view = (CategoryView) convertView;
view.setOrientation(mOrientation);
- view.setAction(getItem(position), this);
+ Action action = getItem(position);
+ view.setAction(action, this);
+ int width = mItemWidth;
+ if (action.getType() == Action.SPACER) {
+ width = width / 2;
+ }
view.setLayoutParams(
- new ListView.LayoutParams(mItemWidth, mItemHeight));
+ new ListView.LayoutParams(width, mItemHeight));
view.setTag(position);
view.invalidate();
return view;
}
if (rep != null) {
for (int i = 0; i < getCount(); i++) {
+ FilterRepresentation itemRep = getItem(i).getRepresentation();
+ if (itemRep == null) {
+ continue;
+ }
if (rep.getName().equalsIgnoreCase(
- getItem(i).getRepresentation().getName())) {
+ itemRep.getName())) {
selected = i;
break;
}
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
private int mBorderStroke;
private float mStartTouchY = 0;
private float mDeleteSlope = 20;
+ private int mSelectionColor = Color.WHITE;
+ private int mSpacerColor = Color.WHITE;
+ private boolean mCanBeRemoved = false;
public CategoryView(Context context) {
super(context);
mSelectionStroke = res.getDimensionPixelSize(R.dimen.thumbnail_margin);
mSelectPaint = new Paint();
mSelectPaint.setStyle(Paint.Style.FILL);
- mSelectPaint.setColor(res.getColor(R.color.filtershow_category_selection));
+ mSelectionColor = res.getColor(R.color.filtershow_category_selection);
+ mSpacerColor = res.getColor(R.color.filtershow_categoryview_text);
+
+ mSelectPaint.setColor(mSelectionColor);
mBorderPaint = new Paint(mSelectPaint);
mBorderPaint.setColor(Color.BLACK);
mBorderStroke = mSelectionStroke / 3;
return false;
}
+ private boolean canBeRemoved() {
+ return mCanBeRemoved;
+ }
+
+ private void drawSpacer(Canvas canvas) {
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
+ mPaint.setColor(mSpacerColor);
+ canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 5, mPaint);
+ }
+
public void onDraw(Canvas canvas) {
if (mAction != null) {
+ if (mAction.getType() == Action.SPACER) {
+ drawSpacer(canvas);
+ return;
+ }
if (mAction.getImage() == null) {
mAction.setImageFrame(new Rect(0, 0, getWidth(), getHeight()), getOrientation());
} else {
mAction = action;
setText(mAction.getName());
mAdapter = adapter;
+ mCanBeRemoved = action.canBeRemoved();
invalidate();
+ if (mAction.getType() == Action.ADD_ACTION) {
+ Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.filtershow_add);
+ setBitmap(bitmap);
+ setUseOnlyDrawable(true);
+ setText(getResources().getString(R.string.filtershow_add_button_looks));
+ }
}
@Override
public void onClick(View view) {
FilterShowActivity activity = (FilterShowActivity) getContext();
- activity.showRepresentation(mAction.getRepresentation());
- mAdapter.setSelected(this);
+ if (mAction.getType() == Action.ADD_ACTION) {
+ activity.addNewPreset();
+ } else if (mAction.getType() != Action.SPACER) {
+ activity.showRepresentation(mAction.getRepresentation());
+ mAdapter.setSelected(this);
+ }
}
@Override
public boolean onTouchEvent(MotionEvent event) {
- super.onTouchEvent(event);
+ boolean ret = super.onTouchEvent(event);
+ if (!canBeRemoved()) {
+ return ret;
+ }
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mStartTouchY = event.getY();
}
"http://schemas.android.com/apk/res/android", "src", 0);
Resources res = context.getResources();
Bitmap bitmap = BitmapFactory.decodeStream(res.openRawResource(bitmapRsc));
- mUseOnlyDrawable = true;
setBitmap(bitmap);
+ setUseOnlyDrawable(true);
}
public IconView(Context context) {
mBitmap = bitmap;
}
+ public void setUseOnlyDrawable(boolean value) {
+ mUseOnlyDrawable = value;
+ }
+
public Rect getBitmapBounds() {
return mBitmapBounds;
}