use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class MemePanel method beginEditText.
/**
* Begin edit text.
*
* @param view
* the view
*/
private void beginEditText(final DrawableHighlightView view) {
mLogger.info("beginEditText", view);
EditText editText = null;
if (view == topHv) {
editText = editTopText;
} else if (view == bottomHv) {
editText = editBottomText;
}
if (editText != null) {
mEditTextWatcher.view = null;
editText.removeTextChangedListener(mEditTextWatcher);
final EditableDrawable editable = (EditableDrawable) view.getContent();
final String oldText = (String) editable.getText();
editText.setText(oldText);
editText.setSelection(editText.length());
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
editText.requestFocusFromTouch();
Handler handler = new Handler();
ResultReceiver receiver = new ResultReceiver(handler);
if (!mInputManager.showSoftInput(editText, 0, receiver)) {
// TODO: verify
mInputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
mEditTextWatcher.view = view;
editText.setOnEditorActionListener(this);
editText.addTextChangedListener(mEditTextWatcher);
((ImageViewDrawableOverlay) mImageView).setSelectedHighlightView(view);
((EditableDrawable) view.getContent()).setText(((EditableDrawable) view.getContent()).getText());
view.forceUpdate();
}
}
use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class StickersPanel method addSticker.
/**
* Adds the sticker.
*
* @param drawable
* - the drawable
* @param rotateAndResize
* - allow rotate and resize
*/
private void addSticker(FeatherDrawable drawable, boolean rotateAndResize, RectF positionRect) {
mLogger.info("addSticker: " + drawable + ", rotate: " + rotateAndResize + ", position: " + positionRect);
setIsChanged(true);
DrawableHighlightView hv = new DrawableHighlightView(mImageView, drawable);
hv.setOnDeleteClickListener(new OnDeleteClickListener() {
@Override
public void onDeleteClick() {
onClearCurrent(true);
}
});
Matrix mImageMatrix = mImageView.getImageViewMatrix();
int cropWidth, cropHeight;
int x, y;
final int width = mImageView.getWidth();
final int height = mImageView.getHeight();
// width/height of the sticker
if (positionRect != null) {
cropWidth = (int) positionRect.width();
cropHeight = (int) positionRect.height();
} else {
cropWidth = drawable.getIntrinsicWidth();
cropHeight = drawable.getIntrinsicHeight();
}
final int cropSize = Math.max(cropWidth, cropHeight);
final int screenSize = Math.min(mImageView.getWidth(), mImageView.getHeight());
if (cropSize > screenSize) {
float ratio;
float widthRatio = (float) mImageView.getWidth() / cropWidth;
float heightRatio = (float) mImageView.getHeight() / cropHeight;
if (widthRatio < heightRatio) {
ratio = widthRatio;
} else {
ratio = heightRatio;
}
cropWidth = (int) ((float) cropWidth * (ratio / 2));
cropHeight = (int) ((float) cropHeight * (ratio / 2));
if (positionRect == null) {
int w = mImageView.getWidth();
int h = mImageView.getHeight();
positionRect = new RectF(w / 2 - cropWidth / 2, h / 2 - cropHeight / 2, w / 2 + cropWidth / 2, h / 2 + cropHeight / 2);
}
positionRect.inset((positionRect.width() - cropWidth) / 2, (positionRect.height() - cropHeight) / 2);
}
if (positionRect != null) {
x = (int) positionRect.left;
y = (int) positionRect.top;
} else {
x = (width - cropWidth) / 2;
y = (height - cropHeight) / 2;
}
Matrix matrix = new Matrix(mImageMatrix);
matrix.invert(matrix);
float[] pts = new float[] { x, y, x + cropWidth, y + cropHeight };
MatrixUtils.mapPoints(matrix, pts);
RectF cropRect = new RectF(pts[0], pts[1], pts[2], pts[3]);
Rect imageRect = new Rect(0, 0, width, height);
hv.setRotateAndScale(rotateAndResize);
hv.setup(mImageMatrix, imageRect, cropRect, false);
hv.drawOutlineFill(true);
hv.drawOutlineStroke(true);
hv.setPadding(mStickerHvPadding);
hv.setOutlineStrokeColor(mStickerHvStrokeColorStateList);
hv.setOutlineFillColor(mStickerHvFillColorStateList);
hv.setOutlineEllipse(mStickerHvEllipse);
hv.setMinSize(mStickerHvMinSize);
Paint stroke = hv.getOutlineStrokePaint();
stroke.setStrokeWidth(mStickerHvStrokeWidth);
hv.getOutlineFillPaint().setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.SRC_ATOP));
((ImageViewDrawableOverlay) mImageView).addHighlightView(hv);
((ImageViewDrawableOverlay) mImageView).setSelectedHighlightView(hv);
}
use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class StickersPanel method onCreate.
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bitmap bitmap) {
super.onCreate(bitmap);
mStatus = new SimpleStatusMachine();
// determine if the external packs are enabled
mExternalPacksEnabled = Constants.getExternalStickersEnabled();
// init layout components
mListPacks = (HorizontalVariableListView) getOptionView().findViewById(R.id.list_packs);
mListStickers = (HorizontalVariableListView) getOptionView().findViewById(R.id.list_stickers);
mViewFlipper = (ViewFlipper) getOptionView().findViewById(R.id.flipper);
mImageView = (ImageViewDrawableOverlay) getContentView().findViewById(R.id.overlay);
// init services
mPluginService = getContext().getService(PluginService.class);
mConfigService = getContext().getService(ConfigService.class);
mPreferenceService = getContext().getService(PreferenceService.class);
mCacheService = getContext().getService(ImageCacheService.class);
// TODO: only for testing
// mCacheService.deleteCache();
// setup the main horizontal listview
mListPacks.setGravity(Gravity.BOTTOM);
mListPacks.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
mListPacks.setEdgeGravityY(Gravity.BOTTOM);
// setup the stickers listview
mListStickers.setGravity(Gravity.BOTTOM);
mListStickers.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
mListStickers.setEdgeGravityY(Gravity.BOTTOM);
// setup the main imageview
((ImageViewDrawableOverlay) mImageView).setForceSingleSelection(false);
((ImageViewDrawableOverlay) mImageView).setDropTargetListener(this);
((ImageViewDrawableOverlay) mImageView).setScaleWithContent(true);
// create the default action list
mActionList = MoaActionFactory.actionList();
// load the configuration for the sticker drawable
mStickerHvEllipse = mConfigService.getInteger(R.integer.feather_sticker_highlight_ellipse);
mStickerHvStrokeWidth = mConfigService.getInteger(R.integer.feather_sticker_highlight_stroke_width);
mStickerHvStrokeColorStateList = mConfigService.getColorStateList(R.color.feather_sticker_color_stroke_selector);
mStickerHvFillColorStateList = mConfigService.getColorStateList(R.color.feather_sticker_color_fill_selector);
mStickerHvMinSize = mConfigService.getInteger(R.integer.feather_sticker_highlight_minsize);
mStickerHvPadding = mConfigService.getInteger(R.integer.feather_sticker_highlight_padding);
mFeaturedCount = mConfigService.getInteger(R.integer.feather_featured_count);
mFeaturedDefaultTitle = mConfigService.getString(R.string.feather_featured);
// update the background drawable
View content = getOptionView().findViewById(R.id.background);
content.setBackgroundDrawable(RepeatableHorizontalDrawable.createFromView(content));
mImageManager = new AsyncImageManager();
// create the preview for the main imageview
createAndConfigurePreview();
if (android.os.Build.VERSION.SDK_INT > 8) {
DragControllerService dragger = getContext().getService(DragControllerService.class);
dragger.addDropTarget((DropTarget) mImageView);
dragger.setMoveTarget(mImageView);
dragger.setDragListener(this);
// TODO: remember to activate this!
// dragger.activate();
setDragController(dragger);
}
}
use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class StickersPanel method onClearCurrent.
/**
* Remove the current sticker.
*
* @param removed
* - true if the current sticker is being removed, otherwise it was flattened
*/
private void onClearCurrent(boolean removed) {
mLogger.info("onClearCurrent. removed=" + removed);
if (stickersOnScreen()) {
final ImageViewDrawableOverlay image = (ImageViewDrawableOverlay) mImageView;
final DrawableHighlightView hv = image.getHighlightViewAt(0);
onClearCurrent(hv, removed);
}
}
use of com.aviary.android.feather.widget.ImageViewDrawableOverlay in project mobile-android by photo.
the class MemePanel method addEditable.
/**
* Adds the editable.
*
* @param hv
* the hv
* @param imageMatrix
* the image matrix
* @param cropRect
* the crop rect
*/
private void addEditable(DrawableHighlightView hv, Matrix imageMatrix, RectF cropRect) {
final ImageViewDrawableOverlay image = (ImageViewDrawableOverlay) mImageView;
hv.setRotateAndScale(true);
hv.showAnchors(false);
hv.drawOutlineFill(false);
hv.drawOutlineStroke(false);
hv.setup(imageMatrix, null, cropRect, false);
hv.getOutlineFillPaint().setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.SRC_ATOP));
hv.setMinSize(10);
hv.setOutlineFillColor(new ColorStateList(new int[][] { { android.R.attr.state_active } }, new int[] { 0 }));
hv.setOutlineStrokeColor(new ColorStateList(new int[][] { { android.R.attr.state_active } }, new int[] { 0 }));
image.addHighlightView(hv);
}
Aggregations