Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7362c026 authored by Chao Zhang's avatar Chao Zhang Committed by Likai Ding
Browse files

Gallery2: improve apply filter operation performance in Photo Editor.

1. modify HazeBuster, SeeStraight and TrueScanner editor interface.
2. open filter directly if has only one category.
3. modify logic of compare button.

Change-Id: Ifa6e77d87548024bea67441c5d87fd12eaaf6f7c
CRs-Fixed: 1018892
parent 391b17fc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@
            android:id="@+id/cancel"
            android:layout_width="@dimen/category_actionbar_panel_height"
            android:layout_height="@dimen/category_actionbar_panel_height"
            android:background="@color/edit_actionbar_background"
            android:background="?android:attr/actionBarItemBackground"
            android:src="@drawable/cancel" />

        <TextView
@@ -155,7 +155,7 @@
            android:id="@+id/done"
            android:layout_width="@dimen/category_actionbar_panel_height"
            android:layout_height="@dimen/category_actionbar_panel_height"
            android:background="@color/edit_actionbar_background"
            android:background="?android:attr/actionBarItemBackground"
            android:layout_gravity="right"
            android:src="@drawable/done" />
    </FrameLayout>
+16 −12
Original line number Diff line number Diff line
@@ -98,7 +98,10 @@ import com.android.gallery3d.filtershow.editors.EditorDualCamFusion;
import com.android.gallery3d.filtershow.editors.EditorManager;
import com.android.gallery3d.filtershow.editors.EditorPanel;
import com.android.gallery3d.filtershow.editors.EditorStraighten;
import com.android.gallery3d.filtershow.editors.HazeBusterEditor;
import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
import com.android.gallery3d.filtershow.editors.SeeStraightEditor;
import com.android.gallery3d.filtershow.editors.TrueScannerEditor;
import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation;
@@ -357,7 +360,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
        transaction.commitAllowingStateLoss();
    }

    public void loadEditorPanel(FilterRepresentation representation,
    public void loadEditorPanel(final FilterRepresentation representation,
                                final Editor currentEditor) {
        if (currentEditor.showsActionBar()) {
            setActionBar();
@@ -387,11 +390,15 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
            }.run();
            return;
        }
        if (currentId == EditorStraighten.ID) {
        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(
@@ -436,6 +443,11 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
        }
    }

    private boolean useStraightenPanel(int EditorID) {
        return (EditorID == EditorStraighten.ID || EditorID == TrueScannerEditor.ID
                || EditorID == HazeBusterEditor.ID || EditorID == SeeStraightEditor.ID);
    }

    public void leaveSeekBarPanel() {
        removeSeekBarPanel();
        showDefaultImageView();
@@ -488,22 +500,14 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
                int action = event.getAction();
                action = action & MotionEvent.ACTION_MASK;
                if (action == MotionEvent.ACTION_DOWN) {

                    HistoryManager adapter = mMasterImage.getHistory();
                    int position = adapter.backToOriginal();// adapter.undo();
                    mMasterImage.onHistoryItemClick(position, false);
                    MasterImage.getImage().setShowsOriginal(true);
                    v.setPressed(true);
                    invalidateViews();
                }
                if (action == MotionEvent.ACTION_UP
                        || action == MotionEvent.ACTION_CANCEL
                        || action == MotionEvent.ACTION_OUTSIDE) {
                    v.setPressed(false);
                    HistoryManager adapter = mMasterImage.getHistory();
                    int position = adapter.backToCurrent();
                    mMasterImage.onHistoryItemClick(position, false);
                    invalidateViews();

                    MasterImage.getImage().setShowsOriginal(false);
                }

                return false;
+48 −21
Original line number Diff line number Diff line
@@ -101,12 +101,21 @@ public class MainPanel extends Fragment implements BottomPanel.BottomPanelDelega
                break;
            }
            case TRUESCANNER: {
                if (trueScannerButton != null) {
                    trueScannerButton.setSelected(value);
                }
                break;
            }
            case HAZEBUSTER: {
                if (hazeBusterButton != null) {
                    hazeBusterButton.setSelected(value);
                }
                break;
            }
            case SEESTRAIGHT: {
                if (seeStraightButton != null) {
                    seeStraightButton.setSelected(value);
                }
                break;
            }
        }
