Search in sources :

Example 1 with FilterRepresentation

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

the class FilterShowActivity method showRepresentation.

public void showRepresentation(FilterRepresentation representation) {
    if (representation == null) {
        return;
    }
    Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
    if (currentPanel instanceof MainPanel && ((MainPanel) currentPanel).hasEditorPanel()) {
        if (representation.equals(MasterImage.getImage().getCurrentFilterRepresentation())) {
            return;
        }
        // cancel previous filter.
        cancelCurrentFilter();
        showDefaultImageView();
        removeSeekBarPanel();
    }
    if (representation instanceof FilterRotateRepresentation) {
        FilterRotateRepresentation r = (FilterRotateRepresentation) representation;
        r.rotateCW();
    }
    if (representation instanceof FilterMirrorRepresentation) {
        FilterMirrorRepresentation r = (FilterMirrorRepresentation) representation;
        r.cycle();
    }
    if (representation.isBooleanFilter()) {
        ImagePreset preset = MasterImage.getImage().getPreset();
        if (preset.getRepresentation(representation) != null) {
            // remove
            ImagePreset copy = new ImagePreset(preset);
            copy.removeFilter(representation);
            FilterRepresentation filterRepresentation = representation.copy();
            MasterImage.getImage().setPreset(copy, filterRepresentation, true);
            MasterImage.getImage().setCurrentFilterRepresentation(null);
            setActionBar();
            showActionBar(true);
            return;
        }
    }
    if (representation.getFilterType() == FilterRepresentation.TYPE_DUALCAM) {
        DisplayMetrics dm = getResources().getDisplayMetrics();
        float[] mTmpPoint = new float[2];
        mTmpPoint[0] = dm.widthPixels / 2;
        mTmpPoint[1] = dm.heightPixels / 2;
        Matrix m = MasterImage.getImage().getScreenToImageMatrix(true);
        m.mapPoints(mTmpPoint);
        if (representation instanceof FilterDualCamBasicRepresentation) {
            ((FilterDualCamBasicRepresentation) representation).setPoint((int) mTmpPoint[0], (int) mTmpPoint[1]);
        }
        if (representation instanceof FilterDualCamFusionRepresentation) {
            ((FilterDualCamFusionRepresentation) representation).setPoint((int) mTmpPoint[0], (int) mTmpPoint[1]);
        }
    }
    if (representation.getFilterType() == FilterRepresentation.TYPE_WATERMARK) {
        if (MasterImage.getImage().getCurrentFilterRepresentation() != null && representation.getSerializationName().equals(MasterImage.getImage().getCurrentFilterRepresentation().getSerializationName())) {
            return;
        }
        showWaterMark(representation);
    }
    if (TrueScannerActs.SERIALIZATION_NAME.equals(representation.getSerializationName())) {
        Bitmap b = MasterImage.getImage().getOriginalBitmapHighres();
        int w = b.getWidth();
        int h = b.getHeight();
        if (w < h) {
            w = h;
            h = b.getWidth();
        }
        if (w <= TrueScannerActs.MIN_WIDTH || h <= TrueScannerActs.MIN_HEIGHT) {
            Toast.makeText(this, getString(R.string.image_size_too_small), Toast.LENGTH_SHORT).show();
            return;
        }
    }
    useFilterRepresentation(representation);
    loadEditorPanel(representation);
}
Also used : FilterMirrorRepresentation(com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation) FilterDualCamFusionRepresentation(com.android.gallery3d.filtershow.filters.FilterDualCamFusionRepresentation) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) Fragment(android.support.v4.app.Fragment) MediaPickerFragment(com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment) DialogFragment(android.support.v4.app.DialogFragment) DisplayMetrics(android.util.DisplayMetrics) FilterDualCamBasicRepresentation(com.android.gallery3d.filtershow.filters.FilterDualCamBasicRepresentation) Point(android.graphics.Point) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) MainPanel(com.android.gallery3d.filtershow.category.MainPanel) FilterRotateRepresentation(com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)

Example 2 with FilterRepresentation

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

the class FilterShowActivity method fillTruePortrait.

private void fillTruePortrait() {
    FiltersManager filtersManager = FiltersManager.getManager();
    ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getTruePortrait();
    if (mCategoryTruePortraitAdapter != null) {
        mCategoryTruePortraitAdapter.clear();
    }
    mCategoryTruePortraitAdapter = new CategoryAdapter(this);
    for (FilterRepresentation representation : filtersRepresentations) {
        if (representation.getTextId() != 0) {
            representation.setName(getString(representation.getTextId()));
        }
        mCategoryTruePortraitAdapter.add(new Action(this, representation));
    }
}
Also used : Action(com.android.gallery3d.filtershow.category.Action) FiltersManager(com.android.gallery3d.filtershow.filters.FiltersManager) CategoryAdapter(com.android.gallery3d.filtershow.category.CategoryAdapter) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 3 with FilterRepresentation

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

