diff options
author | Romain Guy <romainguy@android.com> | 2009-06-09 04:15:22 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2009-06-09 04:15:22 -0700 |
commit | 03f0b21b5a317aa6c0f0cd4d7ac91cabdf379d3e (patch) | |
tree | 6aca14f7b6afad8cf8fdb7d9f97e6c74b4a13660 | |
parent | 2d2b23119f1b4daa3064f065ebeb6397963c1780 (diff) | |
download | frameworks_base-03f0b21b5a317aa6c0f0cd4d7ac91cabdf379d3e.zip frameworks_base-03f0b21b5a317aa6c0f0cd4d7ac91cabdf379d3e.tar.gz frameworks_base-03f0b21b5a317aa6c0f0cd4d7ac91cabdf379d3e.tar.bz2 |
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.
-rw-r--r-- | api/current.xml | 11 | ||||
-rw-r--r-- | core/java/android/gesture/GestureLibraries.java | 10 | ||||
-rwxr-xr-x | core/java/android/gesture/GestureOverlayView.java | 23 | ||||
-rw-r--r-- | core/java/android/gesture/GestureStore.java | 8 |
4 files changed, 37 insertions, 15 deletions
diff --git a/api/current.xml b/api/current.xml index ebbdf39..8acad9f 100644 --- a/api/current.xml +++ b/api/current.xml @@ -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" diff --git a/core/java/android/gesture/GestureLibraries.java b/core/java/android/gesture/GestureLibraries.java index 2ce7a8e..6d6c156 100644 --- a/core/java/android/gesture/GestureLibraries.java +++ b/core/java/android/gesture/GestureLibraries.java @@ -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) { diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java index 0d0fbb5..3b4d3df 100755 --- a/core/java/android/gesture/GestureOverlayView.java +++ b/core/java/android/gesture/GestureOverlayView.java @@ -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); diff --git a/core/java/android/gesture/GestureStore.java b/core/java/android/gesture/GestureStore.java index 7251198..5f1a445 100644 --- a/core/java/android/gesture/GestureStore.java +++ b/core/java/android/gesture/GestureStore.java @@ -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 { |