Search in sources :

Example 1 with AdapterView

use of com.aviary.android.feather.widget.AdapterView in project mobile-android by photo.

the class DelayedSpotDrawPanel method onCreate.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.aviary.android.feather.effects.AbstractEffectPanel#onCreate(android.graphics.Bitmap)
	 */
@Override
public void onCreate(Bitmap bitmap) {
    super.onCreate(bitmap);
    ConfigService config = getContext().getService(ConfigService.class);
    mBrushSizes = config.getSizeArray(R.array.feather_spot_brush_sizes);
    mBrushSize = mBrushSizes[0];
    defaultOption = Math.min(mBrushSizes.length - 1, Math.max(0, config.getInteger(R.integer.feather_spot_brush_selected_size_index)));
    mLensButton = (ImageButton) getContentView().findViewById(R.id.lens_button);
    mImageView = (ImageViewSpotDraw) getContentView().findViewById(R.id.image);
    ((ImageViewSpotDraw) mImageView).setBrushSize((float) mBrushSize);
    ((ImageViewSpotDraw) mImageView).setDrawLimit(mLimitDrawArea ? 1000.0 : 0.0);
    mPreview = BitmapUtils.copy(mBitmap, Config.ARGB_8888);
    mImageView.setImageBitmap(mPreview, true, getContext().getCurrentImageViewMatrix(), UIConfiguration.IMAGE_VIEW_MAX_ZOOM);
    mGallery = (Gallery) getOptionView().findViewById(R.id.gallery);
    mGallery.setCallbackDuringFling(false);
    mGallery.setSpacing(0);
    mGallery.setOnItemsScrollListener(new OnItemsScrollListener() {

        @Override
        public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
            mBrushSize = mBrushSizes[position];
            ((ImageViewSpotDraw) mImageView).setBrushSize((float) mBrushSize);
            setSelectedTool(TouchMode.DRAW);
            updateSelection(view, position);
            hideSizePreview();
        }

        @Override
        public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
            showSizePreview(mBrushSizes[position]);
            setSelectedTool(TouchMode.DRAW);
        }

        @Override
        public void onScroll(AdapterView<?> parent, View view, int position, long id) {
            updateSizePreview(mBrushSizes[position]);
        }
    });
    mBackgroundDrawThread = new MyHandlerThread("filter-thread", Thread.MIN_PRIORITY);
    initAdapter();
}
Also used : ConfigService(com.aviary.android.feather.library.services.ConfigService) OnItemsScrollListener(com.aviary.android.feather.widget.Gallery.OnItemsScrollListener) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(com.aviary.android.feather.widget.AdapterView) ImageViewSpotDraw(com.aviary.android.feather.widget.ImageViewSpotDraw)

Example 2 with AdapterView

use of com.aviary.android.feather.widget.AdapterView in project mobile-android by photo.

the class SpotDrawPanel method onCreate.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.aviary.android.feather.effects.AbstractEffectPanel#onCreate(android.graphics.Bitmap)
	 */
