Search in sources :

Example 1 with MainPanel

use of com.android.gallery3d.filtershow.category.MainPanel 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 MainPanel

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

the class FilterShowActivity method onBackPressed.

@Override
public void onBackPressed() {
    showComparisonButton();
    Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
    if (currentPanel instanceof MainPanel) {
        if (mImageShow.hasModifications()) {
            if (mBackAlertDialogBuilder == null) {
                createBackDialog();
            }
            mBackAlertDialogBuilder.show();
        } else {
            done();
        }
        setActionBar();
        invalidateOptionsMenu();
        if (MasterImage.getImage().getScaleFactor() < 1)
            setScaleImage(false);
        adjustCompareButton(false);
    } else {
        isComingFromEditorScreen = true;
        backToMain();
    }
}
Also used : MainPanel(com.android.gallery3d.filtershow.category.MainPanel) Fragment(android.support.v4.app.Fragment) MediaPickerFragment(com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 3 with MainPanel

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

the class FilterShowActivity method removeSeekBarPanel.

private void removeSeekBarPanel() {
    Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
    if (currentPanel instanceof MainPanel) {
        ((MainPanel) currentPanel).removeEditorPanelFragment();
        if (mCurrentEditor != null) {
            mCurrentEditor.detach();
        }
        mCurrentEditor = null;
    }
}
Also used : MainPanel(com.android.gallery3d.filtershow.category.MainPanel) Fragment(android.support.v4.app.Fragment) MediaPickerFragment(com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 4 with MainPanel

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

the class FilterShowActivity method backToMain.

public void backToMain() {
    removeSeekBarPanel();
    showActionBar(true);
    Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
    if (currentPanel instanceof MainPanel) {
        return;
    }
    mIsReloadByConfigurationChanged = false;
    loadMainPanel();
    showDefaultImageView();
    showComparisonButton();
}
Also used : MainPanel(com.android.gallery3d.filtershow.category.MainPanel) Fragment(android.support.v4.app.Fragment) MediaPickerFragment(com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 5 with MainPanel

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

the class FilterShowActivity method loadEditorPanel.

public void loadEditorPanel(final FilterRepresentation representation) {
    final int currentId = representation.getEditorId();
    // show representation
    if (mCurrentEditor != null) {
        mCurrentEditor.detach();
    }
    mCurrentEditor = mEditorPlaceHolder.showEditor(currentId);
    if (mCurrentEditor.showsActionBar()) {
        setActionBar();
        showActionBar(true);
    } else {
    // showActionBar(false);
    }
    if (representation.getFilterType() == FilterRepresentation.TYPE_WATERMARK_CATEGORY) {
        loadWaterMarkPanel((FilterWatermarkRepresentation) representation);
        return;
    }
    if (currentId == ImageOnlyEditor.ID) {
        mCurrentEditor.reflectCurrentFilter();
        return;
    }
    if (currentId == EditorTruePortraitImageOnly.ID) {
        mCurrentEditor.reflectCurrentFilter();
        setActionBarForEffects(mCurrentEditor);
        return;
    }
    if (currentId == EditorCrop.ID) {
        loadEditorCropPanel();
        return;
    }
    if (useStraightenPanel(currentId)) {
        new Runnable() {

            @Override
            public void run() {
                StraightenPanel panel = new StraightenPanel();
                Bundle bundle = new Bundle();
                bundle.putInt(StraightenPanel.EDITOR_ID, currentId);
                bundle.putString(StraightenPanel.EDITOR_NAME, representation.getName());
                panel.setArguments(bundle);
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
                transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
                transaction.commit();
            }
        }.run();
        return;
    }
    if (currentId == TrueScannerEditor.ID) {
        new Runnable() {

            @Override
            public void run() {
                TrueScannerPanel panel = new TrueScannerPanel();
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
                transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
                transaction.commit();
            }
        }.run();
        return;
    }
    if (currentId == EditorTruePortraitMask.ID) {
        new Runnable() {

            @Override
            public void run() {
                setActionBarForEffects(mCurrentEditor);
                TruePortraitMaskEditorPanel panel = new TruePortraitMaskEditorPanel();
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
                transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
                transaction.commit();
            }
        }.run();
        return;
    }
    Runnable showEditor = new Runnable() {

        @Override
        public void run() {
            EditorPanel panel = new EditorPanel();
            panel.setEditor(currentId);
            setActionBarForEffects(mCurrentEditor);
            Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
            if (main instanceof MainPanel) {
                ((MainPanel) main).setEditorPanelFragment(panel);
            }
        }
    };
    Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
    boolean doAnimation = false;
    if (mShowingImageStatePanel && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        doAnimation = true;
    }
    if (doAnimation && main != null && main instanceof MainPanel) {
        MainPanel mainPanel = (MainPanel) main;
        View container = mainPanel.getView().findViewById(R.id.category_panel_container);
        View bottom = mainPanel.getView().findViewById(R.id.bottom_panel);
        int panelHeight = container.getHeight() + bottom.getHeight();
        ViewPropertyAnimator anim = mainPanel.getView().animate();
        anim.translationY(panelHeight).start();
        final Handler handler = new Handler();
        handler.postDelayed(showEditor, anim.getDuration());
    } else {
        showEditor.run();
    }
}
Also used : Bundle(android.os.Bundle) TruePortraitMaskEditorPanel(com.android.gallery3d.filtershow.category.TruePortraitMaskEditorPanel) EditorPanel(com.android.gallery3d.filtershow.editors.EditorPanel) Handler(android.os.Handler) TruePortraitMaskEditorPanel(com.android.gallery3d.filtershow.category.TruePortraitMaskEditorPanel) Fragment(android.support.v4.app.Fragment) MediaPickerFragment(com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment) DialogFragment(android.support.v4.app.DialogFragment) CategoryView(com.android.gallery3d.filtershow.category.CategoryView) SwipableView(com.android.gallery3d.filtershow.category.SwipableView) WaterMarkView(com.android.gallery3d.filtershow.category.WaterMarkView) View(android.view.View) AdapterView(android.widget.AdapterView) Point(android.graphics.Point) TrueScannerPanel(com.android.gallery3d.filtershow.category.TrueScannerPanel) ViewPropertyAnimator(android.view.ViewPropertyAnimator) FragmentTransaction(android.support.v4.app.FragmentTransaction) MainPanel(com.android.gallery3d.filtershow.category.MainPanel) StraightenPanel(com.android.gallery3d.filtershow.category.StraightenPanel)

Aggregations

MainPanel (com.android.gallery3d.filtershow.category.MainPanel)10 Fragment (android.support.v4.app.Fragment)9 DialogFragment (android.support.v4.app.DialogFragment)8 MediaPickerFragment (com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment)8 Point (android.graphics.Point)3 FragmentTransaction (android.support.v4.app.FragmentTransaction)3 Bundle (android.os.Bundle)2 View (android.view.View)2 TruePortraitMaskEditorPanel (com.android.gallery3d.filtershow.category.TruePortraitMaskEditorPanel)2 EditorPanel (com.android.gallery3d.filtershow.editors.EditorPanel)2 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)2 Bitmap (android.graphics.Bitmap)1 Matrix (android.graphics.Matrix)1 Handler (android.os.Handler)1 DisplayMetrics (android.util.DisplayMetrics)1 ViewPropertyAnimator (android.view.ViewPropertyAnimator)1 AdapterView (android.widget.AdapterView)1 TextView (android.widget.TextView)1 FilterShowActivity (com.android.gallery3d.filtershow.FilterShowActivity)1 Action (com.android.gallery3d.filtershow.category.Action)1