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

Commit 03f0b21b authored by Romain Guy's avatar Romain Guy
Browse files

Fix several issues in the gestures libraries.

This mostly fixes how gestures libraries are saved and loaded.
Saving a library twice in a row was erasing the entire library,
which was preventing the sketch test app from working propertly.
parent 2d2b2311
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -47497,6 +47497,17 @@
 visibility="public"
>
</method>
<method name="hasChanged"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="load"
 return="void"
 abstract="false"
+7 −3
Original line number Diff line number Diff line
@@ -61,17 +61,21 @@ public final class GestureLibraries {
        }

        public boolean save() {
            if (!mStore.hasChanged()) return true;

            final File file = mPath;
            if (!file.canWrite()) return false;

            if (!file.getParentFile().exists()) {
                if (!file.getParentFile().mkdirs()) {
            final File parentFile = file.getParentFile();
            if (!parentFile.exists()) {
                if (!parentFile.mkdirs()) {
                    return false;
                }
            }

            boolean result = false;
            try {
                //noinspection ResultOfMethodCallIgnored
                file.createNewFile();
                mStore.save(new FileOutputStream(file), true);
                result = true;
            } catch (FileNotFoundException e) {
+15 −8
Original line number Diff line number Diff line
@@ -287,8 +287,10 @@ public class GestureOverlayView extends FrameLayout {
        path.computeBounds(bounds, true);

        mPath.rewind();
        mPath.addPath(path, (getWidth() - bounds.width()) / 2.0f,
                (getHeight() - bounds.height()) / 2.0f);
        mPath.addPath(path, -bounds.left + (getWidth() - bounds.width()) / 2.0f,
                -bounds.top + (getHeight() - bounds.height()) / 2.0f);

        mResetGesture = true;

        invalidate();
    }
@@ -367,10 +369,10 @@ public class GestureOverlayView extends FrameLayout {
    }

    public void clear(boolean animated) {
        clear(animated, false);
        clear(animated, false, true);
    }

    private void clear(boolean animated, boolean fireActionPerformed) {
    private void clear(boolean animated, boolean fireActionPerformed, boolean immediate) {
        setPaintAlpha(255);
        removeCallbacks(mFadingOut);
        mResetGesture = false;
@@ -389,15 +391,19 @@ public class GestureOverlayView extends FrameLayout {
            mIsFadingOut = false;
            mFadingHasStarted = false;

            if (fireActionPerformed) {
                postDelayed(mFadingOut, mFadeOffset);
            } else if (mHandleGestureActions) {
            if (immediate) {
                mCurrentGesture = null;
                mPath.rewind();
                invalidate();
            } else if (fireActionPerformed) {
                postDelayed(mFadingOut, mFadeOffset);
            } else if (mGestureStrokeType == GESTURE_STROKE_TYPE_MULTIPLE) {
                mFadingOut.resetMultipleStrokes = true;
                postDelayed(mFadingOut, mFadeOffset);
            } else {
                mCurrentGesture = null;
                mPath.rewind();
                invalidate();
            }
        }
    }
@@ -647,7 +653,8 @@ public class GestureOverlayView extends FrameLayout {
                    listeners.get(i).onGestureEnded(this, event);
                }

                clear(mHandleGestureActions && mFadeEnabled, mHandleGestureActions && mIsGesturing);
                clear(mHandleGestureActions && mFadeEnabled, mHandleGestureActions && mIsGesturing,
                        false);
            } else {
                cancelGesture(event);

+4 −4
Original line number Diff line number Diff line
@@ -206,6 +206,10 @@ public class GestureStore {
        }
    }

    public boolean hasChanged() {
        return mChanged;
    }

    /**
     * Save the gesture library
     */
@@ -214,10 +218,6 @@ public class GestureStore {
    }

    public void save(OutputStream stream, boolean closeStream) throws IOException {
        if (!mChanged) {
            return;
        }

        DataOutputStream out = null;

        try {