Search in sources :

Example 1 with FilterShowActivity

use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.

the class ImageCrop method forceStateConsistency.

private void forceStateConsistency() {
    MasterImage master = MasterImage.getImage();
    Bitmap image = master.getFiltersOnlyImage();
    FilterShowActivity filterShowActivity = (FilterShowActivity) getContext();
    boolean isReload = filterShowActivity.isReloadByConfigurationChanged();
    int width = image.getWidth();
    int height = image.getHeight();
    if (mCropObj == null || (!mUpdateHolder.equals(mGeometry) && !isReload) || mImageBounds.width() != width || mImageBounds.height() != height || !mLocalRep.getCrop().equals(mUpdateHolder.crop)) {
        mImageBounds.set(0, 0, width, height);
        mGeometry.set(mUpdateHolder);
        mLocalRep.setCrop(mUpdateHolder.crop);
        RectF scaledCrop = new RectF(mUpdateHolder.crop);
        FilterCropRepresentation.findScaledCrop(scaledCrop, width, height);
        mCropObj = new CropObject(mImageBounds, scaledCrop, (int) mUpdateHolder.straighten);
        mState = Mode.NONE;
        clearDisplay();
    }
}
Also used : RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) FilterShowActivity(com.android.gallery3d.filtershow.FilterShowActivity) CropObject(com.android.gallery3d.filtershow.crop.CropObject) Paint(android.graphics.Paint)

Example 2 with FilterShowActivity

use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.

the class ImageCrop method onSizeChanged.

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    FilterShowActivity filterShowActivity = (FilterShowActivity) getContext();
    if (filterShowActivity.isShowEditCropPanel()) {
        updateMatrix(w, h);
    } else {
        clearDisplay();
    }
}
Also used : FilterShowActivity(com.android.gallery3d.filtershow.FilterShowActivity)

Example 3 with FilterShowActivity

use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.

the class StateView method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean ret = super.onTouchEvent(event);
    FilterShowActivity activity = (FilterShowActivity) getContext();
    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
        activity.startTouchAnimation(this, event.getX(), event.getY());
    }
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        mStartTouchY = event.getY();
        mStartTouchX = event.getX();
        if (mType == BEGIN) {
            MasterImage.getImage().setShowsOriginal(true);
        }
    }
    if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
        setTranslationX(0);
        setTranslationY(0);
        MasterImage.getImage().setShowsOriginal(false);
        if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_UP) {
            setSelected(true);
            FilterRepresentation representation = getState().getFilterRepresentation();
            MasterImage image = MasterImage.getImage();
            ImagePreset preset = image != null ? image.getCurrentPreset() : null;
            if (getTranslationY() == 0 && image != null && preset != null && representation != image.getCurrentFilterRepresentation() && preset.getRepresentation(representation) != null) {
                activity.showRepresentation(representation);
                setSelected(false);
            }
        }
    }
    if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        float delta = event.getY() - mStartTouchY;
        if (Math.abs(delta) > mDeleteSlope) {
            activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
        }
    }
    return true;
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterShowActivity(com.android.gallery3d.filtershow.FilterShowActivity) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 4 with FilterShowActivity

use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.

the class ImageCurves method showPopupMenu.

private void showPopupMenu(LinearLayout accessoryViewList) {
    final Button button = (Button) accessoryViewList.findViewById(R.id.applyEffect);
    if (button == null) {
        return;
    }
    if (mIdStrLut == null) {
        mIdStrLut = new HashMap<Integer, String>();
        mIdStrLut.put(R.id.curve_menu_rgb, getContext().getString(R.string.curves_channel_rgb));
        mIdStrLut.put(R.id.curve_menu_red, getContext().getString(R.string.curves_channel_red));
        mIdStrLut.put(R.id.curve_menu_green, getContext().getString(R.string.curves_channel_green));
        mIdStrLut.put(R.id.curve_menu_blue, getContext().getString(R.string.curves_channel_blue));
    }
    PopupMenu popupMenu = new PopupMenu(getActivity(), button);
    popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_curves, popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            setChannel(item.getItemId());
            button.setText(mIdStrLut.get(item.getItemId()));
            return true;
        }
    });
    Editor.hackFixStrings(popupMenu.getMenu());
    popupMenu.show();
    ((FilterShowActivity) getContext()).onShowMenu(popupMenu);
}
Also used : Button(android.widget.Button) MenuItem(android.view.MenuItem) FilterShowActivity(com.android.gallery3d.filtershow.FilterShowActivity) PopupMenu(android.widget.PopupMenu)

Example 5 with FilterShowActivity

use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.

the class CategoryView method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean ret = super.onTouchEvent(event);
    FilterShowActivity activity = (FilterShowActivity) getContext();
    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
        activity.startTouchAnimation(this, event.getX(), event.getY());
    }
    if (!canBeRemoved() || checkPreset()) {
        return ret;
    }
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        mStartTouchY = event.getY();
        mStartTouchX = event.getX();
    }
    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
        setTranslationX(0);
        setTranslationY(0);
    }
    if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        float delta = event.getY() - mStartTouchY;
        if (getOrientation() == CategoryView.VERTICAL) {
            delta = event.getX() - mStartTouchX;
        }
        if (Math.abs(delta) > mDeleteSlope) {
            activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
        }
    }
    return true;
}
Also used : FilterShowActivity(com.android.gallery3d.filtershow.FilterShowActivity)

Aggregations

FilterShowActivity (com.android.gallery3d.filtershow.FilterShowActivity)48 View (android.view.View)11 Button (android.widget.Button)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)5 TextView (android.widget.TextView)5 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)5 MenuItem (android.view.MenuItem)4 PopupMenu (android.widget.PopupMenu)4 DialogInterface (android.content.DialogInterface)3 LayoutInflater (android.view.LayoutInflater)3 ViewGroup (android.view.ViewGroup)3 Point (android.graphics.Point)2 Fragment (android.support.v4.app.Fragment)2 FragmentManager (android.support.v4.app.FragmentManager)2 OnClickListener (android.view.View.OnClickListener)2 ImageButton (android.widget.ImageButton)2 MasterImage (com.android.gallery3d.filtershow.imageshow.MasterImage)2 StatePanel (com.android.gallery3d.filtershow.state.StatePanel)2 DoNotShowAgainDialog (com.android.gallery3d.filtershow.ui.DoNotShowAgainDialog)2 AlertDialog (android.app.AlertDialog)1