@Override
public void onCreate(Bitmap bitmap) {
    super.onCreate(bitmap);
    mFilter = createFilter();
    ConfigService config = getContext().getService(ConfigService.class);
    mBrushSizes = config.getSizeArray(R.array.feather_spot_brush_sizes);
    mBrushSize = mBrushSizes[0];
    mLensButton = (ImageButton) getContentView().findViewById(R.id.lens_button);
    mImageView = (ImageViewSpotDraw) getContentView().findViewById(R.id.image);
    ((ImageViewSpotDraw) mImageView).setBrushSize((float) mBrushSize);
    mPreview = BitmapUtils.copy(mBitmap, Config.ARGB_8888);
    mPreviewWidth = mPreview.getWidth();
    mPreviewHeight = mPreview.getHeight();
    mImageView.setImageBitmap(mPreview, true, getContext().getCurrentImageViewMatrix(), UIConfiguration.IMAGE_VIEW_MAX_ZOOM);
    int defaultOption = config.getInteger(R.integer.feather_spot_brush_selected_size_index);
    defaultOption = Math.min(Math.max(defaultOption, 0), mBrushSizes.length - 1);
    mGallery = (Gallery) getOptionView().findViewById(R.id.gallery);
    mGallery.setCallbackDuringFling(false);
    mGallery.setSpacing(0);
    mGallery.setOnItemsScrollListener(new OnItemsScrollListener() {

        @Override
        public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
            mLogger.info("onScrollFinished: " + position);
            mBrushSize = mBrushSizes[position];
            ((ImageViewSpotDraw) mImageView).setBrushSize((float) mBrushSize);
            setSelectedTool(TouchMode.DRAW);
            updateSelection(view, position);
            hideSizePreview();
        }

        @Override
        public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
            showSizePreview(mBrushSizes[position]);
            setSelectedTool(TouchMode.DRAW);
        }

        @Override
        public void onScroll(AdapterView<?> parent, View view, int position, long id) {
            updateSizePreview(mBrushSizes[position]);
        }
    });
    mBackgroundDrawThread = new MyHandlerThread("filter-thread", Thread.MIN_PRIORITY);
    initAdapter();
}
Also used : ConfigService(com.aviary.android.feather.library.services.ConfigService) OnItemsScrollListener(com.aviary.android.feather.widget.Gallery.OnItemsScrollListener) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(com.aviary.android.feather.widget.AdapterView) ImageViewSpotDraw(com.aviary.android.feather.widget.ImageViewSpotDraw)

Example 3 with AdapterView

use of com.aviary.android.feather.widget.AdapterView in project mobile-android by photo.

the class TextPanel method onCreate.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.aviary.android.feather.effects.AbstractEffectPanel#onCreate(android.graphics.Bitmap)
	 */
@Override
public void onCreate(final Bitmap bitmap) {
    super.onCreate(bitmap);
    config = getContext().getService(ConfigService.class);
    mColors = config.getIntArray(R.array.feather_text_fill_colors);
    mStrokeColors = config.getIntArray(R.array.feather_text_stroke_colors);
    mSelectedPosition = config.getInteger(R.integer.feather_text_selected_color);
    mColor = mColors[mSelectedPosition];
    mStrokeColor = mStrokeColors[mSelectedPosition];
    mGallery = (Gallery) getOptionView().findViewById(R.id.gallery);
    mGallery.setCallbackDuringFling(false);
    mGallery.setSpacing(0);
    mGallery.setAdapter(new GalleryAdapter(getContext().getBaseContext(), mColors));
    mGallery.setSelection(mSelectedPosition, false, true);
    mGallery.setOnItemsScrollListener(new OnItemsScrollListener() {

        @Override
        public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
            updateSelection(view, position);
            final int color = mColors[position];
            mColor = color;
            mStrokeColor = mStrokeColors[position];
            updateCurrentHighlightColor();
            updateColorButtonBitmap();
        }

        @Override
        public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onScroll(AdapterView<?> parent, View view, int position, long id) {
        // TODO Auto-generated method stub
        }
    });
    mEditText = (EditText) getContentView().findViewById(R.id.invisible_text);
    mImageView = (ImageViewTouch) getContentView().findViewById(R.id.overlay);
    mImageView.setDoubleTapEnabled(false);
    createAndConfigurePreview();
    updateColorButtonBitmap();
    mImageView.setImageBitmap(mPreview, true, getContext().getCurrentImageViewMatrix(), UIConfiguration.IMAGE_VIEW_MAX_ZOOM);
}
Also used : ConfigService(com.aviary.android.feather.library.services.ConfigService) OnItemsScrollListener(com.aviary.android.feather.widget.Gallery.OnItemsScrollListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AdapterView(com.aviary.android.feather.widget.AdapterView) DrawableHighlightView(com.aviary.android.feather.widget.DrawableHighlightView) Paint(android.graphics.Paint)

Example 4 with AdapterView

use of com.aviary.android.feather.widget.AdapterView in project mobile-android by photo.

the class CropPanel method onActivate.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.aviary.android.feather.effects.AbstractEffectPanel#onActivate()
	 */
@Override
public void onActivate() {
    super.onActivate();
    int position = mGallery.getSelectedItemPosition();
    final double ratio = calculateAspectRatio(position, false);
    disableHapticIsNecessary(mGallery);
    setIsChanged(true);
    contentReady();
    mGallery.setOnItemsScrollListener(new OnItemsScrollListener() {

        @Override
        public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
            if (!isActive())
                return;
            if (position == mSelectedPosition) {
                if (!strict && !nonInvertOptions.contains(position)) {
                    isChecked = !isChecked;
                    CropImageView cview = (CropImageView) mImageView;
                    double currentAspectRatio = cview.getAspectRatio();
                    HighlightView hv = cview.getHighlightView();
                    if (!cview.getAspectRatioIsFixed() && hv != null) {
                        currentAspectRatio = (double) hv.getDrawRect().width() / (double) hv.getDrawRect().height();
                    }
                    double invertedAspectRatio = 1 / currentAspectRatio;
                    cview.setAspectRatio(invertedAspectRatio, cview.getAspectRatioIsFixed());
                    invertRatios(mCropNames, mCropValues);
                    mGallery.invalidateViews();
                }
            } else {
                double ratio = calculateAspectRatio(position, false);
                setCustomRatio(ratio, ratio != 0);
            }
            updateSelection(view, position);
        }

        @Override
        public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
        }

        @Override
        public void onScroll(AdapterView<?> parent, View view, int position, long id) {
        }
    });
    getOptionView().getHandler().post(new Runnable() {

        @Override
        public void run() {
            createCropView(ratio, ratio != 0);
            updateSelection((View) mGallery.getSelectedView(), mGallery.getSelectedItemPosition());
        }
    });
}
Also used : HighlightView(com.aviary.android.feather.widget.HighlightView) OnItemsScrollListener(com.aviary.android.feather.widget.Gallery.OnItemsScrollListener) CropImageView(com.aviary.android.feather.widget.CropImageView) View(android.view.View) CropImageView(com.aviary.android.feather.widget.CropImageView) HighlightView(com.aviary.android.feather.widget.HighlightView) TextView(android.widget.TextView) AdapterView(com.aviary.android.feather.widget.AdapterView) Paint(android.graphics.Paint)

