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

Commit 545eca11 authored by ztenghui's avatar ztenghui
Browse files

Fix the save button issue.

When dealing with non Fx filters, the hasModification() really need to go deep
to figure out whether things has changed.

bug:9468909

Change-Id: I89495f147f7af7c35490def84805aae98e3f917f
parent b55e3368
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -812,9 +812,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
    }

    public void enableSave(boolean enable) {
        if (mSaveButton != null)
        if (mSaveButton != null) {
            mSaveButton.setEnabled(enable);
        }
    }

    private void fillFx() {
        FilterFxRepresentation nullFx =
+3 −0
Original line number Diff line number Diff line
@@ -174,6 +174,9 @@ public class FilterRepresentation implements Cloneable {
        mFilterClass = filterClass;
    }

    // This same() function is different from equals(), basically it checks
    // whether 2 FilterRepresentations are the same type. It doesn't care about
    // the values.
    public boolean same(FilterRepresentation b) {
        if (b == null) {
            return false;
+0 −1
Original line number Diff line number Diff line
@@ -108,7 +108,6 @@ public class ImageShow extends View implements OnGestureListener,

    public void onNewValue(int parameter) {
        invalidate();
        mActivity.enableSave(hasModifications());
    }

    public ImageShow(Context context, AttributeSet attrs, int defStyle) {
+23 −5
Original line number Diff line number Diff line
@@ -231,12 +231,22 @@ public class MasterImage implements RenderingRequestCaller {
    }

    public synchronized boolean hasModifications() {
        // TODO: We need to have a better same effects check to see if two
        // presets are functionally the same. Right now, we are relying on a
        // stricter check as equals().
        ImagePreset loadedPreset = getLoadedPreset();
        if (mPreset == null) {
            return getLoadedPreset() != null;
            if (loadedPreset == null) {
                return false;
            } else {
            // TODO: same() is quite strict check here. We should be only
            // checking for functionality parity.
            return !mPreset.same(getLoadedPreset());
                return loadedPreset.hasModifications();
            }
        } else {
            if (loadedPreset == null) {
                return mPreset.hasModifications();
            } else {
                return !mPreset.equals(getLoadedPreset());
            }
        }
    }

@@ -304,7 +314,6 @@ public class MasterImage implements RenderingRequestCaller {
            }
        }
        invalidatePreview();
        mActivity.enableSave(hasModifications());
    }

    public FilterRepresentation getCurrentFilterRepresentation() {
@@ -404,20 +413,29 @@ public class MasterImage implements RenderingRequestCaller {
        if (request.getBitmap() == null) {
            return;
        }

        boolean needsCheckModification = false;
        if (request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
            mGeometryOnlyBitmap = request.getBitmap();
            needsCheckModification = true;
        }
        if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
            mFiltersOnlyBitmap = request.getBitmap();
            needsCheckModification = true;
        }
        if (request.getType() == RenderingRequest.PARTIAL_RENDERING
                && request.getScaleFactor() == getScaleFactor()) {
            mPartialBitmap = request.getBitmap();
            notifyObservers();
            needsCheckModification = true;
        }
        if (request.getType() == RenderingRequest.HIGHRES_RENDERING) {
            mHighresBitmap = request.getBitmap();
            notifyObservers();
            needsCheckModification = true;
        }
        if (needsCheckModification) {
            mActivity.enableSave(hasModifications());
        }
    }

+14 −0
Original line number Diff line number Diff line
@@ -186,6 +186,20 @@ public class ImagePreset {
        return geo;
    }

    public boolean hasModifications() {
        for (int i = 0; i < mFilters.size(); i++) {
            FilterRepresentation filter = mFilters.elementAt(i);
            if (filter instanceof GeometryMetadata) {
                if (((GeometryMetadata) filter).hasModifications()) {
                    return true;
                }
            } else if (!filter.isNil()) {
                return true;
            }
        }
        return false;
    }

    public boolean isPanoramaSafe() {
        for (FilterRepresentation representation : mFilters) {
            if (representation instanceof GeometryMetadata) {