use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class StickersPanel method onClearCurrent.
/**
* Removes the current active sticker.
*
* @param hv
* - the {@link DrawableHighlightView} of the active sticker
* @param removed
* - current sticker is removed
*/
private void onClearCurrent(DrawableHighlightView hv, boolean removed) {
mLogger.info("onClearCurrent. hv=" + hv + ", removed=" + removed);
if (mCurrentFilter != null) {
mCurrentFilter = null;
}
if (null != hv) {
FeatherDrawable content = hv.getContent();
if (removed) {
if (content instanceof StickerDrawable) {
String name = ((StickerDrawable) content).getStickerName();
String packname = ((StickerDrawable) content).getPackLabel();
Tracker.recordTag(name + ": Cancelled");
Tracker.recordTag(packname + ": Cancelled");
}
}
}
hv.setOnDeleteClickListener(null);
((ImageViewDrawableOverlay) mImageView).removeHightlightView(hv);
((ImageViewDrawableOverlay) mImageView).invalidate();
}
use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class StickersPanel method onApplyCurrent.
/**
* Flatten the current sticker within the preview bitmap. No more changes will be possible on this sticker.
*/
private void onApplyCurrent() {
mLogger.info("onApplyCurrent");
if (!stickersOnScreen())
return;
final DrawableHighlightView hv = ((ImageViewDrawableOverlay) mImageView).getHighlightViewAt(0);
if (hv != null) {
final StickerDrawable stickerDrawable = ((StickerDrawable) hv.getContent());
RectF cropRect = hv.getCropRectF();
Rect rect = new Rect((int) cropRect.left, (int) cropRect.top, (int) cropRect.right, (int) cropRect.bottom);
Matrix rotateMatrix = hv.getCropRotationMatrix();
Matrix matrix = new Matrix(mImageView.getImageMatrix());
if (!matrix.invert(matrix)) {
}
int saveCount = mCanvas.save(Canvas.MATRIX_SAVE_FLAG);
mCanvas.concat(rotateMatrix);
stickerDrawable.setDropShadow(false);
hv.getContent().setBounds(rect);
hv.getContent().draw(mCanvas);
mCanvas.restoreToCount(saveCount);
mImageView.invalidate();
if (mCurrentFilter != null) {
final int w = mBitmap.getWidth();
final int h = mBitmap.getHeight();
mCurrentFilter.setTopLeft(cropRect.left / w, cropRect.top / h);
mCurrentFilter.setBottomRight(cropRect.right / w, cropRect.bottom / h);
mCurrentFilter.setRotation(Math.toRadians(hv.getRotation()));
int dw = stickerDrawable.getBitmapWidth();
int dh = stickerDrawable.getBitmapHeight();
float scalew = cropRect.width() / dw;
float scaleh = cropRect.height() / dh;
mCurrentFilter.setCenter(cropRect.centerX() / w, cropRect.centerY() / h);
mCurrentFilter.setScale(scalew, scaleh);
mActionList.add(mCurrentFilter.getActions().get(0));
Tracker.recordTag(stickerDrawable.getPackLabel() + ": Applied");
mCurrentFilter = null;
}
}
onClearCurrent(false);
onPreviewChanged(mPreview, false);
}
use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class TextPanel method onAddNewText.
/**
* Add a new editable text on the screen.
*/
private void onAddNewText() {
final ImageViewDrawableOverlay image = (ImageViewDrawableOverlay) mImageView;
if (image.getHighlightCount() > 0)
onApplyCurrent(image.getHighlightViewAt(0));
final TextDrawable text = new TextDrawable("", defaultTextSize);
text.setTextColor(mColor);
text.setTextHint(getContext().getBaseContext().getString(R.string.enter_text_here));
final DrawableHighlightView hv = new DrawableHighlightView(mImageView, text);
final Matrix mImageMatrix = mImageView.getImageViewMatrix();
final int width = mImageView.getWidth();
final int height = mImageView.getHeight();
final int imageSize = Math.max(width, height);
// width/height of the sticker
int cropWidth = text.getIntrinsicWidth();
int cropHeight = text.getIntrinsicHeight();
final int cropSize = Math.max(cropWidth, cropHeight);
if (cropSize > imageSize) {
cropWidth = width / 2;
cropHeight = height / 2;
}
final int x = (width - cropWidth) / 2;
final int y = (height - cropHeight) / 2;
final Matrix matrix = new Matrix(mImageMatrix);
matrix.invert(matrix);
final float[] pts = new float[] { x, y, x + cropWidth, y + cropHeight };
MatrixUtils.mapPoints(matrix, pts);
final RectF cropRect = new RectF(pts[0], pts[1], pts[2], pts[3]);
final Rect imageRect = new Rect(0, 0, width, height);
hv.setRotateAndScale(true);
hv.showDelete(false);
hv.setup(mImageMatrix, imageRect, cropRect, false);
hv.drawOutlineFill(true);
hv.drawOutlineStroke(true);
hv.setPadding(textPadding);
hv.setMinSize(minTextSize);
hv.setOutlineEllipse(mHighlightEllipse);
hv.setOutlineFillColor(mHighlightFillColorStateList);
hv.setOutlineStrokeColor(mHighlightStrokeColorStateList);
Paint stroke = hv.getOutlineStrokePaint();
stroke.setStrokeWidth(mHighlightStrokeWidth);
image.addHighlightView(hv);
// image.setSelectedHighlightView( hv );
onClick(hv);
}
use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class TextPanel method updateCurrentHighlightColor.
/**
* Update current highlight color.
*/
private void updateCurrentHighlightColor() {
final ImageViewDrawableOverlay image = (ImageViewDrawableOverlay) mImageView;
if (image.getSelectedHighlightView() != null) {
final DrawableHighlightView hv = image.getSelectedHighlightView();
if (hv.getContent() instanceof EditableDrawable) {
((EditableDrawable) hv.getContent()).setTextColor(mColor);
((EditableDrawable) hv.getContent()).setTextStrokeColor(mStrokeColor);
mImageView.postInvalidate();
}
}
}
use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class TextPanel method onApplyCurrent.
/**
* apply the current text and flatten it over the image.
*/
private MoaActionList onApplyCurrent() {
final MoaActionList nullActions = MoaActionFactory.actionList();
final ImageViewDrawableOverlay image = (ImageViewDrawableOverlay) mImageView;
if (image.getHighlightCount() < 1)
return nullActions;
final DrawableHighlightView hv = ((ImageViewDrawableOverlay) mImageView).getHighlightViewAt(0);
if (hv != null) {
if (hv.getContent() instanceof EditableDrawable) {
EditableDrawable editable = (EditableDrawable) hv.getContent();
if (editable != null) {
if (editable.isTextHint()) {
setIsChanged(false);
return nullActions;
}
}
}
return onApplyCurrent(hv);
}
return nullActions;
}
Aggregations