Example 5 with AdapterView

use of com.aviary.android.feather.widget.AdapterView in project mobile-android by photo.

the class DrawingPanel method onActivate.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.aviary.android.feather.effects.AbstractEffectPanel#onActivate()
	 */
@Override
public void onActivate() {
    super.onActivate();
    disableHapticIsNecessary(mGalleryColor, mGallerySize);
    initToast();
    mGallerySize.setOnItemsScrollListener(new OnItemsScrollListener() {

        @Override
        public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
            mSize = (Integer) mGallerySize.getAdapter().getItem(position);
            final boolean soft = ((GallerySizeAdapter) mGallerySize.getAdapter()).getIsSoft(position);
            if (soft)
                mPaint.setMaskFilter(new BlurMaskFilter(mBlur, Blur.NORMAL));
            else
                mPaint.setMaskFilter(null);
            updatePaint();
            updateSelectedSize(view, position);
            hideToastPreview();
        }

        @Override
        public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
            showToastPreview();
            if (getSelectedTool() == DrawinTool.Zoom) {
                setSelectedTool(DrawinTool.Draw);
            }
        }

        @Override
        public void onScroll(AdapterView<?> parent, View view, int position, long id) {
            GallerySizeAdapter adapter = (GallerySizeAdapter) parent.getAdapter();
            int size = (Integer) adapter.getItem(position);
            int blur = adapter.getIsSoft(position) ? mBlur : 0;
            boolean is_eraser = mGalleryColor.getSelectedItemPosition() == 0 || mGalleryColor.getSelectedItemPosition() == mGalleryColor.getAdapter().getCount() - 1;
            if (is_eraser) {
                updateToastPreview(size, Color.WHITE, blur, true);
            } else {
                updateToastPreview(size, mColor, blur, false);
            }
        }
    });
    mGalleryColor.setOnItemsScrollListener(new OnItemsScrollListener() {

        @Override
        public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
            mColor = (Integer) parent.getAdapter().getItem(position);
            final boolean is_eraser = position == 0 || (position == parent.getAdapter().getCount() - 1);
            if (is_eraser) {
                mColor = 0;
            }
            mPaint.setColor(mColor);
            if (getSelectedTool() == DrawinTool.Zoom) {
                if (is_eraser)
                    setSelectedTool(DrawinTool.Erase);
                else
                    setSelectedTool(DrawinTool.Draw);
            } else {
                if (is_eraser && getSelectedTool() != DrawinTool.Erase)
                    setSelectedTool(DrawinTool.Erase);
                else if (!is_eraser && getSelectedTool() != DrawinTool.Draw)
                    setSelectedTool(DrawinTool.Draw);
            }
            updatePaint();
            updateSelectedColor(view, position);
            hideToastPreview();
        }

        @Override
        public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
            showToastPreview();
            if (getSelectedTool() == DrawinTool.Zoom) {
                setSelectedTool(DrawinTool.Draw);
            }
        }

        @Override
        public void onScroll(AdapterView<?> parent, View view, int position, long id) {
            final boolean is_eraser = position == 0 || (position == parent.getAdapter().getCount() - 1);
            if (is_eraser) {
                updateToastPreview(mSize, Color.WHITE, mBlur, true);
            } else {
                updateToastPreview(mSize, mBrushColors[position], mBlur, false);
            }
        }
    });
    mLensButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            boolean selected = arg0.isSelected();
            arg0.setSelected(!selected);
            if (arg0.isSelected()) {
                setSelectedTool(DrawinTool.Zoom);
            } else {
                if (mGalleryColor.getSelectedItemPosition() == 0) {
                    setSelectedTool(DrawinTool.Erase);
                } else {
                    setSelectedTool(DrawinTool.Draw);
                }
                updatePaint();
            }
        }
    });
    setSelectedTool(DrawinTool.Draw);
    updatePaint();
    updateSelectedSize((View) mGallerySize.getSelectedView(), mGallerySize.getSelectedItemPosition());
    updateSelectedColor((View) mGalleryColor.getSelectedView(), mGalleryColor.getSelectedItemPosition());
    ((ImageViewTouchAndDraw) mImageView).setOnDrawStartListener(this);
    ((ImageViewTouchAndDraw) mImageView).setOnDrawPathListener(this);
    mLensButton.setVisibility(View.VISIBLE);
    getContentView().setVisibility(View.VISIBLE);
    contentReady();
}
Also used : OnClickListener(android.view.View.OnClickListener) ImageViewTouchAndDraw(com.aviary.android.feather.widget.ImageViewTouchAndDraw) BlurMaskFilter(android.graphics.BlurMaskFilter) OnItemsScrollListener(com.aviary.android.feather.widget.Gallery.OnItemsScrollListener) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(com.aviary.android.feather.widget.AdapterView) Paint(android.graphics.Paint)

Aggregations

View (android.view.View)5 AdapterView (com.aviary.android.feather.widget.AdapterView)5 OnItemsScrollListener (com.aviary.android.feather.widget.Gallery.OnItemsScrollListener)5 ImageView (android.widget.ImageView)4 Paint (android.graphics.Paint)3 ConfigService (com.aviary.android.feather.library.services.ConfigService)3 TextView (android.widget.TextView)2 ImageViewSpotDraw (com.aviary.android.feather.widget.ImageViewSpotDraw)2 BlurMaskFilter (android.graphics.BlurMaskFilter)1 OnClickListener (android.view.View.OnClickListener)1 CropImageView (com.aviary.android.feather.widget.CropImageView)1 DrawableHighlightView (com.aviary.android.feather.widget.DrawableHighlightView)1 HighlightView (com.aviary.android.feather.widget.HighlightView)1 ImageViewTouchAndDraw (com.aviary.android.feather.widget.ImageViewTouchAndDraw)1