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.
This commit is contained in:
@@ -47497,6 +47497,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</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"
|
<method name="load"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
|
|||||||
@@ -61,17 +61,21 @@ public final class GestureLibraries {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean save() {
|
public boolean save() {
|
||||||
final File file = mPath;
|
if (!mStore.hasChanged()) return true;
|
||||||
if (!file.canWrite()) return false;
|
|
||||||
|
|
||||||
if (!file.getParentFile().exists()) {
|
final File file = mPath;
|
||||||
if (!file.getParentFile().mkdirs()) {
|
|
||||||
|
final File parentFile = file.getParentFile();
|
||||||
|
if (!parentFile.exists()) {
|
||||||
|
if (!parentFile.mkdirs()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
try {
|
try {
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
file.createNewFile();
|
||||||
mStore.save(new FileOutputStream(file), true);
|
mStore.save(new FileOutputStream(file), true);
|
||||||
result = true;
|
result = true;
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
|
|||||||
@@ -287,8 +287,10 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
path.computeBounds(bounds, true);
|
path.computeBounds(bounds, true);
|
||||||
|
|
||||||
mPath.rewind();
|
mPath.rewind();
|
||||||
mPath.addPath(path, (getWidth() - bounds.width()) / 2.0f,
|
mPath.addPath(path, -bounds.left + (getWidth() - bounds.width()) / 2.0f,
|
||||||
(getHeight() - bounds.height()) / 2.0f);
|
-bounds.top + (getHeight() - bounds.height()) / 2.0f);
|
||||||
|
|
||||||
|
mResetGesture = true;
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
@@ -367,10 +369,10 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clear(boolean animated) {
|
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);
|
setPaintAlpha(255);
|
||||||
removeCallbacks(mFadingOut);
|
removeCallbacks(mFadingOut);
|
||||||
mResetGesture = false;
|
mResetGesture = false;
|
||||||
@@ -389,15 +391,19 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
mIsFadingOut = false;
|
mIsFadingOut = false;
|
||||||
mFadingHasStarted = false;
|
mFadingHasStarted = false;
|
||||||
|
|
||||||
if (fireActionPerformed) {
|
if (immediate) {
|
||||||
postDelayed(mFadingOut, mFadeOffset);
|
|
||||||
} else if (mHandleGestureActions) {
|
|
||||||
mCurrentGesture = null;
|
mCurrentGesture = null;
|
||||||
mPath.rewind();
|
mPath.rewind();
|
||||||
invalidate();
|
invalidate();
|
||||||
|
} else if (fireActionPerformed) {
|
||||||
|
postDelayed(mFadingOut, mFadeOffset);
|
||||||
} else if (mGestureStrokeType == GESTURE_STROKE_TYPE_MULTIPLE) {
|
} else if (mGestureStrokeType == GESTURE_STROKE_TYPE_MULTIPLE) {
|
||||||
mFadingOut.resetMultipleStrokes = true;
|
mFadingOut.resetMultipleStrokes = true;
|
||||||
postDelayed(mFadingOut, mFadeOffset);
|
postDelayed(mFadingOut, mFadeOffset);
|
||||||
|
} else {
|
||||||
|
mCurrentGesture = null;
|
||||||
|
mPath.rewind();
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -647,7 +653,8 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
listeners.get(i).onGestureEnded(this, event);
|
listeners.get(i).onGestureEnded(this, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear(mHandleGestureActions && mFadeEnabled, mHandleGestureActions && mIsGesturing);
|
clear(mHandleGestureActions && mFadeEnabled, mHandleGestureActions && mIsGesturing,
|
||||||
|
false);
|
||||||
} else {
|
} else {
|
||||||
cancelGesture(event);
|
cancelGesture(event);
|
||||||
|
|
||||||
|
|||||||
@@ -206,6 +206,10 @@ public class GestureStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasChanged() {
|
||||||
|
return mChanged;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the gesture library
|
* Save the gesture library
|
||||||
*/
|
*/
|
||||||
@@ -214,10 +218,6 @@ public class GestureStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save(OutputStream stream, boolean closeStream) throws IOException {
|
public void save(OutputStream stream, boolean closeStream) throws IOException {
|
||||||
if (!mChanged) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataOutputStream out = null;
|
DataOutputStream out = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user