Search in sources :

Example 1 with InternalPlugin

use of com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin in project mobile-android by photo.

the class BordersPanel method loadNativeFilter.

protected INativeFilter loadNativeFilter(final EffectPack pack, int position, final CharSequence label, boolean hires) {
    BorderFilter filter = (BorderFilter) FilterLoaderFactory.get(Filters.BORDERS);
    filter.setBorderName(label);
    filter.setHiRes(hires);
    IPlugin plugin = pack.mPluginRef;
    if (null != plugin) {
        if (plugin instanceof InternalPlugin) {
            filter.setSourceApp(((InternalPlugin) plugin).getSourceDir(mPluginType));
            // border size
            int[] sizes = ((InternalPlugin) plugin).listBordersWidths();
            position -= pack.getIndex();
            if (null != sizes && sizes.length > (position - 1) && position > 0) {
                int borderSize = sizes[position - 1];
                filter.setSize((double) borderSize / 100.0);
            }
        }
    }
    return filter;
}
Also used : InternalPlugin(com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin) BorderFilter(com.aviary.android.feather.library.filters.BorderFilter) Point(android.graphics.Point) IPlugin(com.aviary.android.feather.library.plugins.PluginManager.IPlugin)

Example 2 with InternalPlugin

use of com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin in project mobile-android by photo.

the class StickersPanel method startDrag.

// ////////////////////////
// Drag and Drop methods //
// ////////////////////////
/**
	 * Starts the drag and drop operation
	 * 
	 * @param parent
	 *           - the parent list
	 * @param view
	 *           - the current view clicked
	 * @param position
	 *           - the position in the list
	 * @param id
	 *           - the item id
	 * @param nativeClick
	 *           - it's a native click
	 * @return
	 */
private boolean startDrag(AdapterView<?> parent, View view, int position, long id, boolean animate) {
    mLogger.info("startDrag");
    if (android.os.Build.VERSION.SDK_INT < 9)
        return false;
    if (parent == null || view == null || parent.getAdapter() == null) {
        return false;
    }
    if (mStatus.getCurrentStatus() != STATUS_STICKERS)
        return false;
    if (mPlugin == null || !(mPlugin instanceof InternalPlugin))
        return false;
    if (null != view) {
        View image = view.findViewById(R.id.image);
        if (null != image) {
            final String dragInfo = (String) parent.getAdapter().getItem(position);
            int size = mThumbSize;
            Bitmap bitmap;
            try {
                bitmap = ImageLoader.getPluginItemBitmap((InternalPlugin) mPlugin, dragInfo, FeatherIntent.PluginType.TYPE_STICKER, StickerType.Small, size, size);
                int offsetx = Math.abs(image.getWidth() - bitmap.getWidth()) / 2;
                int offsety = Math.abs(image.getHeight() - bitmap.getHeight()) / 2;
                return getDragController().startDrag(image, bitmap, offsetx, offsety, StickersPanel.this, dragInfo, DragControllerService.DRAG_ACTION_MOVE, animate);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return getDragController().startDrag(image, StickersPanel.this, dragInfo, DragControllerService.DRAG_ACTION_MOVE, animate);
        }
    }
    return false;
}
Also used : InternalPlugin(com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin) SimpleCachedRemoteBitmap(com.aviary.android.feather.library.services.ImageCacheService.SimpleCachedRemoteBitmap) Bitmap(android.graphics.Bitmap) ImageView(android.widget.ImageView) DragView(com.aviary.android.feather.library.services.drag.DragView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) DrawableHighlightView(com.aviary.android.feather.widget.DrawableHighlightView) HorizontalVariableListView(com.aviary.android.feather.widget.HorizontalVariableListView) Paint(android.graphics.Paint) Point(android.graphics.Point) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 3 with InternalPlugin

use of com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin in project mobile-android by photo.

the class StickersPanel method addSticker.

/**
	 * Add a new sticker to the canvas.
	 * 
	 * @param drawable
	 *           - the drawable name
	 */
private void addSticker(String drawable, RectF position) {
    if (mPlugin == null || !(mPlugin instanceof InternalPlugin)) {
        return;
    }
    final InternalPlugin plugin = (InternalPlugin) mPlugin;
    onApplyCurrent();
    final boolean rotateAndResize = true;
    InputStream stream = null;
    try {
        stream = plugin.getStickerStream(drawable, StickerType.Small);
    } catch (Exception e) {
        e.printStackTrace();
        onGenericError("Failed to load the selected sticker");
        return;
    }
    if (stream != null) {
        StickerDrawable d = new StickerDrawable(plugin.getResources(), stream, drawable, plugin.getLabel(FeatherIntent.PluginType.TYPE_STICKER).toString());
        d.setAntiAlias(true);
        IOUtils.closeSilently(stream);
        // adding the required action
        ApplicationInfo info = PackageManagerUtils.getApplicationInfo(getContext().getBaseContext(), mPlugin.getPackageName());
        if (info != null) {
            String sourceDir = plugin.getSourceDir(PluginType.TYPE_STICKER);
            if (null == sourceDir) {
                sourceDir = "";
                mLogger.error("Cannot find the source dir");
            }
            mCurrentFilter = new StickerFilter(sourceDir, drawable);
            mCurrentFilter.setSize(d.getBitmapWidth(), d.getBitmapHeight());
            mCurrentFilter.setExternal(0);
            Tracker.recordTag(drawable + ": Selected");
            addSticker(d, rotateAndResize, position);
        } else {
            onGenericError("Sorry I'm not able to load the selected sticker");
        }
    }
}
Also used : InternalPlugin(com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin) InputStream(java.io.InputStream) StickerFilter(com.aviary.android.feather.library.filters.StickerFilter) ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) StickerDrawable(com.aviary.android.feather.library.graphics.drawable.StickerDrawable)

Aggregations

InternalPlugin (com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin)3 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)2 Point (android.graphics.Point)2 ApplicationInfo (android.content.pm.ApplicationInfo)1 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BorderFilter (com.aviary.android.feather.library.filters.BorderFilter)1 StickerFilter (com.aviary.android.feather.library.filters.StickerFilter)1 StickerDrawable (com.aviary.android.feather.library.graphics.drawable.StickerDrawable)1 IPlugin (com.aviary.android.feather.library.plugins.PluginManager.IPlugin)1 SimpleCachedRemoteBitmap (com.aviary.android.feather.library.services.ImageCacheService.SimpleCachedRemoteBitmap)1 DragView (com.aviary.android.feather.library.services.drag.DragView)1 DrawableHighlightView (com.aviary.android.feather.widget.DrawableHighlightView)1 HorizontalVariableListView (com.aviary.android.feather.widget.HorizontalVariableListView)1 InputStream (java.io.InputStream)1