@@ -337,6 +346,11 @@ public class MainPanel extends Fragment implements BottomPanel.BottomPanelDelega
    }

    public void loadCategoryTrueScannerPanel() {
        final FilterShowActivity activity = (FilterShowActivity) getActivity();
        CategoryAdapter adapter = activity.getCategoryTrueScannerAdapter();
        if (adapter.getCount() == 1) {
            activity.showRepresentation(adapter.getItem(0).getRepresentation());
        } else {
            boolean fromRight = isRightAnimation(TRUESCANNER);
            selection(mCurrentSelected, false);
            CategoryPanel categoryPanel = new CategoryPanel();
@@ -345,8 +359,14 @@ public class MainPanel extends Fragment implements BottomPanel.BottomPanelDelega
            mCurrentSelected = TRUESCANNER;
            selection(mCurrentSelected, true);
        }
    }

    public void loadCategoryHazeBusterPanel() {
        final FilterShowActivity activity = (FilterShowActivity) getActivity();
        CategoryAdapter adapter = activity.getCategoryHazeBusterAdapter();
        if (adapter.getCount() == 1) {
            activity.showRepresentation(adapter.getItem(0).getRepresentation());
        } else {
            boolean fromRight = isRightAnimation(HAZEBUSTER);
            selection(mCurrentSelected, false);
            CategoryPanel categoryPanel = new CategoryPanel();
@@ -355,8 +375,14 @@ public class MainPanel extends Fragment implements BottomPanel.BottomPanelDelega
            mCurrentSelected = HAZEBUSTER;
            selection(mCurrentSelected, true);
        }
    }

    public void loadCategorySeeStraightPanel() {
        final FilterShowActivity activity = (FilterShowActivity) getActivity();
        CategoryAdapter adapter = activity.getCategorySeeStraightAdapter();
        if (adapter.getCount() == 1) {
            activity.showRepresentation(adapter.getItem(0).getRepresentation());
        } else {
            boolean fromRight = isRightAnimation(SEESTRAIGHT);
            selection(mCurrentSelected, false);
            CategoryPanel categoryPanel = new CategoryPanel();
@@ -365,6 +391,7 @@ public class MainPanel extends Fragment implements BottomPanel.BottomPanelDelega
            mCurrentSelected = SEESTRAIGHT;
            selection(mCurrentSelected, true);
        }
    }

    public void loadCategoryFiltersPanel() {
        if (mCurrentSelected == FILTERS) {
+38 −12
Original line number Diff line number Diff line
@@ -34,24 +34,50 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import org.codeaurora.gallery.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.editors.EditorStraighten;
import com.android.gallery3d.filtershow.editors.Editor;

import org.codeaurora.gallery.R;

public class StraightenPanel extends BasicGeometryPanel {
    private EditorStraighten mEditorStraighten;
    public static final String EDITOR_ID = "editor_id";
    public static final String EDITOR_NAME = "editor_name";
    public static final int NO_EDITOR = -1;
    private Editor mEditor;
    private int mEditorID = NO_EDITOR;
    private String mName;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    private void initArguments(Bundle arguments) {
        if (arguments != null) {
            mEditorID = arguments.getInt(EDITOR_ID);
            mName = arguments.getString(EDITOR_NAME);
        }
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        initArguments(getArguments());
        if (mEditorID != NO_EDITOR) {
            FilterShowActivity filterShowActivity = (FilterShowActivity) activity;
        mEditorStraighten = (EditorStraighten) filterShowActivity.getEditor(EditorStraighten.ID);
            mEditor = filterShowActivity.getEditor(mEditorID);
            if (mEditor != null) {
                mEditor.attach();
            }
        }
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mEditorName.setText(R.string.straighten);
        if (mName != null) {
            mEditorName.setText(mName);
        }

        mBottomPanel.setVisibility(View.VISIBLE);

@@ -67,7 +93,9 @@ public class StraightenPanel extends BasicGeometryPanel {
        mApplyButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mEditorStraighten.finalApplyCalled();
                if (mEditor != null) {
                    mEditor.finalApplyCalled();
                }
                activity.backToMain();
                activity.setActionBar();
            }
@@ -77,17 +105,15 @@ public class StraightenPanel extends BasicGeometryPanel {
    @Override
    protected void initPanels() {
        super.initPanels();
        int size = mPanels.length;
        for (int i = 0; i < size; i++) {
            View view = mPanels[i];
        for (View view : mPanels) {
            view.setVisibility(View.GONE);
        }
    }

    @Override
    public void onDetach() {
        if (mEditorStraighten != null) {
            mEditorStraighten.detach();
        if (mEditor != null) {
            mEditor.detach();
        }
        super.onDetach();
    }
+5 −0
Original line number Diff line number Diff line
@@ -66,6 +66,11 @@ public class HazeBusterEditor extends Editor {
        super.finalApplyCalled();
    }

    @Override
    public boolean showsActionBar() {
        return false;
    }

    @Override
    public boolean showsSeekBar() {
        return false;
Loading