the class CategoryView method drawBottomRect.

@Override
protected void drawBottomRect(Canvas canvas) {
    super.drawBottomRect(canvas);
    FilterRepresentation filterRepresentation = mAction.getRepresentation();
    if (filterRepresentation != null) {
        if (filterRepresentation.getFilterType() == FilterRepresentation.TYPE_WATERMARK || filterRepresentation.getFilterType() == FilterRepresentation.TYPE_WATERMARK_CATEGORY) {
            return;
        }
        if (filterRepresentation.getFilterType() == FilterRepresentation.TYPE_FX) {
            mPaint.setColor(getResources().getColor(filterRepresentation.getColorId()));
        } else {
            mPaint.setColor(getContext().getResources().getColor(R.color.iconview_bottom_color));
        }
        mPaint.setStyle(Paint.Style.FILL);
        canvas.drawRect(getBitmapBounds().left, getBitmapBounds().bottom - getBottomRectHeight(), getBitmapBounds().right, getBitmapBounds().bottom, mPaint);
    }
}
Also used : FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 4 with FilterRepresentation

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

the class FilterShowActivity method applyCustomFilterRepresentation.

public void applyCustomFilterRepresentation(FilterRepresentation filterRep, FilterRepresentation oldfilterRep) {
    ImagePreset oldPreset = MasterImage.getImage().getPreset();
    ImagePreset copy = new ImagePreset(oldPreset);
    if (oldfilterRep != null)
        copy.removeFilter(oldfilterRep);
    FilterRepresentation rep = copy.getRepresentation(filterRep);
    if (rep == null) {
        filterRep = filterRep.copy();
        copy.addFilter(filterRep);
    } else {
        if (filterRep.allowsSingleInstanceOnly()) {
            // null.
            if (!rep.equals(filterRep)) {
                // Only do this if the filter isn't the same
                // (state panel clicks can lead us here)
                copy.removeFilter(rep);
                copy.addFilter(filterRep);
            }
        }
    }
    MasterImage.getImage().setPreset(copy, filterRep, false);
}
Also used : ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 5 with FilterRepresentation

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

the class FilterShowActivity method fillTrueScanner.

private void fillTrueScanner() {
    FiltersManager filtersManager = FiltersManager.getManager();
    ArrayList<FilterRepresentation> trueScannerRepresentations = filtersManager.getTrueScanner();
    if (mCategoryTrueScannerAdapter != null) {
        mCategoryTrueScannerAdapter.clear();
    }
    mCategoryTrueScannerAdapter = new CategoryAdapter(this);
    for (FilterRepresentation representation : trueScannerRepresentations) {
        if (representation.getTextId() != 0) {
            representation.setName(getString(representation.getTextId()));
        }
        mCategoryTrueScannerAdapter.add(new Action(this, representation));
    }
}
Also used : Action(com.android.gallery3d.filtershow.category.Action) FiltersManager(com.android.gallery3d.filtershow.filters.FiltersManager) CategoryAdapter(com.android.gallery3d.filtershow.category.CategoryAdapter) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Aggregations

FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)78 Action (com.android.gallery3d.filtershow.category.Action)12 FiltersManager (com.android.gallery3d.filtershow.filters.FiltersManager)12 CategoryAdapter (com.android.gallery3d.filtershow.category.CategoryAdapter)11 Point (android.graphics.Point)8 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)8 Bitmap (android.graphics.Bitmap)7 FilterUserPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)6 FilterShowActivity (com.android.gallery3d.filtershow.FilterShowActivity)5 FilterDualCamFusionRepresentation (com.android.gallery3d.filtershow.filters.FilterDualCamFusionRepresentation)5 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)5 MasterImage (com.android.gallery3d.filtershow.imageshow.MasterImage)5 FilterGradRepresentation (com.android.gallery3d.filtershow.filters.FilterGradRepresentation)4 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)4 ArrayList (java.util.ArrayList)4 Uri (android.net.Uri)3 LayoutInflater (android.view.LayoutInflater)3 View (android.view.View)3 OnClickListener (android.view.View.OnClickListener)3 FilterCropRepresentation (com.android.gallery3d.filtershow.filters.FilterCropRepresentation)3